3 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
126 # This use of bold display can be removed on 2011-01-01.
131 # Assume xterm compatible escape sequences.
132 bold_on=`printf '\x1b[1m'`
133 bold_off=`printf '\x1b[0m'`
139 Usage: gnulib-tool --list
140 gnulib-tool --find filename${bold_on}
141 gnulib-tool --import [module1 ... moduleN]
142 gnulib-tool --add-import [module1 ... moduleN]
143 gnulib-tool --remove-import [module1 ... moduleN]${bold_off}
145 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
146 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
147 gnulib-tool --test --dir=directory module1 ... moduleN
148 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
149 gnulib-tool --extract-description module
150 gnulib-tool --extract-comment module
151 gnulib-tool --extract-status module
152 gnulib-tool --extract-notice module
153 gnulib-tool --extract-applicability module
154 gnulib-tool --extract-filelist module
155 gnulib-tool --extract-dependencies module
156 gnulib-tool --extract-autoconf-snippet module
157 gnulib-tool --extract-automake-snippet module
158 gnulib-tool --extract-include-directive module
159 gnulib-tool --extract-link-directive module
160 gnulib-tool --extract-license module
161 gnulib-tool --extract-maintainer module
162 gnulib-tool --extract-tests-module module
163 gnulib-tool --copy-file file [destination]
166 --list print the available module names
167 --find find the modules which contain the specified file${bold_on}
168 --import import the given modules into the current package
169 --add-import augment the list of imports from gnulib into the
170 current package, by adding the given modules;
171 if no modules are specified, update the current
172 package from the current gnulib
173 --remove-import reduce the list of imports from gnulib into the
174 current package, by removing the given modules${bold_off}
175 --update update the current package, restore files omitted
177 --create-testdir create a scratch package with the given modules
178 --create-megatestdir create a mega scratch package with the given modules
179 one by one and all together
180 --test test the combination of the given modules
181 (recommended to use CC=\"gcc -Wall\" here)
182 --megatest test the given modules one by one and all together
183 (recommended to use CC=\"gcc -Wall\" here)
184 --extract-description extract the description
185 --extract-comment extract the comment
186 --extract-status extract the status (obsolete etc.)
187 --extract-notice extract the notice or banner
188 --extract-applicability extract the applicability
189 --extract-filelist extract the list of files
190 --extract-dependencies extract the dependencies
191 --extract-autoconf-snippet extract the snippet for configure.ac
192 --extract-automake-snippet extract the snippet for library makefile
193 --extract-include-directive extract the #include directive
194 --extract-link-directive extract the linker directive
195 --extract-license report the license terms of the source files
197 --extract-maintainer report the maintainer(s) inside gnulib
198 --extract-tests-module report the unit test module, if it exists
199 --copy-file copy a file that is not part of any module
202 --dir=DIRECTORY Specify the target directory.
203 For --import, this specifies where your
204 configure.ac can be found. Defaults to current
206 --local-dir=DIRECTORY Specify a local override directory where to look
207 up files before looking in gnulib's directory.
208 --cache-modules Enable module caching optimization.
209 --no-cache-modules Disable module caching optimization.
210 --verbose Increase verbosity. May be repeated.
211 --quiet Decrease verbosity. May be repeated.
213 Options for --import, --update:
214 --dry-run Only print what would have been done.
216 Options for --import, --create-[mega]testdir, --[mega]test:
217 --with-tests Include unit tests for the included modules.
218 --with-obsolete Include obsolete modules when they occur among the
219 dependencies. By default, dependencies to obsolete
221 --with-c++-tests Include even unit tests for C++ interoperability.
222 --with-longrunning-tests
223 Include even unit tests that are long-runners.
224 --with-privileged-tests
225 Include even unit tests that require root
227 --with-unportable-tests
228 Include even unit tests that fail on some platforms.
229 --with-all-tests Include all kinds of problematic unit tests.
230 --avoid=MODULE Avoid including the given MODULE. Useful if you
231 have code that provides equivalent functionality.
232 This option can be repeated.
233 --libtool Use libtool rules.
234 --no-libtool Don't use libtool rules.
236 Options for --import:
237 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
238 --source-base=DIRECTORY
239 Directory relative to --dir where source code is
240 placed (default \"lib\").
241 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
242 placed (default \"m4\").
243 --po-base=DIRECTORY Directory relative to --dir where *.po files are
244 placed (default \"po\").
245 --doc-base=DIRECTORY Directory relative to --dir where doc files are
246 placed (default \"doc\").
247 --tests-base=DIRECTORY
248 Directory relative to --dir where unit tests are
249 placed (default \"tests\").
250 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
251 tools are placed (default \"build-aux\").
252 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
253 Also modify license template from GPL to LGPL.
254 The version number of the LGPL can be specified;
255 the default is currently LGPLv3.
256 --makefile-name=NAME Name of makefile in automake syntax in the
257 source-base and tests-base directories
258 (default \"Makefile.am\").
259 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
260 'gl_INIT'. Default is 'gl'.
261 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
262 the package name. A suffix '-gnulib' is appended.
263 --vc-files Update version control related files.
264 --no-vc-files Don't update version control related files
265 (.gitignore and/or .cvsignore).
266 --no-changelog Don't update or create ChangeLog files.
268 Options for --create-[mega]testdir, --[mega]test:
269 --without-c++-tests Exclude unit tests for C++ interoperability.
270 --without-longrunning-tests
271 Exclude unit tests that are long-runners.
272 --without-privileged-tests
273 Exclude unit tests that require root privileges.
274 --without-unportable-tests
275 Exclude unit tests that fail on some platforms.
277 Options for --import, --update, --create-[mega]testdir, --[mega]test:
278 -s, --symbolic, --symlink Make symbolic links instead of copying files.
279 --local-symlink Make symbolic links instead of copying files, only
280 for files from the local override directory.
282 Options for --import, --update:
283 -S, --more-symlinks Make symbolic links instead of copying files, and
284 don't replace copyright notices.
286 Report bugs to <bug-gnulib@gnu.org>."
290 # outputs to stdout the --version message.
294 if test -d "$gnulib_dir"/.git \
295 && (git --version) >/dev/null 2>/dev/null \
296 && (date --version) >/dev/null 2>/dev/null; then
297 # gnulib checked out from git.
298 sed_extract_first_date='/^Date/{
302 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
303 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
304 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
305 date=`echo "$date" | sed -e "$sed_year_before_time"`
306 # Use GNU date to compute the time in GMT.
307 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
308 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
310 if test -d "$gnulib_dir"/CVS \
311 && (cvs --version) >/dev/null 2>/dev/null; then
312 # gnulib checked out from CVS.
313 sed_extract_first_date='/^date: /{
314 s/^date: \([0-9][0-9][0-9][0-9]\).\([0-9][0-9]\).\([0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1-\2-\3 \4/p
317 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
319 # gnulib copy without versioning information.
320 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
324 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
326 gnulib-tool (GNU $package $date)$version
327 Copyright (C) $year Free Software Foundation, Inc.
328 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
329 This is free software: you are free to change and redistribute it.
330 There is NO WARRANTY, to the extent permitted by law.
332 Written by" "Bruno Haible" "and" "Simon Josefsson"
335 # func_emit_copyright_notice
336 # outputs to stdout a header for a generated file.
337 func_emit_copyright_notice ()
339 sed -n -e '/Copyright/ {
342 }' < "$self_abspathname"
344 echo "# This file is free software, distributed under the terms of the GNU"
345 echo "# General Public License. As a special exception to the GNU General"
346 echo "# Public License, this file may be distributed as part of a program"
347 echo "# that contains a configuration script generated by Autoconf, under"
348 echo "# the same distribution terms as the rest of that program."
350 echo "# Generated by gnulib-tool."
354 # exits with a given status.
355 # This function needs to be used, rather than 'exit', when a 'trap' handler is
356 # in effect that refers to $?.
363 # locates the directory where the gnulib repository lives
365 # - progname name of this program
367 # - self_abspathname absolute pathname of gnulib-tool
368 # - gnulib_dir absolute pathname of gnulib repository
372 /*) self_abspathname="$progname" ;;
373 */*) self_abspathname=`pwd`/"$progname" ;;
376 # Iterate through the elements of $PATH.
377 # We use IFS=: instead of
378 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
379 # because the latter does not work when some PATH element contains spaces.
380 # We use a canonicalized $pathx instead of $PATH, because empty PATH
381 # elements are by definition equivalent to '.', however field splitting
382 # according to IFS=: loses empty fields in many shells:
383 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
384 # beginning, at the end, and in the middle),
385 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
386 # at the beginning and at the end,
387 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
388 # Solaris lose empty fields at the end.
389 # The 'case' statement is an optimization, to avoid evaluating the
390 # explicit canonicalization command when $PATH contains no empty fields.
392 if test "${PATH_SEPARATOR+set}" != set; then
393 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
394 # contains only /bin. Note that ksh looks also at the FPATH variable,
395 # so we have to set that as well for the test.
397 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
398 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
399 || PATH_SEPARATOR=';'
402 if test "$PATH_SEPARATOR" = ";"; then
403 # On Windows, programs are searched in "." before $PATH.
406 # On Unix, we have to convert empty PATH elements to ".".
410 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
415 IFS="$PATH_SEPARATOR"
419 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
420 self_abspathname="$d/$progname"
425 if test -z "$self_abspathname"; then
426 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
430 while test -h "$self_abspathname"; do
431 # Resolve symbolic link.
432 linkval=`func_readlink "$self_abspathname"`
433 test -n "$linkval" || break
435 /* ) self_abspathname="$linkval" ;;
436 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
439 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
443 # creates a temporary directory.
445 # - progname name of this program
447 # - tmp pathname of freshly created temporary directory
450 # Use the environment variable TMPDIR, falling back to /tmp. This allows
451 # users to specify a different temporary directory, for example, if their
452 # /tmp is filled up or too small.
455 # Use the mktemp program if available. If not available, hide the error
457 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
458 test -n "$tmp" && test -d "$tmp"
461 # Use a simple mkdir command. It is guaranteed to fail if the directory
462 # already exists. $RANDOM is bash specific and expands to empty in shells
463 # other than bash, ksh and zsh. Its use does not increase security;
464 # rather, it minimizes the probability of failure in a very cluttered /tmp
466 tmp=$TMPDIR/gl$$-$RANDOM
467 (umask 077 && mkdir "$tmp")
470 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
475 # func_append var value
476 # appends the given value to the shell variable var.
477 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
478 # Use bash's += operator. It reduces complexity of appending repeatedly to
479 # a single variable from O(n^2) to O(n).
484 fast_func_append=true
488 eval "$1=\"\$$1\$2\""
490 fast_func_append=false
493 # func_remove_prefix var prefix
494 # removes the given prefix from the value of the shell variable var.
495 # var should be the name of a shell variable.
496 # Its value should not contain a newline and not start or end with whitespace.
497 # prefix should not contain the characters "$`\{}[]^|.
498 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
499 func_remove_prefix ()
503 fast_func_remove_prefix=true
505 func_remove_prefix ()
507 eval "value=\"\$$1\""
511 sed_escape_dots='s/\([.]\)/\\\1/g'
512 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
515 value=`echo "$value" | sed -e "s|^${prefix}||"`
516 eval "$1=\"\$value\""
518 fast_func_remove_prefix=false
521 # func_remove_suffix var suffix
522 # removes the given suffix from the value of the shell variable var.
523 # var should be the name of a shell variable.
524 # Its value should not contain a newline and not start or end with whitespace.
525 # suffix should not contain the characters "$`\{}[]^|.
526 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
527 func_remove_suffix ()
531 fast_func_remove_suffix=true
533 func_remove_suffix ()
535 eval "value=\"\$$1\""
539 sed_escape_dots='s/\([.]\)/\\\1/g'
540 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
543 value=`echo "$value" | sed -e "s|${suffix}\$||"`
544 eval "$1=\"\$value\""
546 fast_func_remove_suffix=false
549 # func_fatal_error message
550 # outputs to stderr a fatal error message, and terminates the program.
552 # - progname name of this program
555 echo "$progname: *** $1" 1>&2
556 echo "$progname: *** Stop." 1>&2
560 # func_warning message
561 # Outputs to stderr a warning message,
564 echo "gnulib-tool: warning: $1" 1>&2
567 # func_readlink SYMLINK
568 # outputs the target of the given symlink.
569 if (type -p readlink) > /dev/null 2>&1; then
572 # Use the readlink program from GNU coreutils.
578 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
579 # would do the wrong thing if the link target contains " -> ".
580 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
584 # func_relativize DIR1 DIR2
585 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
587 # - DIR1 relative pathname, relative to the current directory
588 # - DIR2 relative pathname, relative to the current directory
590 # - reldir relative pathname of DIR2, relative to DIR1
596 sed_first='s,^\([^/]*\)/.*$,\1,'
597 sed_rest='s,^[^/]*/*,,'
598 sed_last='s,^.*/\([^/]*\)$,\1,'
599 sed_butlast='s,/*[^/]*$,,'
600 while test -n "$dir1"; do
601 first=`echo "$dir1" | sed -e "$sed_first"`
602 if test "$first" != "."; then
603 if test "$first" = ".."; then
604 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
605 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
607 first2=`echo "$dir2" | sed -e "$sed_first"`
608 if test "$first2" = "$first"; then
609 dir2=`echo "$dir2" | sed -e "$sed_rest"`
613 dir0="$dir0"/"$first"
616 dir1=`echo "$dir1" | sed -e "$sed_rest"`
621 # func_relconcat DIR1 DIR2
622 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
624 # - DIR1 relative pathname, relative to the current directory
625 # - DIR2 relative pathname, relative to DIR1
627 # - relconcat DIR1/DIR2, relative to the current directory
632 sed_first='s,^\([^/]*\)/.*$,\1,'
633 sed_rest='s,^[^/]*/*,,'
634 sed_last='s,^.*/\([^/]*\)$,\1,'
635 sed_butlast='s,/*[^/]*$,,'
637 first=`echo "$dir2" | sed -e "$sed_first"`
638 if test "$first" = "."; then
639 dir2=`echo "$dir2" | sed -e "$sed_rest"`
640 if test -z "$dir2"; then
645 last=`echo "$dir1" | sed -e "$sed_last"`
646 while test "$last" = "."; do
647 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
648 last=`echo "$dir1" | sed -e "$sed_last"`
650 if test -z "$dir1"; then
654 if test "$first" = ".."; then
655 if test "$last" = ".."; then
656 relconcat="$dir1/$dir2"
659 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
660 dir2=`echo "$dir2" | sed -e "$sed_rest"`
661 if test -z "$dir1"; then
665 if test -z "$dir2"; then
670 relconcat="$dir1/$dir2"
678 # Like ln -s, except that SRC is given relative to the current directory (or
679 # absolute), not given relative to the directory of DEST.
685 *) # SRC is relative.
688 ln -s "`pwd`/$1" "$2" ;;
689 *) # DEST is relative too.
690 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
691 test -n "$ln_destdir" || ln_destdir="."
692 func_relativize "$ln_destdir" "$1"
700 # func_ln_if_changed SRC DEST
701 # Like func_ln, but avoids munging timestamps if the link is correct.
702 func_ln_if_changed ()
704 if test $# -ne 2; then
705 echo "usage: func_ln_if_changed SRC DEST" >&2
707 ln_target=`func_readlink "$2"`
708 if test -h "$2" && test "$1" = "$ln_target"; then
716 # Ensure an 'echo' command that
717 # 1. does not interpret backslashes and
718 # 2. does not print an error message "broken pipe" when writing into a pipe
721 # Test cases for problem 1:
722 # echo '\n' | wc -l prints 1 when OK, 2 when KO
723 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
724 # Test cases for problem 2:
725 # echo hi | true frequently prints
726 # "bash: echo: write error: Broken pipe"
727 # to standard error in bash 3.2.
729 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
730 # BSD echo interprets '-n' as an option, which is also not desirable).
731 # Nowadays the problem occurs in 4 situations:
732 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
733 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
734 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
735 # - in zsh, when sh-emulation is not set,
736 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
737 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
738 # - in Solaris /bin/sh and OSF/1 /bin/sh.
739 # We try the following workarounds:
740 # - for all: respawn using $CONFIG_SHELL if that is set and works.
741 # - for bash >= 2.04: unset the shell option xpg_echo.
742 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
743 # - for bash < 2.0: define echo to a function that uses cat of a here document.
744 # - for zsh: turn sh-emulation on.
745 # - for ksh: alias echo to 'print -r'.
746 # - for ksh: alias echo to a function that uses cat of a here document.
747 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
748 # the ksh workaround.
749 # - otherwise: respawn using /bin/sh and rely on the workarounds.
750 # When respawning, we pass --no-reexec as first argument, so as to avoid
751 # turning this script into a fork bomb in unlucky situations.
753 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
754 # the 'printf' built-in. See
755 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
756 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
757 # The workaround is: define echo to a function that uses the printf built-in.
759 if echo '\t' | grep t > /dev/null; then
760 have_echo=yes # Lucky!
762 # Try the workarounds.
763 # Respawn using $CONFIG_SHELL if that is set and works.
764 if test -z "$have_echo" \
765 && test "X$1" != "X--no-reexec" \
766 && test -n "$CONFIG_SHELL" \
767 && test -f "$CONFIG_SHELL" \
768 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
769 exec $CONFIG_SHELL "$0" --no-reexec "$@"
772 # For bash >= 2.04: unset the shell option xpg_echo.
773 if test -z "$have_echo" \
774 && test -n "$BASH_VERSION" \
775 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
779 # For bash >= 2.0: define echo to a function that uses the printf built-in.
780 # For bash < 2.0: define echo to a function that uses cat of a here document.
781 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
782 # Also handle problem 2, specific to bash 3.2, here.
783 if { test -z "$have_echo" \
784 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
786 && test -n "$BASH_VERSION"; then \
787 if type printf 2>/dev/null | grep / > /dev/null; then
788 # 'printf' is not a shell built-in.
796 # 'printf' is a shell built-in.
802 if echo '\t' | grep t > /dev/null; then
806 # For zsh: turn sh-emulation on.
807 if test -z "$have_echo" \
808 && test -n "$ZSH_VERSION" \
809 && (emulate sh) >/dev/null 2>&1; then
812 # For ksh: alias echo to 'print -r'.
813 if test -z "$have_echo" \
814 && (type print) >/dev/null 2>&1; then
815 # A 'print' command exists.
816 if type print 2>/dev/null | grep / > /dev/null; then
819 # 'print' is a shell built-in.
820 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
821 # 'print' is the ksh shell built-in.
822 alias echo='print -r'
826 if test -z "$have_echo" \
827 && echo '\t' | grep t > /dev/null; then
830 # For ksh: alias echo to a function that uses cat of a here document.
831 # The ksh manual page says:
832 # "Aliasing is performed when scripts are read, not while they are executed.
833 # Therefore, for an alias to take effect, the alias definition command has
834 # to be executed before the command which references the alias is read."
835 # Because of this, we have to play strange tricks with have_echo, to ensure
836 # that the top-level statement containing the test starts after the 'alias'
838 if test -z "$have_echo"; then
845 alias echo=bsd_echo 2>/dev/null
847 if test -z "$have_echo" \
848 && echo '\t' | grep t > /dev/null; then
851 if test -z "$have_echo"; then
852 unalias echo 2>/dev/null
854 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
855 if test -z "$have_echo" \
856 && test "X$1" != "X--no-reexec" \
857 && test -f /bin/ksh; then
858 exec /bin/ksh "$0" --no-reexec "$@"
861 # Otherwise: respawn using /bin/sh.
862 if test -z "$have_echo" \
863 && test "X$1" != "X--no-reexec" \
864 && test -f /bin/sh; then
865 exec /bin/sh "$0" --no-reexec "$@"
868 if test -z "$have_echo"; then
869 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
871 if echo '\t' | grep t > /dev/null; then
874 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
876 if test "X$1" = "X--no-reexec"; then
880 # Command-line option processing.
881 # Removes the OPTIONS from the arguments. Sets the variables:
882 # - mode list or import or add-import or remove-import or update
883 # or create-testdir or create-megatestdir
884 # - destdir from --dir
885 # - local_gnulib_dir from --local-dir
886 # - modcache true or false, from --cache-modules/--no-cache-modules
887 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
888 # - libname, supplied_libname from --lib
889 # - sourcebase from --source-base
890 # - m4base from --m4-base
891 # - pobase from --po-base
892 # - docbase from --doc-base
893 # - testsbase from --tests-base
894 # - auxdir from --aux-dir
895 # - inctests true if --with-tests was given, blank otherwise
896 # - incobsolete true if --with-obsolete was given, blank otherwise
897 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
898 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
900 # - inc_privileged_tests true if --with-privileged-tests was given, blank
902 # - inc_unportable_tests true if --with-unportable-tests was given, blank
904 # - inc_all_tests true if --with-all-tests was given, blank otherwise
905 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
906 # - excl_longrunning_tests true if --without-longrunning-tests was given,
908 # - excl_privileged_tests true if --without-privileged-tests was given, blank
910 # - excl_unportable_tests true if --without-unportable-tests was given, blank
912 # - avoidlist list of modules to avoid, from --avoid
913 # - lgpl yes or a number if --lgpl was given, blank otherwise
914 # - makefile_name from --makefile-name
915 # - libtool true if --libtool was given, false if --no-libtool was
916 # given, blank otherwise
917 # - macro_prefix from --macro-prefix
918 # - po_domain from --po-domain
919 # - vc_files true if --vc-files was given, false if --no-vc-files was
920 # given, blank otherwise
921 # - autoconf_minversion minimum supported autoconf version
922 # - do_changelog false if --no-changelog was given, : otherwise
923 # - doit : if actions shall be executed, false if only to be printed
924 # - symbolic true if --symlink or --more-symlinks was given, blank
926 # - lsymbolic true if --local-symlink was given, blank otherwise
927 # - do_copyrights blank if --more-symlinks was given, true otherwise
945 inc_longrunning_tests=
946 inc_privileged_tests=
947 inc_unportable_tests=
950 excl_longrunning_tests=
951 excl_privileged_tests=
952 excl_unportable_tests=
968 while test $# -gt 0; do
973 --find | --fin | --fi | --f )
976 --import | --impor | --impo | --imp | --im | --i )
979 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
982 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
985 --update | --updat | --upda | --upd | --up | --u )
988 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
991 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
992 mode=create-megatestdir
994 --test | --tes | --te | --t )
997 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1001 mode=`echo "X$1" | sed -e 's/^X--//'`
1003 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
1008 if test $# = 0; then
1009 func_fatal_error "missing argument for --dir"
1014 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1018 if test $# = 0; then
1019 func_fatal_error "missing argument for --local-dir"
1024 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1026 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1029 --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 )
1032 --verbose | --verbos | --verbo | --verb )
1033 verbose=`expr $verbose + 1`
1035 --quiet | --quie | --qui | --qu | --q )
1036 verbose=`expr $verbose - 1`
1040 if test $# = 0; then
1041 func_fatal_error "missing argument for --lib"
1044 supplied_libname=true
1047 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1048 supplied_libname=true
1052 if test $# = 0; then
1053 func_fatal_error "missing argument for --source-base"
1058 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1062 if test $# = 0; then
1063 func_fatal_error "missing argument for --m4-base"
1068 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1072 if test $# = 0; then
1073 func_fatal_error "missing argument for --po-base"
1078 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1082 if test $# = 0; then
1083 func_fatal_error "missing argument for --doc-base"
1088 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1092 if test $# = 0; then
1093 func_fatal_error "missing argument for --tests-base"
1098 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1102 if test $# = 0; then
1103 func_fatal_error "missing argument for --aux-dir"
1108 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1110 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1113 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1116 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1119 --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)
1120 inc_longrunning_tests=true
1122 --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)
1123 inc_privileged_tests=true
1125 --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)
1126 inc_unportable_tests=true
1128 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1131 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1134 --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)
1135 excl_longrunning_tests=true
1137 --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)
1138 excl_privileged_tests=true
1140 --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)
1141 excl_unportable_tests=true
1145 if test $# = 0; then
1146 func_fatal_error "missing argument for --avoid"
1148 func_append avoidlist " $1"
1151 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1152 func_append avoidlist " $arg"
1158 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1161 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1167 if test $# = 0; then
1168 func_fatal_error "missing argument for --makefile-name"
1173 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1183 if test $# = 0; then
1184 func_fatal_error "missing argument for --macro-prefix"
1189 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1193 if test $# = 0; then
1194 func_fatal_error "missing argument for --po-domain"
1199 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1207 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1213 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1216 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1219 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1223 --help | --hel | --he | --h )
1226 --version | --versio | --versi | --vers )
1230 # Stop option processing
1234 echo "gnulib-tool: unknown option $1" 1>&2
1235 echo "Try 'gnulib-tool --help' for more information." 1>&2
1242 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1243 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1244 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then
1245 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1246 echo "Try 'gnulib-tool --help' for more information." 1>&2
1250 # This code helps migrating from --import to --add-import or --update. It can
1251 # be removed on 2012-01-01.
1252 if test "$mode" = import && test $# = 0; then
1253 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1254 echo "The meaning of the option '--import' has changed." 1>&2
1255 echo "See the documentation at" 1>&2
1256 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1257 echo "For updating to a newer version of gnulib, use" 1>&2
1258 echo " gnulib-tool --add-import" 1>&2
1259 echo "For restoring files that were omitted from version control, use" 1>&2
1260 echo " gnulib-tool --update" 1>&2
1263 if test "$mode" = update; then
1264 if test $# != 0; then
1265 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1266 echo "Try 'gnulib-tool --help' for more information." 1>&2
1267 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1268 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1271 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1272 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1273 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1274 || test -n "$inctests" || test -n "$incobsolete" \
1275 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1276 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1277 || test -n "$inc_all_tests" \
1278 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1279 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1280 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1281 || test -n "$macro_prefix" || test -n "$po_domain" \
1282 || test -n "$vc_files"; then
1283 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1284 echo "Try 'gnulib-tool --help' for more information." 1>&2
1285 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1286 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1291 if test -n "$pobase" && test -z "$po_domain"; then
1292 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1293 echo "Try 'gnulib-tool --help' for more information." 1>&2
1296 if test -z "$pobase" && test -n "$po_domain"; then
1297 func_warning "--po-domain has no effect without a --po-base option"
1300 # Determine the minimum supported autoconf version from the project's
1302 DEFAULT_AUTOCONF_MINVERSION="2.59"
1303 autoconf_minversion=
1305 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1306 && test -n "$destdir"; then
1307 if test -f "$destdir"/configure.ac; then
1308 configure_ac="$destdir/configure.ac"
1310 if test -f "$destdir"/configure.in; then
1311 configure_ac="$destdir/configure.in"
1315 if test -f configure.ac; then
1316 configure_ac="configure.ac"
1318 if test -f configure.in; then
1319 configure_ac="configure.in"
1323 if test -n "$configure_ac"; then
1324 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1325 # because when some m4 files are omitted from a version control repository,
1326 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1327 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1328 # autom4te: m4 failed with exit status: 1
1335 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1337 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1338 if test -n "$prereqs"; then
1339 autoconf_minversion=`
1340 for version in $prereqs; do echo $version; done |
1341 LC_ALL=C sort -nru | sed -e 1q
1345 if test -z "$autoconf_minversion"; then
1346 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1348 case "$autoconf_minversion" in
1349 1.* | 2.[0-4]* | 2.5[0-8]*)
1350 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1353 # Remove trailing slashes from the directory names. This is necessary for
1354 # m4base (to avoid an error in func_import) and optional for the others.
1355 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1356 case "$local_gnulib_dir" in
1357 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1359 case "$sourcebase" in
1360 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1363 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1366 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1369 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1371 case "$testsbase" in
1372 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1375 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1381 trap 'exit_status=$?
1382 if test "$signal" != 0; then
1383 echo "caught signal $signal" >&2
1386 exit $exit_status' 0
1387 for signal in 1 2 3 13 15; do
1388 trap '{ signal='$signal'; func_exit 1; }' $signal
1392 # Note: The 'eval' silences stderr output in dash.
1393 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1394 # Zsh 4 and Bash 4 have associative arrays.
1395 have_associative=true
1397 # For other shells, use 'eval' with computed shell variable names.
1398 have_associative=false
1401 # func_lookup_file file
1402 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1405 # - local_gnulib_dir from --local-dir
1407 # - lookedup_file name of the merged (combined) file
1408 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1412 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1413 lookedup_file="$local_gnulib_dir/$lkfile"
1416 if test -f "$gnulib_dir/$lkfile"; then
1417 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1418 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1419 rm -f "$tmp/$lkbase"
1420 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1421 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1422 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1423 lookedup_file="$tmp/$lkbase"
1426 lookedup_file="$gnulib_dir/$lkfile"
1430 func_fatal_error "file $gnulib_dir/$lkfile not found"
1435 # func_sanitize_modulelist
1436 # receives a list of possible module names on standard input, one per line.
1437 # It removes those which are just file names unrelated to modules, and outputs
1438 # the resulting list to standard output, one per line.
1439 func_sanitize_modulelist ()
1441 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1442 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1443 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1444 -e '/^README$/d' -e '/\/README$/d' \
1445 -e '/^TEMPLATE$/d' \
1446 -e '/^TEMPLATE-EXTENDED$/d' \
1447 -e '/^TEMPLATE-TESTS$/d' \
1454 # - local_gnulib_dir from --local-dir
1457 # Filter out metainformation files like README, which are not modules.
1458 # Filter out unit test modules; they can be retrieved through
1459 # --extract-tests-module if desired.
1461 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1462 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1463 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1466 | func_sanitize_modulelist \
1467 | sed -e '/-tests$/d' \
1471 # func_exists_module module
1472 # tests whether a module, given by name, exists
1474 # - local_gnulib_dir from --local-dir
1475 func_exists_module ()
1477 { test -f "$gnulib_dir/modules/$1" \
1478 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1479 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1480 && test "CVS" != "$1" \
1481 && test "ChangeLog" != "$1" \
1482 && test "COPYING" != "$1" \
1483 && test "README" != "$1" \
1484 && test "TEMPLATE" != "$1" \
1485 && test "TEMPLATE-EXTENDED" != "$1" \
1486 && test "TEMPLATE-TESTS" != "$1"
1489 # func_verify_module
1490 # verifies a module name
1492 # - local_gnulib_dir from --local-dir
1493 # - module module name argument
1494 func_verify_module ()
1496 if func_exists_module "$module"; then
1497 # OK, $module is a correct module name.
1498 # Verify that building the module description with 'patch' succeeds.
1499 func_lookup_file "modules/$module"
1501 func_warning "module $module doesn't exist"
1506 # func_verify_nontests_module
1507 # verifies a module name, excluding tests modules
1509 # - local_gnulib_dir from --local-dir
1510 # - module module name argument
1511 func_verify_nontests_module ()
1514 *-tests ) module= ;;
1515 * ) func_verify_module ;;
1519 # func_verify_tests_module
1520 # verifies a module name, considering only tests modules
1522 # - local_gnulib_dir from --local-dir
1523 # - module module name argument
1524 func_verify_tests_module ()
1527 *-tests ) func_verify_module ;;
1532 # Suffix of a sed expression that extracts a particular field from a
1533 # module description.
1534 # A field starts with a line that contains a keyword, such as 'Description',
1535 # followed by a colon and optional whitespace. All following lines, up to
1536 # the next field (or end of file if there is none) form the contents of the
1538 # An absent field is equivalent to a field with empty contents.
1539 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1540 sed_extract_prog=':[ ]*$/ {
1543 s/^Description:[ ]*$//
1547 s/^Applicability:[ ]*$//
1549 s/^Depends-on:[ ]*$//
1550 s/^configure\.ac-early:[ ]*$//
1551 s/^configure\.ac:[ ]*$//
1552 s/^Makefile\.am:[ ]*$//
1556 s/^Maintainer:[ ]*$//
1563 # Piece of a sed expression that converts a field header line to a shell
1565 # NOTE: Keep this in sync with sed_extract_prog above!
1566 sed_extract_field_header='
1567 s/^Description:[ ]*$/description/
1568 s/^Comment:[ ]*$/comment/
1569 s/^Status:[ ]*$/status/
1570 s/^Notice:[ ]*$/notice/
1571 s/^Applicability:[ ]*$/applicability/
1572 s/^Files:[ ]*$/files/
1573 s/^Depends-on:[ ]*$/dependson/
1574 s/^configure\.ac-early:[ ]*$/configureac_early/
1575 s/^configure\.ac:[ ]*$/configureac/
1576 s/^Makefile\.am:[ ]*$/makefile/
1577 s/^Include:[ ]*$/include/
1579 s/^License:[ ]*$/license/
1580 s/^Maintainer:[ ]*$/maintainer/'
1584 if $have_associative; then
1586 # Declare the associative arrays.
1587 declare -A modcache_cached
1588 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1589 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1590 eval "$declare_script"
1594 # func_cache_var module
1595 # computes the cache variable name corresponding to $module.
1596 # Note: This computation can map different module names to the same
1597 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1598 # to protect against this case.
1600 # - cachevar a shell variable name
1601 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1602 # Bash 2.0 and newer, ksh, and zsh support the syntax
1603 # ${param//pattern/replacement}
1604 # as a shorthand for
1605 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1606 # Note: The 'eval' above silences stderr output in dash.
1609 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1616 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1625 # func_init_sed_convert_to_cache_statements
1627 # - modcachevar_assignment
1629 # - sed_convert_to_cache_statements
1630 func_init_sed_convert_to_cache_statements ()
1632 # 'sed' script that turns a module description into shell script
1633 # assignments, suitable to be eval'ed. All active characters are escaped.
1636 # Some module's description
1641 # modcache_description[$1]=\
1642 # 'Some module'"'"'s description
1644 # modcache_files[$1]=\
1647 # c_MODULE_description_set=set; c_MODULE_description=\
1648 # 'Some module'"'"'s description
1650 # c_MODULE_files_set=set; c_MODULE_files=\
1652 # The script consists of two parts:
1653 # 1) Ignore the lines before the first field header.
1654 # 2) A loop, treating non-field-header lines by escaping single quotes
1655 # and adding a closing quote in the last line,
1656 sed_convert_to_cache_statements="
1658 # Here we have not yet seen a field header.
1660 # See if the current line contains a field header.
1663 ${sed_extract_field_header}
1666 # No field header. Ignore the line.
1668 # Read the next line. Upon EOF, just exit.
1673 # The current line contains a field header.
1675 # Turn it into the beginning of an assignment.
1676 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1678 # Move it to the hold space. Don't print it yet,
1679 # because we want no assignment if the field is empty.
1682 # Read the next line.
1683 # Upon EOF, the field was empty. Print no assignment. Just exit.
1686 # See if the current line contains a field header.
1689 ${sed_extract_field_header}
1690 # If it is, the previous field was empty. Print no assignment.
1693 # Not a field header.
1695 # Print the previous line, held in the hold space.
1700 # Transform single quotes.
1703 # Prepend a single quote.
1708 # Move it to the hold space.
1711 # Read the next line.
1718 # See if the current line contains a field header.
1721 ${sed_extract_field_header}
1724 # Print the previous line, held in the hold space.
1729 # Transform single quotes.
1736 # Print the previous line, held in the hold space, with a single quote
1737 # to end the assignment.
1747 # Print the previous line, held in the hold space, with a single quote
1748 # to end the assignment.
1755 if ! $sed_comments; then
1757 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1758 | sed -e 's/^ *//' -e 's/^#.*//'`
1762 if $have_associative; then
1763 # sed_convert_to_cache_statements does not depend on the module.
1764 modcachevar_assignment='modcache_\1[$1]='
1765 func_init_sed_convert_to_cache_statements
1768 # func_cache_lookup_module module
1770 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1771 # of its relevant data in a cache in the memory of the processing shell. If
1772 # already cached, it does not look it up again, thus saving file access time.
1774 # - module non-empty string
1775 # Output if $have_associative:
1776 # - modcache_cached[$module] set to yes
1777 # - modcache_description[$module] ==
1778 # - modcache_status[$module] \ set to the field's value, minus the
1779 # - ... / final newline,
1780 # - modcache_maintainer[$module] == or unset if the field's value is empty
1781 # Output if ! $have_associative:
1782 # - cachevar a shell variable name
1783 # - ${cachevar}_cached set to $module
1784 # - ${cachevar}_description ==
1785 # - ${cachevar}_status \ set to the field's value, minus the
1786 # - ... / final newline,
1787 # - ${cachevar}_maintainer == or unset if the field's value is empty
1788 # - ${cachevar}_description_set ==
1789 # - ${cachevar}_status_set \ set to non-empty if the field's value
1790 # - ... / is non-empty,
1791 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1792 func_cache_lookup_module ()
1794 if $have_associative; then
1795 cached=${modcache_cached[$1]}
1798 eval "cached=\"\$${cachevar}_cached\""
1800 if test -z "$cached"; then
1801 # Not found in cache. Look it up on the file system.
1802 func_lookup_file "modules/$1"
1803 if $have_associative; then
1804 modcache_cached[$1]=yes
1806 eval "${cachevar}_cached=\"\$1\""
1808 if ! $have_associative; then
1809 # sed_convert_to_cache_statements depends on the module.
1810 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1811 func_init_sed_convert_to_cache_statements
1813 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1814 eval "$cache_statements"
1816 if ! $have_associative; then
1817 if test "$1" != "$cached"; then
1818 func_fatal_error "cache variable collision between $1 and $cached"
1826 # func_get_description module
1828 # - local_gnulib_dir from --local-dir
1829 # - modcache true or false, from --cache-modules/--no-cache-modules
1830 func_get_description ()
1832 if ! $modcache; then
1833 func_lookup_file "modules/$1"
1834 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1836 func_cache_lookup_module "$1"
1837 # Output the field's value, including the final newline (if any).
1838 if $have_associative; then
1839 if test -n "${modcache_description[$1]+set}"; then
1840 echo "${modcache_description[$1]}"
1843 eval "field_set=\"\$${cachevar}_description_set\""
1844 if test -n "$field_set"; then
1845 eval "field_value=\"\$${cachevar}_description\""
1846 echo "${field_value}"
1852 # func_get_comment module
1854 # - local_gnulib_dir from --local-dir
1855 # - modcache true or false, from --cache-modules/--no-cache-modules
1858 if ! $modcache; then
1859 func_lookup_file "modules/$1"
1860 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1862 func_cache_lookup_module "$1"
1863 # Output the field's value, including the final newline (if any).
1864 if $have_associative; then
1865 if test -n "${modcache_comment[$1]+set}"; then
1866 echo "${modcache_comment[$1]}"
1869 eval "field_set=\"\$${cachevar}_comment_set\""
1870 if test -n "$field_set"; then
1871 eval "field_value=\"\$${cachevar}_comment\""
1872 echo "${field_value}"
1878 # func_get_status module
1880 # - local_gnulib_dir from --local-dir
1881 # - modcache true or false, from --cache-modules/--no-cache-modules
1884 if ! $modcache; then
1885 func_lookup_file "modules/$1"
1886 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1888 func_cache_lookup_module "$1"
1889 # Output the field's value, including the final newline (if any).
1890 if $have_associative; then
1891 if test -n "${modcache_status[$1]+set}"; then
1892 echo "${modcache_status[$1]}"
1895 eval "field_set=\"\$${cachevar}_status_set\""
1896 if test -n "$field_set"; then
1897 eval "field_value=\"\$${cachevar}_status\""
1898 echo "${field_value}"
1904 # func_get_notice module
1906 # - local_gnulib_dir from --local-dir
1907 # - modcache true or false, from --cache-modules/--no-cache-modules
1910 if ! $modcache; then
1911 func_lookup_file "modules/$1"
1912 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1914 func_cache_lookup_module "$1"
1915 # Output the field's value, including the final newline (if any).
1916 if $have_associative; then
1917 if test -n "${modcache_notice[$1]+set}"; then
1918 echo "${modcache_notice[$1]}"
1921 eval "field_set=\"\$${cachevar}_notice_set\""
1922 if test -n "$field_set"; then
1923 eval "field_value=\"\$${cachevar}_notice\""
1924 echo "${field_value}"
1930 # func_get_applicability module
1932 # - local_gnulib_dir from --local-dir
1933 # - modcache true or false, from --cache-modules/--no-cache-modules
1934 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1935 func_get_applicability ()
1937 if ! $modcache; then
1938 func_lookup_file "modules/$1"
1939 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1941 func_cache_lookup_module "$1"
1942 # Get the field's value, without the final newline.
1943 if $have_associative; then
1944 my_applicability="${modcache_applicability[$1]}"
1946 eval "my_applicability=\"\$${cachevar}_applicability\""
1949 if test -n "$my_applicability"; then
1950 echo $my_applicability
1952 # The default is 'main' or 'tests', depending on the module's name.
1954 *-tests) echo "tests";;
1960 # func_get_filelist module
1962 # - local_gnulib_dir from --local-dir
1963 # - modcache true or false, from --cache-modules/--no-cache-modules
1964 func_get_filelist ()
1966 if ! $modcache; then
1967 func_lookup_file "modules/$1"
1968 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1970 func_cache_lookup_module "$1"
1971 # Output the field's value, including the final newline (if any).
1972 if $have_associative; then
1973 if test -n "${modcache_files[$1]+set}"; then
1974 echo "${modcache_files[$1]}"
1977 eval "field_set=\"\$${cachevar}_files_set\""
1978 if test -n "$field_set"; then
1979 eval "field_value=\"\$${cachevar}_files\""
1980 echo "${field_value}"
1985 echo m4/gnulib-common.m4
1986 case "$autoconf_minversion" in
1993 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1994 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1995 # elements starting with prefix and ending with suffix are considered.
1996 # Processing: removed_prefix and removed_suffix are removed from each element,
1997 # added_prefix and added_suffix are added to each element.
1998 # prefix, suffix should not contain shell-special characters.
1999 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2000 # added_prefix, added_suffix should not contain the characters \|&.
2001 func_filter_filelist ()
2003 if test "$2" != "$nl" \
2004 || { $fast_func_append \
2005 && { test -z "$6" || $fast_func_remove_prefix; } \
2006 && { test -z "$7" || $fast_func_remove_suffix; }; \
2010 # Do not quote possibly-empty parameters in case patterns,
2011 # AIX and HP-UX ksh won't match them if they are empty.
2014 if test -n "$6"; then
2015 func_remove_prefix fff "$6"
2017 if test -n "$7"; then
2018 func_remove_suffix fff "$7"
2021 if test -z "$ffflist"; then
2024 func_append ffflist "$2${fff}"
2030 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2031 ffflist=`for fff in $3; do
2033 $4*$5) echo "$fff" ;;
2035 done | sed -e "$sed_fff_filter"`
2037 eval "$1=\"\$ffflist\""
2040 # func_get_dependencies module
2042 # - local_gnulib_dir from --local-dir
2043 # - modcache true or false, from --cache-modules/--no-cache-modules
2044 func_get_dependencies ()
2046 # ${module}-tests implicitly depends on ${module}, if that module exists.
2050 func_remove_suffix fgd1 '-tests'
2051 if func_exists_module "$fgd1"; then
2056 # Then the explicit dependencies listed in the module description.
2057 if ! $modcache; then
2058 func_lookup_file "modules/$1"
2059 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2061 func_cache_lookup_module "$1"
2062 # Output the field's value, including the final newline (if any).
2063 if $have_associative; then
2064 if test -n "${modcache_dependson[$1]+set}"; then
2065 echo "${modcache_dependson[$1]}"
2068 eval "field_set=\"\$${cachevar}_dependson_set\""
2069 if test -n "$field_set"; then
2070 eval "field_value=\"\$${cachevar}_dependson\""
2071 echo "${field_value}"
2077 # func_get_autoconf_early_snippet module
2079 # - local_gnulib_dir from --local-dir
2080 # - modcache true or false, from --cache-modules/--no-cache-modules
2081 func_get_autoconf_early_snippet ()
2083 if ! $modcache; then
2084 func_lookup_file "modules/$1"
2085 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2087 func_cache_lookup_module "$1"
2088 # Output the field's value, including the final newline (if any).
2089 if $have_associative; then
2090 if test -n "${modcache_configureac_early[$1]+set}"; then
2091 echo "${modcache_configureac_early[$1]}"
2094 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2095 if test -n "$field_set"; then
2096 eval "field_value=\"\$${cachevar}_configureac_early\""
2097 echo "${field_value}"
2103 # func_get_autoconf_snippet module
2105 # - local_gnulib_dir from --local-dir
2106 # - modcache true or false, from --cache-modules/--no-cache-modules
2107 func_get_autoconf_snippet ()
2109 if ! $modcache; then
2110 func_lookup_file "modules/$1"
2111 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2113 func_cache_lookup_module "$1"
2114 # Output the field's value, including the final newline (if any).
2115 if $have_associative; then
2116 if test -n "${modcache_configureac[$1]+set}"; then
2117 echo "${modcache_configureac[$1]}"
2120 eval "field_set=\"\$${cachevar}_configureac_set\""
2121 if test -n "$field_set"; then
2122 eval "field_value=\"\$${cachevar}_configureac\""
2123 echo "${field_value}"
2129 # func_get_automake_snippet module
2131 # - local_gnulib_dir from --local-dir
2132 # - modcache true or false, from --cache-modules/--no-cache-modules
2133 func_get_automake_snippet ()
2135 if ! $modcache; then
2136 func_lookup_file "modules/$1"
2137 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2139 func_cache_lookup_module "$1"
2140 # Output the field's value, including the final newline (if any).
2141 if $have_associative; then
2142 if test -n "${modcache_makefile[$1]+set}"; then
2143 echo "${modcache_makefile[$1]}"
2146 eval "field_set=\"\$${cachevar}_makefile_set\""
2147 if test -n "$field_set"; then
2148 eval "field_value=\"\$${cachevar}_makefile\""
2149 echo "${field_value}"
2155 # *-tests module live in tests/, not lib/.
2156 # Synthesize an EXTRA_DIST augmentation.
2157 all_files=`func_get_filelist $1`
2158 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2159 extra_files="$tests_files"
2160 if test -n "$extra_files"; then
2161 echo "EXTRA_DIST +=" $extra_files
2166 # Synthesize an EXTRA_DIST augmentation.
2167 sed_combine_lines='/\\$/{
2174 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2175 already_mentioned_files=` \
2176 { if ! $modcache; then
2177 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2179 if $have_associative; then
2180 if test -n "${modcache_makefile[$1]+set}"; then
2181 echo "${modcache_makefile[$1]}"
2184 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2185 if test -n "$field_set"; then
2186 eval 'field_value="$'"${cachevar}"'_makefile"'
2187 echo "${field_value}"
2192 | sed -e "$sed_combine_lines" \
2193 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2194 all_files=`func_get_filelist $1`
2195 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2196 # Remove $already_mentioned_files from $lib_files.
2197 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2198 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2199 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2200 if test -n "$extra_files"; then
2201 echo "EXTRA_DIST +=" $extra_files
2204 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2205 # This is necessary so that automake can generate the right list of
2207 # A possible approach would be to use autom4te --trace of the redefined
2208 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2209 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2210 # inside autoconf's built-in macros are not missed).
2211 # But it's simpler and more robust to do it here, based on the file list.
2212 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2213 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2214 # automake will generate a useless dependency; this is harmless.
2216 relocatable-prog-wrapper) ;;
2218 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2219 if test -n "$extra_files"; then
2220 echo "EXTRA_lib_SOURCES +=" $extra_files
2225 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2226 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2227 if test -n "$buildaux_files"; then
2228 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2229 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2232 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2233 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2234 if test -n "$top_files"; then
2235 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2236 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2243 # func_get_include_directive module
2245 # - local_gnulib_dir from --local-dir
2246 # - modcache true or false, from --cache-modules/--no-cache-modules
2247 func_get_include_directive ()
2250 if ! $modcache; then
2251 func_lookup_file "modules/$1"
2252 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2254 func_cache_lookup_module "$1"
2255 # Output the field's value, including the final newline (if any).
2256 if $have_associative; then
2257 if test -n "${modcache_include[$1]+set}"; then
2258 echo "${modcache_include[$1]}"
2261 eval "field_set=\"\$${cachevar}_include_set\""
2262 if test -n "$field_set"; then
2263 eval "field_value=\"\$${cachevar}_include\""
2264 echo "${field_value}"
2268 } | sed -e 's/^\(["<]\)/#include \1/'
2271 # func_get_link_directive module
2273 # - local_gnulib_dir from --local-dir
2274 # - modcache true or false, from --cache-modules/--no-cache-modules
2275 func_get_link_directive ()
2277 if ! $modcache; then
2278 func_lookup_file "modules/$1"
2279 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2281 func_cache_lookup_module "$1"
2282 # Output the field's value, including the final newline (if any).
2283 if $have_associative; then
2284 if test -n "${modcache_link[$1]+set}"; then
2285 echo "${modcache_link[$1]}"
2288 eval "field_set=\"\$${cachevar}_link_set\""
2289 if test -n "$field_set"; then
2290 eval "field_value=\"\$${cachevar}_link\""
2291 echo "${field_value}"
2297 # func_get_license module
2299 # - local_gnulib_dir from --local-dir
2300 # - modcache true or false, from --cache-modules/--no-cache-modules
2304 if ! $modcache; then
2305 func_lookup_file "modules/$1"
2306 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2308 func_cache_lookup_module "$1"
2309 # Output the field's value, including the final newline (if any).
2310 if $have_associative; then
2311 if test -n "${modcache_license[$1]+set}"; then
2312 echo "${modcache_license[$1]}"
2315 eval "field_set=\"\$${cachevar}_license_set\""
2316 if test -n "$field_set"; then
2317 eval "field_value=\"\$${cachevar}_license\""
2318 echo "${field_value}"
2322 # The default is GPL.
2324 } | sed -e 's,^ *$,,' | sed -e 1q
2327 # func_get_maintainer module
2329 # - local_gnulib_dir from --local-dir
2330 # - modcache true or false, from --cache-modules/--no-cache-modules
2331 func_get_maintainer ()
2333 if ! $modcache; then
2334 func_lookup_file "modules/$1"
2335 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2337 func_cache_lookup_module "$1"
2338 # Output the field's value, including the final newline (if any).
2339 if $have_associative; then
2340 if test -n "${modcache_maintainer[$1]+set}"; then
2341 echo "${modcache_maintainer[$1]}"
2344 eval "field_set=\"\$${cachevar}_maintainer_set\""
2345 if test -n "$field_set"; then
2346 eval "field_value=\"\$${cachevar}_maintainer\""
2347 echo "${field_value}"
2353 # func_get_tests_module module
2355 # - local_gnulib_dir from --local-dir
2356 func_get_tests_module ()
2358 # The naming convention for tests modules is hardwired: ${module}-tests.
2359 if test -f "$gnulib_dir/modules/$1"-tests \
2360 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2361 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2366 # func_acceptable module
2367 # tests whether a module is acceptable.
2369 # - avoidlist list of modules to avoid
2372 for avoid in $avoidlist; do
2373 if test "$avoid" = "$1"; then
2380 # func_modules_transitive_closure
2382 # - local_gnulib_dir from --local-dir
2383 # - modcache true or false, from --cache-modules/--no-cache-modules
2384 # - modules list of specified modules
2385 # - inctests true if tests should be included, blank otherwise
2386 # - incobsolete true if obsolete modules among dependencies should be
2387 # included, blank otherwise
2388 # - inc_cxx_tests true if C++ interoperability tests should be included,
2390 # - inc_longrunning_tests true if long-runnings tests should be included,
2392 # - inc_privileged_tests true if tests that require root privileges should be
2393 # included, blank otherwise
2394 # - inc_unportable_tests true if tests that fail on some platforms should be
2395 # included, blank otherwise
2396 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2397 # the unit tests of the specified modules should be
2398 # included, blank otherwise
2399 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2400 # the unit tests of the dependencies should be
2401 # included, blank otherwise
2402 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2404 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2406 # - excl_privileged_tests true if tests that require root privileges should be
2407 # excluded, blank otherwise
2408 # - excl_unportable_tests true if tests that fail on some platforms should be
2409 # excluded, blank otherwise
2410 # - avoidlist list of modules to avoid
2411 # - tmp pathname of a temporary directory
2413 # - modules list of modules, including dependencies
2414 func_modules_transitive_closure ()
2416 # In order to process every module only once (for speed), process an "input
2417 # list" of modules, producing an "output list" of modules. During each round,
2418 # more modules can be queued in the input list. Once a module on the input
2419 # list has been processed, it is added to the "handled list", so we can avoid
2420 # to process it again.
2422 inmodules="$modules"
2424 fmtc_inc_all_tests="$inc_all_direct_tests"
2425 while test -n "$inmodules"; do
2426 inmodules_this_round="$inmodules"
2427 inmodules= # Accumulator, queue for next round
2428 for module in $inmodules_this_round; do
2430 if test -n "$module"; then
2431 if func_acceptable $module; then
2432 func_append outmodules " $module"
2433 deps=`func_get_dependencies $module`
2434 # Duplicate dependencies are harmless, but Jim wants a warning.
2435 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2436 if test -n "$duplicated_deps"; then
2437 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2439 if test -n "$inctests"; then
2440 testsmodule=`func_get_tests_module $module`
2441 if test -n "$testsmodule"; then
2442 deps="$deps $testsmodule"
2445 for dep in $deps; do
2446 # Determine whether to include the dependency or tests module.
2448 for word in `func_get_status $dep`; do
2451 test -n "$incobsolete" \
2455 test -z "$excl_cxx_tests" \
2457 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2461 test -z "$excl_longrunning_tests" \
2463 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2467 test -z "$excl_privileged_tests" \
2469 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2473 test -z "$excl_unportable_tests" \
2475 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2479 test -n "$fmtc_inc_all_tests" \
2485 func_append inmodules " $dep"
2491 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2492 # Remove $handledmodules from $inmodules.
2493 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2494 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2495 fmtc_inc_all_tests="$inc_all_indirect_tests"
2497 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2498 rm -f "$tmp"/queued-modules
2501 # func_show_module_list
2503 # - specified_modules list of specified modules (one per line, sorted)
2504 # - modules complete list of modules (one per line, sorted)
2505 # - tmp pathname of a temporary directory
2506 func_show_module_list ()
2512 # Assume xterm compatible escape sequences.
2513 bold_on=`printf '\x1b[1m'`
2514 bold_off=`printf '\x1b[0m'`
2519 echo "Module list with included dependencies (indented):"
2520 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2521 echo "$modules" | sed -e '/^$/d' \
2522 | LC_ALL=C join -t '|' -a 2 "$tmp"/specified-modules - \
2523 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2526 # func_modules_add_dummy
2528 # - local_gnulib_dir from --local-dir
2529 # - modcache true or false, from --cache-modules/--no-cache-modules
2530 # - modules list of modules, including dependencies
2532 # - modules list of modules, including 'dummy' if needed
2533 func_modules_add_dummy ()
2535 # Determine whether any module provides a lib_SOURCES augmentation.
2537 sed_remove_backslash_newline=':a
2544 for module in $modules; do
2545 func_verify_nontests_module
2546 if test -n "$module"; then
2547 # Extract the value of "lib_SOURCES += ...".
2548 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2549 # Ignore .h files since they are not compiled.
2553 have_lib_SOURCES=yes
2560 # Add the dummy module, to make sure the library will be non-empty.
2561 if test -z "$have_lib_SOURCES"; then
2562 if func_acceptable "dummy"; then
2563 func_append modules " dummy"
2568 # func_modules_notice
2570 # - local_gnulib_dir from --local-dir
2571 # - modcache true or false, from --cache-modules/--no-cache-modules
2572 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2573 # - modules list of modules, including dependencies
2574 func_modules_notice ()
2576 if test $verbose -ge -1; then
2577 for module in $modules; do
2579 if test -n "$module"; then
2580 msg=`func_get_notice $module`
2581 if test -n "$msg"; then
2582 echo "Notice from module $module:"
2583 echo "$msg" | sed -e 's/^/ /'
2590 # func_modules_to_filelist
2592 # - local_gnulib_dir from --local-dir
2593 # - modcache true or false, from --cache-modules/--no-cache-modules
2594 # - modules list of modules, including dependencies
2596 # - files list of files
2597 func_modules_to_filelist ()
2600 for module in $modules; do
2602 if test -n "$module"; then
2603 fs=`func_get_filelist $module`
2604 func_append files " $fs"
2607 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2610 # func_execute_command command [args...]
2611 # Executes a command.
2612 # Uses also the variables
2613 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2614 func_execute_command ()
2616 if test $verbose -ge 0; then
2620 # Commands like automake produce output to stderr even when they succeed.
2621 # Turn this output off if the command succeeds.
2622 "$@" > "$tmp"/cmdout 2>&1
2624 if test $cmdret = 0; then
2628 cat "$tmp"/cmdout 1>&2
2635 # func_dest_tmpfilename file
2636 # determines the name of a temporary file (file is relative to destdir).
2638 # - destdir target directory
2639 # - doit : if actions shall be executed, false if only to be printed
2640 # - tmp pathname of a temporary directory
2642 # - tmpfile absolute filename of the temporary file
2643 func_dest_tmpfilename ()
2646 # Put the new contents of $file in a file in the same directory (needed
2647 # to guarantee that an 'mv' to "$destdir/$file" works).
2648 tmpfile="$destdir/$1.tmp"
2650 # Put the new contents of $file in a file in a temporary directory
2651 # (because the directory of "$file" might not exist).
2652 tmpfile="$tmp"/`basename "$1"`.tmp
2657 # copies a file from gnulib into the destination directory. The destination
2658 # is known to not exist.
2660 # - destdir target directory
2661 # - local_gnulib_dir from --local-dir
2662 # - modcache true or false, from --cache-modules/--no-cache-modules
2663 # - f the original file name
2664 # - lookedup_file name of the merged (combined) file
2665 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2666 # - g the rewritten file name
2667 # - tmpfile absolute filename of the temporary file
2668 # - doit : if actions shall be executed, false if only to be printed
2669 # - symbolic true if files should be symlinked, copied otherwise
2670 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2675 echo "Copying file $g"
2676 if { test -n "$symbolic" \
2677 || { test -n "$lsymbolic" \
2678 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2679 && test -z "$lookedup_tmp" \
2680 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2681 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2683 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2691 # copies a file from gnulib into the destination directory. The destination
2692 # is known to exist.
2694 # - destdir target directory
2695 # - local_gnulib_dir from --local-dir
2696 # - modcache true or false, from --cache-modules/--no-cache-modules
2697 # - f the original file name
2698 # - lookedup_file name of the merged (combined) file
2699 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2700 # - g the rewritten file name
2701 # - tmpfile absolute filename of the temporary file
2702 # - doit : if actions shall be executed, false if only to be printed
2703 # - symbolic true if files should be symlinked, copied otherwise
2704 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2706 # - already_present nonempty if the file should already exist, empty otherwise
2709 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2710 : # The file has not changed.
2714 if test -n "$already_present"; then
2715 echo "Updating file $g (backup in ${g}~)"
2717 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2719 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2720 if { test -n "$symbolic" \
2721 || { test -n "$lsymbolic" \
2722 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2723 && test -z "$lookedup_tmp" \
2724 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2725 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2727 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2730 if test -n "$already_present"; then
2731 echo "Update file $g (backup in ${g}~)"
2733 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2739 # func_emit_lib_Makefile_am
2740 # emits the contents of library makefile to standard output.
2742 # - local_gnulib_dir from --local-dir
2743 # - modcache true or false, from --cache-modules/--no-cache-modules
2744 # - modules list of modules, including dependencies
2745 # - libname library name
2746 # - pobase directory relative to destdir where to place *.po files
2747 # - auxdir directory relative to destdir where to place build aux files
2748 # - makefile_name from --makefile-name
2749 # - libtool true if libtool will be used, false or blank otherwise
2750 # - macro_prefix prefix of gl_LIBOBJS macros to use
2751 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2752 # - actioncmd (optional) command that will reproduce this invocation
2753 # - for_test true if creating a package for testing, false otherwise
2754 # - destfile filename relative to destdir of makefile being generated
2756 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2757 # list of edits to be done to Makefile.am variables
2759 # - uses_subdirs nonempty if object files in subdirs exist
2760 func_emit_lib_Makefile_am ()
2762 # When creating an includable Makefile.am snippet, augment variables with
2763 # += instead of assigning them.
2764 if test -n "$makefile_name"; then
2769 if test "$libtool" = true; then
2772 sed_eliminate_LDFLAGS="$sed_noop"
2776 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2779 # When creating a package for testing: Attempt to provoke failures,
2780 # especially link errors, already during "make" rather than during
2781 # "make check", because "make check" is not possible in a cross-compiling
2782 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2783 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2785 sed_transform_check_PROGRAMS="$sed_noop"
2787 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2788 echo "## Process this file with automake to produce Makefile.in."
2789 func_emit_copyright_notice
2790 if test -n "$actioncmd"; then
2791 # The maximum line length (excluding the terminating newline) of any file
2792 # that is to be preprocessed by config.status is 3070. config.status uses
2793 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2794 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2795 len=`echo "$actioncmd" | wc -c`
2796 if test -n "$len" && test "$len" -le 3000; then
2797 echo "# Reproduce by: $actioncmd"
2803 for module in $modules; do
2804 func_verify_nontests_module
2805 if test -n "$module"; then
2807 func_get_automake_snippet "$module" |
2809 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2810 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2811 -e "$sed_eliminate_LDFLAGS" \
2812 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2813 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2814 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2815 -e "$sed_transform_check_PROGRAMS"
2816 if test "$module" = 'alloca'; then
2817 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2818 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2820 } > "$tmp"/amsnippet
2821 # Skip the contents if it's entirely empty.
2822 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2823 echo "## begin gnulib module $module"
2825 cat "$tmp"/amsnippet
2826 echo "## end gnulib module $module"
2829 rm -f "$tmp"/amsnippet
2830 # Test whether there are some source files in subdirectories.
2831 for f in `func_get_filelist "$module"`; do
2841 } > "$tmp"/allsnippets
2842 if test -z "$makefile_name"; then
2843 # If there are source files in subdirectories, prevent collision of the
2844 # object files (example: hash.c and libxml/hash.c).
2846 if test -n "$uses_subdirs"; then
2847 subdir_options=' subdir-objects'
2849 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2852 if test -z "$makefile_name"; then
2854 echo "noinst_HEADERS ="
2855 echo "noinst_LIBRARIES ="
2856 echo "noinst_LTLIBRARIES ="
2857 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2858 # if you specify pkgdata_DATA to empty. This is a workaround.
2859 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2860 echo "pkgdata_DATA ="
2863 echo "BUILT_SOURCES ="
2866 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2867 if test -z "$makefile_name"; then
2868 echo "MOSTLYCLEANDIRS ="
2870 echo "DISTCLEANFILES ="
2871 echo "MAINTAINERCLEANFILES ="
2873 # Execute edits that apply to the Makefile.am being generated.
2875 while test $edit != $makefile_am_edits; do
2876 edit=`expr $edit + 1`
2877 eval dir=\"\$makefile_am_edit${edit}_dir\"
2878 eval var=\"\$makefile_am_edit${edit}_var\"
2879 eval val=\"\$makefile_am_edit${edit}_val\"
2880 if test -n "$var"; then
2881 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2882 echo "${var} += ${val}"
2883 eval "makefile_am_edit${edit}_var="
2887 if test -z "$makefile_name"; then
2890 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
2892 echo "AM_CPPFLAGS ="
2897 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2898 || { test -n "$makefile_name" \
2899 && test -f "$sourcebase/Makefile.am" \
2900 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2902 # One of the snippets or the user's Makefile.am already specifies an
2903 # installation location for the library. Don't confuse automake by saying
2904 # it should not be installed.
2907 # By default, the generated library should not be installed.
2908 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2911 echo "${libname}_${libext}_SOURCES ="
2912 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2913 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2914 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2915 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2916 echo "EXTRA_${libname}_${libext}_SOURCES ="
2917 if test "$libtool" = true; then
2918 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2921 if test -n "$pobase"; then
2922 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2925 cat "$tmp"/allsnippets \
2926 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2928 echo "mostlyclean-local: mostlyclean-generic"
2929 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2930 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2931 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2935 rm -f "$tmp"/allsnippets
2938 # func_emit_po_Makevars
2939 # emits the contents of po/ makefile parameterization to standard output.
2941 # - local_gnulib_dir from --local-dir
2942 # - modcache true or false, from --cache-modules/--no-cache-modules
2943 # - sourcebase directory relative to destdir where to place source code
2944 # - pobase directory relative to destdir where to place *.po files
2945 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2946 func_emit_po_Makevars ()
2948 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2949 func_emit_copyright_notice
2951 echo "# Usually the message domain is the same as the package name."
2952 echo "# But here it has a '-gnulib' suffix."
2953 echo "DOMAIN = ${po_domain}-gnulib"
2955 echo "# These two variables depend on the location of this directory."
2956 echo "subdir = ${pobase}"
2957 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2960 # These options get passed to xgettext.
2961 XGETTEXT_OPTIONS = \
2962 --keyword=_ --flag=_:1:pass-c-format \
2963 --keyword=N_ --flag=N_:1:pass-c-format \
2964 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2965 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2966 --flag=error:3:c-format --flag=error_at_line:5:c-format
2968 # This is the copyright holder that gets inserted into the header of the
2969 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2970 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2972 # This is the email address or URL to which the translators shall report
2973 # bugs in the untranslated strings:
2974 # - Strings which are not entire sentences, see the maintainer guidelines
2975 # in the GNU gettext documentation, section 'Preparing Strings'.
2976 # - Strings which use unclear terms or require additional context to be
2978 # - Strings which make invalid assumptions about notation of date, time or
2980 # - Pluralisation problems.
2981 # - Incorrect English spelling.
2982 # - Incorrect formatting.
2983 # It can be your email address, or a mailing list address where translators
2984 # can write to without being subscribed, or the URL of a web page through
2985 # which the translators can contact you.
2986 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2988 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2989 # message catalogs shall be used. It is usually empty.
2990 EXTRA_LOCALE_CATEGORIES =
2992 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2993 # context. Possible values are "yes" and "no". Set this to yes if the
2994 # package uses functions taking also a message context, like pgettext(), or
2995 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3000 # func_emit_po_POTFILES_in
3001 # emits the file list to be passed to xgettext to standard output.
3003 # - local_gnulib_dir from --local-dir
3004 # - modcache true or false, from --cache-modules/--no-cache-modules
3005 # - sourcebase directory relative to destdir where to place source code
3006 # - files list of new files
3007 func_emit_po_POTFILES_in ()
3009 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3010 func_emit_copyright_notice
3012 echo "# List of files which contain translatable strings."
3013 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3016 # func_emit_tests_Makefile_am witness_macro
3017 # emits the contents of tests makefile to standard output.
3019 # - local_gnulib_dir from --local-dir
3020 # - modcache true or false, from --cache-modules/--no-cache-modules
3021 # - modules list of modules, including dependencies
3022 # - libname library name
3023 # - auxdir directory relative to destdir where to place build aux files
3024 # - makefile_name from --makefile-name
3025 # - libtool true if libtool will be used, false or blank otherwise
3026 # - sourcebase relative directory containing lib source code
3027 # - m4base relative directory containing autoconf macros
3028 # - testsbase relative directory containing unit test code
3029 # - macro_prefix prefix of gl_LIBOBJS macros to use
3030 # - for_test true if creating a package for testing, false otherwise
3031 # - use_libtests true if a libtests.a should be built, false otherwise
3032 # - destfile filename relative to destdir of makefile being generated
3034 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3035 # list of edits to be done to Makefile.am variables
3037 # - uses_subdirs nonempty if object files in subdirs exist
3038 func_emit_tests_Makefile_am ()
3041 if test "$libtool" = true; then
3043 sed_eliminate_LDFLAGS="$sed_noop"
3046 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3049 # When creating a package for testing: Attempt to provoke failures,
3050 # especially link errors, already during "make" rather than during
3051 # "make check", because "make check" is not possible in a cross-compiling
3052 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3053 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3055 sed_transform_check_PROGRAMS="$sed_noop"
3057 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3058 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3059 echo "## Process this file with automake to produce Makefile.in."
3060 func_emit_copyright_notice
3064 for module in $modules; do
3066 func_verify_tests_module
3070 if test -n "$module"; then
3072 func_get_automake_snippet "$module" |
3074 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3075 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3076 -e "$sed_eliminate_LDFLAGS" \
3077 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3078 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3079 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3080 -e "$sed_transform_check_PROGRAMS"
3081 if $use_libtests && test "$module" = 'alloca'; then
3082 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3083 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3085 } > "$tmp"/amsnippet
3086 # Skip the contents if it's entirely empty.
3087 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3088 # Mention long-running tests at the end.
3090 for word in `func_get_status "$module"`; do
3091 if test "$word" = 'longrunning-test'; then
3096 { echo "## begin gnulib module $module"
3098 cat "$tmp"/amsnippet
3099 echo "## end gnulib module $module"
3103 rm -f "$tmp"/amsnippet
3104 # Test whether there are some source files in subdirectories.
3105 for f in `func_get_filelist "$module"`; do
3107 lib/*/*.c | tests/*/*.c)
3115 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3116 # Generate dependencies here, since it eases the debugging of test failures.
3117 # If there are source files in subdirectories, prevent collision of the
3118 # object files (example: hash.c and libxml/hash.c).
3120 if test -n "$uses_subdirs"; then
3121 subdir_options=' subdir-objects'
3123 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3126 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3129 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3130 # variable is needed to avoid an error from automake:
3131 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3134 echo "XFAIL_TESTS ="
3135 echo "TESTS_ENVIRONMENT ="
3136 echo "noinst_PROGRAMS ="
3137 if ! $for_test; then
3138 echo "check_PROGRAMS ="
3140 echo "noinst_HEADERS ="
3141 echo "noinst_LIBRARIES ="
3142 if $use_libtests; then
3144 echo "noinst_LIBRARIES += libtests.a"
3146 echo "check_LIBRARIES = libtests.a"
3149 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3150 # if you specify pkgdata_DATA to empty. This is a workaround.
3151 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3152 echo "pkgdata_DATA ="
3155 echo "BUILT_SOURCES ="
3157 echo "MOSTLYCLEANFILES = core *.stackdump"
3158 echo "MOSTLYCLEANDIRS ="
3160 echo "DISTCLEANFILES ="
3161 echo "MAINTAINERCLEANFILES ="
3162 # Execute edits that apply to the Makefile.am being generated.
3164 while test $edit != $makefile_am_edits; do
3165 edit=`expr $edit + 1`
3166 eval dir=\"\$makefile_am_edit${edit}_dir\"
3167 eval var=\"\$makefile_am_edit${edit}_var\"
3168 eval val=\"\$makefile_am_edit${edit}_val\"
3169 if test -n "$var"; then
3170 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3171 echo "${var} += ${val}"
3172 eval "makefile_am_edit${edit}_var="
3177 echo "AM_CPPFLAGS = \\"
3179 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3181 if test -n "${witness_macro}"; then
3182 echo " -D@${witness_macro}@=1 \\"
3184 echo " -I. -I\$(srcdir) \\"
3185 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3186 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3188 local_ldadd_before=''
3189 local_ldadd_after=''
3190 if $use_libtests; then
3191 # All test programs need to be linked with libtests.a.
3192 # It needs to be passed to the linker before ${libname}.${libext}, since
3193 # the tests-related modules depend on the main modules.
3194 # It also needs to be passed to the linker after ${libname}.${libext}
3195 # because the latter might contain incomplete modules (such as the 'error'
3196 # module whose dependency to 'progname' is voluntarily omitted).
3197 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3199 local_ldadd_before=' libtests.a'
3200 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3202 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3204 if $use_libtests; then
3205 echo "libtests_a_SOURCES ="
3206 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3207 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3208 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3209 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3210 echo "EXTRA_libtests_a_SOURCES ="
3211 # The circular dependency in LDADD requires this.
3212 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3215 # Many test scripts use ${EXEEXT} or ${srcdir}.
3216 # EXEEXT is defined by AC_PROG_CC through autoconf.
3217 # srcdir is defined by autoconf and automake.
3218 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3220 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3221 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3222 echo "# Clean up after Solaris cc."
3224 echo " rm -rf SunWS_cache"
3226 echo "mostlyclean-local: mostlyclean-generic"
3227 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3228 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3229 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3233 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3236 # func_emit_initmacro_start macro_prefix
3237 # emits the first few statements of the gl_INIT macro to standard output.
3238 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3239 func_emit_initmacro_start ()
3241 macro_prefix_arg="$1"
3242 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3243 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3244 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3245 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3247 # Furthermore it avoids an automake error like this when a Makefile.am
3248 # that uses pieces of gnulib also uses $(LIBOBJ):
3249 # automatically discovered file `error.c' should not be explicitly mentioned
3250 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3251 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3252 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3253 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3254 # automatically discovered file `error.c' should not be explicitly mentioned
3255 # We let automake know about the files to be distributed through the
3256 # EXTRA_lib_SOURCES variable.
3257 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3258 # Create data variables for checking the presence of files that are mentioned
3259 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3260 # because we want the check to happen when the configure file is created,
3261 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3262 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3263 # in which to expect them.
3264 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3265 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3269 # func_emit_initmacro_end macro_prefix
3270 # emits the last few statements of the gl_INIT macro to standard output.
3271 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3272 func_emit_initmacro_end ()
3274 macro_prefix_arg="$1"
3275 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3276 # The check is performed only when autoconf is run from the directory where
3277 # the configure.ac resides; if it is run from a different directory, the
3279 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3280 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3281 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3282 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3283 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3287 echo " m4_if(m4_sysval, [0], [],"
3288 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3290 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3291 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3292 echo " m4_popdef([AC_LIBSOURCES])"
3293 echo " m4_popdef([AC_REPLACE_FUNCS])"
3294 echo " m4_popdef([AC_LIBOBJ])"
3295 echo " AC_CONFIG_COMMANDS_PRE(["
3296 echo " ${macro_prefix_arg}_libobjs="
3297 echo " ${macro_prefix_arg}_ltlibobjs="
3298 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3299 echo " # Remove the extension."
3300 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3301 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3302 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3303 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3306 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3307 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3311 # func_emit_initmacro_done macro_prefix sourcebase
3312 # emits a few statements after the gl_INIT macro to standard output.
3313 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3314 # - sourcebase directory relative to destdir where to place source code
3315 func_emit_initmacro_done ()
3317 macro_prefix_arg="$1"
3320 echo "# Like AC_LIBOBJ, except that the module name goes"
3321 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3322 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3323 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3324 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3327 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3328 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3329 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3330 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3331 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3334 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3335 echo "# expected is derived from the gnulib-tool parameterization,"
3336 echo "# and alloca is special cased (for the alloca-opt module)."
3337 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3338 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3339 echo " m4_foreach([_gl_NAME], [\$1], ["
3340 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3341 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3342 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3348 # func_import modules
3349 # Uses also the variables
3350 # - mode import or add-import or remove-import or update
3351 # - destdir target directory
3352 # - local_gnulib_dir from --local-dir
3353 # - modcache true or false, from --cache-modules/--no-cache-modules
3354 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3355 # - libname library name
3356 # - supplied_libname true if --lib was given, blank otherwise
3357 # - sourcebase directory relative to destdir where to place source code
3358 # - m4base directory relative to destdir where to place *.m4 macros
3359 # - pobase directory relative to destdir where to place *.po files
3360 # - docbase directory relative to destdir where to place doc files
3361 # - testsbase directory relative to destdir where to place unit test code
3362 # - auxdir directory relative to destdir where to place build aux files
3363 # - inctests true if --with-tests was given, blank otherwise
3364 # - incobsolete true if --with-obsolete was given, blank otherwise
3365 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3366 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3368 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3370 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3372 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3373 # - avoidlist list of modules to avoid, from --avoid
3374 # - lgpl yes or a number if library's license shall be LGPL,
3376 # - makefile_name from --makefile-name
3377 # - libtool true if --libtool was given, false if --no-libtool was
3378 # given, blank otherwise
3379 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3380 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3381 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3382 # - vc_files true if --vc-files was given, false if --no-vc-files was
3383 # given, blank otherwise
3384 # - autoconf_minversion minimum supported autoconf version
3385 # - doit : if actions shall be executed, false if only to be printed
3386 # - symbolic true if files should be symlinked, copied otherwise
3387 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3389 # - do_copyrights true if copyright notices in files should be replaced,
3393 # Get the cached settings.
3394 # In 'import' mode, we read them only for the purpose of knowing the old
3395 # installed file list, and don't use them as defaults.
3396 cached_local_gnulib_dir=
3397 cached_specified_modules=
3399 cached_inc_cxx_tests=
3400 cached_inc_longrunning_tests=
3401 cached_inc_privileged_tests=
3402 cached_inc_unportable_tests=
3403 cached_inc_all_tests=
3413 cached_makefile_name=
3415 cached_macro_prefix=
3419 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3420 cached_libtool=false
3426 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3436 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3438 /gl_WITH_OBSOLETE/ {
3439 s,^.*$,cached_incobsolete=true,p
3441 /gl_WITH_CXX_TESTS/ {
3442 s,^.*$,cached_inc_cxx_tests=true,p
3444 /gl_WITH_LONGRUNNING_TESTS/ {
3445 s,^.*$,cached_inc_longrunning_tests=true,p
3447 /gl_WITH_PRIVILEGED_TESTS/ {
3448 s,^.*$,cached_inc_privileged_tests=true,p
3450 /gl_WITH_UNPORTABLE_TESTS/ {
3451 s,^.*$,cached_inc_unportable_tests=true,p
3453 /gl_WITH_ALL_TESTS/ {
3454 s,^.*$,cached_inc_all_tests=true,p
3457 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3460 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3463 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3466 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3469 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3472 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3475 s,^.*$,cached_inctests=true,p
3478 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3481 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3484 s,^.*$,cached_lgpl=yes,p
3486 /gl_MAKEFILE_NAME(/ {
3487 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3490 s,^.*$,cached_libtool=true,p
3492 /gl_MACRO_PREFIX(/ {
3493 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3496 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3499 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3501 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3502 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3507 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3508 s,^.*$,cached_files=",p
3521 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3525 if test "$mode" = import; then
3526 # In 'import' mode, the new set of specified modules overrides the cached
3527 # set of modules. Ignore the cached settings.
3528 specified_modules="$1"
3530 # Merge the cached settings with the specified ones.
3531 # The m4base must be the same as expected from the pathname.
3532 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3533 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3535 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3536 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3537 if test -z "$local_gnulib_dir"; then
3538 if test -n "$cached_local_gnulib_dir"; then
3541 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3543 case "$cached_local_gnulib_dir" in
3545 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3547 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3548 local_gnulib_dir="$relconcat" ;;
3555 # Append the cached and the specified module names. So that
3556 # "gnulib-tool --add-import foo" means to add the module foo.
3557 specified_modules="$cached_specified_modules $1"
3560 # Take the cached module names, minus the specified module names.
3562 if $have_associative; then
3563 # Use an associative array, for O(N) worst-case run time.
3564 declare -A to_remove
3568 for module in $cached_specified_modules; do
3569 if test -z "${to_remove[$module]}"; then
3570 func_append specified_modules "$module "
3574 # This loop has O(N²) worst-case run time.
3575 for module in $cached_specified_modules; do
3578 if test "$m" = "$module"; then
3583 if test -z "$to_remove"; then
3584 func_append specified_modules "$module "
3590 # Take the cached module names. There are no specified module names.
3591 specified_modules="$cached_specified_modules"
3594 # Included obsolete modules among the dependencies if specified either way.
3595 if test -z "$incobsolete"; then
3596 incobsolete="$cached_incobsolete"
3598 # Included special kinds of tests modules among the dependencies if specified
3600 if test -z "$inc_cxx_tests"; then
3601 inc_cxx_tests="$cached_inc_cxx_tests"
3603 if test -z "$inc_longrunning_tests"; then
3604 inc_longrunning_tests="$cached_inc_longrunning_tests"
3606 if test -z "$inc_privileged_tests"; then
3607 inc_privileged_tests="$cached_inc_privileged_tests"
3609 if test -z "$inc_unportable_tests"; then
3610 inc_unportable_tests="$cached_inc_unportable_tests"
3612 if test -z "$inc_all_tests"; then
3613 inc_all_tests="$cached_inc_all_tests"
3615 # Append the cached and the specified avoidlist. This is probably better
3616 # than dropping the cached one when --avoid is specified at least once.
3617 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3618 avoidlist=`echo $avoidlist`
3620 # The sourcebase defaults to the cached one.
3621 if test -z "$sourcebase"; then
3622 sourcebase="$cached_sourcebase"
3623 if test -z "$sourcebase"; then
3624 func_fatal_error "missing --source-base option"
3627 # The pobase defaults to the cached one.
3628 if test -z "$pobase"; then
3629 pobase="$cached_pobase"
3631 # The docbase defaults to the cached one.
3632 if test -z "$docbase"; then
3633 docbase="$cached_docbase"
3634 if test -z "$docbase"; then
3635 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."
3638 # The testsbase defaults to the cached one.
3639 if test -z "$testsbase"; then
3640 testsbase="$cached_testsbase"
3641 if test -z "$testsbase"; then
3642 func_fatal_error "missing --tests-base option"
3645 # Require the tests if specified either way.
3646 if test -z "$inctests"; then
3647 inctests="$cached_inctests"
3649 # The libname defaults to the cached one.
3650 if test -z "$supplied_libname"; then
3651 libname="$cached_libname"
3652 if test -z "$libname"; then
3653 func_fatal_error "missing --lib option"
3656 # Require LGPL if specified either way.
3657 if test -z "$lgpl"; then
3660 # The makefile_name defaults to the cached one.
3661 if test -z "$makefile_name"; then
3662 makefile_name="$cached_makefile_name"
3664 # Use libtool if specified either way, or if guessed.
3665 if test -z "$libtool"; then
3666 if test -n "$cached_m4base"; then
3667 libtool="$cached_libtool"
3669 libtool="$guessed_libtool"
3672 # The macro_prefix defaults to the cached one.
3673 if test -z "$macro_prefix"; then
3674 macro_prefix="$cached_macro_prefix"
3675 if test -z "$macro_prefix"; then
3676 func_fatal_error "missing --macro-prefix option"
3679 # The po_domain defaults to the cached one.
3680 if test -z "$po_domain"; then
3681 po_domain="$cached_po_domain"
3683 # The vc_files defaults to the cached one.
3684 if test -z "$vc_files"; then
3685 vc_files="$cached_vc_files"
3688 # --without-*-tests options are not supported here.
3690 excl_longrunning_tests=
3691 excl_privileged_tests=
3692 excl_unportable_tests=
3694 # Canonicalize the list of specified modules.
3695 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3697 # Include all kinds of tests modules if --with-all-tests was specified.
3698 inc_all_direct_tests="$inc_all_tests"
3699 inc_all_indirect_tests="$inc_all_tests"
3701 # Determine final module list.
3702 modules="$specified_modules"
3703 func_modules_transitive_closure
3704 if test $verbose -ge 0; then
3705 func_show_module_list
3707 final_modules="$modules"
3709 # Determine main module list and tests-related module list separately.
3710 # The main module list is the transitive closure of the specified modules,
3711 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3712 # is specified, it will consist only of LGPLed source.
3713 # The tests-related module list is the transitive closure of the specified
3714 # modules, including tests modules, minus the main module list excluding
3715 # modules of applicability 'all'. Its lib/* sources (brought in through
3716 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3717 # source, even if --lgpl is specified.
3718 # Determine main module list.
3719 saved_inctests="$inctests"
3721 modules="$specified_modules"
3722 func_modules_transitive_closure
3723 main_modules="$modules"
3724 inctests="$saved_inctests"
3725 if test $verbose -ge 1; then
3726 echo "Main module list:"
3727 echo "$main_modules" | sed -e 's/^/ /'
3729 # Determine tests-related module list.
3730 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3731 testsrelated_modules=`for module in $main_modules; do
3732 if test \`func_get_applicability $module\` = main; then
3736 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3737 if test $verbose -ge 1; then
3738 echo "Tests-related module list:"
3739 echo "$testsrelated_modules" | sed -e 's/^/ /'
3742 # Add the dummy module to the main module list if needed.
3743 modules="$main_modules"
3744 func_modules_add_dummy
3745 main_modules="$modules"
3747 # Determine whether a $testsbase/libtests.a is needed.
3749 for module in $testsrelated_modules; do
3750 func_verify_nontests_module
3751 if test -n "$module"; then
3752 all_files=`func_get_filelist $module`
3753 # Test whether some file in $all_files lies in lib/.
3754 for f in $all_files; do
3765 # Add the dummy module to the tests-related module list if needed.
3766 if $use_libtests; then
3767 modules="$testsrelated_modules"
3768 func_modules_add_dummy
3769 testsrelated_modules="$modules"
3772 # If --lgpl, verify that the licenses of modules are compatible.
3773 if test -n "$lgpl"; then
3774 license_incompatibilities=
3775 for module in $main_modules; do
3776 license=`func_get_license $module`
3778 'GPLed build tool') ;;
3779 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3784 LGPL | LGPLv2+ | LGPLv3+) ;;
3785 *) func_append license_incompatibilities "$module $license$nl" ;;
3791 *) func_append license_incompatibilities "$module $license$nl" ;;
3794 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3799 if test -n "$license_incompatibilities"; then
3800 # Format the license incompatibilities as a table.
3801 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3802 s,^\(.................................................[^ ]*\) *, \1 ,'
3803 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3804 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3808 # Show banner notice of every module.
3809 modules="$main_modules"
3812 # Determine script to apply to imported library files.
3813 sed_transform_lib_file=
3814 for module in $main_modules; do
3815 if test $module = config-h; then
3816 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3817 sed_transform_lib_file=$sed_transform_lib_file'
3818 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3823 sed_transform_main_lib_file="$sed_transform_lib_file"
3824 if test -n "$do_copyrights"; then
3825 if test -n "$lgpl"; then
3829 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3830 s/GNU General/GNU Lesser General/g
3834 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3835 s/GNU General/GNU Lesser General/g
3836 s/version [23]\([ ,]\)/version 2.1\1/g
3839 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3843 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3844 s/GNU Lesser General/GNU General/g
3845 s/GNU Library General/GNU General/g
3846 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3851 # Determine script to apply to auxiliary files that go into $auxdir/.
3852 sed_transform_build_aux_file=
3853 if test -n "$do_copyrights"; then
3855 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3856 s/GNU Lesser General/GNU General/g
3857 s/GNU Library General/GNU General/g
3858 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3862 # Determine script to apply to library files that go into $testsbase/.
3863 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3864 if test -n "$do_copyrights"; then
3866 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3867 s/GNU Lesser General/GNU General/g
3868 s/GNU Library General/GNU General/g
3869 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3873 # Determine the final file lists.
3874 # They must be computed separately, because files in lib/* go into
3875 # $sourcebase/ if they are in the main file list but into $testsbase/
3876 # if they are in the tests-related file list. Furthermore lib/dummy.c
3878 # Determine final main file list.
3879 modules="$main_modules"
3880 func_modules_to_filelist
3882 # Determine final tests-related file list.
3883 modules="$testsrelated_modules"
3884 func_modules_to_filelist
3885 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3886 # Merge both file lists.
3887 sed_remove_empty_lines='/^$/d'
3888 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3889 if test $verbose -ge 0; then
3891 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3892 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3896 || func_fatal_error "refusing to do nothing"
3898 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3899 new_files="$files m4/gnulib-tool.m4"
3900 old_files="$cached_files"
3901 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3902 func_append old_files " m4/gnulib-tool.m4"
3905 rewritten='%REWRITTEN%'
3906 sed_rewrite_old_files="\
3907 s,^build-aux/,$rewritten$auxdir/,
3908 s,^doc/,$rewritten$cached_docbase/,
3909 s,^lib/,$rewritten$cached_sourcebase/,
3910 s,^m4/,$rewritten$cached_m4base/,
3911 s,^tests/,$rewritten$cached_testsbase/,
3912 s,^tests=lib/,$rewritten$cached_testsbase/,
3915 sed_rewrite_new_files="\
3916 s,^build-aux/,$rewritten$auxdir/,
3917 s,^doc/,$rewritten$docbase/,
3918 s,^lib/,$rewritten$sourcebase/,
3919 s,^m4/,$rewritten$m4base/,
3920 s,^tests/,$rewritten$testsbase/,
3921 s,^tests=lib/,$rewritten$testsbase/,
3925 # Create directories.
3926 { echo "$sourcebase"
3928 if test -n "$pobase"; then
3931 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3932 if test -n "$docfiles"; then
3935 if test -n "$inctests"; then
3939 for f in $files; do echo $f; done \
3940 | sed -e "$sed_rewrite_new_files" \
3941 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3944 { # Rearrange file descriptors. Needed because "while ... done < ..."
3945 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3946 exec 5<&0 < "$tmp"/dirs
3948 if test ! -d "$destdir/$d"; then
3950 echo "Creating directory $destdir/$d"
3951 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3953 echo "Create directory $destdir/$d"
3960 # Copy files or make symbolic links. Remove obsolete files.
3964 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3965 # representing the files according to the last gnulib-tool invocation.
3966 for f in $old_files; do echo $f; done \
3967 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3970 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3971 # representing the files after this gnulib-tool invocation.
3972 for f in $new_files; do echo $f; done \
3973 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3976 # First the files that are in old-files, but not in new-files:
3977 sed_take_first_column='s,'"$delimiter"'.*,,'
3978 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3979 # Remove the file. Do nothing if the user already removed it.
3980 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3982 echo "Removing file $g (backup in ${g}~)"
3983 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3985 echo "Remove file $g (backup in ${g}~)"
3987 func_append removed_files "$g$nl"
3990 # func_add_or_update handles a file that ought to be present afterwards.
3992 # - f the original file name
3993 # - g the rewritten file name
3994 # - already_present nonempty if the file should already exist, empty
3996 func_add_or_update ()
4000 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4002 func_dest_tmpfilename "$g"
4003 func_lookup_file "$f"
4004 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4005 if test -n "$sed_transform_main_lib_file"; then
4008 sed -e "$sed_transform_main_lib_file" \
4009 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4013 if test -n "$sed_transform_build_aux_file"; then
4016 sed -e "$sed_transform_build_aux_file" \
4017 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4021 if test -n "$sed_transform_testsrelated_lib_file"; then
4024 sed -e "$sed_transform_testsrelated_lib_file" \
4025 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4029 if test -f "$destdir/$g"; then
4030 # The file already exists.
4034 # Don't protest if the file should be there but isn't: it happens
4035 # frequently that developers don't put autogenerated files under version control.
4037 func_append added_files "$g$nl"
4041 # Then the files that are in new-files, but not in old-files:
4042 sed_take_last_column='s,^.*'"$delimiter"',,'
4044 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4045 | sed -e "$sed_take_last_column" \
4046 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4047 { # Rearrange file descriptors. Needed because "while ... done < ..."
4048 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4049 exec 5<&0 < "$tmp"/added-files
4055 # Then the files that are in new-files and in old-files:
4056 already_present=true
4057 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4058 | sed -e "$sed_take_last_column" \
4059 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4060 { # Rearrange file descriptors. Needed because "while ... done < ..."
4061 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4062 exec 5<&0 < "$tmp"/kept-files
4069 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4070 actioncmd="gnulib-tool --import"
4071 func_append actioncmd " --dir=$destdir"
4072 if test -n "$local_gnulib_dir"; then
4073 func_append actioncmd " --local-dir=$local_gnulib_dir"
4075 func_append actioncmd " --lib=$libname"
4076 func_append actioncmd " --source-base=$sourcebase"
4077 func_append actioncmd " --m4-base=$m4base"
4078 if test -n "$pobase"; then
4079 func_append actioncmd " --po-base=$pobase"
4081 func_append actioncmd " --doc-base=$docbase"
4082 func_append actioncmd " --tests-base=$testsbase"
4083 func_append actioncmd " --aux-dir=$auxdir"
4084 if test -n "$inctests"; then
4085 func_append actioncmd " --with-tests"
4087 if test -n "$incobsolete"; then
4088 func_append actioncmd " --with-obsolete"
4090 if test -n "$inc_cxx_tests"; then
4091 func_append actioncmd " --with-c++-tests"
4093 if test -n "$inc_longrunning_tests"; then
4094 func_append actioncmd " --with-longrunning-tests"
4096 if test -n "$inc_privileged_tests"; then
4097 func_append actioncmd " --with-privileged-tests"
4099 if test -n "$inc_unportable_tests"; then
4100 func_append actioncmd " --with-unportable-tests"
4102 if test -n "$inc_all_tests"; then
4103 func_append actioncmd " --with-all-tests"
4105 for module in $avoidlist; do
4106 func_append actioncmd " --avoid=$module"
4108 if test -n "$lgpl"; then
4109 if test "$lgpl" = yes; then
4110 func_append actioncmd " --lgpl"
4112 func_append actioncmd " --lgpl=$lgpl"
4115 if test -n "$makefile_name"; then
4116 func_append actioncmd " --makefile-name=$makefile_name"
4118 if test "$libtool" = true; then
4119 func_append actioncmd " --libtool"
4121 func_append actioncmd " --no-libtool"
4123 func_append actioncmd " --macro-prefix=$macro_prefix"
4124 if test -n "$po_domain"; then
4125 func_append actioncmd " --po-domain=$po_domain"
4127 if test -n "$vc_files"; then
4128 if test "$vc_files" = true; then
4129 func_append actioncmd " --vc-files"
4131 func_append actioncmd " --no-vc-files"
4134 func_append actioncmd " `echo $specified_modules`"
4136 # Default the makefile name to Makefile.am.
4137 if test -n "$makefile_name"; then
4138 makefile_am=$makefile_name
4140 makefile_am=Makefile.am
4143 # Create normal Makefile.ams.
4146 # Setup list of Makefile.am edits that are to be performed afterwards.
4147 # Some of these edits apply to files that we will generate; others are
4148 # under the responsibility of the developer.
4150 # func_note_Makefile_am_edit dir var value
4151 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4153 func_note_Makefile_am_edit ()
4155 makefile_am_edits=`expr $makefile_am_edits + 1`
4156 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4157 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4158 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4160 if test "$makefile_am" = Makefile.am; then
4161 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4162 sourcebase_base=`basename "$sourcebase"`
4163 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4165 if test -n "$pobase"; then
4166 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4167 pobase_base=`basename "$pobase"`
4168 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4170 if test -n "$inctests"; then
4171 if test "$makefile_am" = Makefile.am; then
4172 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4173 testsbase_base=`basename "$testsbase"`
4174 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4177 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4179 # Find the first parent directory of $m4base that contains or will contain
4181 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4183 sed_butlast='s,[^/][^/]*//*$,,'
4184 dir1="${m4base}/"; dir2=""
4185 while test -n "$dir1" \
4186 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4187 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4188 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4189 || { test -n "$inctests" \
4190 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4191 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4192 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4193 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4195 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4198 # Create library makefile.
4199 func_dest_tmpfilename $sourcebase/$makefile_am
4200 destfile="$sourcebase/$makefile_am"
4201 modules="$main_modules"
4202 func_emit_lib_Makefile_am > "$tmpfile"
4203 if test -f "$destdir"/$sourcebase/$makefile_am; then
4204 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4208 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4209 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4210 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4212 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4218 echo "Creating $sourcebase/$makefile_am"
4219 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4221 echo "Create $sourcebase/$makefile_am"
4224 func_append added_files "$sourcebase/$makefile_am$nl"
4227 # Create po/ directory.
4228 if test -n "$pobase"; then
4229 # Create po makefile and auxiliary files.
4230 for file in Makefile.in.in remove-potcdate.sin; do
4231 func_dest_tmpfilename $pobase/$file
4232 func_lookup_file build-aux/po/$file
4233 cat "$lookedup_file" > "$tmpfile"
4234 if test -f "$destdir"/$pobase/$file; then
4235 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4239 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4240 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4241 mv -f "$tmpfile" "$destdir"/$pobase/$file
4243 echo "Update $pobase/$file (backup in $pobase/$file~)"
4249 echo "Creating $pobase/$file"
4250 mv -f "$tmpfile" "$destdir"/$pobase/$file
4252 echo "Create $pobase/$file"
4255 func_append added_files "$pobase/$file$nl"
4258 # Create po makefile parameterization, part 1.
4259 func_dest_tmpfilename $pobase/Makevars
4260 func_emit_po_Makevars > "$tmpfile"
4261 if test -f "$destdir"/$pobase/Makevars; then
4262 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4266 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4267 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4268 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4270 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4276 echo "Creating $pobase/Makevars"
4277 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4279 echo "Create $pobase/Makevars"
4282 func_append added_files "$pobase/Makevars$nl"
4284 # Create po makefile parameterization, part 2.
4285 func_dest_tmpfilename $pobase/POTFILES.in
4286 func_emit_po_POTFILES_in > "$tmpfile"
4287 if test -f "$destdir"/$pobase/POTFILES.in; then
4288 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4292 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4293 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4294 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4296 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4302 echo "Creating $pobase/POTFILES.in"
4303 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4305 echo "Create $pobase/POTFILES.in"
4308 func_append added_files "$pobase/POTFILES.in$nl"
4311 TP_URL="http://translationproject.org/latest/"
4312 TP_RSYNC_URI="translationproject.org::tp/latest/"
4314 echo "Fetching gnulib PO files from $TP_URL"
4315 (cd "$destdir"/$pobase \
4316 && { # Prefer rsync over wget if it is available, since it consumes
4317 # less network bandwidth, due to compression.
4318 if type rsync 2>/dev/null | grep / > /dev/null; then
4319 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4321 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4326 echo "Fetch gnulib PO files from $TP_URL"
4328 # Create po/LINGUAS.
4330 func_dest_tmpfilename $pobase/LINGUAS
4331 (cd "$destdir"/$pobase \
4332 && { echo '# Set of available languages.'
4333 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4336 if test -f "$destdir"/$pobase/LINGUAS; then
4337 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4340 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4341 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4342 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4345 echo "Creating $pobase/LINGUAS"
4346 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4347 func_append added_files "$pobase/LINGUAS$nl"
4350 if test -f "$destdir"/$pobase/LINGUAS; then
4351 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4353 echo "Create $pobase/LINGUAS"
4358 # Create m4/gnulib-cache.m4.
4359 func_dest_tmpfilename $m4base/gnulib-cache.m4
4361 func_emit_copyright_notice
4363 echo "# This file represents the specification of how gnulib-tool is used."
4364 echo "# It acts as a cache: It is written and read by gnulib-tool."
4365 echo "# In projects that use version control, this file is meant to be put under"
4366 echo "# version control, like the configure.ac and various Makefile.am files."
4369 echo "# Specification in the form of a command-line invocation:"
4372 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4373 # Store the local_gnulib_dir relative to destdir.
4374 case "$local_gnulib_dir" in
4376 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4379 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4381 # destdir, local_gnulib_dir are both relative.
4382 func_relativize "$destdir" "$local_gnulib_dir"
4383 relative_local_gnulib_dir="$reldir" ;;
4386 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4388 echo "$specified_modules" | sed -e 's/^/ /g'
4390 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4391 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4392 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4393 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4394 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4395 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4396 echo "gl_AVOID([$avoidlist])"
4397 echo "gl_SOURCE_BASE([$sourcebase])"
4398 echo "gl_M4_BASE([$m4base])"
4399 echo "gl_PO_BASE([$pobase])"
4400 echo "gl_DOC_BASE([$docbase])"
4401 echo "gl_TESTS_BASE([$testsbase])"
4402 test -z "$inctests" || echo "gl_WITH_TESTS"
4403 echo "gl_LIB([$libname])"
4404 if test -n "$lgpl"; then
4405 if test "$lgpl" = yes; then
4408 echo "gl_LGPL([$lgpl])"
4411 echo "gl_MAKEFILE_NAME([$makefile_name])"
4412 if test "$libtool" = true; then
4415 echo "gl_MACRO_PREFIX([$macro_prefix])"
4416 echo "gl_PO_DOMAIN([$po_domain])"
4417 if test -n "$vc_files"; then
4418 echo "gl_VC_FILES([$vc_files])"
4421 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4422 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4426 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4427 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4428 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4430 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4434 echo "# gnulib-cache.m4 ends here"
4441 echo "Creating $m4base/gnulib-cache.m4"
4442 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4444 echo "Create $m4base/gnulib-cache.m4"
4450 # Create m4/gnulib-comp.m4.
4451 func_dest_tmpfilename $m4base/gnulib-comp.m4
4453 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4454 func_emit_copyright_notice
4456 echo "# This file represents the compiled summary of the specification in"
4457 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4458 echo "# to be invoked from configure.ac."
4459 echo "# In projects that use version control, this file can be treated like"
4460 echo "# other built files."
4463 echo "# This macro should be invoked from $configure_ac, in the section"
4464 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4465 echo "# any checks for libraries, header files, types and library functions."
4466 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4468 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4469 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4470 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4471 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4472 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4473 if test -n "$uses_subdirs"; then
4474 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4476 for module in $final_modules; do
4478 if test -n "$module"; then
4479 echo "# Code from module $module:"
4480 func_get_autoconf_early_snippet "$module"
4483 | sed -e '/^$/d;' -e 's/^/ /'
4486 echo "# This macro should be invoked from $configure_ac, in the section"
4487 echo "# \"Check for header files, types and library functions\"."
4488 echo "AC_DEFUN([${macro_prefix}_INIT],"
4490 if test "$libtool" = true; then
4491 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4492 echo " gl_cond_libtool=true"
4494 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4495 echo " gl_cond_libtool=false"
4497 echo " gl_ltlibdeps="
4499 if test "$auxdir" != "build-aux"; then
4500 sed_replace_build_aux='
4502 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4503 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4507 sed_replace_build_aux="$sed_noop"
4509 echo " gl_m4_base='$m4base'"
4510 func_emit_initmacro_start $macro_prefix
4511 echo " gl_source_base='$sourcebase'"
4512 for module in $main_modules; do
4514 if test -n "$module"; then
4515 echo " # Code from module $module:"
4516 func_get_autoconf_snippet "$module" \
4517 | sed -e '/^$/d;' -e 's/^/ /' \
4518 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4519 -e "$sed_replace_build_aux"
4520 if test "$module" = 'alloca' && test "$libtool" = true; then
4521 echo 'changequote(,)dnl'
4522 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4523 echo 'changequote([, ])dnl'
4524 echo 'AC_SUBST([LTALLOCA])'
4528 echo " # End of code from modules"
4529 func_emit_initmacro_end $macro_prefix
4530 echo " gltests_libdeps="
4531 echo " gltests_ltlibdeps="
4532 func_emit_initmacro_start ${macro_prefix}tests
4533 echo " gl_source_base='$testsbase'"
4534 # Define a tests witness macro that depends on the package.
4535 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4536 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4537 echo "changequote(,)dnl"
4538 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"
4539 echo "changequote([, ])dnl"
4540 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4541 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4542 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4543 for module in $testsrelated_modules; do
4545 if test -n "$module"; then
4546 func_get_autoconf_snippet "$module" \
4547 | sed -e '/^$/d;' -e 's/^/ /' \
4548 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4549 -e "$sed_replace_build_aux" \
4550 -e 's/\$gl_cond_libtool/false/g' \
4551 -e 's/gl_libdeps/gltests_libdeps/g' \
4552 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4555 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4556 func_emit_initmacro_end ${macro_prefix}tests
4557 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4558 # created using libtool, because libtool already handles the dependencies.
4559 if test "$libtool" != true; then
4560 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4561 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4562 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4563 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4564 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4566 if $use_libtests; then
4567 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4568 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4571 func_emit_initmacro_done $macro_prefix $sourcebase
4572 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4574 echo "# This macro records the list of files which have been installed by"
4575 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4576 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4577 echo "$files" | sed -e 's,^, ,'
4580 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4581 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4585 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4586 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4587 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4589 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4593 echo "# gnulib-comp.m4 ends here"
4600 echo "Creating $m4base/gnulib-comp.m4"
4601 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4603 echo "Create $m4base/gnulib-comp.m4"
4609 if test -n "$inctests"; then
4610 # Create tests makefile.
4611 func_dest_tmpfilename $testsbase/$makefile_am
4612 destfile="$testsbase/$makefile_am"
4613 modules="$testsrelated_modules"
4614 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4615 if test -f "$destdir"/$testsbase/$makefile_am; then
4616 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4620 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4621 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4622 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4624 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4630 echo "Creating $testsbase/$makefile_am"
4631 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4633 echo "Create $testsbase/$makefile_am"
4636 func_append added_files "$testsbase/$makefile_am$nl"
4640 if test "$vc_files" != false; then
4641 # Update the .cvsignore and .gitignore files.
4642 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4643 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4644 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4645 echo "$m4base/|A|gnulib-comp.m4"
4646 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4647 { # Rearrange file descriptors. Needed because "while ... done < ..."
4648 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4649 exec 5<&0 < "$tmp"/fileset-changes
4650 func_update_ignorelist ()
4653 if test "$ignore" = .gitignore; then
4654 # In a .gitignore file, "foo" applies to the current directory and all
4655 # subdirectories, whereas "/foo" applies to the current directory only.
4658 doubly_escaped_anchor='\\/'
4662 doubly_escaped_anchor=''
4664 if test -f "$destdir/$dir$ignore"; then
4665 if test -n "$dir_added" || test -n "$dir_removed"; then
4666 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4667 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4668 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4669 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4670 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4672 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4674 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4675 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4676 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4677 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4678 } > "$tmp"/sed-ignore-removed
4679 { cat "$destdir/$dir$ignore"~
4680 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4681 } | sed -f "$tmp"/sed-ignore-removed \
4682 > "$destdir/$dir$ignore"
4684 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4689 if test -n "$dir_added"; then
4691 echo "Creating $destdir/$dir$ignore"
4693 if test "$ignore" = .cvsignore; then
4695 # Automake generates Makefile rules that create .dirstamp files.
4698 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4699 } > "$destdir/$dir$ignore"
4701 echo "Create $destdir/$dir$ignore"
4711 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4712 func_update_ignorelist .cvsignore
4714 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4715 func_update_ignorelist .gitignore
4722 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4723 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4724 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4725 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4726 if test "$next_dir" != "$last_dir"; then
4727 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4728 last_dir="$next_dir"
4733 A) func_append last_dir_added "$file$nl";;
4734 R) func_append last_dir_removed "$file$nl";;
4737 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4744 echo "You may need to add #include directives for the following .h files."
4745 # Intersect $specified_modules and $main_modules
4746 # (since $specified_modules is not necessarily of subset of $main_modules
4747 # - some may have been skipped through --avoid, and since the elements of
4748 # $main_modules but not in $specified_modules can go away without explicit
4749 # notice - through changes in the module dependencies).
4750 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4751 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4752 # First the #include <...> directives without #ifs, sorted for convenience,
4753 # then the #include "..." directives without #ifs, sorted for convenience,
4754 # then the #include directives that are surrounded by #ifs. Not sorted.
4755 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4756 include_directive=`func_get_include_directive "$module"`
4757 case "$nl$include_directive" in
4759 echo "$include_directive" 1>&5
4762 echo "$include_directive" | grep -v 'include "' 1>&6
4763 echo "$include_directive" | grep 'include "' 1>&7
4766 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4768 LC_ALL=C sort -u "$tmp"/include-angles
4769 LC_ALL=C sort -u "$tmp"/include-quotes
4770 cat "$tmp"/include-if
4771 ) | sed -e '/^$/d' -e 's/^/ /'
4772 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4774 for module in $main_modules; do
4775 func_get_link_directive "$module"
4777 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4778 if test `wc -l < "$tmp"/link` != 0; then
4780 echo "You may need to use the following Makefile variables when linking."
4781 echo "Use them in <program>_LDADD when linking a program, or"
4782 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4788 echo "Don't forget to"
4789 if test "$makefile_am" = Makefile.am; then
4790 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4792 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4794 if test -n "$pobase"; then
4795 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4797 if test -n "$inctests"; then
4798 if test "$makefile_am" = Makefile.am; then
4799 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4801 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4805 while test $edit != $makefile_am_edits; do
4806 edit=`expr $edit + 1`
4807 eval dir=\"\$makefile_am_edit${edit}_dir\"
4808 eval var=\"\$makefile_am_edit${edit}_var\"
4809 eval val=\"\$makefile_am_edit${edit}_val\"
4810 if test -n "$var"; then
4811 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4814 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4815 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4818 # func_create_testdir testdir modules
4820 # - local_gnulib_dir from --local-dir
4821 # - modcache true or false, from --cache-modules/--no-cache-modules
4822 # - auxdir directory relative to destdir where to place build aux files
4823 # - inctests true if tests should be included, blank otherwise
4824 # - incobsolete true if obsolete modules among dependencies should be
4825 # included, blank otherwise
4826 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
4828 # - excl_longrunning_tests true if long-runnings tests should be excluded,
4830 # - excl_privileged_tests true if tests that require root privileges should be
4831 # excluded, blank otherwise
4832 # - excl_unportable_tests true if tests that fail on some platforms should be
4833 # excluded, blank otherwise
4834 # - avoidlist list of modules to avoid
4835 # - libtool true if --libtool was given, false if --no-libtool was
4836 # given, blank otherwise
4837 # - symbolic true if files should be symlinked, copied otherwise
4838 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4840 func_create_testdir ()
4844 if test -z "$modules"; then
4845 # All modules together.
4846 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4847 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4848 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4849 modules=`func_all_modules`
4850 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4852 specified_modules="$modules"
4854 # Canonicalize the list of specified modules.
4855 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4857 # Unlike in func_import, here we want to include all kinds of tests for the
4858 # directly specified modules, but not for dependencies.
4859 inc_all_direct_tests=true
4860 inc_all_indirect_tests="$inc_all_tests"
4862 # Check that the license of every module is consistent with the license of
4864 saved_inctests="$inctests"
4865 # When computing transitive closures, don't consider $module to depend on
4866 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4867 # on GPL modules - therefore we don't want a warning in this case.
4869 for requested_module in $specified_modules; do
4870 requested_license=`func_get_license "$requested_module"`
4871 if test "$requested_license" != GPL; then
4872 # Here we use func_modules_transitive_closure, not just
4873 # func_get_dependencies, so that we also detect weird situations like
4874 # an LGPL module which depends on a GPLed build tool module which depends
4876 modules="$requested_module"
4877 func_modules_transitive_closure
4878 for module in $modules; do
4879 license=`func_get_license "$module"`
4881 'GPLed build tool') ;;
4882 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4884 case "$requested_license" in
4887 GPLv2+ | LGPLv2+) ;;
4888 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4894 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4900 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4909 inctests="$saved_inctests"
4911 # Subdirectory names.
4921 # Determine final module list.
4922 modules="$specified_modules"
4923 func_modules_transitive_closure
4924 if test $verbose -ge 0; then
4925 func_show_module_list
4928 # Add the dummy module if needed.
4929 func_modules_add_dummy
4931 # Show banner notice of every module.
4934 # Determine final file list.
4935 func_modules_to_filelist
4936 if test $verbose -ge 0; then
4938 echo "$files" | sed -e 's/^/ /'
4941 rewritten='%REWRITTEN%'
4942 sed_rewrite_files="\
4943 s,^build-aux/,$rewritten$auxdir/,
4944 s,^doc/,$rewritten$docbase/,
4945 s,^lib/,$rewritten$sourcebase/,
4946 s,^m4/,$rewritten$m4base/,
4947 s,^tests/,$rewritten$testsbase/,
4951 # Create directories.
4952 for f in $files; do echo $f; done \
4953 | sed -e "$sed_rewrite_files" \
4954 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4955 | LC_ALL=C sort -u \
4957 { # Rearrange file descriptors. Needed because "while ... done < ..."
4958 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4959 exec 5<&0 < "$tmp"/dirs
4961 mkdir -p "$testdir/$d"
4966 # Copy files or make symbolic links.
4968 for f in $files; do echo $f; done \
4969 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4972 { # Rearrange file descriptors. Needed because "while ... done < ..."
4973 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4974 exec 5<&0 < "$tmp"/files
4976 func_lookup_file "$f"
4977 if test -n "$lookedup_tmp"; then
4978 cp -p "$lookedup_file" "$testdir/$g"
4980 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4981 if { test -n "$symbolic" \
4982 || { test -n "$lsymbolic" \
4983 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4984 func_ln "$lookedup_file" "$testdir/$g"
4986 cp -p "$lookedup_file" "$testdir/$g"
4993 # Create Makefile.ams that are for testing.
4996 # No special edits are needed.
4999 # Create $sourcebase/Makefile.am.
5000 mkdir -p "$testdir/$sourcebase"
5001 destfile="$sourcebase/Makefile.am"
5002 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5003 any_uses_subdirs="$uses_subdirs"
5005 # Create $m4base/Makefile.am.
5006 mkdir -p "$testdir/$m4base"
5007 (echo "## Process this file with automake to produce Makefile.in."
5013 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5016 ) > "$testdir/$m4base/Makefile.am"
5018 subdirs="$sourcebase $m4base"
5019 subdirs_with_configure_ac=""
5021 if false && test -f "$testdir"/$m4base/gettext.m4; then
5022 # Avoid stupid error message from automake:
5023 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5024 mkdir -p "$testdir/po"
5025 (echo "## Process this file with automake to produce Makefile.in."
5026 ) > "$testdir/po/Makefile.am"
5027 func_append subdirs " po"
5030 if test -n "$inctests"; then
5031 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5032 # Viewed from the $testsbase subdirectory, $auxdir is different.
5033 saved_auxdir="$auxdir"
5034 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5035 # Create $testsbase/Makefile.am.
5037 destfile="$testsbase/Makefile.am"
5038 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5039 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5040 # Create $testsbase/configure.ac.
5041 (echo "# Process this file with autoconf to produce a configure script."
5042 echo "AC_INIT([dummy], [0])"
5043 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5044 echo "AM_INIT_AUTOMAKE"
5046 echo "AC_CONFIG_HEADERS([config.h])"
5049 echo "AC_PROG_INSTALL"
5050 echo "AC_PROG_MAKE_SET"
5051 echo "AC_PROG_RANLIB"
5053 if test -n "$uses_subdirs"; then
5054 echo "AM_PROG_CC_C_O"
5057 for module in $modules; do
5059 if test -n "$module"; then
5061 gnumakefile | maintainer-makefile)
5062 # These modules are meant to be used only in the top-level directory.
5065 func_get_autoconf_early_snippet "$module"
5070 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5071 if test "$libtool" = true; then
5072 echo "LT_INIT([win32-dll])"
5073 echo "LT_LANG([C++])"
5074 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5075 echo "gl_cond_libtool=true"
5077 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5078 echo "gl_cond_libtool=false"
5080 echo "gl_ltlibdeps="
5082 # Wrap the set of autoconf snippets into an autoconf macro that is then
5083 # invoked. This is needed because autoconf does not support AC_REQUIRE
5085 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5086 # but we want the AC_REQUIRE to have its normal meaning (provide one
5087 # expansion of the required macro before the current point, and only one
5089 echo "AC_DEFUN([gl_INIT], ["
5090 sed_replace_build_aux='
5092 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5093 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5096 echo "gl_m4_base='../$m4base'"
5097 func_emit_initmacro_start $macro_prefix
5098 # We don't have explicit ordering constraints between the various
5099 # autoconf snippets. It's cleanest to put those of the library before
5100 # those of the tests.
5101 echo "gl_source_base='../$sourcebase'"
5102 for module in $modules; do
5103 func_verify_nontests_module
5104 if test -n "$module"; then
5106 gnumakefile | maintainer-makefile)
5107 # These modules are meant to be used only in the top-level directory.
5110 func_get_autoconf_snippet "$module" \
5111 | sed -e "$sed_replace_build_aux"
5116 echo "gl_source_base='.'"
5117 for module in $modules; do
5118 func_verify_tests_module
5119 if test -n "$module"; then
5120 func_get_autoconf_snippet "$module" \
5121 | sed -e "$sed_replace_build_aux"
5124 func_emit_initmacro_end $macro_prefix
5125 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5126 # created using libtool, because libtool already handles the dependencies.
5127 if test "$libtool" != true; then
5128 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5129 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5130 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5131 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5132 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5135 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5139 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5140 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5141 echo "AH_TOP([#include \"../config.h\"])"
5143 echo "AC_CONFIG_FILES([Makefile])"
5145 ) > "$testdir/$testsbase/configure.ac"
5146 auxdir="$saved_auxdir"
5147 func_append subdirs " $testsbase"
5148 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5151 # Create Makefile.am.
5152 (echo "## Process this file with automake to produce Makefile.in."
5154 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5156 echo "SUBDIRS = $subdirs"
5158 echo "ACLOCAL_AMFLAGS = -I $m4base"
5159 ) > "$testdir/Makefile.am"
5161 # Create configure.ac.
5162 (echo "# Process this file with autoconf to produce a configure script."
5163 echo "AC_INIT([dummy], [0])"
5164 if test "$auxdir" != "."; then
5165 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5167 echo "AM_INIT_AUTOMAKE"
5169 echo "AC_CONFIG_HEADERS([config.h])"
5172 echo "AC_PROG_INSTALL"
5173 echo "AC_PROG_MAKE_SET"
5175 echo "# For autobuild."
5176 echo "AC_CANONICAL_BUILD"
5177 echo "AC_CANONICAL_HOST"
5179 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5180 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5181 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5182 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5184 echo "AC_PROG_RANLIB"
5186 if test -n "$any_uses_subdirs"; then
5187 echo "AM_PROG_CC_C_O"
5190 for module in $modules; do
5191 func_verify_nontests_module
5192 if test -n "$module"; then
5193 func_get_autoconf_early_snippet "$module"
5196 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5197 if test "$libtool" = true; then
5198 echo "LT_INIT([win32-dll])"
5199 echo "LT_LANG([C++])"
5200 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5201 echo "gl_cond_libtool=true"
5203 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5204 echo "gl_cond_libtool=false"
5206 echo "gl_ltlibdeps="
5208 # Wrap the set of autoconf snippets into an autoconf macro that is then
5209 # invoked. This is needed because autoconf does not support AC_REQUIRE
5211 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5212 # but we want the AC_REQUIRE to have its normal meaning (provide one
5213 # expansion of the required macro before the current point, and only one
5215 echo "AC_DEFUN([gl_INIT], ["
5216 if test "$auxdir" != "build-aux"; then
5217 sed_replace_build_aux='
5219 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5220 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5224 sed_replace_build_aux="$sed_noop"
5226 echo "gl_m4_base='$m4base'"
5227 func_emit_initmacro_start $macro_prefix
5228 echo "gl_source_base='$sourcebase'"
5229 for module in $modules; do
5230 func_verify_nontests_module
5231 if test -n "$module"; then
5232 func_get_autoconf_snippet "$module" \
5233 | sed -e "$sed_replace_build_aux"
5236 func_emit_initmacro_end $macro_prefix
5237 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5238 # created using libtool, because libtool already handles the dependencies.
5239 if test "$libtool" != true; then
5240 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5241 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5242 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5243 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5244 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5247 func_emit_initmacro_done $macro_prefix $sourcebase
5251 if test -n "$subdirs_with_configure_ac"; then
5252 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5254 makefiles="Makefile"
5255 for d in $subdirs; do
5256 # For subdirs that have a configure.ac by their own, it's the subdir's
5257 # configure.ac which creates the subdir's Makefile.am, not this one.
5258 case " $subdirs_with_configure_ac " in
5260 *) func_append makefiles " $d/Makefile" ;;
5263 echo "AC_CONFIG_FILES([$makefiles])"
5265 ) > "$testdir/configure.ac"
5267 # Create autogenerated files.
5269 # Do not use "${AUTORECONF} --force --install", because it may invoke
5270 # autopoint, which brings in older versions of some of our .m4 files.
5271 if test -f $m4base/gettext.m4; then
5272 func_execute_command ${AUTOPOINT} --force || func_exit 1
5273 for f in $m4base/*.m4~; do
5275 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5279 if test "$libtool" = true; then
5280 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5282 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5283 if ! test -d build-aux; then
5284 func_execute_command mkdir build-aux || func_exit 1
5286 func_execute_command ${AUTOCONF} || func_exit 1
5287 func_execute_command ${AUTOHEADER} || func_exit 1
5288 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5290 if test -n "$inctests"; then
5291 # Create autogenerated files.
5292 (cd "$testdir/$testsbase" || func_exit 1
5293 # Do not use "${AUTORECONF} --force --install", because it may invoke
5294 # autopoint, which brings in older versions of some of our .m4 files.
5295 if test -f ../$m4base/gettext.m4; then
5296 func_execute_command ${AUTOPOINT} --force || func_exit 1
5297 for f in ../$m4base/*.m4~; do
5299 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5303 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5304 if ! test -d ../build-aux; then
5305 func_execute_command mkdir ../build-aux
5307 func_execute_command ${AUTOCONF} || func_exit 1
5308 func_execute_command ${AUTOHEADER} || func_exit 1
5309 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5312 # Need to run configure and make once, to create built files that are to be
5313 # distributed (such as getdate.c).
5314 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5315 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5316 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5317 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5318 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5319 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5320 # such $(FOO_H) because they don't refer to distributed files.
5321 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5322 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5323 | sed -e "$sed_remove_make_variables"`
5324 distributed_built_sources=`for file in $built_sources; do
5325 case "$cleaned_files" in
5330 tests_distributed_built_sources=
5331 if test -n "$inctests"; then
5332 # Likewise for built files in the $testsbase directory.
5333 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5334 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5335 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5336 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5337 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5338 | sed -e "$sed_remove_make_variables"`
5339 tests_distributed_built_sources=`for file in $tests_built_sources; do
5340 case "$tests_cleaned_files" in
5346 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5348 ./configure || func_exit 1
5349 if test -n "$distributed_built_sources"; then
5351 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5352 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5357 if test -n "$tests_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 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5372 # func_create_megatestdir megatestdir allmodules
5374 # - local_gnulib_dir from --local-dir
5375 # - modcache true or false, from --cache-modules/--no-cache-modules
5376 # - auxdir directory relative to destdir where to place build aux files
5377 func_create_megatestdir ()
5381 if test -z "$allmodules"; then
5382 allmodules=`func_all_modules`
5386 # First, all modules one by one.
5387 for onemodule in $allmodules; do
5388 func_create_testdir "$megatestdir/$onemodule" $onemodule
5389 func_append megasubdirs "$onemodule "
5391 # Then, all modules all together.
5392 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5393 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5394 func_create_testdir "$megatestdir/ALL" "$allmodules"
5395 func_append megasubdirs "ALL"
5398 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5399 vc_witness="$gnulib_dir/CVS/Entries"; \
5401 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5403 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5404 | sed -e 's,January,01,' -e 's,Jan,01,' \
5405 -e 's,February,02,' -e 's,Feb,02,' \
5406 -e 's,March,03,' -e 's,Mar,03,' \
5407 -e 's,April,04,' -e 's,Apr,04,' \
5409 -e 's,June,06,' -e 's,Jun,06,' \
5410 -e 's,July,07,' -e 's,Jul,07,' \
5411 -e 's,August,08,' -e 's,Aug,08,' \
5412 -e 's,September,09,' -e 's,Sep,09,' \
5413 -e 's,October,10,' -e 's,Oct,10,' \
5414 -e 's,November,11,' -e 's,Nov,11,' \
5415 -e 's,December,12,' -e 's,Dec,12,' \
5416 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5417 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5419 echo "CVSDATE=$cvsdate"
5420 echo ": \${MAKE=make}"
5421 echo "test -d logs || mkdir logs"
5422 echo "for module in $megasubdirs; do"
5423 echo " echo \"Working on module \$module...\""
5424 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5425 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5428 echo " : autobuild project... \$module"
5429 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5430 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5431 echo " : autobuild hostname... \`hostname\`"
5432 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5434 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5436 ) > "$megatestdir/do-autobuild"
5437 chmod a+x "$megatestdir/do-autobuild"
5439 # Create Makefile.am.
5440 (echo "## Process this file with automake to produce Makefile.in."
5442 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5444 echo "SUBDIRS = $megasubdirs"
5446 echo "EXTRA_DIST = do-autobuild"
5447 ) > "$megatestdir/Makefile.am"
5449 # Create configure.ac.
5450 (echo "# Process this file with autoconf to produce a configure script."
5451 echo "AC_INIT([dummy], [0])"
5452 if test "$auxdir" != "."; then
5453 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5455 echo "AM_INIT_AUTOMAKE"
5457 echo "AC_PROG_MAKE_SET"
5459 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5460 echo "AC_CONFIG_FILES([Makefile])"
5462 ) > "$megatestdir/configure.ac"
5464 # Create autogenerated files.
5466 # Do not use "${AUTORECONF} --install", because autoreconf operates
5467 # recursively, but the subdirectories are already finished, therefore
5468 # calling autoreconf here would only waste lots of CPU time.
5469 func_execute_command ${ACLOCAL} || func_exit 1
5470 func_execute_command mkdir build-aux
5471 func_execute_command ${AUTOCONF} || func_exit 1
5472 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5478 func_fatal_error "no mode specified" ;;
5485 # sed expression that converts a literal to a basic regular expression.
5486 # Needs to handle . [ \ * ^ $.
5487 sed_literal_to_basic_regex='s/\\/\\\\/g
5493 if test -f "$gnulib_dir/$filename" \
5494 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5495 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5496 filename_line_regex='^'"$filename_anywhere_regex"'$'
5499 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5500 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5501 (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$,,')
5504 | func_sanitize_modulelist \
5507 for module in $module_candidates; do
5508 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5513 func_warning "file $filename does not exist"
5518 import | add-import | remove-import | update )
5521 if test -z "$destdir"; then
5524 test -d "$destdir" \
5525 || func_fatal_error "destination directory does not exist: $destdir"
5527 # Prefer configure.ac to configure.in.
5528 if test -f "$destdir"/configure.ac; then
5529 configure_ac="$destdir/configure.ac"
5531 if test -f "$destdir"/configure.in; then
5532 configure_ac="$destdir/configure.in"
5534 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5538 # Analyze configure.ac.
5540 guessed_libtool=false
5545 /AC_CONFIG_AUX_DIR/ {
5546 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5548 /A[CM]_PROG_LIBTOOL/ {
5549 s,^.*$,guessed_libtool=true,p
5551 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5553 if test -z "$auxdir"; then
5554 auxdir="$guessed_auxdir"
5557 # Determine where to apply func_import.
5558 if test "$mode" = import; then
5559 # Apply func_import to a particular gnulib directory.
5560 # The command line contains the complete specification; don't look at
5561 # the contents of gnulib-cache.m4.
5562 test -n "$supplied_libname" || supplied_libname=true
5563 test -n "$sourcebase" || sourcebase="lib"
5564 test -n "$m4base" || m4base="m4"
5565 test -n "$docbase" || docbase="doc"
5566 test -n "$testsbase" || testsbase="tests"
5567 test -n "$macro_prefix" || macro_prefix="gl"
5570 if test -n "$m4base"; then
5571 # Apply func_import to a particular gnulib directory.
5572 # Any number of additional modules can be given.
5573 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5574 # First use of gnulib in the given m4base.
5575 test -n "$supplied_libname" || supplied_libname=true
5576 test -n "$sourcebase" || sourcebase="lib"
5577 test -n "$docbase" || docbase="doc"
5578 test -n "$testsbase" || testsbase="tests"
5579 test -n "$macro_prefix" || macro_prefix="gl"
5583 # Apply func_import to all gnulib directories.
5584 # To get this list of directories, look at Makefile.am. (Not at
5585 # configure, because it may be omitted from version control. Also,
5586 # don't run "find $destdir -name gnulib-cache.m4", as it might be
5590 if test -f "$destdir"/Makefile.am; then
5591 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5593 for arg in $aclocal_amflags; do
5594 if test -n "$m4dir_is_next"; then
5595 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5599 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5600 func_append m4dirs " $arg"
5601 m4dirs_count=`expr $m4dirs_count + 1`
5607 if test "X$arg" = "X-I"; then
5615 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5616 if test -f "$destdir"/aclocal.m4; then
5617 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5618 sedexpr2='s,^[^/]*$,.,'
5619 sedexpr3='s,/[^/]*$,,'
5620 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5621 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
5622 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
5625 if test $m4dirs_count = 0; then
5626 # First use of gnulib in a package.
5627 # Any number of additional modules can be given.
5628 test -n "$supplied_libname" || supplied_libname=true
5629 test -n "$sourcebase" || sourcebase="lib"
5631 test -n "$docbase" || docbase="doc"
5632 test -n "$testsbase" || testsbase="tests"
5633 test -n "$macro_prefix" || macro_prefix="gl"
5636 if test $m4dirs_count = 1; then
5637 # There's only one use of gnulib here. Assume the user means it.
5638 # Any number of additional modules can be given.
5639 for m4base in $m4dirs; do
5643 # Ambiguous - guess what the user meant.
5644 if test $# = 0; then
5645 # No further arguments. Guess the user wants to update all of them.
5646 for m4base in $m4dirs; do
5647 # Perform func_import in a subshell, so that variable values
5649 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5650 # inc_longrunning_tests, inc_privileged_tests,
5651 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5652 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5653 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5654 # don't propagate from one directory to another.
5655 (func_import) || func_exit 1
5659 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5668 if test -z "$destdir"; then
5669 func_fatal_error "please specify --dir option"
5672 test -d "$destdir" \
5673 || func_fatal_error "could not create destination directory"
5674 test -n "$auxdir" || auxdir="build-aux"
5675 func_create_testdir "$destdir" "$*"
5678 create-megatestdir )
5679 if test -z "$destdir"; then
5680 func_fatal_error "please specify --dir option"
5682 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5683 test -n "$auxdir" || auxdir="build-aux"
5684 func_create_megatestdir "$destdir" "$*"
5688 test -n "$destdir" || destdir=testdir$$
5689 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5690 test -n "$auxdir" || auxdir="build-aux"
5691 func_create_testdir "$destdir" "$*"
5695 ../configure || func_exit 1
5696 $MAKE || func_exit 1
5697 $MAKE check || func_exit 1
5698 $MAKE distclean || func_exit 1
5699 remaining=`find . -type f -print`
5700 if test -n "$remaining"; then
5701 echo "Remaining files:" $remaining 1>&2
5702 echo "gnulib-tool: *** Stop." 1>&2
5711 test -n "$destdir" || destdir=testdir$$
5712 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5713 test -n "$auxdir" || auxdir="build-aux"
5714 func_create_megatestdir "$destdir" "$*"
5722 remaining=`find . -type f -print`
5723 if test -n "$remaining"; then
5724 echo "Remaining files:" $remaining 1>&2
5725 echo "gnulib-tool: *** Stop." 1>&2
5733 extract-description )
5737 if test -n "$module"; then
5738 func_get_description "$module"
5747 if test -n "$module"; then
5748 func_get_comment "$module"
5757 if test -n "$module"; then
5758 func_get_status "$module"
5767 if test -n "$module"; then
5768 func_get_notice "$module"
5773 extract-applicability )
5777 if test -n "$module"; then
5778 func_get_applicability "$module"
5787 if test -n "$module"; then
5788 func_get_filelist "$module"
5793 extract-dependencies )
5797 if test -n "$module"; then
5798 func_get_dependencies "$module"
5803 extract-autoconf-snippet )
5807 if test -n "$module"; then
5808 func_get_autoconf_snippet "$module"
5813 extract-automake-snippet )
5817 if test -n "$module"; then
5818 func_get_automake_snippet "$module"
5823 extract-include-directive )
5827 if test -n "$module"; then
5828 func_get_include_directive "$module"
5833 extract-link-directive )
5837 if test -n "$module"; then
5838 func_get_link_directive "$module"
5847 if test -n "$module"; then
5848 func_get_license "$module"
5853 extract-maintainer )
5857 if test -n "$module"; then
5858 func_get_maintainer "$module"
5863 extract-tests-module )
5867 if test -n "$module"; then
5868 func_get_tests_module "$module"
5874 # Verify the number of arguments.
5875 if test $# -lt 1 || test $# -gt 2; then
5876 func_fatal_error "invalid number of arguments for --$mode"
5879 # The first argument is the file to be copied.
5881 # Verify the file exists.
5882 func_lookup_file "$f"
5884 # The second argument is the destination; either a directory ot a file.
5885 # It defaults to the current directory.
5887 test -n "$dest" || dest='.'
5888 test -n "$sourcebase" || sourcebase="lib"
5889 test -n "$m4base" || m4base="m4"
5890 test -n "$docbase" || docbase="doc"
5891 test -n "$testsbase" || testsbase="tests"
5892 test -n "$auxdir" || auxdir="build-aux"
5893 rewritten='%REWRITTEN%'
5894 sed_rewrite_files="\
5895 s,^build-aux/,$rewritten$auxdir/,
5896 s,^doc/,$rewritten$docbase/,
5897 s,^lib/,$rewritten$sourcebase/,
5898 s,^m4/,$rewritten$m4base/,
5899 s,^tests/,$rewritten$testsbase/,
5902 if test -d "$dest"; then
5904 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5906 destdir=`dirname "$dest"`
5907 g=`basename "$dest"`
5910 # Create the directory for destfile.
5911 d=`dirname "$destdir/$g"`
5913 if test -n "$d" && test ! -d "$d"; then
5914 mkdir -p "$d" || func_fatal_error "failed"
5918 func_dest_tmpfilename "$g"
5919 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5920 already_present=true
5921 if test -f "$destdir/$g"; then
5922 # The file already exists.
5926 # Don't protest if the file should be there but isn't: it happens
5927 # frequently that developers don't put autogenerated files under version
5935 func_fatal_error "unknown operation mode --$mode" ;;
5939 # Undo the effect of the previous 'trap' command. Some shellology:
5940 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5941 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5942 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5943 # 128 + signal number and is set before the trap-registered command is run.
5945 trap 'func_exit $?' 1 2 3 13 15
5950 # indent-tabs-mode: nil
5951 # whitespace-check-buffer-indent: nil