3 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
126 # This use of bold display can be removed on 2011-01-01.
131 # Assume xterm compatible escape sequences.
132 bold_on=`printf '\x1b[1m'`
133 bold_off=`printf '\x1b[0m'`
139 Usage: gnulib-tool --list
140 gnulib-tool --find filename${bold_on}
141 gnulib-tool --import [module1 ... moduleN]
142 gnulib-tool --add-import [module1 ... moduleN]
143 gnulib-tool --remove-import [module1 ... moduleN]${bold_off}
145 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
146 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
147 gnulib-tool --test --dir=directory module1 ... moduleN
148 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
149 gnulib-tool --extract-description module
150 gnulib-tool --extract-comment module
151 gnulib-tool --extract-status module
152 gnulib-tool --extract-notice module
153 gnulib-tool --extract-applicability module
154 gnulib-tool --extract-filelist module
155 gnulib-tool --extract-dependencies module
156 gnulib-tool --extract-autoconf-snippet module
157 gnulib-tool --extract-automake-snippet module
158 gnulib-tool --extract-include-directive module
159 gnulib-tool --extract-link-directive module
160 gnulib-tool --extract-license module
161 gnulib-tool --extract-maintainer module
162 gnulib-tool --extract-tests-module module
163 gnulib-tool --copy-file file [destination]
166 --list print the available module names
167 --find find the modules which contain the specified file${bold_on}
168 --import import the given modules into the current package
169 --add-import augment the list of imports from gnulib into the
170 current package, by adding the given modules;
171 if no modules are specified, update the current
172 package from the current gnulib
173 --remove-import reduce the list of imports from gnulib into the
174 current package, by removing the given modules${bold_off}
175 --update update the current package, restore files omitted
177 --create-testdir create a scratch package with the given modules
178 --create-megatestdir create a mega scratch package with the given modules
179 one by one and all together
180 --test test the combination of the given modules
181 (recommended to use CC=\"gcc -Wall\" here)
182 --megatest test the given modules one by one and all together
183 (recommended to use CC=\"gcc -Wall\" here)
184 --extract-description extract the description
185 --extract-comment extract the comment
186 --extract-status extract the status (obsolete etc.)
187 --extract-notice extract the notice or banner
188 --extract-applicability extract the applicability
189 --extract-filelist extract the list of files
190 --extract-dependencies extract the dependencies
191 --extract-autoconf-snippet extract the snippet for configure.ac
192 --extract-automake-snippet extract the snippet for library makefile
193 --extract-include-directive extract the #include directive
194 --extract-link-directive extract the linker directive
195 --extract-license report the license terms of the source files
197 --extract-maintainer report the maintainer(s) inside gnulib
198 --extract-tests-module report the unit test module, if it exists
199 --copy-file copy a file that is not part of any module
202 --dir=DIRECTORY Specify the target directory.
203 For --import, this specifies where your
204 configure.ac can be found. Defaults to current
206 --local-dir=DIRECTORY Specify a local override directory where to look
207 up files before looking in gnulib's directory.
208 --cache-modules Enable module caching optimization.
209 --no-cache-modules Disable module caching optimization.
210 --verbose Increase verbosity. May be repeated.
211 --quiet Decrease verbosity. May be repeated.
213 Options for --import, --update:
214 --dry-run Only print what would have been done.
216 Options for --import, --create-[mega]testdir, --[mega]test:
217 --with-tests Include unit tests for the included modules.
218 --with-obsolete Include obsolete modules when they occur among the
219 dependencies. By default, dependencies to obsolete
221 --with-c++-tests Include even unit tests for C++ interoperability.
222 --with-longrunning-tests
223 Include even unit tests that are long-runners.
224 --with-privileged-tests
225 Include even unit tests that require root
227 --with-unportable-tests
228 Include even unit tests that fail on some platforms.
229 --with-all-tests Include all kinds of problematic unit tests.
230 --avoid=MODULE Avoid including the given MODULE. Useful if you
231 have code that provides equivalent functionality.
232 This option can be repeated.
233 --libtool Use libtool rules.
234 --no-libtool Don't use libtool rules.
236 Options for --import:
237 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
238 --source-base=DIRECTORY
239 Directory relative to --dir where source code is
240 placed (default \"lib\").
241 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
242 placed (default \"m4\").
243 --po-base=DIRECTORY Directory relative to --dir where *.po files are
244 placed (default \"po\").
245 --doc-base=DIRECTORY Directory relative to --dir where doc files are
246 placed (default \"doc\").
247 --tests-base=DIRECTORY
248 Directory relative to --dir where unit tests are
249 placed (default \"tests\").
250 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
251 tools are placed (default \"build-aux\").
252 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
253 Also modify license template from GPL to LGPL.
254 The version number of the LGPL can be specified;
255 the default is currently LGPLv3.
256 --makefile-name=NAME Name of makefile in automake syntax in the
257 source-base and tests-base directories
258 (default \"Makefile.am\").
259 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
260 'gl_INIT'. Default is 'gl'.
261 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
262 the package name. A suffix '-gnulib' is appended.
263 --vc-files Update version control related files.
264 --no-vc-files Don't update version control related files
265 (.gitignore and/or .cvsignore).
266 --no-changelog Don't update or create ChangeLog files.
268 Options for --create-[mega]testdir, --[mega]test:
269 --without-c++-tests Exclude unit tests for C++ interoperability.
270 --without-longrunning-tests
271 Exclude unit tests that are long-runners.
272 --without-privileged-tests
273 Exclude unit tests that require root privileges.
274 --without-unportable-tests
275 Exclude unit tests that fail on some platforms.
277 Options for --import, --update, --create-[mega]testdir, --[mega]test:
278 -s, --symbolic, --symlink Make symbolic links instead of copying files.
279 --local-symlink Make symbolic links instead of copying files, only
280 for files from the local override directory.
282 Options for --import, --update:
283 -S, --more-symlinks Make symbolic links instead of copying files, and
284 don't replace copyright notices.
286 Report bugs to <bug-gnulib@gnu.org>."
290 # outputs to stdout the --version message.
294 if test -d "$gnulib_dir"/.git \
295 && (git --version) >/dev/null 2>/dev/null \
296 && (date --version) >/dev/null 2>/dev/null; then
297 # gnulib checked out from git.
298 sed_extract_first_date='/^Date/{
302 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
303 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
304 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
305 date=`echo "$date" | sed -e "$sed_year_before_time"`
306 # Use GNU date to compute the time in GMT.
307 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
308 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
310 if test -d "$gnulib_dir"/CVS \
311 && (cvs --version) >/dev/null 2>/dev/null; then
312 # gnulib checked out from CVS.
313 sed_extract_first_date='/^date: /{
314 s/^date: \([0-9][0-9][0-9][0-9]\).\([0-9][0-9]\).\([0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1-\2-\3 \4/p
317 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
319 # gnulib copy without versioning information.
320 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
324 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
326 gnulib-tool (GNU $package $date)$version
327 Copyright (C) $year Free Software Foundation, Inc.
328 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
329 This is free software: you are free to change and redistribute it.
330 There is NO WARRANTY, to the extent permitted by law.
332 Written by" "Bruno Haible" "and" "Simon Josefsson"
335 # func_emit_copyright_notice
336 # outputs to stdout a header for a generated file.
337 func_emit_copyright_notice ()
339 sed -n -e '/Copyright/ {
342 }' < "$self_abspathname"
344 echo "# This file is free software, distributed under the terms of the GNU"
345 echo "# General Public License. As a special exception to the GNU General"
346 echo "# Public License, this file may be distributed as part of a program"
347 echo "# that contains a configuration script generated by Autoconf, under"
348 echo "# the same distribution terms as the rest of that program."
350 echo "# Generated by gnulib-tool."
354 # exits with a given status.
355 # This function needs to be used, rather than 'exit', when a 'trap' handler is
356 # in effect that refers to $?.
363 # locates the directory where the gnulib repository lives
365 # - progname name of this program
367 # - self_abspathname absolute pathname of gnulib-tool
368 # - gnulib_dir absolute pathname of gnulib repository
372 /*) self_abspathname="$progname" ;;
373 */*) self_abspathname=`pwd`/"$progname" ;;
376 # Iterate through the elements of $PATH.
377 # We use IFS=: instead of
378 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
379 # because the latter does not work when some PATH element contains spaces.
380 # We use a canonicalized $pathx instead of $PATH, because empty PATH
381 # elements are by definition equivalent to '.', however field splitting
382 # according to IFS=: loses empty fields in many shells:
383 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
384 # beginning, at the end, and in the middle),
385 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
386 # at the beginning and at the end,
387 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
388 # Solaris lose empty fields at the end.
389 # The 'case' statement is an optimization, to avoid evaluating the
390 # explicit canonicalization command when $PATH contains no empty fields.
392 if test "${PATH_SEPARATOR+set}" != set; then
393 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
394 # contains only /bin. Note that ksh looks also at the FPATH variable,
395 # so we have to set that as well for the test.
397 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
398 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
399 || PATH_SEPARATOR=';'
402 if test "$PATH_SEPARATOR" = ";"; then
403 # On Windows, programs are searched in "." before $PATH.
406 # On Unix, we have to convert empty PATH elements to ".".
410 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
415 IFS="$PATH_SEPARATOR"
419 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
420 self_abspathname="$d/$progname"
425 if test -z "$self_abspathname"; then
426 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
430 while test -h "$self_abspathname"; do
431 # Resolve symbolic link.
432 linkval=`func_readlink "$self_abspathname"`
433 test -n "$linkval" || break
435 /* ) self_abspathname="$linkval" ;;
436 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
439 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
443 # creates a temporary directory.
445 # - progname name of this program
447 # - tmp pathname of freshly created temporary directory
450 # Use the environment variable TMPDIR, falling back to /tmp. This allows
451 # users to specify a different temporary directory, for example, if their
452 # /tmp is filled up or too small.
455 # Use the mktemp program if available. If not available, hide the error
457 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
458 test -n "$tmp" && test -d "$tmp"
461 # Use a simple mkdir command. It is guaranteed to fail if the directory
462 # already exists. $RANDOM is bash specific and expands to empty in shells
463 # other than bash, ksh and zsh. Its use does not increase security;
464 # rather, it minimizes the probability of failure in a very cluttered /tmp
466 tmp=$TMPDIR/gl$$-$RANDOM
467 (umask 077 && mkdir "$tmp")
470 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
475 # func_append var value
476 # appends the given value to the shell variable var.
477 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
478 # Use bash's += operator. It reduces complexity of appending repeatedly to
479 # a single variable from O(n^2) to O(n).
484 fast_func_append=true
488 eval "$1=\"\$$1\$2\""
490 fast_func_append=false
493 # func_remove_prefix var prefix
494 # removes the given prefix from the value of the shell variable var.
495 # var should be the name of a shell variable.
496 # Its value should not contain a newline and not start or end with whitespace.
497 # prefix should not contain the characters "$`\{}[]^|.
498 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
499 func_remove_prefix ()
503 fast_func_remove_prefix=true
505 func_remove_prefix ()
507 eval "value=\"\$$1\""
511 sed_escape_dots='s/\([.]\)/\\\1/g'
512 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
515 value=`echo "$value" | sed -e "s|^${prefix}||"`
516 eval "$1=\"\$value\""
518 fast_func_remove_prefix=false
521 # func_remove_suffix var suffix
522 # removes the given suffix from the value of the shell variable var.
523 # var should be the name of a shell variable.
524 # Its value should not contain a newline and not start or end with whitespace.
525 # suffix should not contain the characters "$`\{}[]^|.
526 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
527 func_remove_suffix ()
531 fast_func_remove_suffix=true
533 func_remove_suffix ()
535 eval "value=\"\$$1\""
539 sed_escape_dots='s/\([.]\)/\\\1/g'
540 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
543 value=`echo "$value" | sed -e "s|${suffix}\$||"`
544 eval "$1=\"\$value\""
546 fast_func_remove_suffix=false
549 # func_fatal_error message
550 # outputs to stderr a fatal error message, and terminates the program.
552 # - progname name of this program
555 echo "$progname: *** $1" 1>&2
556 echo "$progname: *** Stop." 1>&2
560 # func_warning message
561 # Outputs to stderr a warning message,
564 echo "gnulib-tool: warning: $1" 1>&2
567 # func_readlink SYMLINK
568 # outputs the target of the given symlink.
569 if (type -p readlink) > /dev/null 2>&1; then
572 # Use the readlink program from GNU coreutils.
578 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
579 # would do the wrong thing if the link target contains " -> ".
580 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
584 # func_relativize DIR1 DIR2
585 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
587 # - DIR1 relative pathname, relative to the current directory
588 # - DIR2 relative pathname, relative to the current directory
590 # - reldir relative pathname of DIR2, relative to DIR1
596 sed_first='s,^\([^/]*\)/.*$,\1,'
597 sed_rest='s,^[^/]*/*,,'
598 sed_last='s,^.*/\([^/]*\)$,\1,'
599 sed_butlast='s,/*[^/]*$,,'
600 while test -n "$dir1"; do
601 first=`echo "$dir1" | sed -e "$sed_first"`
602 if test "$first" != "."; then
603 if test "$first" = ".."; then
604 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
605 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
607 first2=`echo "$dir2" | sed -e "$sed_first"`
608 if test "$first2" = "$first"; then
609 dir2=`echo "$dir2" | sed -e "$sed_rest"`
613 dir0="$dir0"/"$first"
616 dir1=`echo "$dir1" | sed -e "$sed_rest"`
621 # func_relconcat DIR1 DIR2
622 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
624 # - DIR1 relative pathname, relative to the current directory
625 # - DIR2 relative pathname, relative to DIR1
627 # - relconcat DIR1/DIR2, relative to the current directory
632 sed_first='s,^\([^/]*\)/.*$,\1,'
633 sed_rest='s,^[^/]*/*,,'
634 sed_last='s,^.*/\([^/]*\)$,\1,'
635 sed_butlast='s,/*[^/]*$,,'
637 first=`echo "$dir2" | sed -e "$sed_first"`
638 if test "$first" = "."; then
639 dir2=`echo "$dir2" | sed -e "$sed_rest"`
640 if test -z "$dir2"; then
645 last=`echo "$dir1" | sed -e "$sed_last"`
646 while test "$last" = "."; do
647 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
648 last=`echo "$dir1" | sed -e "$sed_last"`
650 if test -z "$dir1"; then
654 if test "$first" = ".."; then
655 if test "$last" = ".."; then
656 relconcat="$dir1/$dir2"
659 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
660 dir2=`echo "$dir2" | sed -e "$sed_rest"`
661 if test -z "$dir1"; then
665 if test -z "$dir2"; then
670 relconcat="$dir1/$dir2"
678 # Like ln -s, except that SRC is given relative to the current directory (or
679 # absolute), not given relative to the directory of DEST.
685 *) # SRC is relative.
688 ln -s "`pwd`/$1" "$2" ;;
689 *) # DEST is relative too.
690 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
691 test -n "$ln_destdir" || ln_destdir="."
692 func_relativize "$ln_destdir" "$1"
700 # func_ln_if_changed SRC DEST
701 # Like func_ln, but avoids munging timestamps if the link is correct.
702 func_ln_if_changed ()
704 if test $# -ne 2; then
705 echo "usage: func_ln_if_changed SRC DEST" >&2
707 ln_target=`func_readlink "$2"`
708 if test -h "$2" && test "$1" = "$ln_target"; then
716 # Ensure an 'echo' command that
717 # 1. does not interpret backslashes and
718 # 2. does not print an error message "broken pipe" when writing into a pipe
721 # Test cases for problem 1:
722 # echo '\n' | wc -l prints 1 when OK, 2 when KO
723 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
724 # Test cases for problem 2:
725 # echo hi | true frequently prints
726 # "bash: echo: write error: Broken pipe"
727 # to standard error in bash 3.2.
729 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
730 # BSD echo interprets '-n' as an option, which is also not desirable).
731 # Nowadays the problem occurs in 4 situations:
732 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
733 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
734 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
735 # - in zsh, when sh-emulation is not set,
736 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
737 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
738 # - in Solaris /bin/sh and OSF/1 /bin/sh.
739 # We try the following workarounds:
740 # - for all: respawn using $CONFIG_SHELL if that is set and works.
741 # - for bash >= 2.04: unset the shell option xpg_echo.
742 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
743 # - for bash < 2.0: define echo to a function that uses cat of a here document.
744 # - for zsh: turn sh-emulation on.
745 # - for ksh: alias echo to 'print -r'.
746 # - for ksh: alias echo to a function that uses cat of a here document.
747 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
748 # the ksh workaround.
749 # - otherwise: respawn using /bin/sh and rely on the workarounds.
750 # When respawning, we pass --no-reexec as first argument, so as to avoid
751 # turning this script into a fork bomb in unlucky situations.
753 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
754 # the 'printf' built-in. See
755 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
756 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
757 # The workaround is: define echo to a function that uses the printf built-in.
759 if echo '\t' | grep t > /dev/null; then
760 have_echo=yes # Lucky!
762 # Try the workarounds.
763 # Respawn using $CONFIG_SHELL if that is set and works.
764 if test -z "$have_echo" \
765 && test "X$1" != "X--no-reexec" \
766 && test -n "$CONFIG_SHELL" \
767 && test -f "$CONFIG_SHELL" \
768 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
769 exec $CONFIG_SHELL "$0" --no-reexec "$@"
772 # For bash >= 2.04: unset the shell option xpg_echo.
773 if test -z "$have_echo" \
774 && test -n "$BASH_VERSION" \
775 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
779 # For bash >= 2.0: define echo to a function that uses the printf built-in.
780 # For bash < 2.0: define echo to a function that uses cat of a here document.
781 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
782 # Also handle problem 2, specific to bash 3.2, here.
783 if { test -z "$have_echo" \
784 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
786 && test -n "$BASH_VERSION"; then \
787 if type printf 2>/dev/null | grep / > /dev/null; then
788 # 'printf' is not a shell built-in.
796 # 'printf' is a shell built-in.
802 if echo '\t' | grep t > /dev/null; then
806 # For zsh: turn sh-emulation on.
807 if test -z "$have_echo" \
808 && test -n "$ZSH_VERSION" \
809 && (emulate sh) >/dev/null 2>&1; then
812 # For ksh: alias echo to 'print -r'.
813 if test -z "$have_echo" \
814 && (type print) >/dev/null 2>&1; then
815 # A 'print' command exists.
816 if type print 2>/dev/null | grep / > /dev/null; then
819 # 'print' is a shell built-in.
820 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
821 # 'print' is the ksh shell built-in.
822 alias echo='print -r'
826 if test -z "$have_echo" \
827 && echo '\t' | grep t > /dev/null; then
830 # For ksh: alias echo to a function that uses cat of a here document.
831 # The ksh manual page says:
832 # "Aliasing is performed when scripts are read, not while they are executed.
833 # Therefore, for an alias to take effect, the alias definition command has
834 # to be executed before the command which references the alias is read."
835 # Because of this, we have to play strange tricks with have_echo, to ensure
836 # that the top-level statement containing the test starts after the 'alias'
838 if test -z "$have_echo"; then
851 if test -z "$have_echo" \
852 && echo '\t' | grep t > /dev/null; then
855 if test -z "$have_echo"; then
862 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
863 if test -z "$have_echo" \
864 && test "X$1" != "X--no-reexec" \
865 && test -f /bin/ksh; then
866 exec /bin/ksh "$0" --no-reexec "$@"
869 # Otherwise: respawn using /bin/sh.
870 if test -z "$have_echo" \
871 && test "X$1" != "X--no-reexec" \
872 && test -f /bin/sh; then
873 exec /bin/sh "$0" --no-reexec "$@"
876 if test -z "$have_echo"; then
877 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
879 if echo '\t' | grep t > /dev/null; then
882 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
884 if test "X$1" = "X--no-reexec"; then
888 # Command-line option processing.
889 # Removes the OPTIONS from the arguments. Sets the variables:
890 # - mode list or import or add-import or remove-import or update
891 # or create-testdir or create-megatestdir
892 # - destdir from --dir
893 # - local_gnulib_dir from --local-dir
894 # - modcache true or false, from --cache-modules/--no-cache-modules
895 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
896 # - libname, supplied_libname from --lib
897 # - sourcebase from --source-base
898 # - m4base from --m4-base
899 # - pobase from --po-base
900 # - docbase from --doc-base
901 # - testsbase from --tests-base
902 # - auxdir from --aux-dir
903 # - inctests true if --with-tests was given, blank otherwise
904 # - incobsolete true if --with-obsolete was given, blank otherwise
905 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
906 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
908 # - inc_privileged_tests true if --with-privileged-tests was given, blank
910 # - inc_unportable_tests true if --with-unportable-tests was given, blank
912 # - inc_all_tests true if --with-all-tests was given, blank otherwise
913 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
914 # - excl_longrunning_tests true if --without-longrunning-tests was given,
916 # - excl_privileged_tests true if --without-privileged-tests was given, blank
918 # - excl_unportable_tests true if --without-unportable-tests was given, blank
920 # - avoidlist list of modules to avoid, from --avoid
921 # - lgpl yes or a number if --lgpl was given, blank otherwise
922 # - makefile_name from --makefile-name
923 # - libtool true if --libtool was given, false if --no-libtool was
924 # given, blank otherwise
925 # - macro_prefix from --macro-prefix
926 # - po_domain from --po-domain
927 # - vc_files true if --vc-files was given, false if --no-vc-files was
928 # given, blank otherwise
929 # - autoconf_minversion minimum supported autoconf version
930 # - do_changelog false if --no-changelog was given, : otherwise
931 # - doit : if actions shall be executed, false if only to be printed
932 # - symbolic true if --symlink or --more-symlinks was given, blank
934 # - lsymbolic true if --local-symlink was given, blank otherwise
935 # - do_copyrights blank if --more-symlinks was given, true otherwise
953 inc_longrunning_tests=
954 inc_privileged_tests=
955 inc_unportable_tests=
958 excl_longrunning_tests=
959 excl_privileged_tests=
960 excl_unportable_tests=
976 while test $# -gt 0; do
981 --find | --fin | --fi | --f )
984 --import | --impor | --impo | --imp | --im | --i )
987 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
990 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
993 --update | --updat | --upda | --upd | --up | --u )
996 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
999 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1000 mode=create-megatestdir
1002 --test | --tes | --te | --t )
1005 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1009 mode=`echo "X$1" | sed -e 's/^X--//'`
1011 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
1016 if test $# = 0; then
1017 func_fatal_error "missing argument for --dir"
1022 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1026 if test $# = 0; then
1027 func_fatal_error "missing argument for --local-dir"
1032 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1034 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1037 --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 )
1040 --verbose | --verbos | --verbo | --verb )
1041 verbose=`expr $verbose + 1`
1043 --quiet | --quie | --qui | --qu | --q )
1044 verbose=`expr $verbose - 1`
1048 if test $# = 0; then
1049 func_fatal_error "missing argument for --lib"
1052 supplied_libname=true
1055 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1056 supplied_libname=true
1060 if test $# = 0; then
1061 func_fatal_error "missing argument for --source-base"
1066 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1070 if test $# = 0; then
1071 func_fatal_error "missing argument for --m4-base"
1076 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1080 if test $# = 0; then
1081 func_fatal_error "missing argument for --po-base"
1086 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1090 if test $# = 0; then
1091 func_fatal_error "missing argument for --doc-base"
1096 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1100 if test $# = 0; then
1101 func_fatal_error "missing argument for --tests-base"
1106 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1110 if test $# = 0; then
1111 func_fatal_error "missing argument for --aux-dir"
1116 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1118 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1121 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1124 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1127 --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)
1128 inc_longrunning_tests=true
1130 --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)
1131 inc_privileged_tests=true
1133 --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)
1134 inc_unportable_tests=true
1136 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1139 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1142 --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)
1143 excl_longrunning_tests=true
1145 --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)
1146 excl_privileged_tests=true
1148 --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)
1149 excl_unportable_tests=true
1153 if test $# = 0; then
1154 func_fatal_error "missing argument for --avoid"
1156 func_append avoidlist " $1"
1159 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1160 func_append avoidlist " $arg"
1166 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1169 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1175 if test $# = 0; then
1176 func_fatal_error "missing argument for --makefile-name"
1181 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1191 if test $# = 0; then
1192 func_fatal_error "missing argument for --macro-prefix"
1197 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1201 if test $# = 0; then
1202 func_fatal_error "missing argument for --po-domain"
1207 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1215 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1221 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1224 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1227 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1231 --help | --hel | --he | --h )
1234 --version | --versio | --versi | --vers )
1238 # Stop option processing
1242 echo "gnulib-tool: unknown option $1" 1>&2
1243 echo "Try 'gnulib-tool --help' for more information." 1>&2
1250 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1251 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1252 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then
1253 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1254 echo "Try 'gnulib-tool --help' for more information." 1>&2
1258 # This code helps migrating from --import to --add-import or --update. It can
1259 # be removed on 2012-01-01.
1260 if test "$mode" = import && test $# = 0; then
1261 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1262 echo "The meaning of the option '--import' has changed." 1>&2
1263 echo "See the documentation at" 1>&2
1264 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1265 echo "For updating to a newer version of gnulib, use" 1>&2
1266 echo " gnulib-tool --add-import" 1>&2
1267 echo "For restoring files that were omitted from version control, use" 1>&2
1268 echo " gnulib-tool --update" 1>&2
1271 if test "$mode" = update; then
1272 if test $# != 0; then
1273 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1274 echo "Try 'gnulib-tool --help' for more information." 1>&2
1275 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1276 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1279 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1280 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1281 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1282 || test -n "$inctests" || test -n "$incobsolete" \
1283 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1284 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1285 || test -n "$inc_all_tests" \
1286 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1287 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1288 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1289 || test -n "$macro_prefix" || test -n "$po_domain" \
1290 || test -n "$vc_files"; then
1291 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1292 echo "Try 'gnulib-tool --help' for more information." 1>&2
1293 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1294 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1299 if test -n "$pobase" && test -z "$po_domain"; then
1300 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1301 echo "Try 'gnulib-tool --help' for more information." 1>&2
1304 if test -z "$pobase" && test -n "$po_domain"; then
1305 func_warning "--po-domain has no effect without a --po-base option"
1308 # Determine the minimum supported autoconf version from the project's
1310 DEFAULT_AUTOCONF_MINVERSION="2.59"
1311 autoconf_minversion=
1313 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1314 && test -n "$destdir"; then
1315 if test -f "$destdir"/configure.ac; then
1316 configure_ac="$destdir/configure.ac"
1318 if test -f "$destdir"/configure.in; then
1319 configure_ac="$destdir/configure.in"
1323 if test -f configure.ac; then
1324 configure_ac="configure.ac"
1326 if test -f configure.in; then
1327 configure_ac="configure.in"
1331 if test -n "$configure_ac"; then
1332 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1333 # because when some m4 files are omitted from a version control repository,
1334 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1335 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1336 # autom4te: m4 failed with exit status: 1
1343 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1345 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1346 if test -n "$prereqs"; then
1347 autoconf_minversion=`
1348 for version in $prereqs; do echo $version; done |
1349 LC_ALL=C sort -nru | sed -e 1q
1353 if test -z "$autoconf_minversion"; then
1354 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1356 case "$autoconf_minversion" in
1357 1.* | 2.[0-4]* | 2.5[0-8]*)
1358 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1361 # Remove trailing slashes from the directory names. This is necessary for
1362 # m4base (to avoid an error in func_import) and optional for the others.
1363 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1364 case "$local_gnulib_dir" in
1365 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1367 case "$sourcebase" in
1368 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1371 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1374 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1377 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1379 case "$testsbase" in
1380 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1383 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1389 trap 'exit_status=$?
1390 if test "$signal" != 0; then
1391 echo "caught signal $signal" >&2
1394 exit $exit_status' 0
1395 for signal in 1 2 3 13 15; do
1396 trap '{ signal='$signal'; func_exit 1; }' $signal
1400 # Note: The 'eval' silences stderr output in dash.
1401 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1402 # Zsh 4 and Bash 4 have associative arrays.
1403 have_associative=true
1405 # For other shells, use 'eval' with computed shell variable names.
1406 have_associative=false
1409 # func_lookup_file file
1410 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1413 # - local_gnulib_dir from --local-dir
1415 # - lookedup_file name of the merged (combined) file
1416 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1420 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1421 lookedup_file="$local_gnulib_dir/$lkfile"
1424 if test -f "$gnulib_dir/$lkfile"; then
1425 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1426 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1427 rm -f "$tmp/$lkbase"
1428 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1429 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1430 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1431 lookedup_file="$tmp/$lkbase"
1434 lookedup_file="$gnulib_dir/$lkfile"
1438 func_fatal_error "file $gnulib_dir/$lkfile not found"
1443 # func_sanitize_modulelist
1444 # receives a list of possible module names on standard input, one per line.
1445 # It removes those which are just file names unrelated to modules, and outputs
1446 # the resulting list to standard output, one per line.
1447 func_sanitize_modulelist ()
1449 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1450 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1451 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1452 -e '/^README$/d' -e '/\/README$/d' \
1453 -e '/^TEMPLATE$/d' \
1454 -e '/^TEMPLATE-EXTENDED$/d' \
1455 -e '/^TEMPLATE-TESTS$/d' \
1462 # - local_gnulib_dir from --local-dir
1465 # Filter out metainformation files like README, which are not modules.
1466 # Filter out unit test modules; they can be retrieved through
1467 # --extract-tests-module if desired.
1469 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1470 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1471 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1474 | func_sanitize_modulelist \
1475 | sed -e '/-tests$/d' \
1479 # func_exists_module module
1480 # tests whether a module, given by name, exists
1482 # - local_gnulib_dir from --local-dir
1483 func_exists_module ()
1485 { test -f "$gnulib_dir/modules/$1" \
1486 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1487 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1488 && test "CVS" != "$1" \
1489 && test "ChangeLog" != "$1" \
1490 && test "COPYING" != "$1" \
1491 && test "README" != "$1" \
1492 && test "TEMPLATE" != "$1" \
1493 && test "TEMPLATE-EXTENDED" != "$1" \
1494 && test "TEMPLATE-TESTS" != "$1"
1497 # func_verify_module
1498 # verifies a module name
1500 # - local_gnulib_dir from --local-dir
1501 # - module module name argument
1502 func_verify_module ()
1504 if func_exists_module "$module"; then
1505 # OK, $module is a correct module name.
1506 # Verify that building the module description with 'patch' succeeds.
1507 func_lookup_file "modules/$module"
1509 func_warning "module $module doesn't exist"
1514 # func_verify_nontests_module
1515 # verifies a module name, excluding tests modules
1517 # - local_gnulib_dir from --local-dir
1518 # - module module name argument
1519 func_verify_nontests_module ()
1522 *-tests ) module= ;;
1523 * ) func_verify_module ;;
1527 # func_verify_tests_module
1528 # verifies a module name, considering only tests modules
1530 # - local_gnulib_dir from --local-dir
1531 # - module module name argument
1532 func_verify_tests_module ()
1535 *-tests ) func_verify_module ;;
1540 # Suffix of a sed expression that extracts a particular field from a
1541 # module description.
1542 # A field starts with a line that contains a keyword, such as 'Description',
1543 # followed by a colon and optional whitespace. All following lines, up to
1544 # the next field (or end of file if there is none) form the contents of the
1546 # An absent field is equivalent to a field with empty contents.
1547 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1548 sed_extract_prog=':[ ]*$/ {
1551 s/^Description:[ ]*$//
1555 s/^Applicability:[ ]*$//
1557 s/^Depends-on:[ ]*$//
1558 s/^configure\.ac-early:[ ]*$//
1559 s/^configure\.ac:[ ]*$//
1560 s/^Makefile\.am:[ ]*$//
1564 s/^Maintainer:[ ]*$//
1571 # Piece of a sed expression that converts a field header line to a shell
1573 # NOTE: Keep this in sync with sed_extract_prog above!
1574 sed_extract_field_header='
1575 s/^Description:[ ]*$/description/
1576 s/^Comment:[ ]*$/comment/
1577 s/^Status:[ ]*$/status/
1578 s/^Notice:[ ]*$/notice/
1579 s/^Applicability:[ ]*$/applicability/
1580 s/^Files:[ ]*$/files/
1581 s/^Depends-on:[ ]*$/dependson/
1582 s/^configure\.ac-early:[ ]*$/configureac_early/
1583 s/^configure\.ac:[ ]*$/configureac/
1584 s/^Makefile\.am:[ ]*$/makefile/
1585 s/^Include:[ ]*$/include/
1587 s/^License:[ ]*$/license/
1588 s/^Maintainer:[ ]*$/maintainer/'
1592 if $have_associative; then
1594 # Declare the associative arrays.
1595 declare -A modcache_cached
1596 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1597 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1598 eval "$declare_script"
1602 # func_cache_var module
1603 # computes the cache variable name corresponding to $module.
1604 # Note: This computation can map different module names to the same
1605 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1606 # to protect against this case.
1608 # - cachevar a shell variable name
1609 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1610 # Bash 2.0 and newer, ksh, and zsh support the syntax
1611 # ${param//pattern/replacement}
1612 # as a shorthand for
1613 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1614 # Note: The 'eval' above silences stderr output in dash.
1617 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1624 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1633 # func_init_sed_convert_to_cache_statements
1635 # - modcachevar_assignment
1637 # - sed_convert_to_cache_statements
1638 func_init_sed_convert_to_cache_statements ()
1640 # 'sed' script that turns a module description into shell script
1641 # assignments, suitable to be eval'ed. All active characters are escaped.
1644 # Some module's description
1649 # modcache_description[$1]=\
1650 # 'Some module'"'"'s description
1652 # modcache_files[$1]=\
1655 # c_MODULE_description_set=set; c_MODULE_description=\
1656 # 'Some module'"'"'s description
1658 # c_MODULE_files_set=set; c_MODULE_files=\
1660 # The script consists of two parts:
1661 # 1) Ignore the lines before the first field header.
1662 # 2) A loop, treating non-field-header lines by escaping single quotes
1663 # and adding a closing quote in the last line,
1664 sed_convert_to_cache_statements="
1666 # Here we have not yet seen a field header.
1668 # See if the current line contains a field header.
1671 ${sed_extract_field_header}
1674 # No field header. Ignore the line.
1676 # Read the next line. Upon EOF, just exit.
1681 # The current line contains a field header.
1683 # Turn it into the beginning of an assignment.
1684 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1686 # Move it to the hold space. Don't print it yet,
1687 # because we want no assignment if the field is empty.
1690 # Read the next line.
1691 # Upon EOF, the field was empty. Print no assignment. Just exit.
1694 # See if the current line contains a field header.
1697 ${sed_extract_field_header}
1698 # If it is, the previous field was empty. Print no assignment.
1701 # Not a field header.
1703 # Print the previous line, held in the hold space.
1708 # Transform single quotes.
1711 # Prepend a single quote.
1716 # Move it to the hold space.
1719 # Read the next line.
1726 # See if the current line contains a field header.
1729 ${sed_extract_field_header}
1732 # Print the previous line, held in the hold space.
1737 # Transform single quotes.
1744 # Print the previous line, held in the hold space, with a single quote
1745 # to end the assignment.
1755 # Print the previous line, held in the hold space, with a single quote
1756 # to end the assignment.
1763 if ! $sed_comments; then
1765 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1766 | sed -e 's/^ *//' -e 's/^#.*//'`
1770 if $have_associative; then
1771 # sed_convert_to_cache_statements does not depend on the module.
1772 modcachevar_assignment='modcache_\1[$1]='
1773 func_init_sed_convert_to_cache_statements
1776 # func_cache_lookup_module module
1778 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1779 # of its relevant data in a cache in the memory of the processing shell. If
1780 # already cached, it does not look it up again, thus saving file access time.
1782 # - module non-empty string
1783 # Output if $have_associative:
1784 # - modcache_cached[$module] set to yes
1785 # - modcache_description[$module] ==
1786 # - modcache_status[$module] \ set to the field's value, minus the
1787 # - ... / final newline,
1788 # - modcache_maintainer[$module] == or unset if the field's value is empty
1789 # Output if ! $have_associative:
1790 # - cachevar a shell variable name
1791 # - ${cachevar}_cached set to $module
1792 # - ${cachevar}_description ==
1793 # - ${cachevar}_status \ set to the field's value, minus the
1794 # - ... / final newline,
1795 # - ${cachevar}_maintainer == or unset if the field's value is empty
1796 # - ${cachevar}_description_set ==
1797 # - ${cachevar}_status_set \ set to non-empty if the field's value
1798 # - ... / is non-empty,
1799 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1800 func_cache_lookup_module ()
1802 if $have_associative; then
1803 cached=${modcache_cached[$1]}
1806 eval "cached=\"\$${cachevar}_cached\""
1808 if test -z "$cached"; then
1809 # Not found in cache. Look it up on the file system.
1810 func_lookup_file "modules/$1"
1811 if $have_associative; then
1812 modcache_cached[$1]=yes
1814 eval "${cachevar}_cached=\"\$1\""
1816 if ! $have_associative; then
1817 # sed_convert_to_cache_statements depends on the module.
1818 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1819 func_init_sed_convert_to_cache_statements
1821 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1822 eval "$cache_statements"
1824 if ! $have_associative; then
1825 if test "$1" != "$cached"; then
1826 func_fatal_error "cache variable collision between $1 and $cached"
1834 # func_get_description module
1836 # - local_gnulib_dir from --local-dir
1837 # - modcache true or false, from --cache-modules/--no-cache-modules
1838 func_get_description ()
1840 if ! $modcache; then
1841 func_lookup_file "modules/$1"
1842 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1844 func_cache_lookup_module "$1"
1845 # Output the field's value, including the final newline (if any).
1846 if $have_associative; then
1847 if test -n "${modcache_description[$1]+set}"; then
1848 echo "${modcache_description[$1]}"
1851 eval "field_set=\"\$${cachevar}_description_set\""
1852 if test -n "$field_set"; then
1853 eval "field_value=\"\$${cachevar}_description\""
1854 echo "${field_value}"
1860 # func_get_comment module
1862 # - local_gnulib_dir from --local-dir
1863 # - modcache true or false, from --cache-modules/--no-cache-modules
1866 if ! $modcache; then
1867 func_lookup_file "modules/$1"
1868 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1870 func_cache_lookup_module "$1"
1871 # Output the field's value, including the final newline (if any).
1872 if $have_associative; then
1873 if test -n "${modcache_comment[$1]+set}"; then
1874 echo "${modcache_comment[$1]}"
1877 eval "field_set=\"\$${cachevar}_comment_set\""
1878 if test -n "$field_set"; then
1879 eval "field_value=\"\$${cachevar}_comment\""
1880 echo "${field_value}"
1886 # func_get_status module
1888 # - local_gnulib_dir from --local-dir
1889 # - modcache true or false, from --cache-modules/--no-cache-modules
1892 if ! $modcache; then
1893 func_lookup_file "modules/$1"
1894 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1896 func_cache_lookup_module "$1"
1897 # Output the field's value, including the final newline (if any).
1898 if $have_associative; then
1899 if test -n "${modcache_status[$1]+set}"; then
1900 echo "${modcache_status[$1]}"
1903 eval "field_set=\"\$${cachevar}_status_set\""
1904 if test -n "$field_set"; then
1905 eval "field_value=\"\$${cachevar}_status\""
1906 echo "${field_value}"
1912 # func_get_notice module
1914 # - local_gnulib_dir from --local-dir
1915 # - modcache true or false, from --cache-modules/--no-cache-modules
1918 if ! $modcache; then
1919 func_lookup_file "modules/$1"
1920 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1922 func_cache_lookup_module "$1"
1923 # Output the field's value, including the final newline (if any).
1924 if $have_associative; then
1925 if test -n "${modcache_notice[$1]+set}"; then
1926 echo "${modcache_notice[$1]}"
1929 eval "field_set=\"\$${cachevar}_notice_set\""
1930 if test -n "$field_set"; then
1931 eval "field_value=\"\$${cachevar}_notice\""
1932 echo "${field_value}"
1938 # func_get_applicability module
1940 # - local_gnulib_dir from --local-dir
1941 # - modcache true or false, from --cache-modules/--no-cache-modules
1942 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1943 func_get_applicability ()
1945 if ! $modcache; then
1946 func_lookup_file "modules/$1"
1947 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1949 func_cache_lookup_module "$1"
1950 # Get the field's value, without the final newline.
1951 if $have_associative; then
1952 my_applicability="${modcache_applicability[$1]}"
1954 eval "my_applicability=\"\$${cachevar}_applicability\""
1957 if test -n "$my_applicability"; then
1958 echo $my_applicability
1960 # The default is 'main' or 'tests', depending on the module's name.
1962 *-tests) echo "tests";;
1968 # func_get_filelist module
1970 # - local_gnulib_dir from --local-dir
1971 # - modcache true or false, from --cache-modules/--no-cache-modules
1972 func_get_filelist ()
1974 if ! $modcache; then
1975 func_lookup_file "modules/$1"
1976 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1978 func_cache_lookup_module "$1"
1979 # Output the field's value, including the final newline (if any).
1980 if $have_associative; then
1981 if test -n "${modcache_files[$1]+set}"; then
1982 echo "${modcache_files[$1]}"
1985 eval "field_set=\"\$${cachevar}_files_set\""
1986 if test -n "$field_set"; then
1987 eval "field_value=\"\$${cachevar}_files\""
1988 echo "${field_value}"
1993 echo m4/gnulib-common.m4
1994 case "$autoconf_minversion" in
2001 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2002 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2003 # elements starting with prefix and ending with suffix are considered.
2004 # Processing: removed_prefix and removed_suffix are removed from each element,
2005 # added_prefix and added_suffix are added to each element.
2006 # prefix, suffix should not contain shell-special characters.
2007 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2008 # added_prefix, added_suffix should not contain the characters \|&.
2009 func_filter_filelist ()
2011 if test "$2" != "$nl" \
2012 || { $fast_func_append \
2013 && { test -z "$6" || $fast_func_remove_prefix; } \
2014 && { test -z "$7" || $fast_func_remove_suffix; }; \
2018 # Do not quote possibly-empty parameters in case patterns,
2019 # AIX and HP-UX ksh won't match them if they are empty.
2022 if test -n "$6"; then
2023 func_remove_prefix fff "$6"
2025 if test -n "$7"; then
2026 func_remove_suffix fff "$7"
2029 if test -z "$ffflist"; then
2032 func_append ffflist "$2${fff}"
2038 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2039 ffflist=`for fff in $3; do
2041 $4*$5) echo "$fff" ;;
2043 done | sed -e "$sed_fff_filter"`
2045 eval "$1=\"\$ffflist\""
2048 # func_get_dependencies module
2050 # - local_gnulib_dir from --local-dir
2051 # - modcache true or false, from --cache-modules/--no-cache-modules
2052 func_get_dependencies ()
2054 # ${module}-tests implicitly depends on ${module}, if that module exists.
2058 func_remove_suffix fgd1 '-tests'
2059 if func_exists_module "$fgd1"; then
2064 # Then the explicit dependencies listed in the module description.
2065 if ! $modcache; then
2066 func_lookup_file "modules/$1"
2067 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2069 func_cache_lookup_module "$1"
2070 # Output the field's value, including the final newline (if any).
2071 if $have_associative; then
2072 if test -n "${modcache_dependson[$1]+set}"; then
2073 echo "${modcache_dependson[$1]}"
2076 eval "field_set=\"\$${cachevar}_dependson_set\""
2077 if test -n "$field_set"; then
2078 eval "field_value=\"\$${cachevar}_dependson\""
2079 echo "${field_value}"
2085 # func_get_autoconf_early_snippet module
2087 # - local_gnulib_dir from --local-dir
2088 # - modcache true or false, from --cache-modules/--no-cache-modules
2089 func_get_autoconf_early_snippet ()
2091 if ! $modcache; then
2092 func_lookup_file "modules/$1"
2093 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2095 func_cache_lookup_module "$1"
2096 # Output the field's value, including the final newline (if any).
2097 if $have_associative; then
2098 if test -n "${modcache_configureac_early[$1]+set}"; then
2099 echo "${modcache_configureac_early[$1]}"
2102 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2103 if test -n "$field_set"; then
2104 eval "field_value=\"\$${cachevar}_configureac_early\""
2105 echo "${field_value}"
2111 # func_get_autoconf_snippet module
2113 # - local_gnulib_dir from --local-dir
2114 # - modcache true or false, from --cache-modules/--no-cache-modules
2115 func_get_autoconf_snippet ()
2117 if ! $modcache; then
2118 func_lookup_file "modules/$1"
2119 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2121 func_cache_lookup_module "$1"
2122 # Output the field's value, including the final newline (if any).
2123 if $have_associative; then
2124 if test -n "${modcache_configureac[$1]+set}"; then
2125 echo "${modcache_configureac[$1]}"
2128 eval "field_set=\"\$${cachevar}_configureac_set\""
2129 if test -n "$field_set"; then
2130 eval "field_value=\"\$${cachevar}_configureac\""
2131 echo "${field_value}"
2137 # func_get_automake_snippet module
2139 # - local_gnulib_dir from --local-dir
2140 # - modcache true or false, from --cache-modules/--no-cache-modules
2141 func_get_automake_snippet ()
2143 if ! $modcache; then
2144 func_lookup_file "modules/$1"
2145 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2147 func_cache_lookup_module "$1"
2148 # Output the field's value, including the final newline (if any).
2149 if $have_associative; then
2150 if test -n "${modcache_makefile[$1]+set}"; then
2151 echo "${modcache_makefile[$1]}"
2154 eval "field_set=\"\$${cachevar}_makefile_set\""
2155 if test -n "$field_set"; then
2156 eval "field_value=\"\$${cachevar}_makefile\""
2157 echo "${field_value}"
2163 # *-tests module live in tests/, not lib/.
2164 # Synthesize an EXTRA_DIST augmentation.
2165 all_files=`func_get_filelist $1`
2166 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2167 extra_files="$tests_files"
2168 if test -n "$extra_files"; then
2169 echo "EXTRA_DIST +=" $extra_files
2174 # Synthesize an EXTRA_DIST augmentation.
2175 sed_combine_lines='/\\$/{
2182 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2183 already_mentioned_files=` \
2184 { if ! $modcache; then
2185 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2187 if $have_associative; then
2188 if test -n "${modcache_makefile[$1]+set}"; then
2189 echo "${modcache_makefile[$1]}"
2192 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2193 if test -n "$field_set"; then
2194 eval 'field_value="$'"${cachevar}"'_makefile"'
2195 echo "${field_value}"
2200 | sed -e "$sed_combine_lines" \
2201 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2202 all_files=`func_get_filelist $1`
2203 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2204 # Remove $already_mentioned_files from $lib_files.
2205 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2206 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2207 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2208 if test -n "$extra_files"; then
2209 echo "EXTRA_DIST +=" $extra_files
2212 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2213 # This is necessary so that automake can generate the right list of
2215 # A possible approach would be to use autom4te --trace of the redefined
2216 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2217 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2218 # inside autoconf's built-in macros are not missed).
2219 # But it's simpler and more robust to do it here, based on the file list.
2220 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2221 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2222 # automake will generate a useless dependency; this is harmless.
2224 relocatable-prog-wrapper) ;;
2226 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2227 if test -n "$extra_files"; then
2228 echo "EXTRA_lib_SOURCES +=" $extra_files
2233 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2234 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2235 if test -n "$buildaux_files"; then
2236 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2237 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2240 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2241 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2242 if test -n "$top_files"; then
2243 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2244 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2251 # func_get_include_directive module
2253 # - local_gnulib_dir from --local-dir
2254 # - modcache true or false, from --cache-modules/--no-cache-modules
2255 func_get_include_directive ()
2258 if ! $modcache; then
2259 func_lookup_file "modules/$1"
2260 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2262 func_cache_lookup_module "$1"
2263 # Output the field's value, including the final newline (if any).
2264 if $have_associative; then
2265 if test -n "${modcache_include[$1]+set}"; then
2266 echo "${modcache_include[$1]}"
2269 eval "field_set=\"\$${cachevar}_include_set\""
2270 if test -n "$field_set"; then
2271 eval "field_value=\"\$${cachevar}_include\""
2272 echo "${field_value}"
2276 } | sed -e 's/^\(["<]\)/#include \1/'
2279 # func_get_link_directive module
2281 # - local_gnulib_dir from --local-dir
2282 # - modcache true or false, from --cache-modules/--no-cache-modules
2283 func_get_link_directive ()
2285 if ! $modcache; then
2286 func_lookup_file "modules/$1"
2287 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2289 func_cache_lookup_module "$1"
2290 # Output the field's value, including the final newline (if any).
2291 if $have_associative; then
2292 if test -n "${modcache_link[$1]+set}"; then
2293 echo "${modcache_link[$1]}"
2296 eval "field_set=\"\$${cachevar}_link_set\""
2297 if test -n "$field_set"; then
2298 eval "field_value=\"\$${cachevar}_link\""
2299 echo "${field_value}"
2305 # func_get_license module
2307 # - local_gnulib_dir from --local-dir
2308 # - modcache true or false, from --cache-modules/--no-cache-modules
2312 if ! $modcache; then
2313 func_lookup_file "modules/$1"
2314 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2316 func_cache_lookup_module "$1"
2317 # Output the field's value, including the final newline (if any).
2318 if $have_associative; then
2319 if test -n "${modcache_license[$1]+set}"; then
2320 echo "${modcache_license[$1]}"
2323 eval "field_set=\"\$${cachevar}_license_set\""
2324 if test -n "$field_set"; then
2325 eval "field_value=\"\$${cachevar}_license\""
2326 echo "${field_value}"
2330 # The default is GPL.
2332 } | sed -e 's,^ *$,,' | sed -e 1q
2335 # func_get_maintainer module
2337 # - local_gnulib_dir from --local-dir
2338 # - modcache true or false, from --cache-modules/--no-cache-modules
2339 func_get_maintainer ()
2341 if ! $modcache; then
2342 func_lookup_file "modules/$1"
2343 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2345 func_cache_lookup_module "$1"
2346 # Output the field's value, including the final newline (if any).
2347 if $have_associative; then
2348 if test -n "${modcache_maintainer[$1]+set}"; then
2349 echo "${modcache_maintainer[$1]}"
2352 eval "field_set=\"\$${cachevar}_maintainer_set\""
2353 if test -n "$field_set"; then
2354 eval "field_value=\"\$${cachevar}_maintainer\""
2355 echo "${field_value}"
2361 # func_get_tests_module module
2363 # - local_gnulib_dir from --local-dir
2364 func_get_tests_module ()
2366 # The naming convention for tests modules is hardwired: ${module}-tests.
2367 if test -f "$gnulib_dir/modules/$1"-tests \
2368 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2369 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2374 # func_acceptable module
2375 # tests whether a module is acceptable.
2377 # - avoidlist list of modules to avoid
2380 for avoid in $avoidlist; do
2381 if test "$avoid" = "$1"; then
2388 # func_modules_transitive_closure
2390 # - local_gnulib_dir from --local-dir
2391 # - modcache true or false, from --cache-modules/--no-cache-modules
2392 # - modules list of specified modules
2393 # - inctests true if tests should be included, blank otherwise
2394 # - incobsolete true if obsolete modules among dependencies should be
2395 # included, blank otherwise
2396 # - inc_cxx_tests true if C++ interoperability tests should be included,
2398 # - inc_longrunning_tests true if long-runnings tests should be included,
2400 # - inc_privileged_tests true if tests that require root privileges should be
2401 # included, blank otherwise
2402 # - inc_unportable_tests true if tests that fail on some platforms should be
2403 # included, blank otherwise
2404 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2405 # the unit tests of the specified modules should be
2406 # included, blank otherwise
2407 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2408 # the unit tests of the dependencies should be
2409 # included, blank otherwise
2410 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2412 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2414 # - excl_privileged_tests true if tests that require root privileges should be
2415 # excluded, blank otherwise
2416 # - excl_unportable_tests true if tests that fail on some platforms should be
2417 # excluded, blank otherwise
2418 # - avoidlist list of modules to avoid
2419 # - tmp pathname of a temporary directory
2421 # - modules list of modules, including dependencies
2422 func_modules_transitive_closure ()
2424 # In order to process every module only once (for speed), process an "input
2425 # list" of modules, producing an "output list" of modules. During each round,
2426 # more modules can be queued in the input list. Once a module on the input
2427 # list has been processed, it is added to the "handled list", so we can avoid
2428 # to process it again.
2430 inmodules="$modules"
2432 fmtc_inc_all_tests="$inc_all_direct_tests"
2433 while test -n "$inmodules"; do
2434 inmodules_this_round="$inmodules"
2435 inmodules= # Accumulator, queue for next round
2436 for module in $inmodules_this_round; do
2438 if test -n "$module"; then
2439 if func_acceptable $module; then
2440 func_append outmodules " $module"
2441 deps=`func_get_dependencies $module`
2442 # Duplicate dependencies are harmless, but Jim wants a warning.
2443 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2444 if test -n "$duplicated_deps"; then
2445 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2447 if test -n "$inctests"; then
2448 testsmodule=`func_get_tests_module $module`
2449 if test -n "$testsmodule"; then
2450 deps="$deps $testsmodule"
2453 for dep in $deps; do
2454 # Determine whether to include the dependency or tests module.
2456 for word in `func_get_status $dep`; do
2459 test -n "$incobsolete" \
2463 test -z "$excl_cxx_tests" \
2465 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2469 test -z "$excl_longrunning_tests" \
2471 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2475 test -z "$excl_privileged_tests" \
2477 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2481 test -z "$excl_unportable_tests" \
2483 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2487 test -n "$fmtc_inc_all_tests" \
2493 func_append inmodules " $dep"
2499 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2500 # Remove $handledmodules from $inmodules.
2501 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2502 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2503 fmtc_inc_all_tests="$inc_all_indirect_tests"
2505 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2506 rm -f "$tmp"/queued-modules
2509 # func_show_module_list
2511 # - specified_modules list of specified modules (one per line, sorted)
2512 # - modules complete list of modules (one per line, sorted)
2513 # - tmp pathname of a temporary directory
2514 func_show_module_list ()
2520 # Assume xterm compatible escape sequences.
2521 bold_on=`printf '\x1b[1m'`
2522 bold_off=`printf '\x1b[0m'`
2527 echo "Module list with included dependencies (indented):"
2528 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2529 echo "$modules" | sed -e '/^$/d' \
2530 | LC_ALL=C join -t '|' -a 2 "$tmp"/specified-modules - \
2531 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2534 # func_modules_add_dummy
2536 # - local_gnulib_dir from --local-dir
2537 # - modcache true or false, from --cache-modules/--no-cache-modules
2538 # - modules list of modules, including dependencies
2540 # - modules list of modules, including 'dummy' if needed
2541 func_modules_add_dummy ()
2543 # Determine whether any module provides a lib_SOURCES augmentation.
2545 sed_remove_backslash_newline=':a
2552 for module in $modules; do
2553 func_verify_nontests_module
2554 if test -n "$module"; then
2555 # Extract the value of "lib_SOURCES += ...".
2556 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2557 # Ignore .h files since they are not compiled.
2561 have_lib_SOURCES=yes
2568 # Add the dummy module, to make sure the library will be non-empty.
2569 if test -z "$have_lib_SOURCES"; then
2570 if func_acceptable "dummy"; then
2571 func_append modules " dummy"
2576 # func_modules_notice
2578 # - local_gnulib_dir from --local-dir
2579 # - modcache true or false, from --cache-modules/--no-cache-modules
2580 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2581 # - modules list of modules, including dependencies
2582 func_modules_notice ()
2584 if test $verbose -ge -1; then
2585 for module in $modules; do
2587 if test -n "$module"; then
2588 msg=`func_get_notice $module`
2589 if test -n "$msg"; then
2590 echo "Notice from module $module:"
2591 echo "$msg" | sed -e 's/^/ /'
2598 # func_modules_to_filelist
2600 # - local_gnulib_dir from --local-dir
2601 # - modcache true or false, from --cache-modules/--no-cache-modules
2602 # - modules list of modules, including dependencies
2604 # - files list of files
2605 func_modules_to_filelist ()
2608 for module in $modules; do
2610 if test -n "$module"; then
2611 fs=`func_get_filelist $module`
2612 func_append files " $fs"
2615 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2618 # func_execute_command command [args...]
2619 # Executes a command.
2620 # Uses also the variables
2621 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2622 func_execute_command ()
2624 if test $verbose -ge 0; then
2628 # Commands like automake produce output to stderr even when they succeed.
2629 # Turn this output off if the command succeeds.
2630 "$@" > "$tmp"/cmdout 2>&1
2632 if test $cmdret = 0; then
2636 cat "$tmp"/cmdout 1>&2
2643 # func_dest_tmpfilename file
2644 # determines the name of a temporary file (file is relative to destdir).
2646 # - destdir target directory
2647 # - doit : if actions shall be executed, false if only to be printed
2648 # - tmp pathname of a temporary directory
2650 # - tmpfile absolute filename of the temporary file
2651 func_dest_tmpfilename ()
2654 # Put the new contents of $file in a file in the same directory (needed
2655 # to guarantee that an 'mv' to "$destdir/$file" works).
2656 tmpfile="$destdir/$1.tmp"
2658 # Put the new contents of $file in a file in a temporary directory
2659 # (because the directory of "$file" might not exist).
2660 tmpfile="$tmp"/`basename "$1"`.tmp
2665 # copies a file from gnulib into the destination directory. The destination
2666 # is known to not exist.
2668 # - destdir target directory
2669 # - local_gnulib_dir from --local-dir
2670 # - modcache true or false, from --cache-modules/--no-cache-modules
2671 # - f the original file name
2672 # - lookedup_file name of the merged (combined) file
2673 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2674 # - g the rewritten file name
2675 # - tmpfile absolute filename of the temporary file
2676 # - doit : if actions shall be executed, false if only to be printed
2677 # - symbolic true if files should be symlinked, copied otherwise
2678 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2683 echo "Copying file $g"
2684 if { test -n "$symbolic" \
2685 || { test -n "$lsymbolic" \
2686 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2687 && test -z "$lookedup_tmp" \
2688 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2689 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2691 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2699 # copies a file from gnulib into the destination directory. The destination
2700 # is known to exist.
2702 # - destdir target directory
2703 # - local_gnulib_dir from --local-dir
2704 # - modcache true or false, from --cache-modules/--no-cache-modules
2705 # - f the original file name
2706 # - lookedup_file name of the merged (combined) file
2707 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2708 # - g the rewritten file name
2709 # - tmpfile absolute filename of the temporary file
2710 # - doit : if actions shall be executed, false if only to be printed
2711 # - symbolic true if files should be symlinked, copied otherwise
2712 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2714 # - already_present nonempty if the file should already exist, empty otherwise
2717 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2718 : # The file has not changed.
2722 if test -n "$already_present"; then
2723 echo "Updating file $g (backup in ${g}~)"
2725 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2727 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2728 if { test -n "$symbolic" \
2729 || { test -n "$lsymbolic" \
2730 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2731 && test -z "$lookedup_tmp" \
2732 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2733 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2735 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2738 if test -n "$already_present"; then
2739 echo "Update file $g (backup in ${g}~)"
2741 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2747 # func_emit_lib_Makefile_am
2748 # emits the contents of library makefile to standard output.
2750 # - local_gnulib_dir from --local-dir
2751 # - modcache true or false, from --cache-modules/--no-cache-modules
2752 # - modules list of modules, including dependencies
2753 # - libname library name
2754 # - pobase directory relative to destdir where to place *.po files
2755 # - auxdir directory relative to destdir where to place build aux files
2756 # - makefile_name from --makefile-name
2757 # - libtool true if libtool will be used, false or blank otherwise
2758 # - macro_prefix prefix of gl_LIBOBJS macros to use
2759 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2760 # - actioncmd (optional) command that will reproduce this invocation
2761 # - for_test true if creating a package for testing, false otherwise
2762 # - destfile filename relative to destdir of makefile being generated
2764 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2765 # list of edits to be done to Makefile.am variables
2767 # - uses_subdirs nonempty if object files in subdirs exist
2768 func_emit_lib_Makefile_am ()
2770 # When creating an includable Makefile.am snippet, augment variables with
2771 # += instead of assigning them.
2772 if test -n "$makefile_name"; then
2777 if test "$libtool" = true; then
2780 sed_eliminate_LDFLAGS="$sed_noop"
2784 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2787 # When creating a package for testing: Attempt to provoke failures,
2788 # especially link errors, already during "make" rather than during
2789 # "make check", because "make check" is not possible in a cross-compiling
2790 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2791 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2793 sed_transform_check_PROGRAMS="$sed_noop"
2795 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2796 echo "## Process this file with automake to produce Makefile.in."
2797 func_emit_copyright_notice
2798 if test -n "$actioncmd"; then
2799 # The maximum line length (excluding the terminating newline) of any file
2800 # that is to be preprocessed by config.status is 3070. config.status uses
2801 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2802 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2803 len=`echo "$actioncmd" | wc -c`
2804 if test -n "$len" && test "$len" -le 3000; then
2805 echo "# Reproduce by: $actioncmd"
2811 for module in $modules; do
2812 func_verify_nontests_module
2813 if test -n "$module"; then
2815 func_get_automake_snippet "$module" |
2817 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2818 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2819 -e "$sed_eliminate_LDFLAGS" \
2820 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2821 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2822 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2823 -e "$sed_transform_check_PROGRAMS"
2824 if test "$module" = 'alloca'; then
2825 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2826 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2828 } > "$tmp"/amsnippet
2829 # Skip the contents if it's entirely empty.
2830 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2831 echo "## begin gnulib module $module"
2833 cat "$tmp"/amsnippet
2834 echo "## end gnulib module $module"
2837 rm -f "$tmp"/amsnippet
2838 # Test whether there are some source files in subdirectories.
2839 for f in `func_get_filelist "$module"`; do
2849 } > "$tmp"/allsnippets
2850 if test -z "$makefile_name"; then
2851 # If there are source files in subdirectories, prevent collision of the
2852 # object files (example: hash.c and libxml/hash.c).
2854 if test -n "$uses_subdirs"; then
2855 subdir_options=' subdir-objects'
2857 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2860 if test -z "$makefile_name"; then
2862 echo "noinst_HEADERS ="
2863 echo "noinst_LIBRARIES ="
2864 echo "noinst_LTLIBRARIES ="
2865 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2866 # if you specify pkgdata_DATA to empty. This is a workaround.
2867 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2868 echo "pkgdata_DATA ="
2871 echo "BUILT_SOURCES ="
2874 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2875 if test -z "$makefile_name"; then
2876 echo "MOSTLYCLEANDIRS ="
2878 echo "DISTCLEANFILES ="
2879 echo "MAINTAINERCLEANFILES ="
2881 # Execute edits that apply to the Makefile.am being generated.
2883 while test $edit != $makefile_am_edits; do
2884 edit=`expr $edit + 1`
2885 eval dir=\"\$makefile_am_edit${edit}_dir\"
2886 eval var=\"\$makefile_am_edit${edit}_var\"
2887 eval val=\"\$makefile_am_edit${edit}_val\"
2888 if test -n "$var"; then
2889 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2890 echo "${var} += ${val}"
2891 eval "makefile_am_edit${edit}_var="
2895 if test -z "$makefile_name"; then
2898 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
2900 echo "AM_CPPFLAGS ="
2905 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2906 || { test -n "$makefile_name" \
2907 && test -f "$sourcebase/Makefile.am" \
2908 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2910 # One of the snippets or the user's Makefile.am already specifies an
2911 # installation location for the library. Don't confuse automake by saying
2912 # it should not be installed.
2915 # By default, the generated library should not be installed.
2916 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2919 echo "${libname}_${libext}_SOURCES ="
2920 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2921 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2922 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2923 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2924 echo "EXTRA_${libname}_${libext}_SOURCES ="
2925 if test "$libtool" = true; then
2926 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2929 if test -n "$pobase"; then
2930 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2933 cat "$tmp"/allsnippets \
2934 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2936 echo "mostlyclean-local: mostlyclean-generic"
2937 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2938 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2939 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2943 rm -f "$tmp"/allsnippets
2946 # func_emit_po_Makevars
2947 # emits the contents of po/ makefile parameterization to standard output.
2949 # - local_gnulib_dir from --local-dir
2950 # - modcache true or false, from --cache-modules/--no-cache-modules
2951 # - sourcebase directory relative to destdir where to place source code
2952 # - pobase directory relative to destdir where to place *.po files
2953 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2954 func_emit_po_Makevars ()
2956 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2957 func_emit_copyright_notice
2959 echo "# Usually the message domain is the same as the package name."
2960 echo "# But here it has a '-gnulib' suffix."
2961 echo "DOMAIN = ${po_domain}-gnulib"
2963 echo "# These two variables depend on the location of this directory."
2964 echo "subdir = ${pobase}"
2965 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2968 # These options get passed to xgettext.
2969 XGETTEXT_OPTIONS = \
2970 --keyword=_ --flag=_:1:pass-c-format \
2971 --keyword=N_ --flag=N_:1:pass-c-format \
2972 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2973 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2974 --flag=error:3:c-format --flag=error_at_line:5:c-format
2976 # This is the copyright holder that gets inserted into the header of the
2977 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2978 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2980 # This is the email address or URL to which the translators shall report
2981 # bugs in the untranslated strings:
2982 # - Strings which are not entire sentences, see the maintainer guidelines
2983 # in the GNU gettext documentation, section 'Preparing Strings'.
2984 # - Strings which use unclear terms or require additional context to be
2986 # - Strings which make invalid assumptions about notation of date, time or
2988 # - Pluralisation problems.
2989 # - Incorrect English spelling.
2990 # - Incorrect formatting.
2991 # It can be your email address, or a mailing list address where translators
2992 # can write to without being subscribed, or the URL of a web page through
2993 # which the translators can contact you.
2994 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2996 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2997 # message catalogs shall be used. It is usually empty.
2998 EXTRA_LOCALE_CATEGORIES =
3000 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3001 # context. Possible values are "yes" and "no". Set this to yes if the
3002 # package uses functions taking also a message context, like pgettext(), or
3003 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3008 # func_emit_po_POTFILES_in
3009 # emits the file list to be passed to xgettext to standard output.
3011 # - local_gnulib_dir from --local-dir
3012 # - modcache true or false, from --cache-modules/--no-cache-modules
3013 # - sourcebase directory relative to destdir where to place source code
3014 # - files list of new files
3015 func_emit_po_POTFILES_in ()
3017 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3018 func_emit_copyright_notice
3020 echo "# List of files which contain translatable strings."
3021 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3024 # func_emit_tests_Makefile_am witness_macro
3025 # emits the contents of tests makefile to standard output.
3027 # - local_gnulib_dir from --local-dir
3028 # - modcache true or false, from --cache-modules/--no-cache-modules
3029 # - modules list of modules, including dependencies
3030 # - libname library name
3031 # - auxdir directory relative to destdir where to place build aux files
3032 # - makefile_name from --makefile-name
3033 # - libtool true if libtool will be used, false or blank otherwise
3034 # - sourcebase relative directory containing lib source code
3035 # - m4base relative directory containing autoconf macros
3036 # - testsbase relative directory containing unit test code
3037 # - macro_prefix prefix of gl_LIBOBJS macros to use
3038 # - for_test true if creating a package for testing, false otherwise
3039 # - use_libtests true if a libtests.a should be built, false otherwise
3040 # - destfile filename relative to destdir of makefile being generated
3042 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3043 # list of edits to be done to Makefile.am variables
3045 # - uses_subdirs nonempty if object files in subdirs exist
3046 func_emit_tests_Makefile_am ()
3049 if test "$libtool" = true; then
3051 sed_eliminate_LDFLAGS="$sed_noop"
3054 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3057 # When creating a package for testing: Attempt to provoke failures,
3058 # especially link errors, already during "make" rather than during
3059 # "make check", because "make check" is not possible in a cross-compiling
3060 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3061 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3063 sed_transform_check_PROGRAMS="$sed_noop"
3065 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3066 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3067 echo "## Process this file with automake to produce Makefile.in."
3068 func_emit_copyright_notice
3072 for module in $modules; do
3074 func_verify_tests_module
3078 if test -n "$module"; then
3080 func_get_automake_snippet "$module" |
3082 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3083 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3084 -e "$sed_eliminate_LDFLAGS" \
3085 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3086 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3087 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3088 -e "$sed_transform_check_PROGRAMS"
3089 if $use_libtests && test "$module" = 'alloca'; then
3090 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3091 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3093 } > "$tmp"/amsnippet
3094 # Skip the contents if it's entirely empty.
3095 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3096 # Mention long-running tests at the end.
3098 for word in `func_get_status "$module"`; do
3099 if test "$word" = 'longrunning-test'; then
3104 { echo "## begin gnulib module $module"
3106 cat "$tmp"/amsnippet
3107 echo "## end gnulib module $module"
3111 rm -f "$tmp"/amsnippet
3112 # Test whether there are some source files in subdirectories.
3113 for f in `func_get_filelist "$module"`; do
3115 lib/*/*.c | tests/*/*.c)
3123 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3124 # Generate dependencies here, since it eases the debugging of test failures.
3125 # If there are source files in subdirectories, prevent collision of the
3126 # object files (example: hash.c and libxml/hash.c).
3128 if test -n "$uses_subdirs"; then
3129 subdir_options=' subdir-objects'
3131 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3134 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3137 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3138 # variable is needed to avoid an error from automake:
3139 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3142 echo "XFAIL_TESTS ="
3143 echo "TESTS_ENVIRONMENT ="
3144 echo "noinst_PROGRAMS ="
3145 if ! $for_test; then
3146 echo "check_PROGRAMS ="
3148 echo "noinst_HEADERS ="
3149 echo "noinst_LIBRARIES ="
3150 if $use_libtests; then
3152 echo "noinst_LIBRARIES += libtests.a"
3154 echo "check_LIBRARIES = libtests.a"
3157 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3158 # if you specify pkgdata_DATA to empty. This is a workaround.
3159 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3160 echo "pkgdata_DATA ="
3163 echo "BUILT_SOURCES ="
3165 echo "MOSTLYCLEANFILES = core *.stackdump"
3166 echo "MOSTLYCLEANDIRS ="
3168 echo "DISTCLEANFILES ="
3169 echo "MAINTAINERCLEANFILES ="
3170 # Execute edits that apply to the Makefile.am being generated.
3172 while test $edit != $makefile_am_edits; do
3173 edit=`expr $edit + 1`
3174 eval dir=\"\$makefile_am_edit${edit}_dir\"
3175 eval var=\"\$makefile_am_edit${edit}_var\"
3176 eval val=\"\$makefile_am_edit${edit}_val\"
3177 if test -n "$var"; then
3178 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3179 echo "${var} += ${val}"
3180 eval "makefile_am_edit${edit}_var="
3185 echo "AM_CPPFLAGS = \\"
3187 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3189 if test -n "${witness_macro}"; then
3190 echo " -D@${witness_macro}@=1 \\"
3192 echo " -I. -I\$(srcdir) \\"
3193 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3194 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3196 local_ldadd_before=''
3197 local_ldadd_after=''
3198 if $use_libtests; then
3199 # All test programs need to be linked with libtests.a.
3200 # It needs to be passed to the linker before ${libname}.${libext}, since
3201 # the tests-related modules depend on the main modules.
3202 # It also needs to be passed to the linker after ${libname}.${libext}
3203 # because the latter might contain incomplete modules (such as the 'error'
3204 # module whose dependency to 'progname' is voluntarily omitted).
3205 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3207 local_ldadd_before=' libtests.a'
3208 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3210 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3212 if $use_libtests; then
3213 echo "libtests_a_SOURCES ="
3214 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3215 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3216 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3217 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3218 echo "EXTRA_libtests_a_SOURCES ="
3219 # The circular dependency in LDADD requires this.
3220 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3223 # Many test scripts use ${EXEEXT} or ${srcdir}.
3224 # EXEEXT is defined by AC_PROG_CC through autoconf.
3225 # srcdir is defined by autoconf and automake.
3226 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3228 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3229 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3230 echo "# Clean up after Solaris cc."
3232 echo " rm -rf SunWS_cache"
3234 echo "mostlyclean-local: mostlyclean-generic"
3235 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3236 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3237 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3241 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3244 # func_emit_initmacro_start macro_prefix
3245 # emits the first few statements of the gl_INIT macro to standard output.
3246 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3247 func_emit_initmacro_start ()
3249 macro_prefix_arg="$1"
3250 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3251 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3252 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3253 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3255 # Furthermore it avoids an automake error like this when a Makefile.am
3256 # that uses pieces of gnulib also uses $(LIBOBJ):
3257 # automatically discovered file `error.c' should not be explicitly mentioned
3258 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3259 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3260 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3261 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3262 # automatically discovered file `error.c' should not be explicitly mentioned
3263 # We let automake know about the files to be distributed through the
3264 # EXTRA_lib_SOURCES variable.
3265 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3266 # Create data variables for checking the presence of files that are mentioned
3267 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3268 # because we want the check to happen when the configure file is created,
3269 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3270 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3271 # in which to expect them.
3272 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3273 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3277 # func_emit_initmacro_end macro_prefix
3278 # emits the last few statements of the gl_INIT macro to standard output.
3279 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3280 func_emit_initmacro_end ()
3282 macro_prefix_arg="$1"
3283 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3284 # The check is performed only when autoconf is run from the directory where
3285 # the configure.ac resides; if it is run from a different directory, the
3287 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3288 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3289 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3290 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3291 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3295 echo " m4_if(m4_sysval, [0], [],"
3296 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3298 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3299 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3300 echo " m4_popdef([AC_LIBSOURCES])"
3301 echo " m4_popdef([AC_REPLACE_FUNCS])"
3302 echo " m4_popdef([AC_LIBOBJ])"
3303 echo " AC_CONFIG_COMMANDS_PRE(["
3304 echo " ${macro_prefix_arg}_libobjs="
3305 echo " ${macro_prefix_arg}_ltlibobjs="
3306 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3307 echo " # Remove the extension."
3308 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3309 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3310 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3311 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3314 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3315 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3319 # func_emit_initmacro_done macro_prefix sourcebase
3320 # emits a few statements after the gl_INIT macro to standard output.
3321 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3322 # - sourcebase directory relative to destdir where to place source code
3323 func_emit_initmacro_done ()
3325 macro_prefix_arg="$1"
3328 echo "# Like AC_LIBOBJ, except that the module name goes"
3329 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3330 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3331 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3332 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3335 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3336 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3337 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3338 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3339 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3342 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3343 echo "# expected is derived from the gnulib-tool parameterization,"
3344 echo "# and alloca is special cased (for the alloca-opt module)."
3345 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3346 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3347 echo " m4_foreach([_gl_NAME], [\$1], ["
3348 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3349 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3350 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3356 # func_import modules
3357 # Uses also the variables
3358 # - mode import or add-import or remove-import or update
3359 # - destdir target directory
3360 # - local_gnulib_dir from --local-dir
3361 # - modcache true or false, from --cache-modules/--no-cache-modules
3362 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3363 # - libname library name
3364 # - supplied_libname true if --lib was given, blank otherwise
3365 # - sourcebase directory relative to destdir where to place source code
3366 # - m4base directory relative to destdir where to place *.m4 macros
3367 # - pobase directory relative to destdir where to place *.po files
3368 # - docbase directory relative to destdir where to place doc files
3369 # - testsbase directory relative to destdir where to place unit test code
3370 # - auxdir directory relative to destdir where to place build aux files
3371 # - inctests true if --with-tests was given, blank otherwise
3372 # - incobsolete true if --with-obsolete was given, blank otherwise
3373 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3374 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3376 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3378 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3380 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3381 # - avoidlist list of modules to avoid, from --avoid
3382 # - lgpl yes or a number if library's license shall be LGPL,
3384 # - makefile_name from --makefile-name
3385 # - libtool true if --libtool was given, false if --no-libtool was
3386 # given, blank otherwise
3387 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3388 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3389 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3390 # - vc_files true if --vc-files was given, false if --no-vc-files was
3391 # given, blank otherwise
3392 # - autoconf_minversion minimum supported autoconf version
3393 # - doit : if actions shall be executed, false if only to be printed
3394 # - symbolic true if files should be symlinked, copied otherwise
3395 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3397 # - do_copyrights true if copyright notices in files should be replaced,
3401 # Get the cached settings.
3402 # In 'import' mode, we read them only for the purpose of knowing the old
3403 # installed file list, and don't use them as defaults.
3404 cached_local_gnulib_dir=
3405 cached_specified_modules=
3407 cached_inc_cxx_tests=
3408 cached_inc_longrunning_tests=
3409 cached_inc_privileged_tests=
3410 cached_inc_unportable_tests=
3411 cached_inc_all_tests=
3421 cached_makefile_name=
3423 cached_macro_prefix=
3427 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3428 cached_libtool=false
3434 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3444 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3446 /gl_WITH_OBSOLETE/ {
3447 s,^.*$,cached_incobsolete=true,p
3449 /gl_WITH_CXX_TESTS/ {
3450 s,^.*$,cached_inc_cxx_tests=true,p
3452 /gl_WITH_LONGRUNNING_TESTS/ {
3453 s,^.*$,cached_inc_longrunning_tests=true,p
3455 /gl_WITH_PRIVILEGED_TESTS/ {
3456 s,^.*$,cached_inc_privileged_tests=true,p
3458 /gl_WITH_UNPORTABLE_TESTS/ {
3459 s,^.*$,cached_inc_unportable_tests=true,p
3461 /gl_WITH_ALL_TESTS/ {
3462 s,^.*$,cached_inc_all_tests=true,p
3465 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3468 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3471 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3474 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3477 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3480 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3483 s,^.*$,cached_inctests=true,p
3486 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3489 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3492 s,^.*$,cached_lgpl=yes,p
3494 /gl_MAKEFILE_NAME(/ {
3495 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3498 s,^.*$,cached_libtool=true,p
3500 /gl_MACRO_PREFIX(/ {
3501 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3504 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3507 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3509 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3510 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3515 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3516 s,^.*$,cached_files=",p
3529 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3533 if test "$mode" = import; then
3534 # In 'import' mode, the new set of specified modules overrides the cached
3535 # set of modules. Ignore the cached settings.
3536 specified_modules="$1"
3538 # Merge the cached settings with the specified ones.
3539 # The m4base must be the same as expected from the pathname.
3540 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3541 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3543 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3544 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3545 if test -z "$local_gnulib_dir"; then
3546 if test -n "$cached_local_gnulib_dir"; then
3549 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3551 case "$cached_local_gnulib_dir" in
3553 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3555 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3556 local_gnulib_dir="$relconcat" ;;
3563 # Append the cached and the specified module names. So that
3564 # "gnulib-tool --add-import foo" means to add the module foo.
3565 specified_modules="$cached_specified_modules $1"
3568 # Take the cached module names, minus the specified module names.
3570 if $have_associative; then
3571 # Use an associative array, for O(N) worst-case run time.
3572 declare -A to_remove
3576 for module in $cached_specified_modules; do
3577 if test -z "${to_remove[$module]}"; then
3578 func_append specified_modules "$module "
3582 # This loop has O(N²) worst-case run time.
3583 for module in $cached_specified_modules; do
3586 if test "$m" = "$module"; then
3591 if test -z "$to_remove"; then
3592 func_append specified_modules "$module "
3598 # Take the cached module names. There are no specified module names.
3599 specified_modules="$cached_specified_modules"
3602 # Included obsolete modules among the dependencies if specified either way.
3603 if test -z "$incobsolete"; then
3604 incobsolete="$cached_incobsolete"
3606 # Included special kinds of tests modules among the dependencies if specified
3608 if test -z "$inc_cxx_tests"; then
3609 inc_cxx_tests="$cached_inc_cxx_tests"
3611 if test -z "$inc_longrunning_tests"; then
3612 inc_longrunning_tests="$cached_inc_longrunning_tests"
3614 if test -z "$inc_privileged_tests"; then
3615 inc_privileged_tests="$cached_inc_privileged_tests"
3617 if test -z "$inc_unportable_tests"; then
3618 inc_unportable_tests="$cached_inc_unportable_tests"
3620 if test -z "$inc_all_tests"; then
3621 inc_all_tests="$cached_inc_all_tests"
3623 # Append the cached and the specified avoidlist. This is probably better
3624 # than dropping the cached one when --avoid is specified at least once.
3625 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3626 avoidlist=`echo $avoidlist`
3628 # The sourcebase defaults to the cached one.
3629 if test -z "$sourcebase"; then
3630 sourcebase="$cached_sourcebase"
3631 if test -z "$sourcebase"; then
3632 func_fatal_error "missing --source-base option"
3635 # The pobase defaults to the cached one.
3636 if test -z "$pobase"; then
3637 pobase="$cached_pobase"
3639 # The docbase defaults to the cached one.
3640 if test -z "$docbase"; then
3641 docbase="$cached_docbase"
3642 if test -z "$docbase"; then
3643 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."
3646 # The testsbase defaults to the cached one.
3647 if test -z "$testsbase"; then
3648 testsbase="$cached_testsbase"
3649 if test -z "$testsbase"; then
3650 func_fatal_error "missing --tests-base option"
3653 # Require the tests if specified either way.
3654 if test -z "$inctests"; then
3655 inctests="$cached_inctests"
3657 # The libname defaults to the cached one.
3658 if test -z "$supplied_libname"; then
3659 libname="$cached_libname"
3660 if test -z "$libname"; then
3661 func_fatal_error "missing --lib option"
3664 # Require LGPL if specified either way.
3665 if test -z "$lgpl"; then
3668 # The makefile_name defaults to the cached one.
3669 if test -z "$makefile_name"; then
3670 makefile_name="$cached_makefile_name"
3672 # Use libtool if specified either way, or if guessed.
3673 if test -z "$libtool"; then
3674 if test -n "$cached_m4base"; then
3675 libtool="$cached_libtool"
3677 libtool="$guessed_libtool"
3680 # The macro_prefix defaults to the cached one.
3681 if test -z "$macro_prefix"; then
3682 macro_prefix="$cached_macro_prefix"
3683 if test -z "$macro_prefix"; then
3684 func_fatal_error "missing --macro-prefix option"
3687 # The po_domain defaults to the cached one.
3688 if test -z "$po_domain"; then
3689 po_domain="$cached_po_domain"
3691 # The vc_files defaults to the cached one.
3692 if test -z "$vc_files"; then
3693 vc_files="$cached_vc_files"
3696 # --without-*-tests options are not supported here.
3698 excl_longrunning_tests=
3699 excl_privileged_tests=
3700 excl_unportable_tests=
3702 # Canonicalize the list of specified modules.
3703 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3705 # Include all kinds of tests modules if --with-all-tests was specified.
3706 inc_all_direct_tests="$inc_all_tests"
3707 inc_all_indirect_tests="$inc_all_tests"
3709 # Determine final module list.
3710 modules="$specified_modules"
3711 func_modules_transitive_closure
3712 if test $verbose -ge 0; then
3713 func_show_module_list
3715 final_modules="$modules"
3717 # Determine main module list and tests-related module list separately.
3718 # The main module list is the transitive closure of the specified modules,
3719 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3720 # is specified, it will consist only of LGPLed source.
3721 # The tests-related module list is the transitive closure of the specified
3722 # modules, including tests modules, minus the main module list excluding
3723 # modules of applicability 'all'. Its lib/* sources (brought in through
3724 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3725 # source, even if --lgpl is specified.
3726 # Determine main module list.
3727 saved_inctests="$inctests"
3729 modules="$specified_modules"
3730 func_modules_transitive_closure
3731 main_modules="$modules"
3732 inctests="$saved_inctests"
3733 if test $verbose -ge 1; then
3734 echo "Main module list:"
3735 echo "$main_modules" | sed -e 's/^/ /'
3737 # Determine tests-related module list.
3738 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3739 testsrelated_modules=`for module in $main_modules; do
3740 if test \`func_get_applicability $module\` = main; then
3744 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3745 if test $verbose -ge 1; then
3746 echo "Tests-related module list:"
3747 echo "$testsrelated_modules" | sed -e 's/^/ /'
3750 # Add the dummy module to the main module list if needed.
3751 modules="$main_modules"
3752 func_modules_add_dummy
3753 main_modules="$modules"
3755 # Determine whether a $testsbase/libtests.a is needed.
3757 for module in $testsrelated_modules; do
3758 func_verify_nontests_module
3759 if test -n "$module"; then
3760 all_files=`func_get_filelist $module`
3761 # Test whether some file in $all_files lies in lib/.
3762 for f in $all_files; do
3773 # Add the dummy module to the tests-related module list if needed.
3774 if $use_libtests; then
3775 modules="$testsrelated_modules"
3776 func_modules_add_dummy
3777 testsrelated_modules="$modules"
3780 # If --lgpl, verify that the licenses of modules are compatible.
3781 if test -n "$lgpl"; then
3782 license_incompatibilities=
3783 for module in $main_modules; do
3784 license=`func_get_license $module`
3786 'GPLed build tool') ;;
3787 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3792 LGPL | LGPLv2+ | LGPLv3+) ;;
3793 *) func_append license_incompatibilities "$module $license$nl" ;;
3799 *) func_append license_incompatibilities "$module $license$nl" ;;
3802 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3807 if test -n "$license_incompatibilities"; then
3808 # Format the license incompatibilities as a table.
3809 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3810 s,^\(.................................................[^ ]*\) *, \1 ,'
3811 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3812 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3816 # Show banner notice of every module.
3817 modules="$main_modules"
3820 # Determine script to apply to imported library files.
3821 sed_transform_lib_file=
3822 for module in $main_modules; do
3823 if test $module = config-h; then
3824 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3825 sed_transform_lib_file=$sed_transform_lib_file'
3826 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3831 sed_transform_main_lib_file="$sed_transform_lib_file"
3832 if test -n "$do_copyrights"; then
3833 if test -n "$lgpl"; then
3837 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3838 s/GNU General/GNU Lesser General/g
3842 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3843 s/GNU General/GNU Lesser General/g
3844 s/version [23]\([ ,]\)/version 2.1\1/g
3847 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3851 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3852 s/GNU Lesser General/GNU General/g
3853 s/GNU Library General/GNU General/g
3854 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3859 # Determine script to apply to auxiliary files that go into $auxdir/.
3860 sed_transform_build_aux_file=
3861 if test -n "$do_copyrights"; then
3863 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3864 s/GNU Lesser General/GNU General/g
3865 s/GNU Library General/GNU General/g
3866 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3870 # Determine script to apply to library files that go into $testsbase/.
3871 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3872 if test -n "$do_copyrights"; then
3874 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3875 s/GNU Lesser General/GNU General/g
3876 s/GNU Library General/GNU General/g
3877 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3881 # Determine the final file lists.
3882 # They must be computed separately, because files in lib/* go into
3883 # $sourcebase/ if they are in the main file list but into $testsbase/
3884 # if they are in the tests-related file list. Furthermore lib/dummy.c
3886 # Determine final main file list.
3887 modules="$main_modules"
3888 func_modules_to_filelist
3890 # Determine final tests-related file list.
3891 modules="$testsrelated_modules"
3892 func_modules_to_filelist
3893 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3894 # Merge both file lists.
3895 sed_remove_empty_lines='/^$/d'
3896 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3897 if test $verbose -ge 0; then
3899 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3900 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3904 || func_fatal_error "refusing to do nothing"
3906 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3907 new_files="$files m4/gnulib-tool.m4"
3908 old_files="$cached_files"
3909 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3910 func_append old_files " m4/gnulib-tool.m4"
3913 rewritten='%REWRITTEN%'
3914 sed_rewrite_old_files="\
3915 s,^build-aux/,$rewritten$auxdir/,
3916 s,^doc/,$rewritten$cached_docbase/,
3917 s,^lib/,$rewritten$cached_sourcebase/,
3918 s,^m4/,$rewritten$cached_m4base/,
3919 s,^tests/,$rewritten$cached_testsbase/,
3920 s,^tests=lib/,$rewritten$cached_testsbase/,
3923 sed_rewrite_new_files="\
3924 s,^build-aux/,$rewritten$auxdir/,
3925 s,^doc/,$rewritten$docbase/,
3926 s,^lib/,$rewritten$sourcebase/,
3927 s,^m4/,$rewritten$m4base/,
3928 s,^tests/,$rewritten$testsbase/,
3929 s,^tests=lib/,$rewritten$testsbase/,
3933 # Create directories.
3934 { echo "$sourcebase"
3936 if test -n "$pobase"; then
3939 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3940 if test -n "$docfiles"; then
3943 if test -n "$inctests"; then
3947 for f in $files; do echo $f; done \
3948 | sed -e "$sed_rewrite_new_files" \
3949 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3952 { # Rearrange file descriptors. Needed because "while ... done < ..."
3953 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3954 exec 5<&0 < "$tmp"/dirs
3956 if test ! -d "$destdir/$d"; then
3958 echo "Creating directory $destdir/$d"
3959 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3961 echo "Create directory $destdir/$d"
3968 # Copy files or make symbolic links. Remove obsolete files.
3972 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3973 # representing the files according to the last gnulib-tool invocation.
3974 for f in $old_files; do echo $f; done \
3975 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3978 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3979 # representing the files after this gnulib-tool invocation.
3980 for f in $new_files; do echo $f; done \
3981 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3984 # First the files that are in old-files, but not in new-files:
3985 sed_take_first_column='s,'"$delimiter"'.*,,'
3986 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3987 # Remove the file. Do nothing if the user already removed it.
3988 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3990 echo "Removing file $g (backup in ${g}~)"
3991 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3993 echo "Remove file $g (backup in ${g}~)"
3995 func_append removed_files "$g$nl"
3998 # func_add_or_update handles a file that ought to be present afterwards.
4000 # - f the original file name
4001 # - g the rewritten file name
4002 # - already_present nonempty if the file should already exist, empty
4004 func_add_or_update ()
4008 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4010 func_dest_tmpfilename "$g"
4011 func_lookup_file "$f"
4012 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4013 if test -n "$sed_transform_main_lib_file"; then
4016 sed -e "$sed_transform_main_lib_file" \
4017 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4021 if test -n "$sed_transform_build_aux_file"; then
4024 sed -e "$sed_transform_build_aux_file" \
4025 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4029 if test -n "$sed_transform_testsrelated_lib_file"; then
4032 sed -e "$sed_transform_testsrelated_lib_file" \
4033 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4037 if test -f "$destdir/$g"; then
4038 # The file already exists.
4042 # Don't protest if the file should be there but isn't: it happens
4043 # frequently that developers don't put autogenerated files under version control.
4045 func_append added_files "$g$nl"
4049 # Then the files that are in new-files, but not in old-files:
4050 sed_take_last_column='s,^.*'"$delimiter"',,'
4052 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4053 | sed -e "$sed_take_last_column" \
4054 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4055 { # Rearrange file descriptors. Needed because "while ... done < ..."
4056 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4057 exec 5<&0 < "$tmp"/added-files
4063 # Then the files that are in new-files and in old-files:
4064 already_present=true
4065 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4066 | sed -e "$sed_take_last_column" \
4067 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4068 { # Rearrange file descriptors. Needed because "while ... done < ..."
4069 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4070 exec 5<&0 < "$tmp"/kept-files
4077 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4078 actioncmd="gnulib-tool --import"
4079 func_append actioncmd " --dir=$destdir"
4080 if test -n "$local_gnulib_dir"; then
4081 func_append actioncmd " --local-dir=$local_gnulib_dir"
4083 func_append actioncmd " --lib=$libname"
4084 func_append actioncmd " --source-base=$sourcebase"
4085 func_append actioncmd " --m4-base=$m4base"
4086 if test -n "$pobase"; then
4087 func_append actioncmd " --po-base=$pobase"
4089 func_append actioncmd " --doc-base=$docbase"
4090 func_append actioncmd " --tests-base=$testsbase"
4091 func_append actioncmd " --aux-dir=$auxdir"
4092 if test -n "$inctests"; then
4093 func_append actioncmd " --with-tests"
4095 if test -n "$incobsolete"; then
4096 func_append actioncmd " --with-obsolete"
4098 if test -n "$inc_cxx_tests"; then
4099 func_append actioncmd " --with-c++-tests"
4101 if test -n "$inc_longrunning_tests"; then
4102 func_append actioncmd " --with-longrunning-tests"
4104 if test -n "$inc_privileged_tests"; then
4105 func_append actioncmd " --with-privileged-tests"
4107 if test -n "$inc_unportable_tests"; then
4108 func_append actioncmd " --with-unportable-tests"
4110 if test -n "$inc_all_tests"; then
4111 func_append actioncmd " --with-all-tests"
4113 for module in $avoidlist; do
4114 func_append actioncmd " --avoid=$module"
4116 if test -n "$lgpl"; then
4117 if test "$lgpl" = yes; then
4118 func_append actioncmd " --lgpl"
4120 func_append actioncmd " --lgpl=$lgpl"
4123 if test -n "$makefile_name"; then
4124 func_append actioncmd " --makefile-name=$makefile_name"
4126 if test "$libtool" = true; then
4127 func_append actioncmd " --libtool"
4129 func_append actioncmd " --no-libtool"
4131 func_append actioncmd " --macro-prefix=$macro_prefix"
4132 if test -n "$po_domain"; then
4133 func_append actioncmd " --po-domain=$po_domain"
4135 if test -n "$vc_files"; then
4136 if test "$vc_files" = true; then
4137 func_append actioncmd " --vc-files"
4139 func_append actioncmd " --no-vc-files"
4142 func_append actioncmd " `echo $specified_modules`"
4144 # Default the makefile name to Makefile.am.
4145 if test -n "$makefile_name"; then
4146 makefile_am=$makefile_name
4148 makefile_am=Makefile.am
4151 # Create normal Makefile.ams.
4154 # Setup list of Makefile.am edits that are to be performed afterwards.
4155 # Some of these edits apply to files that we will generate; others are
4156 # under the responsibility of the developer.
4158 # func_note_Makefile_am_edit dir var value
4159 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4161 func_note_Makefile_am_edit ()
4163 makefile_am_edits=`expr $makefile_am_edits + 1`
4164 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4165 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4166 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4168 if test "$makefile_am" = Makefile.am; then
4169 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4170 sourcebase_base=`basename "$sourcebase"`
4171 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4173 if test -n "$pobase"; then
4174 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4175 pobase_base=`basename "$pobase"`
4176 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4178 if test -n "$inctests"; then
4179 if test "$makefile_am" = Makefile.am; then
4180 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4181 testsbase_base=`basename "$testsbase"`
4182 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4185 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4187 # Find the first parent directory of $m4base that contains or will contain
4189 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4191 sed_butlast='s,[^/][^/]*//*$,,'
4192 dir1="${m4base}/"; dir2=""
4193 while test -n "$dir1" \
4194 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4195 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4196 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4197 || { test -n "$inctests" \
4198 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4199 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4200 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4201 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4203 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4206 # Create library makefile.
4207 func_dest_tmpfilename $sourcebase/$makefile_am
4208 destfile="$sourcebase/$makefile_am"
4209 modules="$main_modules"
4210 func_emit_lib_Makefile_am > "$tmpfile"
4211 if test -f "$destdir"/$sourcebase/$makefile_am; then
4212 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4216 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4217 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4218 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4220 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4226 echo "Creating $sourcebase/$makefile_am"
4227 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4229 echo "Create $sourcebase/$makefile_am"
4232 func_append added_files "$sourcebase/$makefile_am$nl"
4235 # Create po/ directory.
4236 if test -n "$pobase"; then
4237 # Create po makefile and auxiliary files.
4238 for file in Makefile.in.in remove-potcdate.sin; do
4239 func_dest_tmpfilename $pobase/$file
4240 func_lookup_file build-aux/po/$file
4241 cat "$lookedup_file" > "$tmpfile"
4242 if test -f "$destdir"/$pobase/$file; then
4243 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4247 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4248 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4249 mv -f "$tmpfile" "$destdir"/$pobase/$file
4251 echo "Update $pobase/$file (backup in $pobase/$file~)"
4257 echo "Creating $pobase/$file"
4258 mv -f "$tmpfile" "$destdir"/$pobase/$file
4260 echo "Create $pobase/$file"
4263 func_append added_files "$pobase/$file$nl"
4266 # Create po makefile parameterization, part 1.
4267 func_dest_tmpfilename $pobase/Makevars
4268 func_emit_po_Makevars > "$tmpfile"
4269 if test -f "$destdir"/$pobase/Makevars; then
4270 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4274 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4275 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4276 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4278 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4284 echo "Creating $pobase/Makevars"
4285 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4287 echo "Create $pobase/Makevars"
4290 func_append added_files "$pobase/Makevars$nl"
4292 # Create po makefile parameterization, part 2.
4293 func_dest_tmpfilename $pobase/POTFILES.in
4294 func_emit_po_POTFILES_in > "$tmpfile"
4295 if test -f "$destdir"/$pobase/POTFILES.in; then
4296 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4300 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4301 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4302 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4304 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4310 echo "Creating $pobase/POTFILES.in"
4311 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4313 echo "Create $pobase/POTFILES.in"
4316 func_append added_files "$pobase/POTFILES.in$nl"
4319 TP_URL="http://translationproject.org/latest/"
4320 TP_RSYNC_URI="translationproject.org::tp/latest/"
4322 echo "Fetching gnulib PO files from $TP_URL"
4323 (cd "$destdir"/$pobase \
4324 && { # Prefer rsync over wget if it is available, since it consumes
4325 # less network bandwidth, due to compression.
4326 if type rsync 2>/dev/null | grep / > /dev/null; then
4327 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4329 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4334 echo "Fetch gnulib PO files from $TP_URL"
4336 # Create po/LINGUAS.
4338 func_dest_tmpfilename $pobase/LINGUAS
4339 (cd "$destdir"/$pobase \
4340 && { echo '# Set of available languages.'
4341 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4344 if test -f "$destdir"/$pobase/LINGUAS; then
4345 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4348 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4349 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4350 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4353 echo "Creating $pobase/LINGUAS"
4354 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4355 func_append added_files "$pobase/LINGUAS$nl"
4358 if test -f "$destdir"/$pobase/LINGUAS; then
4359 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4361 echo "Create $pobase/LINGUAS"
4366 # Create m4/gnulib-cache.m4.
4367 func_dest_tmpfilename $m4base/gnulib-cache.m4
4369 func_emit_copyright_notice
4371 echo "# This file represents the specification of how gnulib-tool is used."
4372 echo "# It acts as a cache: It is written and read by gnulib-tool."
4373 echo "# In projects that use version control, this file is meant to be put under"
4374 echo "# version control, like the configure.ac and various Makefile.am files."
4377 echo "# Specification in the form of a command-line invocation:"
4380 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4381 # Store the local_gnulib_dir relative to destdir.
4382 case "$local_gnulib_dir" in
4384 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4387 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4389 # destdir, local_gnulib_dir are both relative.
4390 func_relativize "$destdir" "$local_gnulib_dir"
4391 relative_local_gnulib_dir="$reldir" ;;
4394 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4396 echo "$specified_modules" | sed -e 's/^/ /g'
4398 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4399 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4400 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4401 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4402 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4403 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4404 echo "gl_AVOID([$avoidlist])"
4405 echo "gl_SOURCE_BASE([$sourcebase])"
4406 echo "gl_M4_BASE([$m4base])"
4407 echo "gl_PO_BASE([$pobase])"
4408 echo "gl_DOC_BASE([$docbase])"
4409 echo "gl_TESTS_BASE([$testsbase])"
4410 test -z "$inctests" || echo "gl_WITH_TESTS"
4411 echo "gl_LIB([$libname])"
4412 if test -n "$lgpl"; then
4413 if test "$lgpl" = yes; then
4416 echo "gl_LGPL([$lgpl])"
4419 echo "gl_MAKEFILE_NAME([$makefile_name])"
4420 if test "$libtool" = true; then
4423 echo "gl_MACRO_PREFIX([$macro_prefix])"
4424 echo "gl_PO_DOMAIN([$po_domain])"
4425 if test -n "$vc_files"; then
4426 echo "gl_VC_FILES([$vc_files])"
4429 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4430 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4434 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4435 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4436 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4438 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4442 echo "# gnulib-cache.m4 ends here"
4449 echo "Creating $m4base/gnulib-cache.m4"
4450 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4452 echo "Create $m4base/gnulib-cache.m4"
4458 # Create m4/gnulib-comp.m4.
4459 func_dest_tmpfilename $m4base/gnulib-comp.m4
4461 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4462 func_emit_copyright_notice
4464 echo "# This file represents the compiled summary of the specification in"
4465 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4466 echo "# to be invoked from configure.ac."
4467 echo "# In projects that use version control, this file can be treated like"
4468 echo "# other built files."
4471 echo "# This macro should be invoked from $configure_ac, in the section"
4472 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4473 echo "# any checks for libraries, header files, types and library functions."
4474 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4476 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4477 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4478 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4479 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4480 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4481 if test -n "$uses_subdirs"; then
4482 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4484 for module in $final_modules; do
4486 if test -n "$module"; then
4487 echo "# Code from module $module:"
4488 func_get_autoconf_early_snippet "$module"
4491 | sed -e '/^$/d;' -e 's/^/ /'
4494 echo "# This macro should be invoked from $configure_ac, in the section"
4495 echo "# \"Check for header files, types and library functions\"."
4496 echo "AC_DEFUN([${macro_prefix}_INIT],"
4498 if test "$libtool" = true; then
4499 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4500 echo " gl_cond_libtool=true"
4502 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4503 echo " gl_cond_libtool=false"
4505 echo " gl_ltlibdeps="
4507 if test "$auxdir" != "build-aux"; then
4508 sed_replace_build_aux='
4510 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4511 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4515 sed_replace_build_aux="$sed_noop"
4517 echo " gl_m4_base='$m4base'"
4518 func_emit_initmacro_start $macro_prefix
4519 echo " gl_source_base='$sourcebase'"
4520 for module in $main_modules; do
4522 if test -n "$module"; then
4523 echo " # Code from module $module:"
4524 func_get_autoconf_snippet "$module" \
4525 | sed -e '/^$/d;' -e 's/^/ /' \
4526 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4527 -e "$sed_replace_build_aux"
4528 if test "$module" = 'alloca' && test "$libtool" = true; then
4529 echo 'changequote(,)dnl'
4530 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4531 echo 'changequote([, ])dnl'
4532 echo 'AC_SUBST([LTALLOCA])'
4536 echo " # End of code from modules"
4537 func_emit_initmacro_end $macro_prefix
4538 echo " gltests_libdeps="
4539 echo " gltests_ltlibdeps="
4540 func_emit_initmacro_start ${macro_prefix}tests
4541 echo " gl_source_base='$testsbase'"
4542 # Define a tests witness macro that depends on the package.
4543 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4544 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4545 echo "changequote(,)dnl"
4546 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"
4547 echo "changequote([, ])dnl"
4548 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4549 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4550 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4551 for module in $testsrelated_modules; do
4553 if test -n "$module"; then
4554 func_get_autoconf_snippet "$module" \
4555 | sed -e '/^$/d;' -e 's/^/ /' \
4556 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4557 -e "$sed_replace_build_aux" \
4558 -e 's/\$gl_cond_libtool/false/g' \
4559 -e 's/gl_libdeps/gltests_libdeps/g' \
4560 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4563 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4564 func_emit_initmacro_end ${macro_prefix}tests
4565 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4566 # created using libtool, because libtool already handles the dependencies.
4567 if test "$libtool" != true; then
4568 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4569 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4570 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4571 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4572 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4574 if $use_libtests; then
4575 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4576 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4579 func_emit_initmacro_done $macro_prefix $sourcebase
4580 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4582 echo "# This macro records the list of files which have been installed by"
4583 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4584 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4585 echo "$files" | sed -e 's,^, ,'
4588 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4589 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4593 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4594 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4595 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4597 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4601 echo "# gnulib-comp.m4 ends here"
4608 echo "Creating $m4base/gnulib-comp.m4"
4609 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4611 echo "Create $m4base/gnulib-comp.m4"
4617 if test -n "$inctests"; then
4618 # Create tests makefile.
4619 func_dest_tmpfilename $testsbase/$makefile_am
4620 destfile="$testsbase/$makefile_am"
4621 modules="$testsrelated_modules"
4622 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4623 if test -f "$destdir"/$testsbase/$makefile_am; then
4624 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4628 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4629 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4630 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4632 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4638 echo "Creating $testsbase/$makefile_am"
4639 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4641 echo "Create $testsbase/$makefile_am"
4644 func_append added_files "$testsbase/$makefile_am$nl"
4648 if test "$vc_files" != false; then
4649 # Update the .cvsignore and .gitignore files.
4650 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4651 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4652 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4653 echo "$m4base/|A|gnulib-comp.m4"
4654 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4655 { # Rearrange file descriptors. Needed because "while ... done < ..."
4656 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4657 exec 5<&0 < "$tmp"/fileset-changes
4658 func_update_ignorelist ()
4661 if test "$ignore" = .gitignore; then
4662 # In a .gitignore file, "foo" applies to the current directory and all
4663 # subdirectories, whereas "/foo" applies to the current directory only.
4666 doubly_escaped_anchor='\\/'
4670 doubly_escaped_anchor=''
4672 if test -f "$destdir/$dir$ignore"; then
4673 if test -n "$dir_added" || test -n "$dir_removed"; then
4674 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4675 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4676 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4677 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4678 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4680 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4682 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4683 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4684 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4685 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4686 } > "$tmp"/sed-ignore-removed
4687 { cat "$destdir/$dir$ignore"~
4688 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4689 } | sed -f "$tmp"/sed-ignore-removed \
4690 > "$destdir/$dir$ignore"
4692 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4697 if test -n "$dir_added"; then
4699 echo "Creating $destdir/$dir$ignore"
4701 if test "$ignore" = .cvsignore; then
4703 # Automake generates Makefile rules that create .dirstamp files.
4706 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4707 } > "$destdir/$dir$ignore"
4709 echo "Create $destdir/$dir$ignore"
4719 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4720 func_update_ignorelist .cvsignore
4722 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4723 func_update_ignorelist .gitignore
4730 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4731 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4732 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4733 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4734 if test "$next_dir" != "$last_dir"; then
4735 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4736 last_dir="$next_dir"
4741 A) func_append last_dir_added "$file$nl";;
4742 R) func_append last_dir_removed "$file$nl";;
4745 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4752 echo "You may need to add #include directives for the following .h files."
4753 # Intersect $specified_modules and $main_modules
4754 # (since $specified_modules is not necessarily of subset of $main_modules
4755 # - some may have been skipped through --avoid, and since the elements of
4756 # $main_modules but not in $specified_modules can go away without explicit
4757 # notice - through changes in the module dependencies).
4758 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4759 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4760 # First the #include <...> directives without #ifs, sorted for convenience,
4761 # then the #include "..." directives without #ifs, sorted for convenience,
4762 # then the #include directives that are surrounded by #ifs. Not sorted.
4763 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4764 include_directive=`func_get_include_directive "$module"`
4765 case "$nl$include_directive" in
4767 echo "$include_directive" 1>&5
4770 echo "$include_directive" | grep -v 'include "' 1>&6
4771 echo "$include_directive" | grep 'include "' 1>&7
4774 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4776 LC_ALL=C sort -u "$tmp"/include-angles
4777 LC_ALL=C sort -u "$tmp"/include-quotes
4778 cat "$tmp"/include-if
4779 ) | sed -e '/^$/d' -e 's/^/ /'
4780 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4782 for module in $main_modules; do
4783 func_get_link_directive "$module"
4785 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4786 if test `wc -l < "$tmp"/link` != 0; then
4788 echo "You may need to use the following Makefile variables when linking."
4789 echo "Use them in <program>_LDADD when linking a program, or"
4790 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4796 echo "Don't forget to"
4797 if test "$makefile_am" = Makefile.am; then
4798 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4800 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4802 if test -n "$pobase"; then
4803 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4805 if test -n "$inctests"; then
4806 if test "$makefile_am" = Makefile.am; then
4807 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4809 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4813 while test $edit != $makefile_am_edits; do
4814 edit=`expr $edit + 1`
4815 eval dir=\"\$makefile_am_edit${edit}_dir\"
4816 eval var=\"\$makefile_am_edit${edit}_var\"
4817 eval val=\"\$makefile_am_edit${edit}_val\"
4818 if test -n "$var"; then
4819 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4822 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4823 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4826 # func_create_testdir testdir modules
4828 # - local_gnulib_dir from --local-dir
4829 # - modcache true or false, from --cache-modules/--no-cache-modules
4830 # - auxdir directory relative to destdir where to place build aux files
4831 # - inctests true if tests should be included, blank otherwise
4832 # - incobsolete true if obsolete modules among dependencies should be
4833 # included, blank otherwise
4834 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
4836 # - excl_longrunning_tests true if long-runnings tests should be excluded,
4838 # - excl_privileged_tests true if tests that require root privileges should be
4839 # excluded, blank otherwise
4840 # - excl_unportable_tests true if tests that fail on some platforms should be
4841 # excluded, blank otherwise
4842 # - avoidlist list of modules to avoid
4843 # - libtool true if --libtool was given, false if --no-libtool was
4844 # given, blank otherwise
4845 # - symbolic true if files should be symlinked, copied otherwise
4846 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4848 func_create_testdir ()
4852 if test -z "$modules"; then
4853 # All modules together.
4854 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4855 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4856 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4857 modules=`func_all_modules`
4858 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4860 specified_modules="$modules"
4862 # Canonicalize the list of specified modules.
4863 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4865 # Unlike in func_import, here we want to include all kinds of tests for the
4866 # directly specified modules, but not for dependencies.
4867 inc_all_direct_tests=true
4868 inc_all_indirect_tests="$inc_all_tests"
4870 # Check that the license of every module is consistent with the license of
4872 saved_inctests="$inctests"
4873 # When computing transitive closures, don't consider $module to depend on
4874 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4875 # on GPL modules - therefore we don't want a warning in this case.
4877 for requested_module in $specified_modules; do
4878 requested_license=`func_get_license "$requested_module"`
4879 if test "$requested_license" != GPL; then
4880 # Here we use func_modules_transitive_closure, not just
4881 # func_get_dependencies, so that we also detect weird situations like
4882 # an LGPL module which depends on a GPLed build tool module which depends
4884 modules="$requested_module"
4885 func_modules_transitive_closure
4886 for module in $modules; do
4887 license=`func_get_license "$module"`
4889 'GPLed build tool') ;;
4890 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4892 case "$requested_license" in
4895 GPLv2+ | LGPLv2+) ;;
4896 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4902 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4908 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4917 inctests="$saved_inctests"
4919 # Subdirectory names.
4929 # Determine final module list.
4930 modules="$specified_modules"
4931 func_modules_transitive_closure
4932 if test $verbose -ge 0; then
4933 func_show_module_list
4936 # Add the dummy module if needed.
4937 func_modules_add_dummy
4939 # Show banner notice of every module.
4942 # Determine final file list.
4943 func_modules_to_filelist
4944 if test $verbose -ge 0; then
4946 echo "$files" | sed -e 's/^/ /'
4949 rewritten='%REWRITTEN%'
4950 sed_rewrite_files="\
4951 s,^build-aux/,$rewritten$auxdir/,
4952 s,^doc/,$rewritten$docbase/,
4953 s,^lib/,$rewritten$sourcebase/,
4954 s,^m4/,$rewritten$m4base/,
4955 s,^tests/,$rewritten$testsbase/,
4959 # Create directories.
4960 for f in $files; do echo $f; done \
4961 | sed -e "$sed_rewrite_files" \
4962 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4963 | LC_ALL=C sort -u \
4965 { # Rearrange file descriptors. Needed because "while ... done < ..."
4966 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4967 exec 5<&0 < "$tmp"/dirs
4969 mkdir -p "$testdir/$d"
4974 # Copy files or make symbolic links.
4976 for f in $files; do echo $f; done \
4977 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4980 { # Rearrange file descriptors. Needed because "while ... done < ..."
4981 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4982 exec 5<&0 < "$tmp"/files
4984 func_lookup_file "$f"
4985 if test -n "$lookedup_tmp"; then
4986 cp -p "$lookedup_file" "$testdir/$g"
4988 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4989 if { test -n "$symbolic" \
4990 || { test -n "$lsymbolic" \
4991 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4992 func_ln "$lookedup_file" "$testdir/$g"
4994 cp -p "$lookedup_file" "$testdir/$g"
5001 # Create Makefile.ams that are for testing.
5004 # No special edits are needed.
5007 # Create $sourcebase/Makefile.am.
5008 mkdir -p "$testdir/$sourcebase"
5009 destfile="$sourcebase/Makefile.am"
5010 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5011 any_uses_subdirs="$uses_subdirs"
5013 # Create $m4base/Makefile.am.
5014 mkdir -p "$testdir/$m4base"
5015 (echo "## Process this file with automake to produce Makefile.in."
5021 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5024 ) > "$testdir/$m4base/Makefile.am"
5026 subdirs="$sourcebase $m4base"
5027 subdirs_with_configure_ac=""
5029 if false && test -f "$testdir"/$m4base/gettext.m4; then
5030 # Avoid stupid error message from automake:
5031 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5032 mkdir -p "$testdir/po"
5033 (echo "## Process this file with automake to produce Makefile.in."
5034 ) > "$testdir/po/Makefile.am"
5035 func_append subdirs " po"
5038 if test -n "$inctests"; then
5039 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5040 # Viewed from the $testsbase subdirectory, $auxdir is different.
5041 saved_auxdir="$auxdir"
5042 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5043 # Create $testsbase/Makefile.am.
5045 destfile="$testsbase/Makefile.am"
5046 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5047 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5048 # Create $testsbase/configure.ac.
5049 (echo "# Process this file with autoconf to produce a configure script."
5050 echo "AC_INIT([dummy], [0])"
5051 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5052 echo "AM_INIT_AUTOMAKE"
5054 echo "AC_CONFIG_HEADERS([config.h])"
5057 echo "AC_PROG_INSTALL"
5058 echo "AC_PROG_MAKE_SET"
5059 echo "AC_PROG_RANLIB"
5061 if test -n "$uses_subdirs"; then
5062 echo "AM_PROG_CC_C_O"
5065 for module in $modules; do
5067 if test -n "$module"; then
5069 gnumakefile | maintainer-makefile)
5070 # These modules are meant to be used only in the top-level directory.
5073 func_get_autoconf_early_snippet "$module"
5078 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5079 if test "$libtool" = true; then
5080 echo "LT_INIT([win32-dll])"
5081 echo "LT_LANG([C++])"
5082 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5083 echo "gl_cond_libtool=true"
5085 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5086 echo "gl_cond_libtool=false"
5088 echo "gl_ltlibdeps="
5090 # Wrap the set of autoconf snippets into an autoconf macro that is then
5091 # invoked. This is needed because autoconf does not support AC_REQUIRE
5093 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5094 # but we want the AC_REQUIRE to have its normal meaning (provide one
5095 # expansion of the required macro before the current point, and only one
5097 echo "AC_DEFUN([gl_INIT], ["
5098 sed_replace_build_aux='
5100 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5101 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5104 echo "gl_m4_base='../$m4base'"
5105 func_emit_initmacro_start $macro_prefix
5106 # We don't have explicit ordering constraints between the various
5107 # autoconf snippets. It's cleanest to put those of the library before
5108 # those of the tests.
5109 echo "gl_source_base='../$sourcebase'"
5110 for module in $modules; do
5111 func_verify_nontests_module
5112 if test -n "$module"; then
5114 gnumakefile | maintainer-makefile)
5115 # These modules are meant to be used only in the top-level directory.
5118 func_get_autoconf_snippet "$module" \
5119 | sed -e "$sed_replace_build_aux"
5124 echo "gl_source_base='.'"
5125 for module in $modules; do
5126 func_verify_tests_module
5127 if test -n "$module"; then
5128 func_get_autoconf_snippet "$module" \
5129 | sed -e "$sed_replace_build_aux"
5132 func_emit_initmacro_end $macro_prefix
5133 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5134 # created using libtool, because libtool already handles the dependencies.
5135 if test "$libtool" != true; then
5136 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5137 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5138 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5139 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5140 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5143 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5147 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5148 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5149 echo "AH_TOP([#include \"../config.h\"])"
5151 echo "AC_CONFIG_FILES([Makefile])"
5153 ) > "$testdir/$testsbase/configure.ac"
5154 auxdir="$saved_auxdir"
5155 func_append subdirs " $testsbase"
5156 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5159 # Create Makefile.am.
5160 (echo "## Process this file with automake to produce Makefile.in."
5162 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5164 echo "SUBDIRS = $subdirs"
5166 echo "ACLOCAL_AMFLAGS = -I $m4base"
5167 ) > "$testdir/Makefile.am"
5169 # Create configure.ac.
5170 (echo "# Process this file with autoconf to produce a configure script."
5171 echo "AC_INIT([dummy], [0])"
5172 if test "$auxdir" != "."; then
5173 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5175 echo "AM_INIT_AUTOMAKE"
5177 echo "AC_CONFIG_HEADERS([config.h])"
5180 echo "AC_PROG_INSTALL"
5181 echo "AC_PROG_MAKE_SET"
5183 echo "# For autobuild."
5184 echo "AC_CANONICAL_BUILD"
5185 echo "AC_CANONICAL_HOST"
5187 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5188 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5189 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5190 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5192 echo "AC_PROG_RANLIB"
5194 if test -n "$any_uses_subdirs"; then
5195 echo "AM_PROG_CC_C_O"
5198 for module in $modules; do
5199 func_verify_nontests_module
5200 if test -n "$module"; then
5201 func_get_autoconf_early_snippet "$module"
5204 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5205 if test "$libtool" = true; then
5206 echo "LT_INIT([win32-dll])"
5207 echo "LT_LANG([C++])"
5208 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5209 echo "gl_cond_libtool=true"
5211 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5212 echo "gl_cond_libtool=false"
5214 echo "gl_ltlibdeps="
5216 # Wrap the set of autoconf snippets into an autoconf macro that is then
5217 # invoked. This is needed because autoconf does not support AC_REQUIRE
5219 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5220 # but we want the AC_REQUIRE to have its normal meaning (provide one
5221 # expansion of the required macro before the current point, and only one
5223 echo "AC_DEFUN([gl_INIT], ["
5224 if test "$auxdir" != "build-aux"; then
5225 sed_replace_build_aux='
5227 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5228 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5232 sed_replace_build_aux="$sed_noop"
5234 echo "gl_m4_base='$m4base'"
5235 func_emit_initmacro_start $macro_prefix
5236 echo "gl_source_base='$sourcebase'"
5237 for module in $modules; do
5238 func_verify_nontests_module
5239 if test -n "$module"; then
5240 func_get_autoconf_snippet "$module" \
5241 | sed -e "$sed_replace_build_aux"
5244 func_emit_initmacro_end $macro_prefix
5245 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5246 # created using libtool, because libtool already handles the dependencies.
5247 if test "$libtool" != true; then
5248 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5249 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5250 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5251 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5252 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5255 func_emit_initmacro_done $macro_prefix $sourcebase
5259 if test -n "$subdirs_with_configure_ac"; then
5260 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5262 makefiles="Makefile"
5263 for d in $subdirs; do
5264 # For subdirs that have a configure.ac by their own, it's the subdir's
5265 # configure.ac which creates the subdir's Makefile.am, not this one.
5266 case " $subdirs_with_configure_ac " in
5268 *) func_append makefiles " $d/Makefile" ;;
5271 echo "AC_CONFIG_FILES([$makefiles])"
5273 ) > "$testdir/configure.ac"
5275 # Create autogenerated files.
5277 # Do not use "${AUTORECONF} --force --install", because it may invoke
5278 # autopoint, which brings in older versions of some of our .m4 files.
5279 if test -f $m4base/gettext.m4; then
5280 func_execute_command ${AUTOPOINT} --force || func_exit 1
5281 for f in $m4base/*.m4~; do
5283 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5287 if test "$libtool" = true; then
5288 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5290 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5291 if ! test -d build-aux; then
5292 func_execute_command mkdir build-aux || func_exit 1
5294 func_execute_command ${AUTOCONF} || func_exit 1
5295 func_execute_command ${AUTOHEADER} || func_exit 1
5296 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5298 if test -n "$inctests"; then
5299 # Create autogenerated files.
5300 (cd "$testdir/$testsbase" || func_exit 1
5301 # Do not use "${AUTORECONF} --force --install", because it may invoke
5302 # autopoint, which brings in older versions of some of our .m4 files.
5303 if test -f ../$m4base/gettext.m4; then
5304 func_execute_command ${AUTOPOINT} --force || func_exit 1
5305 for f in ../$m4base/*.m4~; do
5307 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5311 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5312 if ! test -d ../build-aux; then
5313 func_execute_command mkdir ../build-aux
5315 func_execute_command ${AUTOCONF} || func_exit 1
5316 func_execute_command ${AUTOHEADER} || func_exit 1
5317 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5320 # Need to run configure and make once, to create built files that are to be
5321 # distributed (such as getdate.c).
5322 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5323 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5324 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5325 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5326 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5327 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5328 # such $(FOO_H) because they don't refer to distributed files.
5329 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5330 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5331 | sed -e "$sed_remove_make_variables"`
5332 distributed_built_sources=`for file in $built_sources; do
5333 case "$cleaned_files" in
5338 tests_distributed_built_sources=
5339 if test -n "$inctests"; then
5340 # Likewise for built files in the $testsbase directory.
5341 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5342 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5343 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5344 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5345 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5346 | sed -e "$sed_remove_make_variables"`
5347 tests_distributed_built_sources=`for file in $tests_built_sources; do
5348 case "$tests_cleaned_files" in
5354 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5356 ./configure || func_exit 1
5357 if test -n "$distributed_built_sources"; then
5359 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5360 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5365 if test -n "$tests_distributed_built_sources"; then
5367 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5368 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5373 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5380 # func_create_megatestdir megatestdir allmodules
5382 # - local_gnulib_dir from --local-dir
5383 # - modcache true or false, from --cache-modules/--no-cache-modules
5384 # - auxdir directory relative to destdir where to place build aux files
5385 func_create_megatestdir ()
5389 if test -z "$allmodules"; then
5390 allmodules=`func_all_modules`
5394 # First, all modules one by one.
5395 for onemodule in $allmodules; do
5396 func_create_testdir "$megatestdir/$onemodule" $onemodule
5397 func_append megasubdirs "$onemodule "
5399 # Then, all modules all together.
5400 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5401 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5402 func_create_testdir "$megatestdir/ALL" "$allmodules"
5403 func_append megasubdirs "ALL"
5406 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5407 vc_witness="$gnulib_dir/CVS/Entries"; \
5409 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5411 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5412 | sed -e 's,January,01,' -e 's,Jan,01,' \
5413 -e 's,February,02,' -e 's,Feb,02,' \
5414 -e 's,March,03,' -e 's,Mar,03,' \
5415 -e 's,April,04,' -e 's,Apr,04,' \
5417 -e 's,June,06,' -e 's,Jun,06,' \
5418 -e 's,July,07,' -e 's,Jul,07,' \
5419 -e 's,August,08,' -e 's,Aug,08,' \
5420 -e 's,September,09,' -e 's,Sep,09,' \
5421 -e 's,October,10,' -e 's,Oct,10,' \
5422 -e 's,November,11,' -e 's,Nov,11,' \
5423 -e 's,December,12,' -e 's,Dec,12,' \
5424 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5425 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5427 echo "CVSDATE=$cvsdate"
5428 echo ": \${MAKE=make}"
5429 echo "test -d logs || mkdir logs"
5430 echo "for module in $megasubdirs; do"
5431 echo " echo \"Working on module \$module...\""
5432 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5433 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5436 echo " : autobuild project... \$module"
5437 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5438 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5439 echo " : autobuild hostname... \`hostname\`"
5440 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5442 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5444 ) > "$megatestdir/do-autobuild"
5445 chmod a+x "$megatestdir/do-autobuild"
5447 # Create Makefile.am.
5448 (echo "## Process this file with automake to produce Makefile.in."
5450 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5452 echo "SUBDIRS = $megasubdirs"
5454 echo "EXTRA_DIST = do-autobuild"
5455 ) > "$megatestdir/Makefile.am"
5457 # Create configure.ac.
5458 (echo "# Process this file with autoconf to produce a configure script."
5459 echo "AC_INIT([dummy], [0])"
5460 if test "$auxdir" != "."; then
5461 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5463 echo "AM_INIT_AUTOMAKE"
5465 echo "AC_PROG_MAKE_SET"
5467 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5468 echo "AC_CONFIG_FILES([Makefile])"
5470 ) > "$megatestdir/configure.ac"
5472 # Create autogenerated files.
5474 # Do not use "${AUTORECONF} --install", because autoreconf operates
5475 # recursively, but the subdirectories are already finished, therefore
5476 # calling autoreconf here would only waste lots of CPU time.
5477 func_execute_command ${ACLOCAL} || func_exit 1
5478 func_execute_command mkdir build-aux
5479 func_execute_command ${AUTOCONF} || func_exit 1
5480 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5486 func_fatal_error "no mode specified" ;;
5493 # sed expression that converts a literal to a basic regular expression.
5494 # Needs to handle . [ \ * ^ $.
5495 sed_literal_to_basic_regex='s/\\/\\\\/g
5501 if test -f "$gnulib_dir/$filename" \
5502 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5503 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5504 filename_line_regex='^'"$filename_anywhere_regex"'$'
5507 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5508 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5509 (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$,,')
5512 | func_sanitize_modulelist \
5515 for module in $module_candidates; do
5516 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5521 func_warning "file $filename does not exist"
5526 import | add-import | remove-import | update )
5529 if test -z "$destdir"; then
5532 test -d "$destdir" \
5533 || func_fatal_error "destination directory does not exist: $destdir"
5535 # Prefer configure.ac to configure.in.
5536 if test -f "$destdir"/configure.ac; then
5537 configure_ac="$destdir/configure.ac"
5539 if test -f "$destdir"/configure.in; then
5540 configure_ac="$destdir/configure.in"
5542 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5546 # Analyze configure.ac.
5548 guessed_libtool=false
5553 /AC_CONFIG_AUX_DIR/ {
5554 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5556 /A[CM]_PROG_LIBTOOL/ {
5557 s,^.*$,guessed_libtool=true,p
5559 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5561 if test -z "$auxdir"; then
5562 auxdir="$guessed_auxdir"
5565 # Determine where to apply func_import.
5566 if test "$mode" = import; then
5567 # Apply func_import to a particular gnulib directory.
5568 # The command line contains the complete specification; don't look at
5569 # the contents of gnulib-cache.m4.
5570 test -n "$supplied_libname" || supplied_libname=true
5571 test -n "$sourcebase" || sourcebase="lib"
5572 test -n "$m4base" || m4base="m4"
5573 test -n "$docbase" || docbase="doc"
5574 test -n "$testsbase" || testsbase="tests"
5575 test -n "$macro_prefix" || macro_prefix="gl"
5578 if test -n "$m4base"; then
5579 # Apply func_import to a particular gnulib directory.
5580 # Any number of additional modules can be given.
5581 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5582 # First use of gnulib in the given m4base.
5583 test -n "$supplied_libname" || supplied_libname=true
5584 test -n "$sourcebase" || sourcebase="lib"
5585 test -n "$docbase" || docbase="doc"
5586 test -n "$testsbase" || testsbase="tests"
5587 test -n "$macro_prefix" || macro_prefix="gl"
5591 # Apply func_import to all gnulib directories.
5592 # To get this list of directories, look at Makefile.am. (Not at
5593 # configure, because it may be omitted from version control. Also,
5594 # don't run "find $destdir -name gnulib-cache.m4", as it might be
5598 if test -f "$destdir"/Makefile.am; then
5599 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5601 for arg in $aclocal_amflags; do
5602 if test -n "$m4dir_is_next"; then
5603 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5607 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5608 func_append m4dirs " $arg"
5609 m4dirs_count=`expr $m4dirs_count + 1`
5615 if test "X$arg" = "X-I"; then
5623 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5624 if test -f "$destdir"/aclocal.m4; then
5625 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5626 sedexpr2='s,^[^/]*$,.,'
5627 sedexpr3='s,/[^/]*$,,'
5628 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5629 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
5630 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
5633 if test $m4dirs_count = 0; then
5634 # First use of gnulib in a package.
5635 # Any number of additional modules can be given.
5636 test -n "$supplied_libname" || supplied_libname=true
5637 test -n "$sourcebase" || sourcebase="lib"
5639 test -n "$docbase" || docbase="doc"
5640 test -n "$testsbase" || testsbase="tests"
5641 test -n "$macro_prefix" || macro_prefix="gl"
5644 if test $m4dirs_count = 1; then
5645 # There's only one use of gnulib here. Assume the user means it.
5646 # Any number of additional modules can be given.
5647 for m4base in $m4dirs; do
5651 # Ambiguous - guess what the user meant.
5652 if test $# = 0; then
5653 # No further arguments. Guess the user wants to update all of them.
5654 for m4base in $m4dirs; do
5655 # Perform func_import in a subshell, so that variable values
5657 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5658 # inc_longrunning_tests, inc_privileged_tests,
5659 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5660 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5661 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5662 # don't propagate from one directory to another.
5663 (func_import) || func_exit 1
5667 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5676 if test -z "$destdir"; then
5677 func_fatal_error "please specify --dir option"
5680 test -d "$destdir" \
5681 || func_fatal_error "could not create destination directory"
5682 test -n "$auxdir" || auxdir="build-aux"
5683 func_create_testdir "$destdir" "$*"
5686 create-megatestdir )
5687 if test -z "$destdir"; then
5688 func_fatal_error "please specify --dir option"
5690 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5691 test -n "$auxdir" || auxdir="build-aux"
5692 func_create_megatestdir "$destdir" "$*"
5696 test -n "$destdir" || destdir=testdir$$
5697 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5698 test -n "$auxdir" || auxdir="build-aux"
5699 func_create_testdir "$destdir" "$*"
5703 ../configure || func_exit 1
5704 $MAKE || func_exit 1
5705 $MAKE check || func_exit 1
5706 $MAKE distclean || func_exit 1
5707 remaining=`find . -type f -print`
5708 if test -n "$remaining"; then
5709 echo "Remaining files:" $remaining 1>&2
5710 echo "gnulib-tool: *** Stop." 1>&2
5719 test -n "$destdir" || destdir=testdir$$
5720 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5721 test -n "$auxdir" || auxdir="build-aux"
5722 func_create_megatestdir "$destdir" "$*"
5730 remaining=`find . -type f -print`
5731 if test -n "$remaining"; then
5732 echo "Remaining files:" $remaining 1>&2
5733 echo "gnulib-tool: *** Stop." 1>&2
5741 extract-description )
5745 if test -n "$module"; then
5746 func_get_description "$module"
5755 if test -n "$module"; then
5756 func_get_comment "$module"
5765 if test -n "$module"; then
5766 func_get_status "$module"
5775 if test -n "$module"; then
5776 func_get_notice "$module"
5781 extract-applicability )
5785 if test -n "$module"; then
5786 func_get_applicability "$module"
5795 if test -n "$module"; then
5796 func_get_filelist "$module"
5801 extract-dependencies )
5805 if test -n "$module"; then
5806 func_get_dependencies "$module"
5811 extract-autoconf-snippet )
5815 if test -n "$module"; then
5816 func_get_autoconf_snippet "$module"
5821 extract-automake-snippet )
5825 if test -n "$module"; then
5826 func_get_automake_snippet "$module"
5831 extract-include-directive )
5835 if test -n "$module"; then
5836 func_get_include_directive "$module"
5841 extract-link-directive )
5845 if test -n "$module"; then
5846 func_get_link_directive "$module"
5855 if test -n "$module"; then
5856 func_get_license "$module"
5861 extract-maintainer )
5865 if test -n "$module"; then
5866 func_get_maintainer "$module"
5871 extract-tests-module )
5875 if test -n "$module"; then
5876 func_get_tests_module "$module"
5882 # Verify the number of arguments.
5883 if test $# -lt 1 || test $# -gt 2; then
5884 func_fatal_error "invalid number of arguments for --$mode"
5887 # The first argument is the file to be copied.
5889 # Verify the file exists.
5890 func_lookup_file "$f"
5892 # The second argument is the destination; either a directory ot a file.
5893 # It defaults to the current directory.
5895 test -n "$dest" || dest='.'
5896 test -n "$sourcebase" || sourcebase="lib"
5897 test -n "$m4base" || m4base="m4"
5898 test -n "$docbase" || docbase="doc"
5899 test -n "$testsbase" || testsbase="tests"
5900 test -n "$auxdir" || auxdir="build-aux"
5901 rewritten='%REWRITTEN%'
5902 sed_rewrite_files="\
5903 s,^build-aux/,$rewritten$auxdir/,
5904 s,^doc/,$rewritten$docbase/,
5905 s,^lib/,$rewritten$sourcebase/,
5906 s,^m4/,$rewritten$m4base/,
5907 s,^tests/,$rewritten$testsbase/,
5910 if test -d "$dest"; then
5912 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5914 destdir=`dirname "$dest"`
5915 g=`basename "$dest"`
5918 # Create the directory for destfile.
5919 d=`dirname "$destdir/$g"`
5921 if test -n "$d" && test ! -d "$d"; then
5922 mkdir -p "$d" || func_fatal_error "failed"
5926 func_dest_tmpfilename "$g"
5927 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5928 already_present=true
5929 if test -f "$destdir/$g"; then
5930 # The file already exists.
5934 # Don't protest if the file should be there but isn't: it happens
5935 # frequently that developers don't put autogenerated files under version
5943 func_fatal_error "unknown operation mode --$mode" ;;
5947 # Undo the effect of the previous 'trap' command. Some shellology:
5948 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5949 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5950 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5951 # 128 + signal number and is set before the trap-registered command is run.
5953 trap 'func_exit $?' 1 2 3 13 15
5958 # indent-tabs-mode: nil
5959 # whitespace-check-buffer-indent: nil