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.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
130 gnulib-tool --add-import [module1 ... moduleN]
131 gnulib-tool --remove-import [module1 ... moduleN]
133 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
134 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
135 gnulib-tool --test --dir=directory module1 ... moduleN
136 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
137 gnulib-tool --extract-description module
138 gnulib-tool --extract-comment module
139 gnulib-tool --extract-status module
140 gnulib-tool --extract-notice module
141 gnulib-tool --extract-applicability module
142 gnulib-tool --extract-filelist module
143 gnulib-tool --extract-dependencies module
144 gnulib-tool --extract-autoconf-snippet module
145 gnulib-tool --extract-automake-snippet module
146 gnulib-tool --extract-include-directive module
147 gnulib-tool --extract-link-directive module
148 gnulib-tool --extract-license module
149 gnulib-tool --extract-maintainer module
150 gnulib-tool --extract-tests-module module
151 gnulib-tool --copy-file file [destination]
154 --list print the available module names
155 --find find the modules which contain the specified file
156 --import import the given modules into the current package
157 --add-import augment the list of imports from gnulib into the
158 current package, by adding the given modules;
159 if no modules are specified, update the current
160 package from the current gnulib
161 --remove-import reduce the list of imports from gnulib into the
162 current package, by removing the given modules
163 --update update the current package, restore files omitted
165 --create-testdir create a scratch package with the given modules
166 --create-megatestdir create a mega scratch package with the given modules
167 one by one and all together
168 --test test the combination of the given modules
169 (recommended to use CC=\"gcc -Wall\" here)
170 --megatest test the given modules one by one and all together
171 (recommended to use CC=\"gcc -Wall\" here)
172 --extract-description extract the description
173 --extract-comment extract the comment
174 --extract-status extract the status (obsolete etc.)
175 --extract-notice extract the notice or banner
176 --extract-applicability extract the applicability
177 --extract-filelist extract the list of files
178 --extract-dependencies extract the dependencies
179 --extract-autoconf-snippet extract the snippet for configure.ac
180 --extract-automake-snippet extract the snippet for library makefile
181 --extract-include-directive extract the #include directive
182 --extract-link-directive extract the linker directive
183 --extract-license report the license terms of the source files
185 --extract-maintainer report the maintainer(s) inside gnulib
186 --extract-tests-module report the unit test module, if it exists
187 --copy-file copy a file that is not part of any module
190 --dir=DIRECTORY Specify the target directory.
191 For --import, this specifies where your
192 configure.ac can be found. Defaults to current
194 --local-dir=DIRECTORY Specify a local override directory where to look
195 up files before looking in gnulib's directory.
196 --cache-modules Enable module caching optimization.
197 --no-cache-modules Disable module caching optimization.
198 --verbose Increase verbosity. May be repeated.
199 --quiet Decrease verbosity. May be repeated.
201 Options for --import, --update:
202 --dry-run Only print what would have been done.
204 Options for --import, --create-[mega]testdir, --[mega]test:
205 --with-tests Include unit tests for the included modules.
206 --with-obsolete Include obsolete modules when they occur among the
207 dependencies. By default, dependencies to obsolete
209 --with-c++-tests Include even unit tests for C++ interoperability.
210 --with-longrunning-tests
211 Include even unit tests that are long-runners.
212 --with-privileged-tests
213 Include even unit tests that require root
215 --with-unportable-tests
216 Include even unit tests that fail on some platforms.
217 --with-all-tests Include all kinds of problematic unit tests.
218 --avoid=MODULE Avoid including the given MODULE. Useful if you
219 have code that provides equivalent functionality.
220 This option can be repeated.
221 --libtool Use libtool rules.
222 --no-libtool Don't use libtool rules.
224 Options for --import:
225 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
226 --source-base=DIRECTORY
227 Directory relative to --dir where source code is
228 placed (default \"lib\").
229 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
230 placed (default \"m4\").
231 --po-base=DIRECTORY Directory relative to --dir where *.po files are
232 placed (default \"po\").
233 --doc-base=DIRECTORY Directory relative to --dir where doc files are
234 placed (default \"doc\").
235 --tests-base=DIRECTORY
236 Directory relative to --dir where unit tests are
237 placed (default \"tests\").
238 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
239 tools are placed (default \"build-aux\").
240 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
241 Also modify license template from GPL to LGPL.
242 The version number of the LGPL can be specified;
243 the default is currently LGPLv3.
244 --makefile-name=NAME Name of makefile in automake syntax in the
245 source-base and tests-base directories
246 (default \"Makefile.am\").
247 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
248 'gl_INIT'. Default is 'gl'.
249 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
250 the package name. A suffix '-gnulib' is appended.
251 --vc-files Update version control related files.
252 --no-vc-files Don't update version control related files
253 (.gitignore and/or .cvsignore).
254 --no-changelog Don't update or create ChangeLog files.
256 Options for --create-[mega]testdir, --[mega]test:
257 --without-c++-tests Exclude unit tests for C++ interoperability.
258 --without-longrunning-tests
259 Exclude unit tests that are long-runners.
260 --without-privileged-tests
261 Exclude unit tests that require root privileges.
262 --without-unportable-tests
263 Exclude unit tests that fail on some platforms.
265 Options for --import, --update, --create-[mega]testdir, --[mega]test:
266 -s, --symbolic, --symlink Make symbolic links instead of copying files.
267 --local-symlink Make symbolic links instead of copying files, only
268 for files from the local override directory.
270 Options for --import, --update:
271 -S, --more-symlinks Make symbolic links instead of copying files, and
272 don't replace copyright notices.
274 Report bugs to <bug-gnulib@gnu.org>."
278 # outputs to stdout the --version message.
282 if test -d "$gnulib_dir"/.git \
283 && (git --version) >/dev/null 2>/dev/null \
284 && (date --version) >/dev/null 2>/dev/null; then
285 # gnulib checked out from git.
286 sed_extract_first_date='/^Date/{
290 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
291 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
292 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
293 date=`echo "$date" | sed -e "$sed_year_before_time"`
294 # Use GNU date to compute the time in GMT.
295 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
296 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
298 if test -d "$gnulib_dir"/CVS \
299 && (cvs --version) >/dev/null 2>/dev/null; then
300 # gnulib checked out from CVS.
301 sed_extract_first_date='/^date: /{
302 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
305 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
307 # gnulib copy without versioning information.
308 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
312 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
314 gnulib-tool (GNU $package $date)$version
315 Copyright (C) $year Free Software Foundation, Inc.
316 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
317 This is free software: you are free to change and redistribute it.
318 There is NO WARRANTY, to the extent permitted by law.
320 Written by" "Bruno Haible" "and" "Simon Josefsson"
323 # func_emit_copyright_notice
324 # outputs to stdout a header for a generated file.
325 func_emit_copyright_notice ()
327 sed -n -e '/Copyright/ {
330 }' < "$self_abspathname"
332 echo "# This file is free software, distributed under the terms of the GNU"
333 echo "# General Public License. As a special exception to the GNU General"
334 echo "# Public License, this file may be distributed as part of a program"
335 echo "# that contains a configuration script generated by Autoconf, under"
336 echo "# the same distribution terms as the rest of that program."
338 echo "# Generated by gnulib-tool."
342 # exits with a given status.
343 # This function needs to be used, rather than 'exit', when a 'trap' handler is
344 # in effect that refers to $?.
351 # locates the directory where the gnulib repository lives
353 # - progname name of this program
355 # - self_abspathname absolute pathname of gnulib-tool
356 # - gnulib_dir absolute pathname of gnulib repository
360 /*) self_abspathname="$progname" ;;
361 */*) self_abspathname=`pwd`/"$progname" ;;
364 # Iterate through the elements of $PATH.
365 # We use IFS=: instead of
366 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
367 # because the latter does not work when some PATH element contains spaces.
368 # We use a canonicalized $pathx instead of $PATH, because empty PATH
369 # elements are by definition equivalent to '.', however field splitting
370 # according to IFS=: loses empty fields in many shells:
371 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
372 # beginning, at the end, and in the middle),
373 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
374 # at the beginning and at the end,
375 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
376 # Solaris lose empty fields at the end.
377 # The 'case' statement is an optimization, to avoid evaluating the
378 # explicit canonicalization command when $PATH contains no empty fields.
380 if test "${PATH_SEPARATOR+set}" != set; then
381 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
382 # contains only /bin. Note that ksh looks also at the FPATH variable,
383 # so we have to set that as well for the test.
385 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
386 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
387 || PATH_SEPARATOR=';'
390 if test "$PATH_SEPARATOR" = ";"; then
391 # On Windows, programs are searched in "." before $PATH.
394 # On Unix, we have to convert empty PATH elements to ".".
398 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
403 IFS="$PATH_SEPARATOR"
407 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
408 self_abspathname="$d/$progname"
413 if test -z "$self_abspathname"; then
414 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
418 while test -h "$self_abspathname"; do
419 # Resolve symbolic link.
420 linkval=`func_readlink "$self_abspathname"`
421 test -n "$linkval" || break
423 /* ) self_abspathname="$linkval" ;;
424 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
427 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
431 # creates a temporary directory.
433 # - progname name of this program
435 # - tmp pathname of freshly created temporary directory
438 # Use the environment variable TMPDIR, falling back to /tmp. This allows
439 # users to specify a different temporary directory, for example, if their
440 # /tmp is filled up or too small.
443 # Use the mktemp program if available. If not available, hide the error
445 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
446 test -n "$tmp" && test -d "$tmp"
449 # Use a simple mkdir command. It is guaranteed to fail if the directory
450 # already exists. $RANDOM is bash specific and expands to empty in shells
451 # other than bash, ksh and zsh. Its use does not increase security;
452 # rather, it minimizes the probability of failure in a very cluttered /tmp
454 tmp=$TMPDIR/gl$$-$RANDOM
455 (umask 077 && mkdir "$tmp")
458 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
463 # func_append var value
464 # appends the given value to the shell variable var.
465 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
466 # Use bash's += operator. It reduces complexity of appending repeatedly to
467 # a single variable from O(n^2) to O(n).
472 fast_func_append=true
476 eval "$1=\"\$$1\$2\""
478 fast_func_append=false
481 # func_remove_prefix var prefix
482 # removes the given prefix from the value of the shell variable var.
483 # var should be the name of a shell variable.
484 # Its value should not contain a newline and not start or end with whitespace.
485 # prefix should not contain the characters "$`\{}[]^|.
486 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
487 func_remove_prefix ()
491 fast_func_remove_prefix=true
493 func_remove_prefix ()
495 eval "value=\"\$$1\""
499 sed_escape_dots='s/\([.]\)/\\\1/g'
500 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
503 value=`echo "$value" | sed -e "s|^${prefix}||"`
504 eval "$1=\"\$value\""
506 fast_func_remove_prefix=false
509 # func_remove_suffix var suffix
510 # removes the given suffix from the value of the shell variable var.
511 # var should be the name of a shell variable.
512 # Its value should not contain a newline and not start or end with whitespace.
513 # suffix should not contain the characters "$`\{}[]^|.
514 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
515 func_remove_suffix ()
519 fast_func_remove_suffix=true
521 func_remove_suffix ()
523 eval "value=\"\$$1\""
527 sed_escape_dots='s/\([.]\)/\\\1/g'
528 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
531 value=`echo "$value" | sed -e "s|${suffix}\$||"`
532 eval "$1=\"\$value\""
534 fast_func_remove_suffix=false
537 # func_fatal_error message
538 # outputs to stderr a fatal error message, and terminates the program.
540 # - progname name of this program
543 echo "$progname: *** $1" 1>&2
544 echo "$progname: *** Stop." 1>&2
548 # func_warning message
549 # Outputs to stderr a warning message,
552 echo "gnulib-tool: warning: $1" 1>&2
555 # func_readlink SYMLINK
556 # outputs the target of the given symlink.
557 if (type -p readlink) > /dev/null 2>&1; then
560 # Use the readlink program from GNU coreutils.
566 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
567 # would do the wrong thing if the link target contains " -> ".
568 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
572 # func_relativize DIR1 DIR2
573 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
575 # - DIR1 relative pathname, relative to the current directory
576 # - DIR2 relative pathname, relative to the current directory
578 # - reldir relative pathname of DIR2, relative to DIR1
584 sed_first='s,^\([^/]*\)/.*$,\1,'
585 sed_rest='s,^[^/]*/*,,'
586 sed_last='s,^.*/\([^/]*\)$,\1,'
587 sed_butlast='s,/*[^/]*$,,'
588 while test -n "$dir1"; do
589 first=`echo "$dir1" | sed -e "$sed_first"`
590 if test "$first" != "."; then
591 if test "$first" = ".."; then
592 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
593 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
595 first2=`echo "$dir2" | sed -e "$sed_first"`
596 if test "$first2" = "$first"; then
597 dir2=`echo "$dir2" | sed -e "$sed_rest"`
601 dir0="$dir0"/"$first"
604 dir1=`echo "$dir1" | sed -e "$sed_rest"`
609 # func_relconcat DIR1 DIR2
610 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
612 # - DIR1 relative pathname, relative to the current directory
613 # - DIR2 relative pathname, relative to DIR1
615 # - relconcat DIR1/DIR2, relative to the current directory
620 sed_first='s,^\([^/]*\)/.*$,\1,'
621 sed_rest='s,^[^/]*/*,,'
622 sed_last='s,^.*/\([^/]*\)$,\1,'
623 sed_butlast='s,/*[^/]*$,,'
625 first=`echo "$dir2" | sed -e "$sed_first"`
626 if test "$first" = "."; then
627 dir2=`echo "$dir2" | sed -e "$sed_rest"`
628 if test -z "$dir2"; then
633 last=`echo "$dir1" | sed -e "$sed_last"`
634 while test "$last" = "."; do
635 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
636 last=`echo "$dir1" | sed -e "$sed_last"`
638 if test -z "$dir1"; then
642 if test "$first" = ".."; then
643 if test "$last" = ".."; then
644 relconcat="$dir1/$dir2"
647 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
648 dir2=`echo "$dir2" | sed -e "$sed_rest"`
649 if test -z "$dir1"; then
653 if test -z "$dir2"; then
658 relconcat="$dir1/$dir2"
666 # Like ln -s, except that SRC is given relative to the current directory (or
667 # absolute), not given relative to the directory of DEST.
673 *) # SRC is relative.
676 ln -s "`pwd`/$1" "$2" ;;
677 *) # DEST is relative too.
678 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
679 test -n "$ln_destdir" || ln_destdir="."
680 func_relativize "$ln_destdir" "$1"
688 # func_ln_if_changed SRC DEST
689 # Like func_ln, but avoids munging timestamps if the link is correct.
690 func_ln_if_changed ()
692 if test $# -ne 2; then
693 echo "usage: func_ln_if_changed SRC DEST" >&2
695 ln_target=`func_readlink "$2"`
696 if test -h "$2" && test "$1" = "$ln_target"; then
704 # Ensure an 'echo' command that
705 # 1. does not interpret backslashes and
706 # 2. does not print an error message "broken pipe" when writing into a pipe
709 # Test cases for problem 1:
710 # echo '\n' | wc -l prints 1 when OK, 2 when KO
711 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
712 # Test cases for problem 2:
713 # echo hi | true frequently prints
714 # "bash: echo: write error: Broken pipe"
715 # to standard error in bash 3.2.
717 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
718 # BSD echo interprets '-n' as an option, which is also not desirable).
719 # Nowadays the problem occurs in 4 situations:
720 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
721 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
722 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
723 # - in zsh, when sh-emulation is not set,
724 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
725 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
726 # - in Solaris /bin/sh and OSF/1 /bin/sh.
727 # We try the following workarounds:
728 # - for all: respawn using $CONFIG_SHELL if that is set and works.
729 # - for bash >= 2.04: unset the shell option xpg_echo.
730 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
731 # - for bash < 2.0: define echo to a function that uses cat of a here document.
732 # - for zsh: turn sh-emulation on.
733 # - for ksh: alias echo to 'print -r'.
734 # - for ksh: alias echo to a function that uses cat of a here document.
735 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
736 # the ksh workaround.
737 # - otherwise: respawn using /bin/sh and rely on the workarounds.
738 # When respawning, we pass --no-reexec as first argument, so as to avoid
739 # turning this script into a fork bomb in unlucky situations.
741 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
742 # the 'printf' built-in. See
743 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
744 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
745 # The workaround is: define echo to a function that uses the printf built-in.
747 if echo '\t' | grep t > /dev/null; then
748 have_echo=yes # Lucky!
750 # Try the workarounds.
751 # Respawn using $CONFIG_SHELL if that is set and works.
752 if test -z "$have_echo" \
753 && test "X$1" != "X--no-reexec" \
754 && test -n "$CONFIG_SHELL" \
755 && test -f "$CONFIG_SHELL" \
756 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
757 exec $CONFIG_SHELL "$0" --no-reexec "$@"
760 # For bash >= 2.04: unset the shell option xpg_echo.
761 if test -z "$have_echo" \
762 && test -n "$BASH_VERSION" \
763 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
767 # For bash >= 2.0: define echo to a function that uses the printf built-in.
768 # For bash < 2.0: define echo to a function that uses cat of a here document.
769 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
770 # Also handle problem 2, specific to bash 3.2, here.
771 if { test -z "$have_echo" \
772 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
774 && test -n "$BASH_VERSION"; then \
775 if type printf 2>/dev/null | grep / > /dev/null; then
776 # 'printf' is not a shell built-in.
784 # 'printf' is a shell built-in.
790 if echo '\t' | grep t > /dev/null; then
794 # For zsh: turn sh-emulation on.
795 if test -z "$have_echo" \
796 && test -n "$ZSH_VERSION" \
797 && (emulate sh) >/dev/null 2>&1; then
800 # For ksh: alias echo to 'print -r'.
801 if test -z "$have_echo" \
802 && (type print) >/dev/null 2>&1; then
803 # A 'print' command exists.
804 if type print 2>/dev/null | grep / > /dev/null; then
807 # 'print' is a shell built-in.
808 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
809 # 'print' is the ksh shell built-in.
810 alias echo='print -r'
814 if test -z "$have_echo" \
815 && echo '\t' | grep t > /dev/null; then
818 # For ksh: alias echo to a function that uses cat of a here document.
819 # The ksh manual page says:
820 # "Aliasing is performed when scripts are read, not while they are executed.
821 # Therefore, for an alias to take effect, the alias definition command has
822 # to be executed before the command which references the alias is read."
823 # Because of this, we have to play strange tricks with have_echo, to ensure
824 # that the top-level statement containing the test starts after the 'alias'
826 if test -z "$have_echo"; then
833 alias echo=bsd_echo 2>/dev/null
835 if test -z "$have_echo" \
836 && echo '\t' | grep t > /dev/null; then
839 if test -z "$have_echo"; then
840 unalias echo 2>/dev/null
842 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
843 if test -z "$have_echo" \
844 && test "X$1" != "X--no-reexec" \
845 && test -f /bin/ksh; then
846 exec /bin/ksh "$0" --no-reexec "$@"
849 # Otherwise: respawn using /bin/sh.
850 if test -z "$have_echo" \
851 && test "X$1" != "X--no-reexec" \
852 && test -f /bin/sh; then
853 exec /bin/sh "$0" --no-reexec "$@"
856 if test -z "$have_echo"; then
857 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
859 if echo '\t' | grep t > /dev/null; then
862 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
864 if test "X$1" = "X--no-reexec"; then
868 # Command-line option processing.
869 # Removes the OPTIONS from the arguments. Sets the variables:
870 # - mode list or import or add-import or remove-import or update
871 # or create-testdir or create-megatestdir
872 # - destdir from --dir
873 # - local_gnulib_dir from --local-dir
874 # - modcache true or false, from --cache-modules/--no-cache-modules
875 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
876 # - libname, supplied_libname from --lib
877 # - sourcebase from --source-base
878 # - m4base from --m4-base
879 # - pobase from --po-base
880 # - docbase from --doc-base
881 # - testsbase from --tests-base
882 # - auxdir from --aux-dir
883 # - inctests true if --with-tests was given, blank otherwise
884 # - incobsolete true if --with-obsolete was given, blank otherwise
885 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
886 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
888 # - inc_privileged_tests true if --with-privileged-tests was given, blank
890 # - inc_unportable_tests true if --with-unportable-tests was given, blank
892 # - inc_all_tests true if --with-all-tests was given, blank otherwise
893 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
894 # - excl_longrunning_tests true if --without-longrunning-tests was given,
896 # - excl_privileged_tests true if --without-privileged-tests was given, blank
898 # - excl_unportable_tests true if --without-unportable-tests was given, blank
900 # - avoidlist list of modules to avoid, from --avoid
901 # - lgpl yes or a number if --lgpl was given, blank otherwise
902 # - makefile_name from --makefile-name
903 # - libtool true if --libtool was given, false if --no-libtool was
904 # given, blank otherwise
905 # - macro_prefix from --macro-prefix
906 # - po_domain from --po-domain
907 # - vc_files true if --vc-files was given, false if --no-vc-files was
908 # given, blank otherwise
909 # - autoconf_minversion minimum supported autoconf version
910 # - do_changelog false if --no-changelog was given, : otherwise
911 # - doit : if actions shall be executed, false if only to be printed
912 # - symbolic true if --symlink or --more-symlinks was given, blank
914 # - lsymbolic true if --local-symlink was given, blank otherwise
915 # - do_copyrights blank if --more-symlinks was given, true otherwise
933 inc_longrunning_tests=
934 inc_privileged_tests=
935 inc_unportable_tests=
938 excl_longrunning_tests=
939 excl_privileged_tests=
940 excl_unportable_tests=
956 while test $# -gt 0; do
961 --find | --fin | --fi | --f )
964 --import | --impor | --impo | --imp | --im | --i )
967 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
970 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
973 --update | --updat | --upda | --upd | --up | --u )
976 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
979 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
980 mode=create-megatestdir
982 --test | --tes | --te | --t )
985 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
989 mode=`echo "X$1" | sed -e 's/^X--//'`
991 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
997 func_fatal_error "missing argument for --dir"
1002 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1006 if test $# = 0; then
1007 func_fatal_error "missing argument for --local-dir"
1012 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1014 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1017 --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 )
1020 --verbose | --verbos | --verbo | --verb )
1021 verbose=`expr $verbose + 1`
1023 --quiet | --quie | --qui | --qu | --q )
1024 verbose=`expr $verbose - 1`
1028 if test $# = 0; then
1029 func_fatal_error "missing argument for --lib"
1032 supplied_libname=true
1035 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1036 supplied_libname=true
1040 if test $# = 0; then
1041 func_fatal_error "missing argument for --source-base"
1046 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1050 if test $# = 0; then
1051 func_fatal_error "missing argument for --m4-base"
1056 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1060 if test $# = 0; then
1061 func_fatal_error "missing argument for --po-base"
1066 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1070 if test $# = 0; then
1071 func_fatal_error "missing argument for --doc-base"
1076 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1080 if test $# = 0; then
1081 func_fatal_error "missing argument for --tests-base"
1086 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1090 if test $# = 0; then
1091 func_fatal_error "missing argument for --aux-dir"
1096 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1098 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1101 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1104 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1107 --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)
1108 inc_longrunning_tests=true
1110 --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)
1111 inc_privileged_tests=true
1113 --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)
1114 inc_unportable_tests=true
1116 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1119 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1122 --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)
1123 excl_longrunning_tests=true
1125 --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)
1126 excl_privileged_tests=true
1128 --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)
1129 excl_unportable_tests=true
1133 if test $# = 0; then
1134 func_fatal_error "missing argument for --avoid"
1136 func_append avoidlist " $1"
1139 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1140 func_append avoidlist " $arg"
1146 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1149 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1155 if test $# = 0; then
1156 func_fatal_error "missing argument for --makefile-name"
1161 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1171 if test $# = 0; then
1172 func_fatal_error "missing argument for --macro-prefix"
1177 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1181 if test $# = 0; then
1182 func_fatal_error "missing argument for --po-domain"
1187 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1195 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1201 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1204 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1207 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1211 --help | --hel | --he | --h )
1214 --version | --versio | --versi | --vers )
1218 # Stop option processing
1222 echo "gnulib-tool: unknown option $1" 1>&2
1223 echo "Try 'gnulib-tool --help' for more information." 1>&2
1230 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1231 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1232 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then
1233 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1234 echo "Try 'gnulib-tool --help' for more information." 1>&2
1238 # This code helps migrating from --import to --add-import or --update. It can
1239 # be removed on 2012-01-01.
1240 if test "$mode" = import && test $# = 0; then
1241 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1242 echo "The meaning of the option '--import' has changed." 1>&2
1243 echo "See the documentation at" 1>&2
1244 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1245 echo "For updating to a newer version of gnulib, use" 1>&2
1246 echo " gnulib-tool --add-import" 1>&2
1247 echo "For restoring files that were omitted from version control, use" 1>&2
1248 echo " gnulib-tool --update" 1>&2
1251 if test "$mode" = update; then
1252 if test $# != 0; then
1253 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1254 echo "Try 'gnulib-tool --help' for more information." 1>&2
1255 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1256 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1259 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1260 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1261 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1262 || test -n "$inctests" || test -n "$incobsolete" \
1263 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1264 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1265 || test -n "$inc_all_tests" \
1266 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1267 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1268 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1269 || test -n "$macro_prefix" || test -n "$po_domain" \
1270 || test -n "$vc_files"; then
1271 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1272 echo "Try 'gnulib-tool --help' for more information." 1>&2
1273 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1274 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1279 if test -n "$pobase" && test -z "$po_domain"; then
1280 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1281 echo "Try 'gnulib-tool --help' for more information." 1>&2
1284 if test -z "$pobase" && test -n "$po_domain"; then
1285 func_warning "--po-domain has no effect without a --po-base option"
1288 # Determine the minimum supported autoconf version from the project's
1290 DEFAULT_AUTOCONF_MINVERSION="2.59"
1291 autoconf_minversion=
1293 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1294 && test -n "$destdir"; then
1295 if test -f "$destdir"/configure.ac; then
1296 configure_ac="$destdir/configure.ac"
1298 if test -f "$destdir"/configure.in; then
1299 configure_ac="$destdir/configure.in"
1303 if test -f configure.ac; then
1304 configure_ac="configure.ac"
1306 if test -f configure.in; then
1307 configure_ac="configure.in"
1311 if test -n "$configure_ac"; then
1312 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1313 # because when some m4 files are omitted from a version control repository,
1314 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1315 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1316 # autom4te: m4 failed with exit status: 1
1323 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1325 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1326 if test -n "$prereqs"; then
1327 autoconf_minversion=`
1328 for version in $prereqs; do echo $version; done |
1329 LC_ALL=C sort -nru | sed -e 1q
1333 if test -z "$autoconf_minversion"; then
1334 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1336 case "$autoconf_minversion" in
1337 1.* | 2.[0-4]* | 2.5[0-8]*)
1338 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1341 # Remove trailing slashes from the directory names. This is necessary for
1342 # m4base (to avoid an error in func_import) and optional for the others.
1343 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1344 case "$local_gnulib_dir" in
1345 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1347 case "$sourcebase" in
1348 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1351 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1354 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1357 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1359 case "$testsbase" in
1360 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1363 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1369 trap 'exit_status=$?
1370 if test "$signal" != 0; then
1371 echo "caught signal $signal" >&2
1374 exit $exit_status' 0
1375 for signal in 1 2 3 13 15; do
1376 trap '{ signal='$signal'; func_exit 1; }' $signal
1380 # Note: The 'eval' silences stderr output in dash.
1381 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1382 # Zsh 4 and Bash 4 have associative arrays.
1383 have_associative=true
1385 # For other shells, use 'eval' with computed shell variable names.
1386 have_associative=false
1389 # func_lookup_file file
1390 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1393 # - local_gnulib_dir from --local-dir
1395 # - lookedup_file name of the merged (combined) file
1396 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1400 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1401 lookedup_file="$local_gnulib_dir/$lkfile"
1404 if test -f "$gnulib_dir/$lkfile"; then
1405 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1406 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1407 rm -f "$tmp/$lkbase"
1408 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1409 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1410 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1411 lookedup_file="$tmp/$lkbase"
1414 lookedup_file="$gnulib_dir/$lkfile"
1418 func_fatal_error "file $gnulib_dir/$lkfile not found"
1423 # func_sanitize_modulelist
1424 # receives a list of possible module names on standard input, one per line.
1425 # It removes those which are just file names unrelated to modules, and outputs
1426 # the resulting list to standard output, one per line.
1427 func_sanitize_modulelist ()
1429 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1430 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1431 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1432 -e '/^README$/d' -e '/\/README$/d' \
1433 -e '/^TEMPLATE$/d' \
1434 -e '/^TEMPLATE-EXTENDED$/d' \
1435 -e '/^TEMPLATE-TESTS$/d' \
1442 # - local_gnulib_dir from --local-dir
1445 # Filter out metainformation files like README, which are not modules.
1446 # Filter out unit test modules; they can be retrieved through
1447 # --extract-tests-module if desired.
1449 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1450 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1451 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1454 | func_sanitize_modulelist \
1455 | sed -e '/-tests$/d' \
1459 # func_exists_module module
1460 # tests whether a module, given by name, exists
1462 # - local_gnulib_dir from --local-dir
1463 func_exists_module ()
1465 { test -f "$gnulib_dir/modules/$1" \
1466 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1467 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1468 && test "CVS" != "$1" \
1469 && test "ChangeLog" != "$1" \
1470 && test "COPYING" != "$1" \
1471 && test "README" != "$1" \
1472 && test "TEMPLATE" != "$1" \
1473 && test "TEMPLATE-EXTENDED" != "$1" \
1474 && test "TEMPLATE-TESTS" != "$1"
1477 # func_verify_module
1478 # verifies a module name
1480 # - local_gnulib_dir from --local-dir
1481 # - module module name argument
1482 func_verify_module ()
1484 if func_exists_module "$module"; then
1485 # OK, $module is a correct module name.
1486 # Verify that building the module description with 'patch' succeeds.
1487 func_lookup_file "modules/$module"
1489 func_warning "module $module doesn't exist"
1494 # func_verify_nontests_module
1495 # verifies a module name, excluding tests modules
1497 # - local_gnulib_dir from --local-dir
1498 # - module module name argument
1499 func_verify_nontests_module ()
1502 *-tests ) module= ;;
1503 * ) func_verify_module ;;
1507 # func_verify_tests_module
1508 # verifies a module name, considering only tests modules
1510 # - local_gnulib_dir from --local-dir
1511 # - module module name argument
1512 func_verify_tests_module ()
1515 *-tests ) func_verify_module ;;
1520 # Suffix of a sed expression that extracts a particular field from a
1521 # module description.
1522 # A field starts with a line that contains a keyword, such as 'Description',
1523 # followed by a colon and optional whitespace. All following lines, up to
1524 # the next field (or end of file if there is none) form the contents of the
1526 # An absent field is equivalent to a field with empty contents.
1527 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1528 sed_extract_prog=':[ ]*$/ {
1531 s/^Description:[ ]*$//
1535 s/^Applicability:[ ]*$//
1537 s/^Depends-on:[ ]*$//
1538 s/^configure\.ac-early:[ ]*$//
1539 s/^configure\.ac:[ ]*$//
1540 s/^Makefile\.am:[ ]*$//
1544 s/^Maintainer:[ ]*$//
1551 # Piece of a sed expression that converts a field header line to a shell
1553 # NOTE: Keep this in sync with sed_extract_prog above!
1554 sed_extract_field_header='
1555 s/^Description:[ ]*$/description/
1556 s/^Comment:[ ]*$/comment/
1557 s/^Status:[ ]*$/status/
1558 s/^Notice:[ ]*$/notice/
1559 s/^Applicability:[ ]*$/applicability/
1560 s/^Files:[ ]*$/files/
1561 s/^Depends-on:[ ]*$/dependson/
1562 s/^configure\.ac-early:[ ]*$/configureac_early/
1563 s/^configure\.ac:[ ]*$/configureac/
1564 s/^Makefile\.am:[ ]*$/makefile/
1565 s/^Include:[ ]*$/include/
1567 s/^License:[ ]*$/license/
1568 s/^Maintainer:[ ]*$/maintainer/'
1572 if $have_associative; then
1574 # Declare the associative arrays.
1575 declare -A modcache_cached
1576 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1577 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1578 eval "$declare_script"
1582 # func_cache_var module
1583 # computes the cache variable name corresponding to $module.
1584 # Note: This computation can map different module names to the same
1585 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1586 # to protect against this case.
1588 # - cachevar a shell variable name
1589 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1590 # Bash 2.0 and newer, ksh, and zsh support the syntax
1591 # ${param//pattern/replacement}
1592 # as a shorthand for
1593 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1594 # Note: The 'eval' above silences stderr output in dash.
1597 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1604 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1613 # func_init_sed_convert_to_cache_statements
1615 # - modcachevar_assignment
1617 # - sed_convert_to_cache_statements
1618 func_init_sed_convert_to_cache_statements ()
1620 # 'sed' script that turns a module description into shell script
1621 # assignments, suitable to be eval'ed. All active characters are escaped.
1624 # Some module's description
1629 # modcache_description[$1]=\
1630 # 'Some module'"'"'s description
1632 # modcache_files[$1]=\
1635 # c_MODULE_description_set=set; c_MODULE_description=\
1636 # 'Some module'"'"'s description
1638 # c_MODULE_files_set=set; c_MODULE_files=\
1640 # The script consists of two parts:
1641 # 1) Ignore the lines before the first field header.
1642 # 2) A loop, treating non-field-header lines by escaping single quotes
1643 # and adding a closing quote in the last line,
1644 sed_convert_to_cache_statements="
1646 # Here we have not yet seen a field header.
1648 # See if the current line contains a field header.
1651 ${sed_extract_field_header}
1654 # No field header. Ignore the line.
1656 # Read the next line. Upon EOF, just exit.
1661 # The current line contains a field header.
1663 # Turn it into the beginning of an assignment.
1664 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1666 # Move it to the hold space. Don't print it yet,
1667 # because we want no assignment if the field is empty.
1670 # Read the next line.
1671 # Upon EOF, the field was empty. Print no assignment. Just exit.
1674 # See if the current line contains a field header.
1677 ${sed_extract_field_header}
1678 # If it is, the previous field was empty. Print no assignment.
1681 # Not a field header.
1683 # Print the previous line, held in the hold space.
1688 # Transform single quotes.
1691 # Prepend a single quote.
1696 # Move it to the hold space.
1699 # Read the next line.
1706 # See if the current line contains a field header.
1709 ${sed_extract_field_header}
1712 # Print the previous line, held in the hold space.
1717 # Transform single quotes.
1724 # Print the previous line, held in the hold space, with a single quote
1725 # to end the assignment.
1735 # Print the previous line, held in the hold space, with a single quote
1736 # to end the assignment.
1743 if ! $sed_comments; then
1745 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1746 | sed -e 's/^ *//' -e 's/^#.*//'`
1750 if $have_associative; then
1751 # sed_convert_to_cache_statements does not depend on the module.
1752 modcachevar_assignment='modcache_\1[$1]='
1753 func_init_sed_convert_to_cache_statements
1756 # func_cache_lookup_module module
1758 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1759 # of its relevant data in a cache in the memory of the processing shell. If
1760 # already cached, it does not look it up again, thus saving file access time.
1762 # - module non-empty string
1763 # Output if $have_associative:
1764 # - modcache_cached[$module] set to yes
1765 # - modcache_description[$module] ==
1766 # - modcache_status[$module] \ set to the field's value, minus the
1767 # - ... / final newline,
1768 # - modcache_maintainer[$module] == or unset if the field's value is empty
1769 # Output if ! $have_associative:
1770 # - cachevar a shell variable name
1771 # - ${cachevar}_cached set to $module
1772 # - ${cachevar}_description ==
1773 # - ${cachevar}_status \ set to the field's value, minus the
1774 # - ... / final newline,
1775 # - ${cachevar}_maintainer == or unset if the field's value is empty
1776 # - ${cachevar}_description_set ==
1777 # - ${cachevar}_status_set \ set to non-empty if the field's value
1778 # - ... / is non-empty,
1779 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1780 func_cache_lookup_module ()
1782 if $have_associative; then
1783 cached=${modcache_cached[$1]}
1786 eval "cached=\"\$${cachevar}_cached\""
1788 if test -z "$cached"; then
1789 # Not found in cache. Look it up on the file system.
1790 func_lookup_file "modules/$1"
1791 if $have_associative; then
1792 modcache_cached[$1]=yes
1794 eval "${cachevar}_cached=\"\$1\""
1796 if ! $have_associative; then
1797 # sed_convert_to_cache_statements depends on the module.
1798 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1799 func_init_sed_convert_to_cache_statements
1801 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1802 eval "$cache_statements"
1804 if ! $have_associative; then
1805 if test "$1" != "$cached"; then
1806 func_fatal_error "cache variable collision between $1 and $cached"
1814 # func_get_description module
1816 # - local_gnulib_dir from --local-dir
1817 # - modcache true or false, from --cache-modules/--no-cache-modules
1818 func_get_description ()
1820 if ! $modcache; then
1821 func_lookup_file "modules/$1"
1822 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1824 func_cache_lookup_module "$1"
1825 # Output the field's value, including the final newline (if any).
1826 if $have_associative; then
1827 if test -n "${modcache_description[$1]+set}"; then
1828 echo "${modcache_description[$1]}"
1831 eval "field_set=\"\$${cachevar}_description_set\""
1832 if test -n "$field_set"; then
1833 eval "field_value=\"\$${cachevar}_description\""
1834 echo "${field_value}"
1840 # func_get_comment module
1842 # - local_gnulib_dir from --local-dir
1843 # - modcache true or false, from --cache-modules/--no-cache-modules
1846 if ! $modcache; then
1847 func_lookup_file "modules/$1"
1848 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1850 func_cache_lookup_module "$1"
1851 # Output the field's value, including the final newline (if any).
1852 if $have_associative; then
1853 if test -n "${modcache_comment[$1]+set}"; then
1854 echo "${modcache_comment[$1]}"
1857 eval "field_set=\"\$${cachevar}_comment_set\""
1858 if test -n "$field_set"; then
1859 eval "field_value=\"\$${cachevar}_comment\""
1860 echo "${field_value}"
1866 # func_get_status module
1868 # - local_gnulib_dir from --local-dir
1869 # - modcache true or false, from --cache-modules/--no-cache-modules
1872 if ! $modcache; then
1873 func_lookup_file "modules/$1"
1874 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1876 func_cache_lookup_module "$1"
1877 # Output the field's value, including the final newline (if any).
1878 if $have_associative; then
1879 if test -n "${modcache_status[$1]+set}"; then
1880 echo "${modcache_status[$1]}"
1883 eval "field_set=\"\$${cachevar}_status_set\""
1884 if test -n "$field_set"; then
1885 eval "field_value=\"\$${cachevar}_status\""
1886 echo "${field_value}"
1892 # func_get_notice module
1894 # - local_gnulib_dir from --local-dir
1895 # - modcache true or false, from --cache-modules/--no-cache-modules
1898 if ! $modcache; then
1899 func_lookup_file "modules/$1"
1900 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1902 func_cache_lookup_module "$1"
1903 # Output the field's value, including the final newline (if any).
1904 if $have_associative; then
1905 if test -n "${modcache_notice[$1]+set}"; then
1906 echo "${modcache_notice[$1]}"
1909 eval "field_set=\"\$${cachevar}_notice_set\""
1910 if test -n "$field_set"; then
1911 eval "field_value=\"\$${cachevar}_notice\""
1912 echo "${field_value}"
1918 # func_get_applicability module
1920 # - local_gnulib_dir from --local-dir
1921 # - modcache true or false, from --cache-modules/--no-cache-modules
1922 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1923 func_get_applicability ()
1925 if ! $modcache; then
1926 func_lookup_file "modules/$1"
1927 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1929 func_cache_lookup_module "$1"
1930 # Get the field's value, without the final newline.
1931 if $have_associative; then
1932 my_applicability="${modcache_applicability[$1]}"
1934 eval "my_applicability=\"\$${cachevar}_applicability\""
1937 if test -n "$my_applicability"; then
1938 echo $my_applicability
1940 # The default is 'main' or 'tests', depending on the module's name.
1942 *-tests) echo "tests";;
1948 # func_get_filelist module
1950 # - local_gnulib_dir from --local-dir
1951 # - modcache true or false, from --cache-modules/--no-cache-modules
1952 func_get_filelist ()
1954 if ! $modcache; then
1955 func_lookup_file "modules/$1"
1956 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1958 func_cache_lookup_module "$1"
1959 # Output the field's value, including the final newline (if any).
1960 if $have_associative; then
1961 if test -n "${modcache_files[$1]+set}"; then
1962 echo "${modcache_files[$1]}"
1965 eval "field_set=\"\$${cachevar}_files_set\""
1966 if test -n "$field_set"; then
1967 eval "field_value=\"\$${cachevar}_files\""
1968 echo "${field_value}"
1973 echo m4/gnulib-common.m4
1974 case "$autoconf_minversion" in
1981 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1982 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1983 # elements starting with prefix and ending with suffix are considered.
1984 # Processing: removed_prefix and removed_suffix are removed from each element,
1985 # added_prefix and added_suffix are added to each element.
1986 # prefix, suffix should not contain shell-special characters.
1987 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1988 # added_prefix, added_suffix should not contain the characters \|&.
1989 func_filter_filelist ()
1991 if test "$2" != "$nl" \
1992 || { $fast_func_append \
1993 && { test -z "$6" || $fast_func_remove_prefix; } \
1994 && { test -z "$7" || $fast_func_remove_suffix; }; \
1998 # Do not quote possibly-empty parameters in case patterns,
1999 # AIX and HP-UX ksh won't match them if they are empty.
2002 if test -n "$6"; then
2003 func_remove_prefix fff "$6"
2005 if test -n "$7"; then
2006 func_remove_suffix fff "$7"
2009 if test -z "$ffflist"; then
2012 func_append ffflist "$2${fff}"
2018 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2019 ffflist=`for fff in $3; do
2021 $4*$5) echo "$fff" ;;
2023 done | sed -e "$sed_fff_filter"`
2025 eval "$1=\"\$ffflist\""
2028 # func_get_dependencies module
2030 # - local_gnulib_dir from --local-dir
2031 # - modcache true or false, from --cache-modules/--no-cache-modules
2032 func_get_dependencies ()
2034 # ${module}-tests implicitly depends on ${module}, if that module exists.
2038 func_remove_suffix fgd1 '-tests'
2039 if func_exists_module "$fgd1"; then
2044 # Then the explicit dependencies listed in the module description.
2045 if ! $modcache; then
2046 func_lookup_file "modules/$1"
2047 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2049 func_cache_lookup_module "$1"
2050 # Output the field's value, including the final newline (if any).
2051 if $have_associative; then
2052 if test -n "${modcache_dependson[$1]+set}"; then
2053 echo "${modcache_dependson[$1]}"
2056 eval "field_set=\"\$${cachevar}_dependson_set\""
2057 if test -n "$field_set"; then
2058 eval "field_value=\"\$${cachevar}_dependson\""
2059 echo "${field_value}"
2065 # func_get_autoconf_early_snippet module
2067 # - local_gnulib_dir from --local-dir
2068 # - modcache true or false, from --cache-modules/--no-cache-modules
2069 func_get_autoconf_early_snippet ()
2071 if ! $modcache; then
2072 func_lookup_file "modules/$1"
2073 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2075 func_cache_lookup_module "$1"
2076 # Output the field's value, including the final newline (if any).
2077 if $have_associative; then
2078 if test -n "${modcache_configureac_early[$1]+set}"; then
2079 echo "${modcache_configureac_early[$1]}"
2082 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2083 if test -n "$field_set"; then
2084 eval "field_value=\"\$${cachevar}_configureac_early\""
2085 echo "${field_value}"
2091 # func_get_autoconf_snippet module
2093 # - local_gnulib_dir from --local-dir
2094 # - modcache true or false, from --cache-modules/--no-cache-modules
2095 func_get_autoconf_snippet ()
2097 if ! $modcache; then
2098 func_lookup_file "modules/$1"
2099 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2101 func_cache_lookup_module "$1"
2102 # Output the field's value, including the final newline (if any).
2103 if $have_associative; then
2104 if test -n "${modcache_configureac[$1]+set}"; then
2105 echo "${modcache_configureac[$1]}"
2108 eval "field_set=\"\$${cachevar}_configureac_set\""
2109 if test -n "$field_set"; then
2110 eval "field_value=\"\$${cachevar}_configureac\""
2111 echo "${field_value}"
2117 # func_get_automake_snippet module
2119 # - local_gnulib_dir from --local-dir
2120 # - modcache true or false, from --cache-modules/--no-cache-modules
2121 func_get_automake_snippet ()
2123 if ! $modcache; then
2124 func_lookup_file "modules/$1"
2125 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2127 func_cache_lookup_module "$1"
2128 # Output the field's value, including the final newline (if any).
2129 if $have_associative; then
2130 if test -n "${modcache_makefile[$1]+set}"; then
2131 echo "${modcache_makefile[$1]}"
2134 eval "field_set=\"\$${cachevar}_makefile_set\""
2135 if test -n "$field_set"; then
2136 eval "field_value=\"\$${cachevar}_makefile\""
2137 echo "${field_value}"
2143 # *-tests module live in tests/, not lib/.
2144 # Synthesize an EXTRA_DIST augmentation.
2145 all_files=`func_get_filelist $1`
2146 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2147 extra_files="$tests_files"
2148 if test -n "$extra_files"; then
2149 echo "EXTRA_DIST +=" $extra_files
2154 # Synthesize an EXTRA_DIST augmentation.
2155 sed_combine_lines='/\\$/{
2162 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2163 already_mentioned_files=` \
2164 { if ! $modcache; then
2165 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2167 if $have_associative; then
2168 if test -n "${modcache_makefile[$1]+set}"; then
2169 echo "${modcache_makefile[$1]}"
2172 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2173 if test -n "$field_set"; then
2174 eval 'field_value="$'"${cachevar}"'_makefile"'
2175 echo "${field_value}"
2180 | sed -e "$sed_combine_lines" \
2181 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2182 all_files=`func_get_filelist $1`
2183 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2184 # Remove $already_mentioned_files from $lib_files.
2185 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2186 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2187 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2188 if test -n "$extra_files"; then
2189 echo "EXTRA_DIST +=" $extra_files
2192 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2193 # This is necessary so that automake can generate the right list of
2195 # A possible approach would be to use autom4te --trace of the redefined
2196 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2197 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2198 # inside autoconf's built-in macros are not missed).
2199 # But it's simpler and more robust to do it here, based on the file list.
2200 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2201 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2202 # automake will generate a useless dependency; this is harmless.
2204 relocatable-prog-wrapper) ;;
2206 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2207 if test -n "$extra_files"; then
2208 echo "EXTRA_lib_SOURCES +=" $extra_files
2213 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2214 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2215 if test -n "$buildaux_files"; then
2216 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2217 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2220 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2221 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2222 if test -n "$top_files"; then
2223 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2224 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2231 # func_get_include_directive module
2233 # - local_gnulib_dir from --local-dir
2234 # - modcache true or false, from --cache-modules/--no-cache-modules
2235 func_get_include_directive ()
2238 if ! $modcache; then
2239 func_lookup_file "modules/$1"
2240 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2242 func_cache_lookup_module "$1"
2243 # Output the field's value, including the final newline (if any).
2244 if $have_associative; then
2245 if test -n "${modcache_include[$1]+set}"; then
2246 echo "${modcache_include[$1]}"
2249 eval "field_set=\"\$${cachevar}_include_set\""
2250 if test -n "$field_set"; then
2251 eval "field_value=\"\$${cachevar}_include\""
2252 echo "${field_value}"
2256 } | sed -e 's/^\(["<]\)/#include \1/'
2259 # func_get_link_directive module
2261 # - local_gnulib_dir from --local-dir
2262 # - modcache true or false, from --cache-modules/--no-cache-modules
2263 func_get_link_directive ()
2265 if ! $modcache; then
2266 func_lookup_file "modules/$1"
2267 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2269 func_cache_lookup_module "$1"
2270 # Output the field's value, including the final newline (if any).
2271 if $have_associative; then
2272 if test -n "${modcache_link[$1]+set}"; then
2273 echo "${modcache_link[$1]}"
2276 eval "field_set=\"\$${cachevar}_link_set\""
2277 if test -n "$field_set"; then
2278 eval "field_value=\"\$${cachevar}_link\""
2279 echo "${field_value}"
2285 # func_get_license module
2287 # - local_gnulib_dir from --local-dir
2288 # - modcache true or false, from --cache-modules/--no-cache-modules
2292 if ! $modcache; then
2293 func_lookup_file "modules/$1"
2294 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2296 func_cache_lookup_module "$1"
2297 # Output the field's value, including the final newline (if any).
2298 if $have_associative; then
2299 if test -n "${modcache_license[$1]+set}"; then
2300 echo "${modcache_license[$1]}"
2303 eval "field_set=\"\$${cachevar}_license_set\""
2304 if test -n "$field_set"; then
2305 eval "field_value=\"\$${cachevar}_license\""
2306 echo "${field_value}"
2310 # The default is GPL.
2312 } | sed -e 's,^ *$,,' | sed -e 1q
2315 # func_get_maintainer module
2317 # - local_gnulib_dir from --local-dir
2318 # - modcache true or false, from --cache-modules/--no-cache-modules
2319 func_get_maintainer ()
2321 if ! $modcache; then
2322 func_lookup_file "modules/$1"
2323 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2325 func_cache_lookup_module "$1"
2326 # Output the field's value, including the final newline (if any).
2327 if $have_associative; then
2328 if test -n "${modcache_maintainer[$1]+set}"; then
2329 echo "${modcache_maintainer[$1]}"
2332 eval "field_set=\"\$${cachevar}_maintainer_set\""
2333 if test -n "$field_set"; then
2334 eval "field_value=\"\$${cachevar}_maintainer\""
2335 echo "${field_value}"
2341 # func_get_tests_module module
2343 # - local_gnulib_dir from --local-dir
2344 func_get_tests_module ()
2346 # The naming convention for tests modules is hardwired: ${module}-tests.
2347 if test -f "$gnulib_dir/modules/$1"-tests \
2348 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2349 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2354 # func_acceptable module
2355 # tests whether a module is acceptable.
2357 # - avoidlist list of modules to avoid
2360 for avoid in $avoidlist; do
2361 if test "$avoid" = "$1"; then
2368 # func_modules_transitive_closure
2370 # - local_gnulib_dir from --local-dir
2371 # - modcache true or false, from --cache-modules/--no-cache-modules
2372 # - modules list of specified modules
2373 # - inctests true if tests should be included, blank otherwise
2374 # - incobsolete true if obsolete modules among dependencies should be
2375 # included, blank otherwise
2376 # - inc_cxx_tests true if C++ interoperability tests should be included,
2378 # - inc_longrunning_tests true if long-runnings tests should be included,
2380 # - inc_privileged_tests true if tests that require root privileges should be
2381 # included, blank otherwise
2382 # - inc_unportable_tests true if tests that fail on some platforms should be
2383 # included, blank otherwise
2384 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2385 # the unit tests of the specified modules should be
2386 # included, blank otherwise
2387 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2388 # the unit tests of the dependencies should be
2389 # included, blank otherwise
2390 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2392 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2394 # - excl_privileged_tests true if tests that require root privileges should be
2395 # excluded, blank otherwise
2396 # - excl_unportable_tests true if tests that fail on some platforms should be
2397 # excluded, blank otherwise
2398 # - avoidlist list of modules to avoid
2399 # - tmp pathname of a temporary directory
2401 # - modules list of modules, including dependencies
2402 func_modules_transitive_closure ()
2404 # In order to process every module only once (for speed), process an "input
2405 # list" of modules, producing an "output list" of modules. During each round,
2406 # more modules can be queued in the input list. Once a module on the input
2407 # list has been processed, it is added to the "handled list", so we can avoid
2408 # to process it again.
2410 inmodules="$modules"
2412 fmtc_inc_all_tests="$inc_all_direct_tests"
2413 while test -n "$inmodules"; do
2414 inmodules_this_round="$inmodules"
2415 inmodules= # Accumulator, queue for next round
2416 for module in $inmodules_this_round; do
2418 if test -n "$module"; then
2419 if func_acceptable $module; then
2420 func_append outmodules " $module"
2421 deps=`func_get_dependencies $module`
2422 # Duplicate dependencies are harmless, but Jim wants a warning.
2423 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2424 if test -n "$duplicated_deps"; then
2425 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2427 if test -n "$inctests"; then
2428 testsmodule=`func_get_tests_module $module`
2429 if test -n "$testsmodule"; then
2430 deps="$deps $testsmodule"
2433 for dep in $deps; do
2434 # Determine whether to include the dependency or tests module.
2436 for word in `func_get_status $dep`; do
2439 test -n "$incobsolete" \
2443 test -z "$excl_cxx_tests" \
2445 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2449 test -z "$excl_longrunning_tests" \
2451 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2455 test -z "$excl_privileged_tests" \
2457 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2461 test -z "$excl_unportable_tests" \
2463 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2467 test -n "$fmtc_inc_all_tests" \
2473 func_append inmodules " $dep"
2479 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2480 # Remove $handledmodules from $inmodules.
2481 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2482 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2483 fmtc_inc_all_tests="$inc_all_indirect_tests"
2485 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2486 rm -f "$tmp"/queued-modules
2489 # func_show_module_list
2491 # - specified_modules list of specified modules (one per line, sorted)
2492 # - modules complete list of modules (one per line, sorted)
2493 # - tmp pathname of a temporary directory
2494 func_show_module_list ()
2500 # Assume xterm compatible escape sequences.
2501 bold_on=`printf '\x1b[1m'`
2502 bold_off=`printf '\x1b[0m'`
2507 echo "Module list with included dependencies (indented):"
2508 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2509 echo "$modules" | sed -e '/^$/d' \
2510 | LC_ALL=C join -t '|' -a 2 "$tmp"/specified-modules - \
2511 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2514 # func_modules_add_dummy
2516 # - local_gnulib_dir from --local-dir
2517 # - modcache true or false, from --cache-modules/--no-cache-modules
2518 # - modules list of modules, including dependencies
2520 # - modules list of modules, including 'dummy' if needed
2521 func_modules_add_dummy ()
2523 # Determine whether any module provides a lib_SOURCES augmentation.
2525 sed_remove_backslash_newline=':a
2532 for module in $modules; do
2533 func_verify_nontests_module
2534 if test -n "$module"; then
2535 # Extract the value of "lib_SOURCES += ...".
2536 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2537 # Ignore .h files since they are not compiled.
2541 have_lib_SOURCES=yes
2548 # Add the dummy module, to make sure the library will be non-empty.
2549 if test -z "$have_lib_SOURCES"; then
2550 if func_acceptable "dummy"; then
2551 func_append modules " dummy"
2556 # func_modules_notice
2558 # - local_gnulib_dir from --local-dir
2559 # - modcache true or false, from --cache-modules/--no-cache-modules
2560 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2561 # - modules list of modules, including dependencies
2562 func_modules_notice ()
2564 if test $verbose -ge -1; then
2565 for module in $modules; do
2567 if test -n "$module"; then
2568 msg=`func_get_notice $module`
2569 if test -n "$msg"; then
2570 echo "Notice from module $module:"
2571 echo "$msg" | sed -e 's/^/ /'
2578 # func_modules_to_filelist
2580 # - local_gnulib_dir from --local-dir
2581 # - modcache true or false, from --cache-modules/--no-cache-modules
2582 # - modules list of modules, including dependencies
2584 # - files list of files
2585 func_modules_to_filelist ()
2588 for module in $modules; do
2590 if test -n "$module"; then
2591 fs=`func_get_filelist $module`
2592 func_append files " $fs"
2595 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2598 # func_execute_command command [args...]
2599 # Executes a command.
2600 # Uses also the variables
2601 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2602 func_execute_command ()
2604 if test $verbose -ge 0; then
2608 # Commands like automake produce output to stderr even when they succeed.
2609 # Turn this output off if the command succeeds.
2610 "$@" > "$tmp"/cmdout 2>&1
2612 if test $cmdret = 0; then
2616 cat "$tmp"/cmdout 1>&2
2623 # func_dest_tmpfilename file
2624 # determines the name of a temporary file (file is relative to destdir).
2626 # - destdir target directory
2627 # - doit : if actions shall be executed, false if only to be printed
2628 # - tmp pathname of a temporary directory
2630 # - tmpfile absolute filename of the temporary file
2631 func_dest_tmpfilename ()
2634 # Put the new contents of $file in a file in the same directory (needed
2635 # to guarantee that an 'mv' to "$destdir/$file" works).
2636 tmpfile="$destdir/$1.tmp"
2638 # Put the new contents of $file in a file in a temporary directory
2639 # (because the directory of "$file" might not exist).
2640 tmpfile="$tmp"/`basename "$1"`.tmp
2645 # copies a file from gnulib into the destination directory. The destination
2646 # is known to not exist.
2648 # - destdir target directory
2649 # - local_gnulib_dir from --local-dir
2650 # - modcache true or false, from --cache-modules/--no-cache-modules
2651 # - f the original file name
2652 # - lookedup_file name of the merged (combined) file
2653 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2654 # - g the rewritten file name
2655 # - tmpfile absolute filename of the temporary file
2656 # - doit : if actions shall be executed, false if only to be printed
2657 # - symbolic true if files should be symlinked, copied otherwise
2658 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2663 echo "Copying file $g"
2664 if { test -n "$symbolic" \
2665 || { test -n "$lsymbolic" \
2666 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2667 && test -z "$lookedup_tmp" \
2668 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2669 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2671 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2679 # copies a file from gnulib into the destination directory. The destination
2680 # is known to exist.
2682 # - destdir target directory
2683 # - local_gnulib_dir from --local-dir
2684 # - modcache true or false, from --cache-modules/--no-cache-modules
2685 # - f the original file name
2686 # - lookedup_file name of the merged (combined) file
2687 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2688 # - g the rewritten file name
2689 # - tmpfile absolute filename of the temporary file
2690 # - doit : if actions shall be executed, false if only to be printed
2691 # - symbolic true if files should be symlinked, copied otherwise
2692 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2694 # - already_present nonempty if the file should already exist, empty otherwise
2697 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2698 : # The file has not changed.
2702 if test -n "$already_present"; then
2703 echo "Updating file $g (backup in ${g}~)"
2705 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2707 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2708 if { test -n "$symbolic" \
2709 || { test -n "$lsymbolic" \
2710 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2711 && test -z "$lookedup_tmp" \
2712 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2713 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2715 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2718 if test -n "$already_present"; then
2719 echo "Update file $g (backup in ${g}~)"
2721 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2727 # func_emit_lib_Makefile_am
2728 # emits the contents of library makefile to standard output.
2730 # - local_gnulib_dir from --local-dir
2731 # - modcache true or false, from --cache-modules/--no-cache-modules
2732 # - modules list of modules, including dependencies
2733 # - libname library name
2734 # - pobase directory relative to destdir where to place *.po files
2735 # - auxdir directory relative to destdir where to place build aux files
2736 # - makefile_name from --makefile-name
2737 # - libtool true if libtool will be used, false or blank otherwise
2738 # - macro_prefix prefix of gl_LIBOBJS macros to use
2739 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2740 # - actioncmd (optional) command that will reproduce this invocation
2741 # - for_test true if creating a package for testing, false otherwise
2742 # - destfile filename relative to destdir of makefile being generated
2744 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2745 # list of edits to be done to Makefile.am variables
2747 # - uses_subdirs nonempty if object files in subdirs exist
2748 func_emit_lib_Makefile_am ()
2750 # When creating an includable Makefile.am snippet, augment variables with
2751 # += instead of assigning them.
2752 if test -n "$makefile_name"; then
2757 if test "$libtool" = true; then
2760 sed_eliminate_LDFLAGS="$sed_noop"
2764 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2767 # When creating a package for testing: Attempt to provoke failures,
2768 # especially link errors, already during "make" rather than during
2769 # "make check", because "make check" is not possible in a cross-compiling
2770 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2771 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2773 sed_transform_check_PROGRAMS="$sed_noop"
2775 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2776 echo "## Process this file with automake to produce Makefile.in."
2777 func_emit_copyright_notice
2778 if test -n "$actioncmd"; then
2779 # The maximum line length (excluding the terminating newline) of any file
2780 # that is to be preprocessed by config.status is 3070. config.status uses
2781 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2782 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2783 len=`echo "$actioncmd" | wc -c`
2784 if test -n "$len" && test "$len" -le 3000; then
2785 echo "# Reproduce by: $actioncmd"
2791 for module in $modules; do
2792 func_verify_nontests_module
2793 if test -n "$module"; then
2795 func_get_automake_snippet "$module" |
2797 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2798 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2799 -e "$sed_eliminate_LDFLAGS" \
2800 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2801 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2802 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2803 -e "$sed_transform_check_PROGRAMS"
2804 if test "$module" = 'alloca'; then
2805 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2806 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2808 } > "$tmp"/amsnippet
2809 # Skip the contents if it's entirely empty.
2810 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2811 echo "## begin gnulib module $module"
2813 cat "$tmp"/amsnippet
2814 echo "## end gnulib module $module"
2817 rm -f "$tmp"/amsnippet
2818 # Test whether there are some source files in subdirectories.
2819 for f in `func_get_filelist "$module"`; do
2829 } > "$tmp"/allsnippets
2830 if test -z "$makefile_name"; then
2831 # If there are source files in subdirectories, prevent collision of the
2832 # object files (example: hash.c and libxml/hash.c).
2834 if test -n "$uses_subdirs"; then
2835 subdir_options=' subdir-objects'
2837 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2840 if test -z "$makefile_name"; then
2842 echo "noinst_HEADERS ="
2843 echo "noinst_LIBRARIES ="
2844 echo "noinst_LTLIBRARIES ="
2845 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2846 # if you specify pkgdata_DATA to empty. This is a workaround.
2847 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2848 echo "pkgdata_DATA ="
2851 echo "BUILT_SOURCES ="
2854 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2855 if test -z "$makefile_name"; then
2856 echo "MOSTLYCLEANDIRS ="
2858 echo "DISTCLEANFILES ="
2859 echo "MAINTAINERCLEANFILES ="
2861 # Execute edits that apply to the Makefile.am being generated.
2863 while test $edit != $makefile_am_edits; do
2864 edit=`expr $edit + 1`
2865 eval dir=\"\$makefile_am_edit${edit}_dir\"
2866 eval var=\"\$makefile_am_edit${edit}_var\"
2867 eval val=\"\$makefile_am_edit${edit}_val\"
2868 if test -n "$var"; then
2869 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2870 echo "${var} += ${val}"
2871 eval "makefile_am_edit${edit}_var="
2875 if test -z "$makefile_name"; then
2878 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
2880 echo "AM_CPPFLAGS ="
2885 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2886 || { test -n "$makefile_name" \
2887 && test -f "$sourcebase/Makefile.am" \
2888 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2890 # One of the snippets or the user's Makefile.am already specifies an
2891 # installation location for the library. Don't confuse automake by saying
2892 # it should not be installed.
2895 # By default, the generated library should not be installed.
2896 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2899 echo "${libname}_${libext}_SOURCES ="
2900 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2901 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2902 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2903 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2904 echo "EXTRA_${libname}_${libext}_SOURCES ="
2905 if test "$libtool" = true; then
2906 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2909 if test -n "$pobase"; then
2910 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2913 cat "$tmp"/allsnippets \
2914 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2916 echo "mostlyclean-local: mostlyclean-generic"
2917 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2918 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2919 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2923 rm -f "$tmp"/allsnippets
2926 # func_emit_po_Makevars
2927 # emits the contents of po/ makefile parameterization to standard output.
2929 # - local_gnulib_dir from --local-dir
2930 # - modcache true or false, from --cache-modules/--no-cache-modules
2931 # - sourcebase directory relative to destdir where to place source code
2932 # - pobase directory relative to destdir where to place *.po files
2933 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2934 func_emit_po_Makevars ()
2936 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2937 func_emit_copyright_notice
2939 echo "# Usually the message domain is the same as the package name."
2940 echo "# But here it has a '-gnulib' suffix."
2941 echo "DOMAIN = ${po_domain}-gnulib"
2943 echo "# These two variables depend on the location of this directory."
2944 echo "subdir = ${pobase}"
2945 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2948 # These options get passed to xgettext.
2949 XGETTEXT_OPTIONS = \
2950 --keyword=_ --flag=_:1:pass-c-format \
2951 --keyword=N_ --flag=N_:1:pass-c-format \
2952 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2953 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2954 --flag=error:3:c-format --flag=error_at_line:5:c-format
2956 # This is the copyright holder that gets inserted into the header of the
2957 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2958 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2960 # This is the email address or URL to which the translators shall report
2961 # bugs in the untranslated strings:
2962 # - Strings which are not entire sentences, see the maintainer guidelines
2963 # in the GNU gettext documentation, section 'Preparing Strings'.
2964 # - Strings which use unclear terms or require additional context to be
2966 # - Strings which make invalid assumptions about notation of date, time or
2968 # - Pluralisation problems.
2969 # - Incorrect English spelling.
2970 # - Incorrect formatting.
2971 # It can be your email address, or a mailing list address where translators
2972 # can write to without being subscribed, or the URL of a web page through
2973 # which the translators can contact you.
2974 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2976 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2977 # message catalogs shall be used. It is usually empty.
2978 EXTRA_LOCALE_CATEGORIES =
2980 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2981 # context. Possible values are "yes" and "no". Set this to yes if the
2982 # package uses functions taking also a message context, like pgettext(), or
2983 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2988 # func_emit_po_POTFILES_in
2989 # emits the file list to be passed to xgettext to standard output.
2991 # - local_gnulib_dir from --local-dir
2992 # - modcache true or false, from --cache-modules/--no-cache-modules
2993 # - sourcebase directory relative to destdir where to place source code
2994 # - files list of new files
2995 func_emit_po_POTFILES_in ()
2997 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2998 func_emit_copyright_notice
3000 echo "# List of files which contain translatable strings."
3001 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3004 # func_emit_tests_Makefile_am witness_macro
3005 # emits the contents of tests makefile to standard output.
3007 # - local_gnulib_dir from --local-dir
3008 # - modcache true or false, from --cache-modules/--no-cache-modules
3009 # - modules list of modules, including dependencies
3010 # - libname library name
3011 # - auxdir directory relative to destdir where to place build aux files
3012 # - makefile_name from --makefile-name
3013 # - libtool true if libtool will be used, false or blank otherwise
3014 # - sourcebase relative directory containing lib source code
3015 # - m4base relative directory containing autoconf macros
3016 # - testsbase relative directory containing unit test code
3017 # - macro_prefix prefix of gl_LIBOBJS macros to use
3018 # - for_test true if creating a package for testing, false otherwise
3019 # - use_libtests true if a libtests.a should be built, false otherwise
3020 # - destfile filename relative to destdir of makefile being generated
3022 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3023 # list of edits to be done to Makefile.am variables
3025 # - uses_subdirs nonempty if object files in subdirs exist
3026 func_emit_tests_Makefile_am ()
3029 if test "$libtool" = true; then
3031 sed_eliminate_LDFLAGS="$sed_noop"
3034 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3037 # When creating a package for testing: Attempt to provoke failures,
3038 # especially link errors, already during "make" rather than during
3039 # "make check", because "make check" is not possible in a cross-compiling
3040 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3041 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3043 sed_transform_check_PROGRAMS="$sed_noop"
3045 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3046 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3047 echo "## Process this file with automake to produce Makefile.in."
3048 func_emit_copyright_notice
3052 for module in $modules; do
3054 func_verify_tests_module
3058 if test -n "$module"; then
3060 func_get_automake_snippet "$module" |
3062 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3063 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3064 -e "$sed_eliminate_LDFLAGS" \
3065 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3066 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3067 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3068 -e "$sed_transform_check_PROGRAMS"
3069 if $use_libtests && test "$module" = 'alloca'; then
3070 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3071 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3073 } > "$tmp"/amsnippet
3074 # Skip the contents if it's entirely empty.
3075 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3076 # Mention long-running tests at the end.
3078 for word in `func_get_status "$module"`; do
3079 if test "$word" = 'longrunning-test'; then
3084 { echo "## begin gnulib module $module"
3086 cat "$tmp"/amsnippet
3087 echo "## end gnulib module $module"
3091 rm -f "$tmp"/amsnippet
3092 # Test whether there are some source files in subdirectories.
3093 for f in `func_get_filelist "$module"`; do
3095 lib/*/*.c | tests/*/*.c)
3103 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3104 # Generate dependencies here, since it eases the debugging of test failures.
3105 # If there are source files in subdirectories, prevent collision of the
3106 # object files (example: hash.c and libxml/hash.c).
3108 if test -n "$uses_subdirs"; then
3109 subdir_options=' subdir-objects'
3111 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3114 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3117 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3118 # variable is needed to avoid an error from automake:
3119 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3122 echo "XFAIL_TESTS ="
3123 echo "TESTS_ENVIRONMENT ="
3124 echo "noinst_PROGRAMS ="
3125 if ! $for_test; then
3126 echo "check_PROGRAMS ="
3128 echo "noinst_HEADERS ="
3129 echo "noinst_LIBRARIES ="
3130 if $use_libtests; then
3132 echo "noinst_LIBRARIES += libtests.a"
3134 echo "check_LIBRARIES = libtests.a"
3137 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3138 # if you specify pkgdata_DATA to empty. This is a workaround.
3139 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3140 echo "pkgdata_DATA ="
3143 echo "BUILT_SOURCES ="
3145 echo "MOSTLYCLEANFILES = core *.stackdump"
3146 echo "MOSTLYCLEANDIRS ="
3148 echo "DISTCLEANFILES ="
3149 echo "MAINTAINERCLEANFILES ="
3150 # Execute edits that apply to the Makefile.am being generated.
3152 while test $edit != $makefile_am_edits; do
3153 edit=`expr $edit + 1`
3154 eval dir=\"\$makefile_am_edit${edit}_dir\"
3155 eval var=\"\$makefile_am_edit${edit}_var\"
3156 eval val=\"\$makefile_am_edit${edit}_val\"
3157 if test -n "$var"; then
3158 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3159 echo "${var} += ${val}"
3160 eval "makefile_am_edit${edit}_var="
3165 echo "AM_CPPFLAGS = \\"
3167 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3169 if test -n "${witness_macro}"; then
3170 echo " -D@${witness_macro}@=1 \\"
3172 echo " -I. -I\$(srcdir) \\"
3173 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3174 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3176 local_ldadd_before=''
3177 local_ldadd_after=''
3178 if $use_libtests; then
3179 # All test programs need to be linked with libtests.a.
3180 # It needs to be passed to the linker before ${libname}.${libext}, since
3181 # the tests-related modules depend on the main modules.
3182 # It also needs to be passed to the linker after ${libname}.${libext}
3183 # because the latter might contain incomplete modules (such as the 'error'
3184 # module whose dependency to 'progname' is voluntarily omitted).
3185 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3187 local_ldadd_before=' libtests.a'
3188 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3190 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3192 if $use_libtests; then
3193 echo "libtests_a_SOURCES ="
3194 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3195 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3196 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3197 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3198 echo "EXTRA_libtests_a_SOURCES ="
3199 # The circular dependency in LDADD requires this.
3200 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3203 # Many test scripts use ${EXEEXT} or ${srcdir}.
3204 # EXEEXT is defined by AC_PROG_CC through autoconf.
3205 # srcdir is defined by autoconf and automake.
3206 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3208 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3209 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3210 echo "# Clean up after Solaris cc."
3212 echo " rm -rf SunWS_cache"
3214 echo "mostlyclean-local: mostlyclean-generic"
3215 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3216 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3217 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3221 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3224 # func_emit_initmacro_start macro_prefix
3225 # emits the first few statements of the gl_INIT macro to standard output.
3226 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3227 func_emit_initmacro_start ()
3229 macro_prefix_arg="$1"
3230 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3231 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3232 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3233 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3235 # Furthermore it avoids an automake error like this when a Makefile.am
3236 # that uses pieces of gnulib also uses $(LIBOBJ):
3237 # automatically discovered file `error.c' should not be explicitly mentioned
3238 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3239 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3240 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3241 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3242 # automatically discovered file `error.c' should not be explicitly mentioned
3243 # We let automake know about the files to be distributed through the
3244 # EXTRA_lib_SOURCES variable.
3245 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3246 # Create data variables for checking the presence of files that are mentioned
3247 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3248 # because we want the check to happen when the configure file is created,
3249 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3250 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3251 # in which to expect them.
3252 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3253 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3257 # func_emit_initmacro_end macro_prefix
3258 # emits the last few statements of the gl_INIT macro to standard output.
3259 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3260 func_emit_initmacro_end ()
3262 macro_prefix_arg="$1"
3263 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3264 # The check is performed only when autoconf is run from the directory where
3265 # the configure.ac resides; if it is run from a different directory, the
3267 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3268 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3269 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3270 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3271 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3275 echo " m4_if(m4_sysval, [0], [],"
3276 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3278 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3279 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3280 echo " m4_popdef([AC_LIBSOURCES])"
3281 echo " m4_popdef([AC_REPLACE_FUNCS])"
3282 echo " m4_popdef([AC_LIBOBJ])"
3283 echo " AC_CONFIG_COMMANDS_PRE(["
3284 echo " ${macro_prefix_arg}_libobjs="
3285 echo " ${macro_prefix_arg}_ltlibobjs="
3286 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3287 echo " # Remove the extension."
3288 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3289 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3290 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3291 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3294 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3295 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3299 # func_emit_initmacro_done macro_prefix sourcebase
3300 # emits a few statements after the gl_INIT macro to standard output.
3301 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3302 # - sourcebase directory relative to destdir where to place source code
3303 func_emit_initmacro_done ()
3305 macro_prefix_arg="$1"
3308 echo "# Like AC_LIBOBJ, except that the module name goes"
3309 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3310 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3311 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3312 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3315 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3316 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3317 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3318 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3319 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3322 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3323 echo "# expected is derived from the gnulib-tool parameterization,"
3324 echo "# and alloca is special cased (for the alloca-opt module)."
3325 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3326 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3327 echo " m4_foreach([_gl_NAME], [\$1], ["
3328 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3329 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3330 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3336 # func_import modules
3337 # Uses also the variables
3338 # - mode import or add-import or remove-import or update
3339 # - destdir target directory
3340 # - local_gnulib_dir from --local-dir
3341 # - modcache true or false, from --cache-modules/--no-cache-modules
3342 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3343 # - libname library name
3344 # - supplied_libname true if --lib was given, blank otherwise
3345 # - sourcebase directory relative to destdir where to place source code
3346 # - m4base directory relative to destdir where to place *.m4 macros
3347 # - pobase directory relative to destdir where to place *.po files
3348 # - docbase directory relative to destdir where to place doc files
3349 # - testsbase directory relative to destdir where to place unit test code
3350 # - auxdir directory relative to destdir where to place build aux files
3351 # - inctests true if --with-tests was given, blank otherwise
3352 # - incobsolete true if --with-obsolete was given, blank otherwise
3353 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3354 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3356 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3358 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3360 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3361 # - avoidlist list of modules to avoid, from --avoid
3362 # - lgpl yes or a number if library's license shall be LGPL,
3364 # - makefile_name from --makefile-name
3365 # - libtool true if --libtool was given, false if --no-libtool was
3366 # given, blank otherwise
3367 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3368 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3369 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3370 # - vc_files true if --vc-files was given, false if --no-vc-files was
3371 # given, blank otherwise
3372 # - autoconf_minversion minimum supported autoconf version
3373 # - doit : if actions shall be executed, false if only to be printed
3374 # - symbolic true if files should be symlinked, copied otherwise
3375 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3377 # - do_copyrights true if copyright notices in files should be replaced,
3381 # Get the cached settings.
3382 # In 'import' mode, we read them only for the purpose of knowing the old
3383 # installed file list, and don't use them as defaults.
3384 cached_local_gnulib_dir=
3385 cached_specified_modules=
3387 cached_inc_cxx_tests=
3388 cached_inc_longrunning_tests=
3389 cached_inc_privileged_tests=
3390 cached_inc_unportable_tests=
3391 cached_inc_all_tests=
3401 cached_makefile_name=
3403 cached_macro_prefix=
3407 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3408 cached_libtool=false
3414 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3424 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3426 /gl_WITH_OBSOLETE/ {
3427 s,^.*$,cached_incobsolete=true,p
3429 /gl_WITH_CXX_TESTS/ {
3430 s,^.*$,cached_inc_cxx_tests=true,p
3432 /gl_WITH_LONGRUNNING_TESTS/ {
3433 s,^.*$,cached_inc_longrunning_tests=true,p
3435 /gl_WITH_PRIVILEGED_TESTS/ {
3436 s,^.*$,cached_inc_privileged_tests=true,p
3438 /gl_WITH_UNPORTABLE_TESTS/ {
3439 s,^.*$,cached_inc_unportable_tests=true,p
3441 /gl_WITH_ALL_TESTS/ {
3442 s,^.*$,cached_inc_all_tests=true,p
3445 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3448 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3451 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3454 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3457 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3460 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3463 s,^.*$,cached_inctests=true,p
3466 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3469 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3472 s,^.*$,cached_lgpl=yes,p
3474 /gl_MAKEFILE_NAME(/ {
3475 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3478 s,^.*$,cached_libtool=true,p
3480 /gl_MACRO_PREFIX(/ {
3481 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3484 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3487 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3489 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3490 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3495 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3496 s,^.*$,cached_files=",p
3509 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3513 if test "$mode" = import; then
3514 # In 'import' mode, the new set of specified modules overrides the cached
3515 # set of modules. Ignore the cached settings.
3516 specified_modules="$1"
3518 # Merge the cached settings with the specified ones.
3519 # The m4base must be the same as expected from the pathname.
3520 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3521 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3523 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3524 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3525 if test -z "$local_gnulib_dir"; then
3526 if test -n "$cached_local_gnulib_dir"; then
3529 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3531 case "$cached_local_gnulib_dir" in
3533 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3535 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3536 local_gnulib_dir="$relconcat" ;;
3543 # Append the cached and the specified module names. So that
3544 # "gnulib-tool --add-import foo" means to add the module foo.
3545 specified_modules="$cached_specified_modules $1"
3548 # Take the cached module names, minus the specified module names.
3550 if $have_associative; then
3551 # Use an associative array, for O(N) worst-case run time.
3552 declare -A to_remove
3556 for module in $cached_specified_modules; do
3557 if test -z "${to_remove[$module]}"; then
3558 func_append specified_modules "$module "
3562 # This loop has O(N²) worst-case run time.
3563 for module in $cached_specified_modules; do
3566 if test "$m" = "$module"; then
3571 if test -z "$to_remove"; then
3572 func_append specified_modules "$module "
3578 # Take the cached module names. There are no specified module names.
3579 specified_modules="$cached_specified_modules"
3582 # Included obsolete modules among the dependencies if specified either way.
3583 if test -z "$incobsolete"; then
3584 incobsolete="$cached_incobsolete"
3586 # Included special kinds of tests modules among the dependencies if specified
3588 if test -z "$inc_cxx_tests"; then
3589 inc_cxx_tests="$cached_inc_cxx_tests"
3591 if test -z "$inc_longrunning_tests"; then
3592 inc_longrunning_tests="$cached_inc_longrunning_tests"
3594 if test -z "$inc_privileged_tests"; then
3595 inc_privileged_tests="$cached_inc_privileged_tests"
3597 if test -z "$inc_unportable_tests"; then
3598 inc_unportable_tests="$cached_inc_unportable_tests"
3600 if test -z "$inc_all_tests"; then
3601 inc_all_tests="$cached_inc_all_tests"
3603 # Append the cached and the specified avoidlist. This is probably better
3604 # than dropping the cached one when --avoid is specified at least once.
3605 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3606 avoidlist=`echo $avoidlist`
3608 # The sourcebase defaults to the cached one.
3609 if test -z "$sourcebase"; then
3610 sourcebase="$cached_sourcebase"
3611 if test -z "$sourcebase"; then
3612 func_fatal_error "missing --source-base option"
3615 # The pobase defaults to the cached one.
3616 if test -z "$pobase"; then
3617 pobase="$cached_pobase"
3619 # The docbase defaults to the cached one.
3620 if test -z "$docbase"; then
3621 docbase="$cached_docbase"
3622 if test -z "$docbase"; then
3623 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."
3626 # The testsbase defaults to the cached one.
3627 if test -z "$testsbase"; then
3628 testsbase="$cached_testsbase"
3629 if test -z "$testsbase"; then
3630 func_fatal_error "missing --tests-base option"
3633 # Require the tests if specified either way.
3634 if test -z "$inctests"; then
3635 inctests="$cached_inctests"
3637 # The libname defaults to the cached one.
3638 if test -z "$supplied_libname"; then
3639 libname="$cached_libname"
3640 if test -z "$libname"; then
3641 func_fatal_error "missing --lib option"
3644 # Require LGPL if specified either way.
3645 if test -z "$lgpl"; then
3648 # The makefile_name defaults to the cached one.
3649 if test -z "$makefile_name"; then
3650 makefile_name="$cached_makefile_name"
3652 # Use libtool if specified either way, or if guessed.
3653 if test -z "$libtool"; then
3654 if test -n "$cached_m4base"; then
3655 libtool="$cached_libtool"
3657 libtool="$guessed_libtool"
3660 # The macro_prefix defaults to the cached one.
3661 if test -z "$macro_prefix"; then
3662 macro_prefix="$cached_macro_prefix"
3663 if test -z "$macro_prefix"; then
3664 func_fatal_error "missing --macro-prefix option"
3667 # The po_domain defaults to the cached one.
3668 if test -z "$po_domain"; then
3669 po_domain="$cached_po_domain"
3671 # The vc_files defaults to the cached one.
3672 if test -z "$vc_files"; then
3673 vc_files="$cached_vc_files"
3676 # --without-*-tests options are not supported here.
3678 excl_longrunning_tests=
3679 excl_privileged_tests=
3680 excl_unportable_tests=
3682 # Canonicalize the list of specified modules.
3683 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3685 # Include all kinds of tests modules if --with-all-tests was specified.
3686 inc_all_direct_tests="$inc_all_tests"
3687 inc_all_indirect_tests="$inc_all_tests"
3689 # Determine final module list.
3690 modules="$specified_modules"
3691 func_modules_transitive_closure
3692 if test $verbose -ge 0; then
3693 func_show_module_list
3695 final_modules="$modules"
3697 # Determine main module list and tests-related module list separately.
3698 # The main module list is the transitive closure of the specified modules,
3699 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3700 # is specified, it will consist only of LGPLed source.
3701 # The tests-related module list is the transitive closure of the specified
3702 # modules, including tests modules, minus the main module list excluding
3703 # modules of applicability 'all'. Its lib/* sources (brought in through
3704 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3705 # source, even if --lgpl is specified.
3706 # Determine main module list.
3707 saved_inctests="$inctests"
3709 modules="$specified_modules"
3710 func_modules_transitive_closure
3711 main_modules="$modules"
3712 inctests="$saved_inctests"
3713 if test $verbose -ge 1; then
3714 echo "Main module list:"
3715 echo "$main_modules" | sed -e 's/^/ /'
3717 # Determine tests-related module list.
3718 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3719 testsrelated_modules=`for module in $main_modules; do
3720 if test \`func_get_applicability $module\` = main; then
3724 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3725 if test $verbose -ge 1; then
3726 echo "Tests-related module list:"
3727 echo "$testsrelated_modules" | sed -e 's/^/ /'
3730 # Add the dummy module to the main module list if needed.
3731 modules="$main_modules"
3732 func_modules_add_dummy
3733 main_modules="$modules"
3735 # Determine whether a $testsbase/libtests.a is needed.
3737 for module in $testsrelated_modules; do
3738 func_verify_nontests_module
3739 if test -n "$module"; then
3740 all_files=`func_get_filelist $module`
3741 # Test whether some file in $all_files lies in lib/.
3742 for f in $all_files; do
3753 # Add the dummy module to the tests-related module list if needed.
3754 if $use_libtests; then
3755 modules="$testsrelated_modules"
3756 func_modules_add_dummy
3757 testsrelated_modules="$modules"
3760 # If --lgpl, verify that the licenses of modules are compatible.
3761 if test -n "$lgpl"; then
3762 license_incompatibilities=
3763 for module in $main_modules; do
3764 license=`func_get_license $module`
3766 'GPLed build tool') ;;
3767 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3772 LGPL | LGPLv2+ | LGPLv3+) ;;
3773 *) func_append license_incompatibilities "$module $license$nl" ;;
3779 *) func_append license_incompatibilities "$module $license$nl" ;;
3782 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3787 if test -n "$license_incompatibilities"; then
3788 # Format the license incompatibilities as a table.
3789 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3790 s,^\(.................................................[^ ]*\) *, \1 ,'
3791 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3792 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3796 # Show banner notice of every module.
3797 modules="$main_modules"
3800 # Determine script to apply to imported library files.
3801 sed_transform_lib_file=
3802 for module in $main_modules; do
3803 if test $module = config-h; then
3804 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3805 sed_transform_lib_file=$sed_transform_lib_file'
3806 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3811 sed_transform_main_lib_file="$sed_transform_lib_file"
3812 if test -n "$do_copyrights"; then
3813 if test -n "$lgpl"; then
3817 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3818 s/GNU General/GNU Lesser General/g
3822 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3823 s/GNU General/GNU Lesser General/g
3824 s/version [23]\([ ,]\)/version 2.1\1/g
3827 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3831 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3832 s/GNU Lesser General/GNU General/g
3833 s/GNU Library General/GNU General/g
3834 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3839 # Determine script to apply to auxiliary files that go into $auxdir/.
3840 sed_transform_build_aux_file=
3841 if test -n "$do_copyrights"; then
3843 sed_transform_build_aux_file=$sed_transform_build_aux_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
3850 # Determine script to apply to library files that go into $testsbase/.
3851 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3852 if test -n "$do_copyrights"; then
3854 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3855 s/GNU Lesser General/GNU General/g
3856 s/GNU Library General/GNU General/g
3857 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3861 # Determine the final file lists.
3862 # They must be computed separately, because files in lib/* go into
3863 # $sourcebase/ if they are in the main file list but into $testsbase/
3864 # if they are in the tests-related file list. Furthermore lib/dummy.c
3866 # Determine final main file list.
3867 modules="$main_modules"
3868 func_modules_to_filelist
3870 # Determine final tests-related file list.
3871 modules="$testsrelated_modules"
3872 func_modules_to_filelist
3873 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3874 # Merge both file lists.
3875 sed_remove_empty_lines='/^$/d'
3876 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3877 if test $verbose -ge 0; then
3879 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3880 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3884 || func_fatal_error "refusing to do nothing"
3886 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3887 new_files="$files m4/gnulib-tool.m4"
3888 old_files="$cached_files"
3889 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3890 func_append old_files " m4/gnulib-tool.m4"
3893 rewritten='%REWRITTEN%'
3894 sed_rewrite_old_files="\
3895 s,^build-aux/,$rewritten$auxdir/,
3896 s,^doc/,$rewritten$cached_docbase/,
3897 s,^lib/,$rewritten$cached_sourcebase/,
3898 s,^m4/,$rewritten$cached_m4base/,
3899 s,^tests/,$rewritten$cached_testsbase/,
3900 s,^tests=lib/,$rewritten$cached_testsbase/,
3903 sed_rewrite_new_files="\
3904 s,^build-aux/,$rewritten$auxdir/,
3905 s,^doc/,$rewritten$docbase/,
3906 s,^lib/,$rewritten$sourcebase/,
3907 s,^m4/,$rewritten$m4base/,
3908 s,^tests/,$rewritten$testsbase/,
3909 s,^tests=lib/,$rewritten$testsbase/,
3913 # Create directories.
3914 { echo "$sourcebase"
3916 if test -n "$pobase"; then
3919 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3920 if test -n "$docfiles"; then
3923 if test -n "$inctests"; then
3927 for f in $files; do echo $f; done \
3928 | sed -e "$sed_rewrite_new_files" \
3929 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3932 { # Rearrange file descriptors. Needed because "while ... done < ..."
3933 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3934 exec 5<&0 < "$tmp"/dirs
3936 if test ! -d "$destdir/$d"; then
3938 echo "Creating directory $destdir/$d"
3939 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3941 echo "Create directory $destdir/$d"
3948 # Copy files or make symbolic links. Remove obsolete files.
3952 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3953 # representing the files according to the last gnulib-tool invocation.
3954 for f in $old_files; do echo $f; done \
3955 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3958 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3959 # representing the files after this gnulib-tool invocation.
3960 for f in $new_files; do echo $f; done \
3961 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3964 # First the files that are in old-files, but not in new-files:
3965 sed_take_first_column='s,'"$delimiter"'.*,,'
3966 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3967 # Remove the file. Do nothing if the user already removed it.
3968 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3970 echo "Removing file $g (backup in ${g}~)"
3971 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3973 echo "Remove file $g (backup in ${g}~)"
3975 func_append removed_files "$g$nl"
3978 # func_add_or_update handles a file that ought to be present afterwards.
3980 # - f the original file name
3981 # - g the rewritten file name
3982 # - already_present nonempty if the file should already exist, empty
3984 func_add_or_update ()
3988 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3990 func_dest_tmpfilename "$g"
3991 func_lookup_file "$f"
3992 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3993 if test -n "$sed_transform_main_lib_file"; then
3996 sed -e "$sed_transform_main_lib_file" \
3997 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4001 if test -n "$sed_transform_build_aux_file"; then
4004 sed -e "$sed_transform_build_aux_file" \
4005 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4009 if test -n "$sed_transform_testsrelated_lib_file"; then
4012 sed -e "$sed_transform_testsrelated_lib_file" \
4013 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4017 if test -f "$destdir/$g"; then
4018 # The file already exists.
4022 # Don't protest if the file should be there but isn't: it happens
4023 # frequently that developers don't put autogenerated files under version control.
4025 func_append added_files "$g$nl"
4029 # Then the files that are in new-files, but not in old-files:
4030 sed_take_last_column='s,^.*'"$delimiter"',,'
4032 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4033 | sed -e "$sed_take_last_column" \
4034 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4035 { # Rearrange file descriptors. Needed because "while ... done < ..."
4036 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4037 exec 5<&0 < "$tmp"/added-files
4043 # Then the files that are in new-files and in old-files:
4044 already_present=true
4045 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4046 | sed -e "$sed_take_last_column" \
4047 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4048 { # Rearrange file descriptors. Needed because "while ... done < ..."
4049 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4050 exec 5<&0 < "$tmp"/kept-files
4057 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4058 actioncmd="gnulib-tool --import"
4059 func_append actioncmd " --dir=$destdir"
4060 if test -n "$local_gnulib_dir"; then
4061 func_append actioncmd " --local-dir=$local_gnulib_dir"
4063 func_append actioncmd " --lib=$libname"
4064 func_append actioncmd " --source-base=$sourcebase"
4065 func_append actioncmd " --m4-base=$m4base"
4066 if test -n "$pobase"; then
4067 func_append actioncmd " --po-base=$pobase"
4069 func_append actioncmd " --doc-base=$docbase"
4070 func_append actioncmd " --tests-base=$testsbase"
4071 func_append actioncmd " --aux-dir=$auxdir"
4072 if test -n "$inctests"; then
4073 func_append actioncmd " --with-tests"
4075 if test -n "$incobsolete"; then
4076 func_append actioncmd " --with-obsolete"
4078 if test -n "$inc_cxx_tests"; then
4079 func_append actioncmd " --with-c++-tests"
4081 if test -n "$inc_longrunning_tests"; then
4082 func_append actioncmd " --with-longrunning-tests"
4084 if test -n "$inc_privileged_tests"; then
4085 func_append actioncmd " --with-privileged-tests"
4087 if test -n "$inc_unportable_tests"; then
4088 func_append actioncmd " --with-unportable-tests"
4090 if test -n "$inc_all_tests"; then
4091 func_append actioncmd " --with-all-tests"
4093 for module in $avoidlist; do
4094 func_append actioncmd " --avoid=$module"
4096 if test -n "$lgpl"; then
4097 if test "$lgpl" = yes; then
4098 func_append actioncmd " --lgpl"
4100 func_append actioncmd " --lgpl=$lgpl"
4103 if test -n "$makefile_name"; then
4104 func_append actioncmd " --makefile-name=$makefile_name"
4106 if test "$libtool" = true; then
4107 func_append actioncmd " --libtool"
4109 func_append actioncmd " --no-libtool"
4111 func_append actioncmd " --macro-prefix=$macro_prefix"
4112 if test -n "$po_domain"; then
4113 func_append actioncmd " --po-domain=$po_domain"
4115 if test -n "$vc_files"; then
4116 if test "$vc_files" = true; then
4117 func_append actioncmd " --vc-files"
4119 func_append actioncmd " --no-vc-files"
4122 func_append actioncmd " `echo $specified_modules`"
4124 # Default the makefile name to Makefile.am.
4125 if test -n "$makefile_name"; then
4126 makefile_am=$makefile_name
4128 makefile_am=Makefile.am
4131 # Create normal Makefile.ams.
4134 # Setup list of Makefile.am edits that are to be performed afterwards.
4135 # Some of these edits apply to files that we will generate; others are
4136 # under the responsibility of the developer.
4138 # func_note_Makefile_am_edit dir var value
4139 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4141 func_note_Makefile_am_edit ()
4143 makefile_am_edits=`expr $makefile_am_edits + 1`
4144 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4145 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4146 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4148 if test "$makefile_am" = Makefile.am; then
4149 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4150 sourcebase_base=`basename "$sourcebase"`
4151 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4153 if test -n "$pobase"; then
4154 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4155 pobase_base=`basename "$pobase"`
4156 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4158 if test -n "$inctests"; then
4159 if test "$makefile_am" = Makefile.am; then
4160 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4161 testsbase_base=`basename "$testsbase"`
4162 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4165 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4167 # Find the first parent directory of $m4base that contains or will contain
4169 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4171 sed_butlast='s,[^/][^/]*//*$,,'
4172 dir1="${m4base}/"; dir2=""
4173 while test -n "$dir1" \
4174 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4175 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4176 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4177 || { test -n "$inctests" \
4178 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4179 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4180 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4181 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4183 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4186 # Create library makefile.
4187 func_dest_tmpfilename $sourcebase/$makefile_am
4188 destfile="$sourcebase/$makefile_am"
4189 modules="$main_modules"
4190 func_emit_lib_Makefile_am > "$tmpfile"
4191 if test -f "$destdir"/$sourcebase/$makefile_am; then
4192 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4196 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4197 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4198 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4200 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4206 echo "Creating $sourcebase/$makefile_am"
4207 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4209 echo "Create $sourcebase/$makefile_am"
4212 func_append added_files "$sourcebase/$makefile_am$nl"
4215 # Create po/ directory.
4216 if test -n "$pobase"; then
4217 # Create po makefile and auxiliary files.
4218 for file in Makefile.in.in remove-potcdate.sin; do
4219 func_dest_tmpfilename $pobase/$file
4220 func_lookup_file build-aux/po/$file
4221 cat "$lookedup_file" > "$tmpfile"
4222 if test -f "$destdir"/$pobase/$file; then
4223 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4227 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4228 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4229 mv -f "$tmpfile" "$destdir"/$pobase/$file
4231 echo "Update $pobase/$file (backup in $pobase/$file~)"
4237 echo "Creating $pobase/$file"
4238 mv -f "$tmpfile" "$destdir"/$pobase/$file
4240 echo "Create $pobase/$file"
4243 func_append added_files "$pobase/$file$nl"
4246 # Create po makefile parameterization, part 1.
4247 func_dest_tmpfilename $pobase/Makevars
4248 func_emit_po_Makevars > "$tmpfile"
4249 if test -f "$destdir"/$pobase/Makevars; then
4250 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4254 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4255 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4256 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4258 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4264 echo "Creating $pobase/Makevars"
4265 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4267 echo "Create $pobase/Makevars"
4270 func_append added_files "$pobase/Makevars$nl"
4272 # Create po makefile parameterization, part 2.
4273 func_dest_tmpfilename $pobase/POTFILES.in
4274 func_emit_po_POTFILES_in > "$tmpfile"
4275 if test -f "$destdir"/$pobase/POTFILES.in; then
4276 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4280 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4281 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4282 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4284 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4290 echo "Creating $pobase/POTFILES.in"
4291 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4293 echo "Create $pobase/POTFILES.in"
4296 func_append added_files "$pobase/POTFILES.in$nl"
4299 TP_URL="http://translationproject.org/latest/"
4300 TP_RSYNC_URI="translationproject.org::tp/latest/"
4302 echo "Fetching gnulib PO files from $TP_URL"
4303 (cd "$destdir"/$pobase \
4304 && { # Prefer rsync over wget if it is available, since it consumes
4305 # less network bandwidth, due to compression.
4306 if type rsync 2>/dev/null | grep / > /dev/null; then
4307 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4309 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4314 echo "Fetch gnulib PO files from $TP_URL"
4316 # Create po/LINGUAS.
4318 func_dest_tmpfilename $pobase/LINGUAS
4319 (cd "$destdir"/$pobase \
4320 && { echo '# Set of available languages.'
4321 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4324 if test -f "$destdir"/$pobase/LINGUAS; then
4325 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4328 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4329 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4330 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4333 echo "Creating $pobase/LINGUAS"
4334 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4335 func_append added_files "$pobase/LINGUAS$nl"
4338 if test -f "$destdir"/$pobase/LINGUAS; then
4339 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4341 echo "Create $pobase/LINGUAS"
4346 # Create m4/gnulib-cache.m4.
4347 func_dest_tmpfilename $m4base/gnulib-cache.m4
4349 func_emit_copyright_notice
4351 echo "# This file represents the specification of how gnulib-tool is used."
4352 echo "# It acts as a cache: It is written and read by gnulib-tool."
4353 echo "# In projects that use version control, this file is meant to be put under"
4354 echo "# version control, like the configure.ac and various Makefile.am files."
4357 echo "# Specification in the form of a command-line invocation:"
4360 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4361 # Store the local_gnulib_dir relative to destdir.
4362 case "$local_gnulib_dir" in
4364 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4367 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4369 # destdir, local_gnulib_dir are both relative.
4370 func_relativize "$destdir" "$local_gnulib_dir"
4371 relative_local_gnulib_dir="$reldir" ;;
4374 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4376 echo "$specified_modules" | sed -e 's/^/ /g'
4378 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4379 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4380 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4381 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4382 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4383 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4384 echo "gl_AVOID([$avoidlist])"
4385 echo "gl_SOURCE_BASE([$sourcebase])"
4386 echo "gl_M4_BASE([$m4base])"
4387 echo "gl_PO_BASE([$pobase])"
4388 echo "gl_DOC_BASE([$docbase])"
4389 echo "gl_TESTS_BASE([$testsbase])"
4390 test -z "$inctests" || echo "gl_WITH_TESTS"
4391 echo "gl_LIB([$libname])"
4392 if test -n "$lgpl"; then
4393 if test "$lgpl" = yes; then
4396 echo "gl_LGPL([$lgpl])"
4399 echo "gl_MAKEFILE_NAME([$makefile_name])"
4400 if test "$libtool" = true; then
4403 echo "gl_MACRO_PREFIX([$macro_prefix])"
4404 echo "gl_PO_DOMAIN([$po_domain])"
4405 if test -n "$vc_files"; then
4406 echo "gl_VC_FILES([$vc_files])"
4409 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4410 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4414 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4415 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4416 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4418 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4422 echo "# gnulib-cache.m4 ends here"
4429 echo "Creating $m4base/gnulib-cache.m4"
4430 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4432 echo "Create $m4base/gnulib-cache.m4"
4438 # Create m4/gnulib-comp.m4.
4439 func_dest_tmpfilename $m4base/gnulib-comp.m4
4441 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4442 func_emit_copyright_notice
4444 echo "# This file represents the compiled summary of the specification in"
4445 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4446 echo "# to be invoked from configure.ac."
4447 echo "# In projects that use version control, this file can be treated like"
4448 echo "# other built files."
4451 echo "# This macro should be invoked from $configure_ac, in the section"
4452 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4453 echo "# any checks for libraries, header files, types and library functions."
4454 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4456 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4457 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4458 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4459 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4460 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4461 if test -n "$uses_subdirs"; then
4462 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4464 for module in $final_modules; do
4466 if test -n "$module"; then
4467 echo "# Code from module $module:"
4468 func_get_autoconf_early_snippet "$module"
4471 | sed -e '/^$/d;' -e 's/^/ /'
4474 echo "# This macro should be invoked from $configure_ac, in the section"
4475 echo "# \"Check for header files, types and library functions\"."
4476 echo "AC_DEFUN([${macro_prefix}_INIT],"
4478 if test "$libtool" = true; then
4479 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4480 echo " gl_cond_libtool=true"
4482 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4483 echo " gl_cond_libtool=false"
4485 echo " gl_ltlibdeps="
4487 if test "$auxdir" != "build-aux"; then
4488 sed_replace_build_aux='
4490 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4491 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4495 sed_replace_build_aux="$sed_noop"
4497 echo " gl_m4_base='$m4base'"
4498 func_emit_initmacro_start $macro_prefix
4499 echo " gl_source_base='$sourcebase'"
4500 for module in $main_modules; do
4502 if test -n "$module"; then
4503 echo " # Code from module $module:"
4504 func_get_autoconf_snippet "$module" \
4505 | sed -e '/^$/d;' -e 's/^/ /' \
4506 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4507 -e "$sed_replace_build_aux"
4508 if test "$module" = 'alloca' && test "$libtool" = true; then
4509 echo 'changequote(,)dnl'
4510 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4511 echo 'changequote([, ])dnl'
4512 echo 'AC_SUBST([LTALLOCA])'
4516 echo " # End of code from modules"
4517 func_emit_initmacro_end $macro_prefix
4518 echo " gltests_libdeps="
4519 echo " gltests_ltlibdeps="
4520 func_emit_initmacro_start ${macro_prefix}tests
4521 echo " gl_source_base='$testsbase'"
4522 # Define a tests witness macro that depends on the package.
4523 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4524 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4525 echo "changequote(,)dnl"
4526 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"
4527 echo "changequote([, ])dnl"
4528 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4529 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4530 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4531 for module in $testsrelated_modules; do
4533 if test -n "$module"; then
4534 func_get_autoconf_snippet "$module" \
4535 | sed -e '/^$/d;' -e 's/^/ /' \
4536 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4537 -e "$sed_replace_build_aux" \
4538 -e 's/\$gl_cond_libtool/false/g' \
4539 -e 's/gl_libdeps/gltests_libdeps/g' \
4540 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4543 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4544 func_emit_initmacro_end ${macro_prefix}tests
4545 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4546 # created using libtool, because libtool already handles the dependencies.
4547 if test "$libtool" != true; then
4548 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4549 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4550 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4551 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4552 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4554 if $use_libtests; then
4555 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4556 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4559 func_emit_initmacro_done $macro_prefix $sourcebase
4560 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4562 echo "# This macro records the list of files which have been installed by"
4563 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4564 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4565 echo "$files" | sed -e 's,^, ,'
4568 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4569 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4573 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4574 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4575 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4577 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4581 echo "# gnulib-comp.m4 ends here"
4588 echo "Creating $m4base/gnulib-comp.m4"
4589 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4591 echo "Create $m4base/gnulib-comp.m4"
4597 if test -n "$inctests"; then
4598 # Create tests makefile.
4599 func_dest_tmpfilename $testsbase/$makefile_am
4600 destfile="$testsbase/$makefile_am"
4601 modules="$testsrelated_modules"
4602 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4603 if test -f "$destdir"/$testsbase/$makefile_am; then
4604 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4608 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4609 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4610 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4612 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4618 echo "Creating $testsbase/$makefile_am"
4619 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4621 echo "Create $testsbase/$makefile_am"
4624 func_append added_files "$testsbase/$makefile_am$nl"
4628 if test "$vc_files" != false; then
4629 # Update the .cvsignore and .gitignore files.
4630 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4631 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4632 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4633 echo "$m4base/|A|gnulib-comp.m4"
4634 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4635 { # Rearrange file descriptors. Needed because "while ... done < ..."
4636 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4637 exec 5<&0 < "$tmp"/fileset-changes
4638 func_update_ignorelist ()
4641 if test "$ignore" = .gitignore; then
4642 # In a .gitignore file, "foo" applies to the current directory and all
4643 # subdirectories, whereas "/foo" applies to the current directory only.
4646 doubly_escaped_anchor='\\/'
4650 doubly_escaped_anchor=''
4652 if test -f "$destdir/$dir$ignore"; then
4653 if test -n "$dir_added" || test -n "$dir_removed"; then
4654 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4655 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4656 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4657 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4658 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4660 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4662 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4663 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4664 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4665 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4666 } > "$tmp"/sed-ignore-removed
4667 { cat "$destdir/$dir$ignore"~
4668 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4669 } | sed -f "$tmp"/sed-ignore-removed \
4670 > "$destdir/$dir$ignore"
4672 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4677 if test -n "$dir_added"; then
4679 echo "Creating $destdir/$dir$ignore"
4681 if test "$ignore" = .cvsignore; then
4683 # Automake generates Makefile rules that create .dirstamp files.
4686 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4687 } > "$destdir/$dir$ignore"
4689 echo "Create $destdir/$dir$ignore"
4699 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4700 func_update_ignorelist .cvsignore
4702 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4703 func_update_ignorelist .gitignore
4710 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4711 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4712 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4713 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4714 if test "$next_dir" != "$last_dir"; then
4715 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4716 last_dir="$next_dir"
4721 A) func_append last_dir_added "$file$nl";;
4722 R) func_append last_dir_removed "$file$nl";;
4725 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4732 echo "You may need to add #include directives for the following .h files."
4733 # Intersect $specified_modules and $main_modules
4734 # (since $specified_modules is not necessarily of subset of $main_modules
4735 # - some may have been skipped through --avoid, and since the elements of
4736 # $main_modules but not in $specified_modules can go away without explicit
4737 # notice - through changes in the module dependencies).
4738 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4739 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4740 # First the #include <...> directives without #ifs, sorted for convenience,
4741 # then the #include "..." directives without #ifs, sorted for convenience,
4742 # then the #include directives that are surrounded by #ifs. Not sorted.
4743 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4744 include_directive=`func_get_include_directive "$module"`
4745 case "$nl$include_directive" in
4747 echo "$include_directive" 1>&5
4750 echo "$include_directive" | grep -v 'include "' 1>&6
4751 echo "$include_directive" | grep 'include "' 1>&7
4754 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4756 LC_ALL=C sort -u "$tmp"/include-angles
4757 LC_ALL=C sort -u "$tmp"/include-quotes
4758 cat "$tmp"/include-if
4759 ) | sed -e '/^$/d' -e 's/^/ /'
4760 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4762 for module in $main_modules; do
4763 func_get_link_directive "$module"
4765 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4766 if test `wc -l < "$tmp"/link` != 0; then
4768 echo "You may need to use the following Makefile variables when linking."
4769 echo "Use them in <program>_LDADD when linking a program, or"
4770 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4776 echo "Don't forget to"
4777 if test "$makefile_am" = Makefile.am; then
4778 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4780 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4782 if test -n "$pobase"; then
4783 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4785 if test -n "$inctests"; then
4786 if test "$makefile_am" = Makefile.am; then
4787 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4789 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4793 while test $edit != $makefile_am_edits; do
4794 edit=`expr $edit + 1`
4795 eval dir=\"\$makefile_am_edit${edit}_dir\"
4796 eval var=\"\$makefile_am_edit${edit}_var\"
4797 eval val=\"\$makefile_am_edit${edit}_val\"
4798 if test -n "$var"; then
4799 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4802 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4803 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4806 # func_create_testdir testdir modules
4808 # - local_gnulib_dir from --local-dir
4809 # - modcache true or false, from --cache-modules/--no-cache-modules
4810 # - auxdir directory relative to destdir where to place build aux files
4811 # - inctests true if tests should be included, blank otherwise
4812 # - incobsolete true if obsolete modules among dependencies should be
4813 # included, blank otherwise
4814 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
4816 # - excl_longrunning_tests true if long-runnings tests should be excluded,
4818 # - excl_privileged_tests true if tests that require root privileges should be
4819 # excluded, blank otherwise
4820 # - excl_unportable_tests true if tests that fail on some platforms should be
4821 # excluded, blank otherwise
4822 # - avoidlist list of modules to avoid
4823 # - libtool true if --libtool was given, false if --no-libtool was
4824 # given, blank otherwise
4825 # - symbolic true if files should be symlinked, copied otherwise
4826 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4828 func_create_testdir ()
4832 if test -z "$modules"; then
4833 # All modules together.
4834 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4835 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4836 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4837 modules=`func_all_modules`
4838 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4840 specified_modules="$modules"
4842 # Canonicalize the list of specified modules.
4843 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4845 # Unlike in func_import, here we want to include all kinds of tests for the
4846 # directly specified modules, but not for dependencies.
4847 inc_all_direct_tests=true
4848 inc_all_indirect_tests="$inc_all_tests"
4850 # Check that the license of every module is consistent with the license of
4852 saved_inctests="$inctests"
4853 # When computing transitive closures, don't consider $module to depend on
4854 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4855 # on GPL modules - therefore we don't want a warning in this case.
4857 for requested_module in $specified_modules; do
4858 requested_license=`func_get_license "$requested_module"`
4859 if test "$requested_license" != GPL; then
4860 # Here we use func_modules_transitive_closure, not just
4861 # func_get_dependencies, so that we also detect weird situations like
4862 # an LGPL module which depends on a GPLed build tool module which depends
4864 modules="$requested_module"
4865 func_modules_transitive_closure
4866 for module in $modules; do
4867 license=`func_get_license "$module"`
4869 'GPLed build tool') ;;
4870 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4872 case "$requested_license" in
4875 GPLv2+ | LGPLv2+) ;;
4876 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4882 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4888 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4897 inctests="$saved_inctests"
4899 # Subdirectory names.
4909 # Determine final module list.
4910 modules="$specified_modules"
4911 func_modules_transitive_closure
4912 if test $verbose -ge 0; then
4913 func_show_module_list
4916 # Add the dummy module if needed.
4917 func_modules_add_dummy
4919 # Show banner notice of every module.
4922 # Determine final file list.
4923 func_modules_to_filelist
4924 if test $verbose -ge 0; then
4926 echo "$files" | sed -e 's/^/ /'
4929 rewritten='%REWRITTEN%'
4930 sed_rewrite_files="\
4931 s,^build-aux/,$rewritten$auxdir/,
4932 s,^doc/,$rewritten$docbase/,
4933 s,^lib/,$rewritten$sourcebase/,
4934 s,^m4/,$rewritten$m4base/,
4935 s,^tests/,$rewritten$testsbase/,
4939 # Create directories.
4940 for f in $files; do echo $f; done \
4941 | sed -e "$sed_rewrite_files" \
4942 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4943 | LC_ALL=C sort -u \
4945 { # Rearrange file descriptors. Needed because "while ... done < ..."
4946 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4947 exec 5<&0 < "$tmp"/dirs
4949 mkdir -p "$testdir/$d"
4954 # Copy files or make symbolic links.
4956 for f in $files; do echo $f; done \
4957 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4960 { # Rearrange file descriptors. Needed because "while ... done < ..."
4961 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4962 exec 5<&0 < "$tmp"/files
4964 func_lookup_file "$f"
4965 if test -n "$lookedup_tmp"; then
4966 cp -p "$lookedup_file" "$testdir/$g"
4968 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4969 if { test -n "$symbolic" \
4970 || { test -n "$lsymbolic" \
4971 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4972 func_ln "$lookedup_file" "$testdir/$g"
4974 cp -p "$lookedup_file" "$testdir/$g"
4981 # Create Makefile.ams that are for testing.
4984 # No special edits are needed.
4987 # Create $sourcebase/Makefile.am.
4988 mkdir -p "$testdir/$sourcebase"
4989 destfile="$sourcebase/Makefile.am"
4990 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4991 any_uses_subdirs="$uses_subdirs"
4993 # Create $m4base/Makefile.am.
4994 mkdir -p "$testdir/$m4base"
4995 (echo "## Process this file with automake to produce Makefile.in."
5001 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5004 ) > "$testdir/$m4base/Makefile.am"
5006 subdirs="$sourcebase $m4base"
5007 subdirs_with_configure_ac=""
5009 if false && test -f "$testdir"/$m4base/gettext.m4; then
5010 # Avoid stupid error message from automake:
5011 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5012 mkdir -p "$testdir/po"
5013 (echo "## Process this file with automake to produce Makefile.in."
5014 ) > "$testdir/po/Makefile.am"
5015 func_append subdirs " po"
5018 if test -n "$inctests"; then
5019 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5020 # Viewed from the $testsbase subdirectory, $auxdir is different.
5021 saved_auxdir="$auxdir"
5022 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5023 # Create $testsbase/Makefile.am.
5025 destfile="$testsbase/Makefile.am"
5026 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5027 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5028 # Create $testsbase/configure.ac.
5029 (echo "# Process this file with autoconf to produce a configure script."
5030 echo "AC_INIT([dummy], [0])"
5031 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5032 echo "AM_INIT_AUTOMAKE"
5034 echo "AC_CONFIG_HEADERS([config.h])"
5037 echo "AC_PROG_INSTALL"
5038 echo "AC_PROG_MAKE_SET"
5039 echo "AC_PROG_RANLIB"
5041 if test -n "$uses_subdirs"; then
5042 echo "AM_PROG_CC_C_O"
5045 for module in $modules; do
5047 if test -n "$module"; then
5049 gnumakefile | maintainer-makefile)
5050 # These modules are meant to be used only in the top-level directory.
5053 func_get_autoconf_early_snippet "$module"
5058 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5059 if test "$libtool" = true; then
5060 echo "LT_INIT([win32-dll])"
5061 echo "LT_LANG([C++])"
5062 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5063 echo "gl_cond_libtool=true"
5065 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5066 echo "gl_cond_libtool=false"
5068 echo "gl_ltlibdeps="
5070 # Wrap the set of autoconf snippets into an autoconf macro that is then
5071 # invoked. This is needed because autoconf does not support AC_REQUIRE
5073 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5074 # but we want the AC_REQUIRE to have its normal meaning (provide one
5075 # expansion of the required macro before the current point, and only one
5077 echo "AC_DEFUN([gl_INIT], ["
5078 sed_replace_build_aux='
5080 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5081 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5084 echo "gl_m4_base='../$m4base'"
5085 func_emit_initmacro_start $macro_prefix
5086 # We don't have explicit ordering constraints between the various
5087 # autoconf snippets. It's cleanest to put those of the library before
5088 # those of the tests.
5089 echo "gl_source_base='../$sourcebase'"
5090 for module in $modules; do
5091 func_verify_nontests_module
5092 if test -n "$module"; then
5094 gnumakefile | maintainer-makefile)
5095 # These modules are meant to be used only in the top-level directory.
5098 func_get_autoconf_snippet "$module" \
5099 | sed -e "$sed_replace_build_aux"
5104 echo "gl_source_base='.'"
5105 for module in $modules; do
5106 func_verify_tests_module
5107 if test -n "$module"; then
5108 func_get_autoconf_snippet "$module" \
5109 | sed -e "$sed_replace_build_aux"
5112 func_emit_initmacro_end $macro_prefix
5113 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5114 # created using libtool, because libtool already handles the dependencies.
5115 if test "$libtool" != true; then
5116 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5117 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5118 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5119 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5120 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5123 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5127 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5128 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5129 echo "AH_TOP([#include \"../config.h\"])"
5131 echo "AC_CONFIG_FILES([Makefile])"
5133 ) > "$testdir/$testsbase/configure.ac"
5134 auxdir="$saved_auxdir"
5135 func_append subdirs " $testsbase"
5136 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5139 # Create Makefile.am.
5140 (echo "## Process this file with automake to produce Makefile.in."
5142 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5144 echo "SUBDIRS = $subdirs"
5146 echo "ACLOCAL_AMFLAGS = -I $m4base"
5147 ) > "$testdir/Makefile.am"
5149 # Create configure.ac.
5150 (echo "# Process this file with autoconf to produce a configure script."
5151 echo "AC_INIT([dummy], [0])"
5152 if test "$auxdir" != "."; then
5153 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5155 echo "AM_INIT_AUTOMAKE"
5157 echo "AC_CONFIG_HEADERS([config.h])"
5160 echo "AC_PROG_INSTALL"
5161 echo "AC_PROG_MAKE_SET"
5163 echo "# For autobuild."
5164 echo "AC_CANONICAL_BUILD"
5165 echo "AC_CANONICAL_HOST"
5167 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5168 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5169 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5170 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5172 echo "AC_PROG_RANLIB"
5174 if test -n "$any_uses_subdirs"; then
5175 echo "AM_PROG_CC_C_O"
5178 for module in $modules; do
5179 func_verify_nontests_module
5180 if test -n "$module"; then
5181 func_get_autoconf_early_snippet "$module"
5184 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5185 if test "$libtool" = true; then
5186 echo "LT_INIT([win32-dll])"
5187 echo "LT_LANG([C++])"
5188 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5189 echo "gl_cond_libtool=true"
5191 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5192 echo "gl_cond_libtool=false"
5194 echo "gl_ltlibdeps="
5196 # Wrap the set of autoconf snippets into an autoconf macro that is then
5197 # invoked. This is needed because autoconf does not support AC_REQUIRE
5199 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5200 # but we want the AC_REQUIRE to have its normal meaning (provide one
5201 # expansion of the required macro before the current point, and only one
5203 echo "AC_DEFUN([gl_INIT], ["
5204 if test "$auxdir" != "build-aux"; then
5205 sed_replace_build_aux='
5207 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5208 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5212 sed_replace_build_aux="$sed_noop"
5214 echo "gl_m4_base='$m4base'"
5215 func_emit_initmacro_start $macro_prefix
5216 echo "gl_source_base='$sourcebase'"
5217 for module in $modules; do
5218 func_verify_nontests_module
5219 if test -n "$module"; then
5220 func_get_autoconf_snippet "$module" \
5221 | sed -e "$sed_replace_build_aux"
5224 func_emit_initmacro_end $macro_prefix
5225 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5226 # created using libtool, because libtool already handles the dependencies.
5227 if test "$libtool" != true; then
5228 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5229 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5230 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5231 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5232 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5235 func_emit_initmacro_done $macro_prefix $sourcebase
5239 if test -n "$subdirs_with_configure_ac"; then
5240 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5242 makefiles="Makefile"
5243 for d in $subdirs; do
5244 # For subdirs that have a configure.ac by their own, it's the subdir's
5245 # configure.ac which creates the subdir's Makefile.am, not this one.
5246 case " $subdirs_with_configure_ac " in
5248 *) func_append makefiles " $d/Makefile" ;;
5251 echo "AC_CONFIG_FILES([$makefiles])"
5253 ) > "$testdir/configure.ac"
5255 # Create autogenerated files.
5257 # Do not use "${AUTORECONF} --force --install", because it may invoke
5258 # autopoint, which brings in older versions of some of our .m4 files.
5259 if test -f $m4base/gettext.m4; then
5260 func_execute_command ${AUTOPOINT} --force || func_exit 1
5261 for f in $m4base/*.m4~; do
5263 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5267 if test "$libtool" = true; then
5268 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5270 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5271 if ! test -d build-aux; then
5272 func_execute_command mkdir build-aux || func_exit 1
5274 func_execute_command ${AUTOCONF} || func_exit 1
5275 func_execute_command ${AUTOHEADER} || func_exit 1
5276 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5278 if test -n "$inctests"; then
5279 # Create autogenerated files.
5280 (cd "$testdir/$testsbase" || func_exit 1
5281 # Do not use "${AUTORECONF} --force --install", because it may invoke
5282 # autopoint, which brings in older versions of some of our .m4 files.
5283 if test -f ../$m4base/gettext.m4; then
5284 func_execute_command ${AUTOPOINT} --force || func_exit 1
5285 for f in ../$m4base/*.m4~; do
5287 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5291 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5292 if ! test -d ../build-aux; then
5293 func_execute_command mkdir ../build-aux
5295 func_execute_command ${AUTOCONF} || func_exit 1
5296 func_execute_command ${AUTOHEADER} || func_exit 1
5297 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5300 # Need to run configure and make once, to create built files that are to be
5301 # distributed (such as getdate.c).
5302 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5303 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5304 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5305 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5306 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5307 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5308 # such $(FOO_H) because they don't refer to distributed files.
5309 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5310 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5311 | sed -e "$sed_remove_make_variables"`
5312 distributed_built_sources=`for file in $built_sources; do
5313 case "$cleaned_files" in
5318 tests_distributed_built_sources=
5319 if test -n "$inctests"; then
5320 # Likewise for built files in the $testsbase directory.
5321 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5322 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5323 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5324 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5325 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5326 | sed -e "$sed_remove_make_variables"`
5327 tests_distributed_built_sources=`for file in $tests_built_sources; do
5328 case "$tests_cleaned_files" in
5334 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5336 ./configure || func_exit 1
5337 if test -n "$distributed_built_sources"; then
5339 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5340 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5345 if test -n "$tests_distributed_built_sources"; then
5347 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5348 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5353 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5360 # func_create_megatestdir megatestdir allmodules
5362 # - local_gnulib_dir from --local-dir
5363 # - modcache true or false, from --cache-modules/--no-cache-modules
5364 # - auxdir directory relative to destdir where to place build aux files
5365 func_create_megatestdir ()
5369 if test -z "$allmodules"; then
5370 allmodules=`func_all_modules`
5374 # First, all modules one by one.
5375 for onemodule in $allmodules; do
5376 func_create_testdir "$megatestdir/$onemodule" $onemodule
5377 func_append megasubdirs "$onemodule "
5379 # Then, all modules all together.
5380 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5381 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5382 func_create_testdir "$megatestdir/ALL" "$allmodules"
5383 func_append megasubdirs "ALL"
5386 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5387 vc_witness="$gnulib_dir/CVS/Entries"; \
5389 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5391 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5392 | sed -e 's,January,01,' -e 's,Jan,01,' \
5393 -e 's,February,02,' -e 's,Feb,02,' \
5394 -e 's,March,03,' -e 's,Mar,03,' \
5395 -e 's,April,04,' -e 's,Apr,04,' \
5397 -e 's,June,06,' -e 's,Jun,06,' \
5398 -e 's,July,07,' -e 's,Jul,07,' \
5399 -e 's,August,08,' -e 's,Aug,08,' \
5400 -e 's,September,09,' -e 's,Sep,09,' \
5401 -e 's,October,10,' -e 's,Oct,10,' \
5402 -e 's,November,11,' -e 's,Nov,11,' \
5403 -e 's,December,12,' -e 's,Dec,12,' \
5404 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5405 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5407 echo "CVSDATE=$cvsdate"
5408 echo ": \${MAKE=make}"
5409 echo "test -d logs || mkdir logs"
5410 echo "for module in $megasubdirs; do"
5411 echo " echo \"Working on module \$module...\""
5412 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5413 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5416 echo " : autobuild project... \$module"
5417 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5418 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5419 echo " : autobuild hostname... \`hostname\`"
5420 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5422 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5424 ) > "$megatestdir/do-autobuild"
5425 chmod a+x "$megatestdir/do-autobuild"
5427 # Create Makefile.am.
5428 (echo "## Process this file with automake to produce Makefile.in."
5430 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5432 echo "SUBDIRS = $megasubdirs"
5434 echo "EXTRA_DIST = do-autobuild"
5435 ) > "$megatestdir/Makefile.am"
5437 # Create configure.ac.
5438 (echo "# Process this file with autoconf to produce a configure script."
5439 echo "AC_INIT([dummy], [0])"
5440 if test "$auxdir" != "."; then
5441 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5443 echo "AM_INIT_AUTOMAKE"
5445 echo "AC_PROG_MAKE_SET"
5447 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5448 echo "AC_CONFIG_FILES([Makefile])"
5450 ) > "$megatestdir/configure.ac"
5452 # Create autogenerated files.
5454 # Do not use "${AUTORECONF} --install", because autoreconf operates
5455 # recursively, but the subdirectories are already finished, therefore
5456 # calling autoreconf here would only waste lots of CPU time.
5457 func_execute_command ${ACLOCAL} || func_exit 1
5458 func_execute_command mkdir build-aux
5459 func_execute_command ${AUTOCONF} || func_exit 1
5460 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5466 func_fatal_error "no mode specified" ;;
5473 # sed expression that converts a literal to a basic regular expression.
5474 # Needs to handle . [ \ * ^ $.
5475 sed_literal_to_basic_regex='s/\\/\\\\/g
5481 if test -f "$gnulib_dir/$filename" \
5482 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5483 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5484 filename_line_regex='^'"$filename_anywhere_regex"'$'
5487 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5488 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5489 (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$,,')
5492 | func_sanitize_modulelist \
5495 for module in $module_candidates; do
5496 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5501 func_warning "file $filename does not exist"
5506 import | add-import | remove-import | update )
5509 if test -z "$destdir"; then
5512 test -d "$destdir" \
5513 || func_fatal_error "destination directory does not exist: $destdir"
5515 # Prefer configure.ac to configure.in.
5516 if test -f "$destdir"/configure.ac; then
5517 configure_ac="$destdir/configure.ac"
5519 if test -f "$destdir"/configure.in; then
5520 configure_ac="$destdir/configure.in"
5522 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5526 # Analyze configure.ac.
5528 guessed_libtool=false
5533 /AC_CONFIG_AUX_DIR/ {
5534 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5536 /A[CM]_PROG_LIBTOOL/ {
5537 s,^.*$,guessed_libtool=true,p
5539 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5541 if test -z "$auxdir"; then
5542 auxdir="$guessed_auxdir"
5545 # Determine where to apply func_import.
5546 if test "$mode" = import; then
5547 # Apply func_import to a particular gnulib directory.
5548 # The command line contains the complete specification; don't look at
5549 # the contents of gnulib-cache.m4.
5550 test -n "$supplied_libname" || supplied_libname=true
5551 test -n "$sourcebase" || sourcebase="lib"
5552 test -n "$m4base" || m4base="m4"
5553 test -n "$docbase" || docbase="doc"
5554 test -n "$testsbase" || testsbase="tests"
5555 test -n "$macro_prefix" || macro_prefix="gl"
5558 if test -n "$m4base"; then
5559 # Apply func_import to a particular gnulib directory.
5560 # Any number of additional modules can be given.
5561 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5562 # First use of gnulib in the given m4base.
5563 test -n "$supplied_libname" || supplied_libname=true
5564 test -n "$sourcebase" || sourcebase="lib"
5565 test -n "$docbase" || docbase="doc"
5566 test -n "$testsbase" || testsbase="tests"
5567 test -n "$macro_prefix" || macro_prefix="gl"
5571 # Apply func_import to all gnulib directories.
5572 # To get this list of directories, look at Makefile.am. (Not at
5573 # configure, because it may be omitted from version control. Also,
5574 # don't run "find $destdir -name gnulib-cache.m4", as it might be
5578 if test -f "$destdir"/Makefile.am; then
5579 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5581 for arg in $aclocal_amflags; do
5582 if test -n "$m4dir_is_next"; then
5583 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5587 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5588 func_append m4dirs " $arg"
5589 m4dirs_count=`expr $m4dirs_count + 1`
5595 if test "X$arg" = "X-I"; then
5603 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5604 if test -f "$destdir"/aclocal.m4; then
5605 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5606 sedexpr2='s,^[^/]*$,.,'
5607 sedexpr3='s,/[^/]*$,,'
5608 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5609 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
5610 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
5613 if test $m4dirs_count = 0; then
5614 # First use of gnulib in a package.
5615 # Any number of additional modules can be given.
5616 test -n "$supplied_libname" || supplied_libname=true
5617 test -n "$sourcebase" || sourcebase="lib"
5619 test -n "$docbase" || docbase="doc"
5620 test -n "$testsbase" || testsbase="tests"
5621 test -n "$macro_prefix" || macro_prefix="gl"
5624 if test $m4dirs_count = 1; then
5625 # There's only one use of gnulib here. Assume the user means it.
5626 # Any number of additional modules can be given.
5627 for m4base in $m4dirs; do
5631 # Ambiguous - guess what the user meant.
5632 if test $# = 0; then
5633 # No further arguments. Guess the user wants to update all of them.
5634 for m4base in $m4dirs; do
5635 # Perform func_import in a subshell, so that variable values
5637 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5638 # inc_longrunning_tests, inc_privileged_tests,
5639 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5640 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5641 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5642 # don't propagate from one directory to another.
5643 (func_import) || func_exit 1
5647 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5656 if test -z "$destdir"; then
5657 func_fatal_error "please specify --dir option"
5660 test -d "$destdir" \
5661 || func_fatal_error "could not create destination directory"
5662 test -n "$auxdir" || auxdir="build-aux"
5663 func_create_testdir "$destdir" "$*"
5666 create-megatestdir )
5667 if test -z "$destdir"; then
5668 func_fatal_error "please specify --dir option"
5670 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5671 test -n "$auxdir" || auxdir="build-aux"
5672 func_create_megatestdir "$destdir" "$*"
5676 test -n "$destdir" || destdir=testdir$$
5677 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5678 test -n "$auxdir" || auxdir="build-aux"
5679 func_create_testdir "$destdir" "$*"
5683 ../configure || func_exit 1
5684 $MAKE || func_exit 1
5685 $MAKE check || func_exit 1
5686 $MAKE distclean || func_exit 1
5687 remaining=`find . -type f -print`
5688 if test -n "$remaining"; then
5689 echo "Remaining files:" $remaining 1>&2
5690 echo "gnulib-tool: *** Stop." 1>&2
5699 test -n "$destdir" || destdir=testdir$$
5700 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5701 test -n "$auxdir" || auxdir="build-aux"
5702 func_create_megatestdir "$destdir" "$*"
5710 remaining=`find . -type f -print`
5711 if test -n "$remaining"; then
5712 echo "Remaining files:" $remaining 1>&2
5713 echo "gnulib-tool: *** Stop." 1>&2
5721 extract-description )
5725 if test -n "$module"; then
5726 func_get_description "$module"
5735 if test -n "$module"; then
5736 func_get_comment "$module"
5745 if test -n "$module"; then
5746 func_get_status "$module"
5755 if test -n "$module"; then
5756 func_get_notice "$module"
5761 extract-applicability )
5765 if test -n "$module"; then
5766 func_get_applicability "$module"
5775 if test -n "$module"; then
5776 func_get_filelist "$module"
5781 extract-dependencies )
5785 if test -n "$module"; then
5786 func_get_dependencies "$module"
5791 extract-autoconf-snippet )
5795 if test -n "$module"; then
5796 func_get_autoconf_snippet "$module"
5801 extract-automake-snippet )
5805 if test -n "$module"; then
5806 func_get_automake_snippet "$module"
5811 extract-include-directive )
5815 if test -n "$module"; then
5816 func_get_include_directive "$module"
5821 extract-link-directive )
5825 if test -n "$module"; then
5826 func_get_link_directive "$module"
5835 if test -n "$module"; then
5836 func_get_license "$module"
5841 extract-maintainer )
5845 if test -n "$module"; then
5846 func_get_maintainer "$module"
5851 extract-tests-module )
5855 if test -n "$module"; then
5856 func_get_tests_module "$module"
5862 # Verify the number of arguments.
5863 if test $# -lt 1 || test $# -gt 2; then
5864 func_fatal_error "invalid number of arguments for --$mode"
5867 # The first argument is the file to be copied.
5869 # Verify the file exists.
5870 func_lookup_file "$f"
5872 # The second argument is the destination; either a directory ot a file.
5873 # It defaults to the current directory.
5875 test -n "$dest" || dest='.'
5876 test -n "$sourcebase" || sourcebase="lib"
5877 test -n "$m4base" || m4base="m4"
5878 test -n "$docbase" || docbase="doc"
5879 test -n "$testsbase" || testsbase="tests"
5880 test -n "$auxdir" || auxdir="build-aux"
5881 rewritten='%REWRITTEN%'
5882 sed_rewrite_files="\
5883 s,^build-aux/,$rewritten$auxdir/,
5884 s,^doc/,$rewritten$docbase/,
5885 s,^lib/,$rewritten$sourcebase/,
5886 s,^m4/,$rewritten$m4base/,
5887 s,^tests/,$rewritten$testsbase/,
5890 if test -d "$dest"; then
5892 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5894 destdir=`dirname "$dest"`
5895 g=`basename "$dest"`
5898 # Create the directory for destfile.
5899 d=`dirname "$destdir/$g"`
5901 if test -n "$d" && test ! -d "$d"; then
5902 mkdir -p "$d" || func_fatal_error "failed"
5906 func_dest_tmpfilename "$g"
5907 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5908 already_present=true
5909 if test -f "$destdir/$g"; then
5910 # The file already exists.
5914 # Don't protest if the file should be there but isn't: it happens
5915 # frequently that developers don't put autogenerated files under version
5923 func_fatal_error "unknown operation mode --$mode" ;;
5927 # Undo the effect of the previous 'trap' command. Some shellology:
5928 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5929 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5930 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5931 # 128 + signal number and is set before the trap-registered command is run.
5933 trap 'func_exit $?' 1 2 3 13 15
5938 # indent-tabs-mode: nil
5939 # whitespace-check-buffer-indent: nil