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]
131 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
132 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
133 gnulib-tool --test --dir=directory module1 ... moduleN
134 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
135 gnulib-tool --extract-description module
136 gnulib-tool --extract-comment module
137 gnulib-tool --extract-status module
138 gnulib-tool --extract-notice module
139 gnulib-tool --extract-applicability module
140 gnulib-tool --extract-filelist module
141 gnulib-tool --extract-dependencies module
142 gnulib-tool --extract-autoconf-snippet module
143 gnulib-tool --extract-automake-snippet module
144 gnulib-tool --extract-include-directive module
145 gnulib-tool --extract-link-directive module
146 gnulib-tool --extract-license module
147 gnulib-tool --extract-maintainer module
148 gnulib-tool --extract-tests-module module
149 gnulib-tool --copy-file file [destination]
152 --list print the available module names
153 --find find the modules which contain the specified file
154 --import import the given modules into the current package;
155 if no modules are specified, update the current
156 package from the current gnulib
157 --update update the current package, restore files omitted
159 --create-testdir create a scratch package with the given modules
160 --create-megatestdir create a mega scratch package with the given modules
161 one by one and all together
162 --test test the combination of the given modules
163 (recommended to use CC=\"gcc -Wall\" here)
164 --megatest test the given modules one by one and all together
165 (recommended to use CC=\"gcc -Wall\" here)
166 --extract-description extract the description
167 --extract-comment extract the comment
168 --extract-status extract the status (obsolete etc.)
169 --extract-notice extract the notice or banner
170 --extract-applicability extract the applicability
171 --extract-filelist extract the list of files
172 --extract-dependencies extract the dependencies
173 --extract-autoconf-snippet extract the snippet for configure.ac
174 --extract-automake-snippet extract the snippet for library makefile
175 --extract-include-directive extract the #include directive
176 --extract-link-directive extract the linker directive
177 --extract-license report the license terms of the source files
179 --extract-maintainer report the maintainer(s) inside gnulib
180 --extract-tests-module report the unit test module, if it exists
181 --copy-file copy a file that is not part of any module
184 --dir=DIRECTORY Specify the target directory.
185 For --import, this specifies where your
186 configure.ac can be found. Defaults to current
188 --local-dir=DIRECTORY Specify a local override directory where to look
189 up files before looking in gnulib's directory.
190 --cache-modules Enable module caching optimization.
191 --no-cache-modules Disable module caching optimization.
192 --verbose Increase verbosity. May be repeated.
193 --quiet Decrease verbosity. May be repeated.
195 Options for --import, --update:
196 --dry-run Only print what would have been done.
198 Options for --import, --create-[mega]testdir, --[mega]test:
199 --with-tests Include unit tests for the included modules.
200 --with-obsolete Include obsolete modules when they occur among the
201 dependencies. By default, dependencies to obsolete
203 --with-c++-tests Include even unit tests for C++ interoperability.
204 --with-longrunning-tests
205 Include even unit tests that are long-runners.
206 --with-privileged-tests
207 Include even unit tests that require root
209 --with-unportable-tests
210 Include even unit tests that fail on some platforms.
211 --with-all-tests Include all kinds of problematic unit tests.
212 --avoid=MODULE Avoid including the given MODULE. Useful if you
213 have code that provides equivalent functionality.
214 This option can be repeated.
215 --libtool Use libtool rules.
216 --no-libtool Don't use libtool rules.
218 Options for --import:
219 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
220 --source-base=DIRECTORY
221 Directory relative to --dir where source code is
222 placed (default \"lib\").
223 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
224 placed (default \"m4\").
225 --po-base=DIRECTORY Directory relative to --dir where *.po files are
226 placed (default \"po\").
227 --doc-base=DIRECTORY Directory relative to --dir where doc files are
228 placed (default \"doc\").
229 --tests-base=DIRECTORY
230 Directory relative to --dir where unit tests are
231 placed (default \"tests\").
232 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
233 tools are placed (default \"build-aux\").
234 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
235 Also modify license template from GPL to LGPL.
236 The version number of the LGPL can be specified;
237 the default is currently LGPLv3.
238 --makefile-name=NAME Name of makefile in automake syntax in the
239 source-base and tests-base directories
240 (default \"Makefile.am\").
241 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
242 'gl_INIT'. Default is 'gl'.
243 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
244 the package name. A suffix '-gnulib' is appended.
245 --vc-files Update version control related files.
246 --no-vc-files Don't update version control related files
247 (.gitignore and/or .cvsignore).
248 --no-changelog Don't update or create ChangeLog files.
250 Options for --create-[mega]testdir, --[mega]test:
251 --without-c++-tests Exclude unit tests for C++ interoperability.
252 --without-longrunning-tests
253 Exclude unit tests that are long-runners.
254 --without-privileged-tests
255 Exclude unit tests that require root privileges.
256 --without-unportable-tests
257 Exclude unit tests that fail on some platforms.
259 Options for --import, --update, --create-[mega]testdir, --[mega]test:
260 -s, --symbolic, --symlink Make symbolic links instead of copying files.
261 --local-symlink Make symbolic links instead of copying files, only
262 for files from the local override directory.
264 Options for --import, --update:
265 -S, --more-symlinks Make symbolic links instead of copying files, and
266 don't replace copyright notices.
268 Report bugs to <bug-gnulib@gnu.org>."
272 # outputs to stdout the --version message.
276 if test -d "$gnulib_dir"/.git \
277 && (git --version) >/dev/null 2>/dev/null \
278 && (date --version) >/dev/null 2>/dev/null; then
279 # gnulib checked out from git.
280 sed_extract_first_date='/^Date/{
284 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
285 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
286 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
287 date=`echo "$date" | sed -e "$sed_year_before_time"`
288 # Use GNU date to compute the time in GMT.
289 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
290 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
292 if test -d "$gnulib_dir"/CVS \
293 && (cvs --version) >/dev/null 2>/dev/null; then
294 # gnulib checked out from CVS.
295 sed_extract_first_date='/^date: /{
296 s/^date: \([0-9][0-9][0-9][0-9]\).\([0-9][0-9]\).\([0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1-\2-\3 \4/p
299 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
301 # gnulib copy without versioning information.
302 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
306 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
308 gnulib-tool (GNU $package $date)$version
309 Copyright (C) $year Free Software Foundation, Inc.
310 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
311 This is free software: you are free to change and redistribute it.
312 There is NO WARRANTY, to the extent permitted by law.
314 Written by" "Bruno Haible" "and" "Simon Josefsson"
317 # func_emit_copyright_notice
318 # outputs to stdout a header for a generated file.
319 func_emit_copyright_notice ()
321 sed -n -e '/Copyright/ {
324 }' < "$self_abspathname"
326 echo "# This file is free software, distributed under the terms of the GNU"
327 echo "# General Public License. As a special exception to the GNU General"
328 echo "# Public License, this file may be distributed as part of a program"
329 echo "# that contains a configuration script generated by Autoconf, under"
330 echo "# the same distribution terms as the rest of that program."
332 echo "# Generated by gnulib-tool."
336 # exits with a given status.
337 # This function needs to be used, rather than 'exit', when a 'trap' handler is
338 # in effect that refers to $?.
345 # locates the directory where the gnulib repository lives
347 # - progname name of this program
349 # - self_abspathname absolute pathname of gnulib-tool
350 # - gnulib_dir absolute pathname of gnulib repository
354 /*) self_abspathname="$progname" ;;
355 */*) self_abspathname=`pwd`/"$progname" ;;
358 # Iterate through the elements of $PATH.
359 # We use IFS=: instead of
360 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
361 # because the latter does not work when some PATH element contains spaces.
362 # We use a canonicalized $pathx instead of $PATH, because empty PATH
363 # elements are by definition equivalent to '.', however field splitting
364 # according to IFS=: loses empty fields in many shells:
365 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
366 # beginning, at the end, and in the middle),
367 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
368 # at the beginning and at the end,
369 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
370 # Solaris lose empty fields at the end.
371 # The 'case' statement is an optimization, to avoid evaluating the
372 # explicit canonicalization command when $PATH contains no empty fields.
374 if test "${PATH_SEPARATOR+set}" != set; then
375 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
376 # contains only /bin. Note that ksh looks also at the FPATH variable,
377 # so we have to set that as well for the test.
379 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
380 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
381 || PATH_SEPARATOR=';'
384 if test "$PATH_SEPARATOR" = ";"; then
385 # On Windows, programs are searched in "." before $PATH.
388 # On Unix, we have to convert empty PATH elements to ".".
392 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
397 IFS="$PATH_SEPARATOR"
401 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
402 self_abspathname="$d/$progname"
407 if test -z "$self_abspathname"; then
408 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
412 while test -h "$self_abspathname"; do
413 # Resolve symbolic link.
414 linkval=`func_readlink "$self_abspathname"`
415 test -n "$linkval" || break
417 /* ) self_abspathname="$linkval" ;;
418 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
421 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
425 # creates a temporary directory.
427 # - progname name of this program
429 # - tmp pathname of freshly created temporary directory
432 # Use the environment variable TMPDIR, falling back to /tmp. This allows
433 # users to specify a different temporary directory, for example, if their
434 # /tmp is filled up or too small.
437 # Use the mktemp program if available. If not available, hide the error
439 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
440 test -n "$tmp" && test -d "$tmp"
443 # Use a simple mkdir command. It is guaranteed to fail if the directory
444 # already exists. $RANDOM is bash specific and expands to empty in shells
445 # other than bash, ksh and zsh. Its use does not increase security;
446 # rather, it minimizes the probability of failure in a very cluttered /tmp
448 tmp=$TMPDIR/gl$$-$RANDOM
449 (umask 077 && mkdir "$tmp")
452 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
457 # func_append var value
458 # appends the given value to the shell variable var.
459 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
460 # Use bash's += operator. It reduces complexity of appending repeatedly to
461 # a single variable from O(n^2) to O(n).
466 fast_func_append=true
470 eval "$1=\"\$$1\$2\""
472 fast_func_append=false
475 # func_remove_prefix var prefix
476 # removes the given prefix from the value of the shell variable var.
477 # var should be the name of a shell variable.
478 # Its value should not contain a newline and not start or end with whitespace.
479 # prefix should not contain the characters "$`\{}[]^|.
480 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
481 func_remove_prefix ()
485 fast_func_remove_prefix=true
487 func_remove_prefix ()
489 eval "value=\"\$$1\""
493 sed_escape_dots='s/\([.]\)/\\\1/g'
494 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
497 value=`echo "$value" | sed -e "s|^${prefix}||"`
498 eval "$1=\"\$value\""
500 fast_func_remove_prefix=false
503 # func_remove_suffix var suffix
504 # removes the given suffix from the value of the shell variable var.
505 # var should be the name of a shell variable.
506 # Its value should not contain a newline and not start or end with whitespace.
507 # suffix should not contain the characters "$`\{}[]^|.
508 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
509 func_remove_suffix ()
513 fast_func_remove_suffix=true
515 func_remove_suffix ()
517 eval "value=\"\$$1\""
521 sed_escape_dots='s/\([.]\)/\\\1/g'
522 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
525 value=`echo "$value" | sed -e "s|${suffix}\$||"`
526 eval "$1=\"\$value\""
528 fast_func_remove_suffix=false
531 # func_fatal_error message
532 # outputs to stderr a fatal error message, and terminates the program.
534 # - progname name of this program
537 echo "$progname: *** $1" 1>&2
538 echo "$progname: *** Stop." 1>&2
542 # func_warning message
543 # Outputs to stderr a warning message,
546 echo "gnulib-tool: warning: $1" 1>&2
549 # func_readlink SYMLINK
550 # outputs the target of the given symlink.
551 if (type -p readlink) > /dev/null 2>&1; then
554 # Use the readlink program from GNU coreutils.
560 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
561 # would do the wrong thing if the link target contains " -> ".
562 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
566 # func_relativize DIR1 DIR2
567 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
569 # - DIR1 relative pathname, relative to the current directory
570 # - DIR2 relative pathname, relative to the current directory
572 # - reldir relative pathname of DIR2, relative to DIR1
578 sed_first='s,^\([^/]*\)/.*$,\1,'
579 sed_rest='s,^[^/]*/*,,'
580 sed_last='s,^.*/\([^/]*\)$,\1,'
581 sed_butlast='s,/*[^/]*$,,'
582 while test -n "$dir1"; do
583 first=`echo "$dir1" | sed -e "$sed_first"`
584 if test "$first" != "."; then
585 if test "$first" = ".."; then
586 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
587 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
589 first2=`echo "$dir2" | sed -e "$sed_first"`
590 if test "$first2" = "$first"; then
591 dir2=`echo "$dir2" | sed -e "$sed_rest"`
595 dir0="$dir0"/"$first"
598 dir1=`echo "$dir1" | sed -e "$sed_rest"`
603 # func_relconcat DIR1 DIR2
604 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
606 # - DIR1 relative pathname, relative to the current directory
607 # - DIR2 relative pathname, relative to DIR1
609 # - relconcat DIR1/DIR2, relative to the current directory
614 sed_first='s,^\([^/]*\)/.*$,\1,'
615 sed_rest='s,^[^/]*/*,,'
616 sed_last='s,^.*/\([^/]*\)$,\1,'
617 sed_butlast='s,/*[^/]*$,,'
619 first=`echo "$dir2" | sed -e "$sed_first"`
620 if test "$first" = "."; then
621 dir2=`echo "$dir2" | sed -e "$sed_rest"`
622 if test -z "$dir2"; then
627 last=`echo "$dir1" | sed -e "$sed_last"`
628 while test "$last" = "."; do
629 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
630 last=`echo "$dir1" | sed -e "$sed_last"`
632 if test -z "$dir1"; then
636 if test "$first" = ".."; then
637 if test "$last" = ".."; then
638 relconcat="$dir1/$dir2"
641 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
642 dir2=`echo "$dir2" | sed -e "$sed_rest"`
643 if test -z "$dir1"; then
647 if test -z "$dir2"; then
652 relconcat="$dir1/$dir2"
660 # Like ln -s, except that SRC is given relative to the current directory (or
661 # absolute), not given relative to the directory of DEST.
667 *) # SRC is relative.
670 ln -s "`pwd`/$1" "$2" ;;
671 *) # DEST is relative too.
672 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
673 test -n "$ln_destdir" || ln_destdir="."
674 func_relativize "$ln_destdir" "$1"
682 # func_ln_if_changed SRC DEST
683 # Like func_ln, but avoids munging timestamps if the link is correct.
684 func_ln_if_changed ()
686 if test $# -ne 2; then
687 echo "usage: func_ln_if_changed SRC DEST" >&2
689 ln_target=`func_readlink "$2"`
690 if test -h "$2" && test "$1" = "$ln_target"; then
698 # Ensure an 'echo' command that
699 # 1. does not interpret backslashes and
700 # 2. does not print an error message "broken pipe" when writing into a pipe
703 # Test cases for problem 1:
704 # echo '\n' | wc -l prints 1 when OK, 2 when KO
705 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
706 # Test cases for problem 2:
707 # echo hi | true frequently prints
708 # "bash: echo: write error: Broken pipe"
709 # to standard error in bash 3.2.
711 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
712 # BSD echo interprets '-n' as an option, which is also not desirable).
713 # Nowadays the problem occurs in 4 situations:
714 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
715 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
716 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
717 # - in zsh, when sh-emulation is not set,
718 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
719 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
720 # - in Solaris /bin/sh and OSF/1 /bin/sh.
721 # We try the following workarounds:
722 # - for all: respawn using $CONFIG_SHELL if that is set and works.
723 # - for bash >= 2.04: unset the shell option xpg_echo.
724 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
725 # - for bash < 2.0: define echo to a function that uses cat of a here document.
726 # - for zsh: turn sh-emulation on.
727 # - for ksh: alias echo to 'print -r'.
728 # - for ksh: alias echo to a function that uses cat of a here document.
729 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
730 # the ksh workaround.
731 # - otherwise: respawn using /bin/sh and rely on the workarounds.
732 # When respawning, we pass --no-reexec as first argument, so as to avoid
733 # turning this script into a fork bomb in unlucky situations.
735 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
736 # the 'printf' built-in. See
737 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
738 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
739 # The workaround is: define echo to a function that uses the printf built-in.
741 if echo '\t' | grep t > /dev/null; then
742 have_echo=yes # Lucky!
744 # Try the workarounds.
745 # Respawn using $CONFIG_SHELL if that is set and works.
746 if test -z "$have_echo" \
747 && test "X$1" != "X--no-reexec" \
748 && test -n "$CONFIG_SHELL" \
749 && test -f "$CONFIG_SHELL" \
750 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
751 exec $CONFIG_SHELL "$0" --no-reexec "$@"
754 # For bash >= 2.04: unset the shell option xpg_echo.
755 if test -z "$have_echo" \
756 && test -n "$BASH_VERSION" \
757 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
761 # For bash >= 2.0: define echo to a function that uses the printf built-in.
762 # For bash < 2.0: define echo to a function that uses cat of a here document.
763 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
764 # Also handle problem 2, specific to bash 3.2, here.
765 if { test -z "$have_echo" \
766 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
768 && test -n "$BASH_VERSION"; then \
769 if type printf 2>/dev/null | grep / > /dev/null; then
770 # 'printf' is not a shell built-in.
778 # 'printf' is a shell built-in.
784 if echo '\t' | grep t > /dev/null; then
788 # For zsh: turn sh-emulation on.
789 if test -z "$have_echo" \
790 && test -n "$ZSH_VERSION" \
791 && (emulate sh) >/dev/null 2>&1; then
794 # For ksh: alias echo to 'print -r'.
795 if test -z "$have_echo" \
796 && (type print) >/dev/null 2>&1; then
797 # A 'print' command exists.
798 if type print 2>/dev/null | grep / > /dev/null; then
801 # 'print' is a shell built-in.
802 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
803 # 'print' is the ksh shell built-in.
804 alias echo='print -r'
808 if test -z "$have_echo" \
809 && echo '\t' | grep t > /dev/null; then
812 # For ksh: alias echo to a function that uses cat of a here document.
813 # The ksh manual page says:
814 # "Aliasing is performed when scripts are read, not while they are executed.
815 # Therefore, for an alias to take effect, the alias definition command has
816 # to be executed before the command which references the alias is read."
817 # Because of this, we have to play strange tricks with have_echo, to ensure
818 # that the top-level statement containing the test starts after the 'alias'
820 if test -z "$have_echo"; then
827 alias echo=bsd_echo 2>/dev/null
829 if test -z "$have_echo" \
830 && echo '\t' | grep t > /dev/null; then
833 if test -z "$have_echo"; then
834 unalias echo 2>/dev/null
836 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
837 if test -z "$have_echo" \
838 && test "X$1" != "X--no-reexec" \
839 && test -f /bin/ksh; then
840 exec /bin/ksh "$0" --no-reexec "$@"
843 # Otherwise: respawn using /bin/sh.
844 if test -z "$have_echo" \
845 && test "X$1" != "X--no-reexec" \
846 && test -f /bin/sh; then
847 exec /bin/sh "$0" --no-reexec "$@"
850 if test -z "$have_echo"; then
851 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
853 if echo '\t' | grep t > /dev/null; then
856 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
858 if test "X$1" = "X--no-reexec"; then
862 # Command-line option processing.
863 # Removes the OPTIONS from the arguments. Sets the variables:
864 # - mode list or import or create-testdir or create-megatestdir
865 # - destdir from --dir
866 # - local_gnulib_dir from --local-dir
867 # - modcache true or false, from --cache-modules/--no-cache-modules
868 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
869 # - libname, supplied_libname from --lib
870 # - sourcebase from --source-base
871 # - m4base from --m4-base
872 # - pobase from --po-base
873 # - docbase from --doc-base
874 # - testsbase from --tests-base
875 # - auxdir from --aux-dir
876 # - inctests true if --with-tests was given, blank otherwise
877 # - incobsolete true if --with-obsolete was given, blank otherwise
878 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
879 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
881 # - inc_privileged_tests true if --with-privileged-tests was given, blank
883 # - inc_unportable_tests true if --with-unportable-tests was given, blank
885 # - inc_all_tests true if --with-all-tests was given, blank otherwise
886 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
887 # - excl_longrunning_tests true if --without-longrunning-tests was given,
889 # - excl_privileged_tests true if --without-privileged-tests was given, blank
891 # - excl_unportable_tests true if --without-unportable-tests was given, blank
893 # - avoidlist list of modules to avoid, from --avoid
894 # - lgpl yes or a number if --lgpl was given, blank otherwise
895 # - makefile_name from --makefile-name
896 # - libtool true if --libtool was given, false if --no-libtool was
897 # given, blank otherwise
898 # - macro_prefix from --macro-prefix
899 # - po_domain from --po-domain
900 # - vc_files true if --vc-files was given, false if --no-vc-files was
901 # given, blank otherwise
902 # - autoconf_minversion minimum supported autoconf version
903 # - do_changelog false if --no-changelog was given, : otherwise
904 # - doit : if actions shall be executed, false if only to be printed
905 # - symbolic true if --symlink or --more-symlinks was given, blank
907 # - lsymbolic true if --local-symlink was given, blank otherwise
908 # - do_copyrights blank if --more-symlinks was given, true otherwise
926 inc_longrunning_tests=
927 inc_privileged_tests=
928 inc_unportable_tests=
931 excl_longrunning_tests=
932 excl_privileged_tests=
933 excl_unportable_tests=
949 while test $# -gt 0; do
954 --find | --fin | --fi | --f )
957 --import | --impor | --impo | --imp | --im | --i )
960 --update | --updat | --upda | --upd | --up | --u )
963 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
966 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
967 mode=create-megatestdir
969 --test | --tes | --te | --t )
972 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
976 mode=`echo "X$1" | sed -e 's/^X--//'`
978 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
984 func_fatal_error "missing argument for --dir"
989 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
994 func_fatal_error "missing argument for --local-dir"
999 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1001 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1004 --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 )
1007 --verbose | --verbos | --verbo | --verb )
1008 verbose=`expr $verbose + 1`
1010 --quiet | --quie | --qui | --qu | --q )
1011 verbose=`expr $verbose - 1`
1015 if test $# = 0; then
1016 func_fatal_error "missing argument for --lib"
1019 supplied_libname=true
1022 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1023 supplied_libname=true
1027 if test $# = 0; then
1028 func_fatal_error "missing argument for --source-base"
1033 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1037 if test $# = 0; then
1038 func_fatal_error "missing argument for --m4-base"
1043 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1047 if test $# = 0; then
1048 func_fatal_error "missing argument for --po-base"
1053 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1057 if test $# = 0; then
1058 func_fatal_error "missing argument for --doc-base"
1063 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1067 if test $# = 0; then
1068 func_fatal_error "missing argument for --tests-base"
1073 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1077 if test $# = 0; then
1078 func_fatal_error "missing argument for --aux-dir"
1083 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1085 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1088 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1091 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1094 --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)
1095 inc_longrunning_tests=true
1097 --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)
1098 inc_privileged_tests=true
1100 --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)
1101 inc_unportable_tests=true
1103 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1106 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1109 --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)
1110 excl_longrunning_tests=true
1112 --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)
1113 excl_privileged_tests=true
1115 --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)
1116 excl_unportable_tests=true
1120 if test $# = 0; then
1121 func_fatal_error "missing argument for --avoid"
1123 func_append avoidlist " $1"
1126 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1127 func_append avoidlist " $arg"
1133 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1136 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1142 if test $# = 0; then
1143 func_fatal_error "missing argument for --makefile-name"
1148 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1158 if test $# = 0; then
1159 func_fatal_error "missing argument for --macro-prefix"
1164 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1168 if test $# = 0; then
1169 func_fatal_error "missing argument for --po-domain"
1174 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1182 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1188 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1191 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1194 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1198 --help | --hel | --he | --h )
1201 --version | --versio | --versi | --vers )
1205 # Stop option processing
1209 echo "gnulib-tool: unknown option $1" 1>&2
1210 echo "Try 'gnulib-tool --help' for more information." 1>&2
1217 if test "$mode" = import; then
1218 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1219 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then
1220 echo "gnulib-tool: invalid options for 'import' mode" 1>&2
1221 echo "Try 'gnulib-tool --help' for more information." 1>&2
1225 if test "$mode" = update; then
1226 if test $# != 0; then
1227 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1228 echo "Try 'gnulib-tool --help' for more information." 1>&2
1229 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1230 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1233 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1234 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1235 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1236 || test -n "$inctests" || test -n "$incobsolete" \
1237 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1238 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1239 || test -n "$inc_all_tests" \
1240 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1241 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1242 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1243 || test -n "$macro_prefix" || test -n "$po_domain" \
1244 || test -n "$vc_files"; then
1245 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1246 echo "Try 'gnulib-tool --help' for more information." 1>&2
1247 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1248 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1253 if test -n "$pobase" && test -z "$po_domain"; then
1254 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1255 echo "Try 'gnulib-tool --help' for more information." 1>&2
1258 if test -z "$pobase" && test -n "$po_domain"; then
1259 func_warning "--po-domain has no effect without a --po-base option"
1262 # Determine the minimum supported autoconf version from the project's
1264 DEFAULT_AUTOCONF_MINVERSION="2.59"
1265 autoconf_minversion=
1267 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1268 if test -f "$destdir"/configure.ac; then
1269 configure_ac="$destdir/configure.ac"
1271 if test -f "$destdir"/configure.in; then
1272 configure_ac="$destdir/configure.in"
1276 if test -f configure.ac; then
1277 configure_ac="configure.ac"
1279 if test -f configure.in; then
1280 configure_ac="configure.in"
1284 if test -n "$configure_ac"; then
1285 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1286 # because when some m4 files are omitted from a CVS repository,
1287 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1288 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1289 # autom4te: m4 failed with exit status: 1
1296 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1298 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1299 if test -n "$prereqs"; then
1300 autoconf_minversion=`
1301 for version in $prereqs; do echo $version; done |
1302 LC_ALL=C sort -nru | sed -e 1q
1306 if test -z "$autoconf_minversion"; then
1307 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1309 case "$autoconf_minversion" in
1310 1.* | 2.[0-4]* | 2.5[0-8]*)
1311 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1314 # Remove trailing slashes from the directory names. This is necessary for
1315 # m4base (to avoid an error in func_import) and optional for the others.
1316 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1317 case "$local_gnulib_dir" in
1318 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1320 case "$sourcebase" in
1321 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1324 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1327 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1330 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1332 case "$testsbase" in
1333 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1336 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1342 trap 'exit_status=$?
1343 if test "$signal" != 0; then
1344 echo "caught signal $signal" >&2
1347 exit $exit_status' 0
1348 for signal in 1 2 3 13 15; do
1349 trap '{ signal='$signal'; func_exit 1; }' $signal
1353 # func_lookup_file file
1354 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1357 # - local_gnulib_dir from --local-dir
1359 # - lookedup_file name of the merged (combined) file
1360 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1364 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1365 lookedup_file="$local_gnulib_dir/$lkfile"
1368 if test -f "$gnulib_dir/$lkfile"; then
1369 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1370 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1371 rm -f "$tmp/$lkbase"
1372 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1373 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1374 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1375 lookedup_file="$tmp/$lkbase"
1378 lookedup_file="$gnulib_dir/$lkfile"
1382 func_fatal_error "file $gnulib_dir/$lkfile not found"
1387 # func_sanitize_modulelist
1388 # receives a list of possible module names on standard input, one per line.
1389 # It removes those which are just file names unrelated to modules, and outputs
1390 # the resulting list to standard output, one per line.
1391 func_sanitize_modulelist ()
1393 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1394 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1395 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1396 -e '/^README$/d' -e '/\/README$/d' \
1397 -e '/^TEMPLATE$/d' \
1398 -e '/^TEMPLATE-EXTENDED$/d' \
1399 -e '/^TEMPLATE-TESTS$/d' \
1406 # - local_gnulib_dir from --local-dir
1409 # Filter out metainformation files like README, which are not modules.
1410 # Filter out unit test modules; they can be retrieved through
1411 # --extract-tests-module if desired.
1413 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1414 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1415 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1418 | func_sanitize_modulelist \
1419 | sed -e '/-tests$/d' \
1423 # func_exists_module module
1424 # tests whether a module, given by name, exists
1426 # - local_gnulib_dir from --local-dir
1427 func_exists_module ()
1429 { test -f "$gnulib_dir/modules/$1" \
1430 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1431 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1432 && test "CVS" != "$1" \
1433 && test "ChangeLog" != "$1" \
1434 && test "COPYING" != "$1" \
1435 && test "README" != "$1" \
1436 && test "TEMPLATE" != "$1" \
1437 && test "TEMPLATE-EXTENDED" != "$1" \
1438 && test "TEMPLATE-TESTS" != "$1"
1441 # func_verify_module
1442 # verifies a module name
1444 # - local_gnulib_dir from --local-dir
1445 # - module module name argument
1446 func_verify_module ()
1448 if func_exists_module "$module"; then
1449 # OK, $module is a correct module name.
1450 # Verify that building the module description with 'patch' succeeds.
1451 func_lookup_file "modules/$module"
1453 func_warning "module $module doesn't exist"
1458 # func_verify_nontests_module
1459 # verifies a module name, excluding tests modules
1461 # - local_gnulib_dir from --local-dir
1462 # - module module name argument
1463 func_verify_nontests_module ()
1466 *-tests ) module= ;;
1467 * ) func_verify_module ;;
1471 # func_verify_tests_module
1472 # verifies a module name, considering only tests modules
1474 # - local_gnulib_dir from --local-dir
1475 # - module module name argument
1476 func_verify_tests_module ()
1479 *-tests ) func_verify_module ;;
1484 # Suffix of a sed expression that extracts a particular field from a
1485 # module description.
1486 # A field starts with a line that contains a keyword, such as 'Description',
1487 # followed by a colon and optional whitespace. All following lines, up to
1488 # the next field (or end of file if there is none) form the contents of the
1490 # An absent field is equivalent to a field with empty contents.
1491 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1492 sed_extract_prog=':[ ]*$/ {
1495 s/^Description:[ ]*$//
1499 s/^Applicability:[ ]*$//
1501 s/^Depends-on:[ ]*$//
1502 s/^configure\.ac-early:[ ]*$//
1503 s/^configure\.ac:[ ]*$//
1504 s/^Makefile\.am:[ ]*$//
1508 s/^Maintainer:[ ]*$//
1515 # Piece of a sed expression that converts a field header line to a shell
1517 # NOTE: Keep this in sync with sed_extract_prog above!
1518 sed_extract_field_header='
1519 s/^Description:[ ]*$/description/
1520 s/^Comment:[ ]*$/comment/
1521 s/^Status:[ ]*$/status/
1522 s/^Notice:[ ]*$/notice/
1523 s/^Applicability:[ ]*$/applicability/
1524 s/^Files:[ ]*$/files/
1525 s/^Depends-on:[ ]*$/dependson/
1526 s/^configure\.ac-early:[ ]*$/configureac_early/
1527 s/^configure\.ac:[ ]*$/configureac/
1528 s/^Makefile\.am:[ ]*$/makefile/
1529 s/^Include:[ ]*$/include/
1531 s/^License:[ ]*$/license/
1532 s/^Maintainer:[ ]*$/maintainer/'
1536 # Note: The 'eval' silences stderr output in dash.
1537 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1538 # Zsh 4 and Bash 4 have associative arrays.
1539 have_associative=true
1541 # For other shells, use 'eval' with computed shell variable names.
1542 have_associative=false
1545 if $have_associative; then
1547 # Declare the associative arrays.
1548 declare -A modcache_cached
1549 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1550 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1551 eval "$declare_script"
1555 # func_cache_var module
1556 # computes the cache variable name corresponding to $module.
1557 # Note: This computation can map different module names to the same
1558 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1559 # to protect against this case.
1561 # - cachevar a shell variable name
1562 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1563 # Bash 2.0 and newer, ksh, and zsh support the syntax
1564 # ${param//pattern/replacement}
1565 # as a shorthand for
1566 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1567 # Note: The 'eval' above silences stderr output in dash.
1570 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1577 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1586 # func_init_sed_convert_to_cache_statements
1588 # - modcachevar_assignment
1590 # - sed_convert_to_cache_statements
1591 func_init_sed_convert_to_cache_statements ()
1593 # 'sed' script that turns a module description into shell script
1594 # assignments, suitable to be eval'ed. All active characters are escaped.
1597 # Some module's description
1602 # modcache_description[$1]=\
1603 # 'Some module'"'"'s description
1605 # modcache_files[$1]=\
1608 # c_MODULE_description_set=set; c_MODULE_description=\
1609 # 'Some module'"'"'s description
1611 # c_MODULE_files_set=set; c_MODULE_files=\
1613 # The script consists of two parts:
1614 # 1) Ignore the lines before the first field header.
1615 # 2) A loop, treating non-field-header lines by escaping single quotes
1616 # and adding a closing quote in the last line,
1617 sed_convert_to_cache_statements="
1619 # Here we have not yet seen a field header.
1621 # See if the current line contains a field header.
1624 ${sed_extract_field_header}
1627 # No field header. Ignore the line.
1629 # Read the next line. Upon EOF, just exit.
1634 # The current line contains a field header.
1636 # Turn it into the beginning of an assignment.
1637 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1639 # Move it to the hold space. Don't print it yet,
1640 # because we want no assignment if the field is empty.
1643 # Read the next line.
1644 # Upon EOF, the field was empty. Print no assignment. Just exit.
1647 # See if the current line contains a field header.
1650 ${sed_extract_field_header}
1651 # If it is, the previous field was empty. Print no assignment.
1654 # Not a field header.
1656 # Print the previous line, held in the hold space.
1661 # Transform single quotes.
1664 # Prepend a single quote.
1669 # Move it to the hold space.
1672 # Read the next line.
1679 # See if the current line contains a field header.
1682 ${sed_extract_field_header}
1685 # Print the previous line, held in the hold space.
1690 # Transform single quotes.
1697 # Print the previous line, held in the hold space, with a single quote
1698 # to end the assignment.
1708 # Print the previous line, held in the hold space, with a single quote
1709 # to end the assignment.
1716 if ! $sed_comments; then
1718 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1719 | sed -e 's/^ *//' -e 's/^#.*//'`
1723 if $have_associative; then
1724 # sed_convert_to_cache_statements does not depend on the module.
1725 modcachevar_assignment='modcache_\1[$1]='
1726 func_init_sed_convert_to_cache_statements
1729 # func_cache_lookup_module module
1731 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1732 # of its relevant data in a cache in the memory of the processing shell. If
1733 # already cached, it does not look it up again, thus saving file access time.
1735 # - module non-empty string
1736 # Output if $have_associative:
1737 # - modcache_cached[$module] set to yes
1738 # - modcache_description[$module] ==
1739 # - modcache_status[$module] \ set to the field's value, minus the
1740 # - ... / final newline,
1741 # - modcache_maintainer[$module] == or unset if the field's value is empty
1742 # Output if ! $have_associative:
1743 # - cachevar a shell variable name
1744 # - ${cachevar}_cached set to $module
1745 # - ${cachevar}_description ==
1746 # - ${cachevar}_status \ set to the field's value, minus the
1747 # - ... / final newline,
1748 # - ${cachevar}_maintainer == or unset if the field's value is empty
1749 # - ${cachevar}_description_set ==
1750 # - ${cachevar}_status_set \ set to non-empty if the field's value
1751 # - ... / is non-empty,
1752 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1753 func_cache_lookup_module ()
1755 if $have_associative; then
1756 cached=${modcache_cached[$1]}
1759 eval "cached=\"\$${cachevar}_cached\""
1761 if test -z "$cached"; then
1762 # Not found in cache. Look it up on the file system.
1763 func_lookup_file "modules/$1"
1764 if $have_associative; then
1765 modcache_cached[$1]=yes
1767 eval "${cachevar}_cached=\"\$1\""
1769 if ! $have_associative; then
1770 # sed_convert_to_cache_statements depends on the module.
1771 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1772 func_init_sed_convert_to_cache_statements
1774 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1775 eval "$cache_statements"
1777 if ! $have_associative; then
1778 if test "$1" != "$cached"; then
1779 func_fatal_error "cache variable collision between $1 and $cached"
1787 # func_get_description module
1789 # - local_gnulib_dir from --local-dir
1790 # - modcache true or false, from --cache-modules/--no-cache-modules
1791 func_get_description ()
1793 if ! $modcache; then
1794 func_lookup_file "modules/$1"
1795 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1797 func_cache_lookup_module "$1"
1798 # Output the field's value, including the final newline (if any).
1799 if $have_associative; then
1800 if test -n "${modcache_description[$1]+set}"; then
1801 echo "${modcache_description[$1]}"
1804 eval "field_set=\"\$${cachevar}_description_set\""
1805 if test -n "$field_set"; then
1806 eval "field_value=\"\$${cachevar}_description\""
1807 echo "${field_value}"
1813 # func_get_comment module
1815 # - local_gnulib_dir from --local-dir
1816 # - modcache true or false, from --cache-modules/--no-cache-modules
1819 if ! $modcache; then
1820 func_lookup_file "modules/$1"
1821 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1823 func_cache_lookup_module "$1"
1824 # Output the field's value, including the final newline (if any).
1825 if $have_associative; then
1826 if test -n "${modcache_comment[$1]+set}"; then
1827 echo "${modcache_comment[$1]}"
1830 eval "field_set=\"\$${cachevar}_comment_set\""
1831 if test -n "$field_set"; then
1832 eval "field_value=\"\$${cachevar}_comment\""
1833 echo "${field_value}"
1839 # func_get_status module
1841 # - local_gnulib_dir from --local-dir
1842 # - modcache true or false, from --cache-modules/--no-cache-modules
1845 if ! $modcache; then
1846 func_lookup_file "modules/$1"
1847 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1849 func_cache_lookup_module "$1"
1850 # Output the field's value, including the final newline (if any).
1851 if $have_associative; then
1852 if test -n "${modcache_status[$1]+set}"; then
1853 echo "${modcache_status[$1]}"
1856 eval "field_set=\"\$${cachevar}_status_set\""
1857 if test -n "$field_set"; then
1858 eval "field_value=\"\$${cachevar}_status\""
1859 echo "${field_value}"
1865 # func_get_notice module
1867 # - local_gnulib_dir from --local-dir
1868 # - modcache true or false, from --cache-modules/--no-cache-modules
1871 if ! $modcache; then
1872 func_lookup_file "modules/$1"
1873 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1875 func_cache_lookup_module "$1"
1876 # Output the field's value, including the final newline (if any).
1877 if $have_associative; then
1878 if test -n "${modcache_notice[$1]+set}"; then
1879 echo "${modcache_notice[$1]}"
1882 eval "field_set=\"\$${cachevar}_notice_set\""
1883 if test -n "$field_set"; then
1884 eval "field_value=\"\$${cachevar}_notice\""
1885 echo "${field_value}"
1891 # func_get_applicability module
1893 # - local_gnulib_dir from --local-dir
1894 # - modcache true or false, from --cache-modules/--no-cache-modules
1895 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1896 func_get_applicability ()
1898 if ! $modcache; then
1899 func_lookup_file "modules/$1"
1900 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1902 func_cache_lookup_module "$1"
1903 # Get the field's value, without the final newline.
1904 if $have_associative; then
1905 my_applicability="${modcache_applicability[$1]}"
1907 eval "my_applicability=\"\$${cachevar}_applicability\""
1910 if test -n "$my_applicability"; then
1911 echo $my_applicability
1913 # The default is 'main' or 'tests', depending on the module's name.
1915 *-tests) echo "tests";;
1921 # func_get_filelist module
1923 # - local_gnulib_dir from --local-dir
1924 # - modcache true or false, from --cache-modules/--no-cache-modules
1925 func_get_filelist ()
1927 if ! $modcache; then
1928 func_lookup_file "modules/$1"
1929 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1931 func_cache_lookup_module "$1"
1932 # Output the field's value, including the final newline (if any).
1933 if $have_associative; then
1934 if test -n "${modcache_files[$1]+set}"; then
1935 echo "${modcache_files[$1]}"
1938 eval "field_set=\"\$${cachevar}_files_set\""
1939 if test -n "$field_set"; then
1940 eval "field_value=\"\$${cachevar}_files\""
1941 echo "${field_value}"
1946 echo m4/gnulib-common.m4
1947 case "$autoconf_minversion" in
1954 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1955 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1956 # elements starting with prefix and ending with suffix are considered.
1957 # Processing: removed_prefix and removed_suffix are removed from each element,
1958 # added_prefix and added_suffix are added to each element.
1959 # prefix, suffix should not contain shell-special characters.
1960 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1961 # added_prefix, added_suffix should not contain the characters \|&.
1962 func_filter_filelist ()
1964 if test "$2" != "$nl" \
1965 || { $fast_func_append \
1966 && { test -z "$6" || $fast_func_remove_prefix; } \
1967 && { test -z "$7" || $fast_func_remove_suffix; }; \
1971 # Do not quote possibly-empty parameters in case patterns,
1972 # AIX and HP-UX ksh won't match them if they are empty.
1975 if test -n "$6"; then
1976 func_remove_prefix fff "$6"
1978 if test -n "$7"; then
1979 func_remove_suffix fff "$7"
1982 if test -z "$ffflist"; then
1985 func_append ffflist "$2${fff}"
1991 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1992 ffflist=`for fff in $3; do
1994 $4*$5) echo "$fff" ;;
1996 done | sed -e "$sed_fff_filter"`
1998 eval "$1=\"\$ffflist\""
2001 # func_get_dependencies module
2003 # - local_gnulib_dir from --local-dir
2004 # - modcache true or false, from --cache-modules/--no-cache-modules
2005 func_get_dependencies ()
2007 # ${module}-tests implicitly depends on ${module}, if that module exists.
2011 func_remove_suffix fgd1 '-tests'
2012 if func_exists_module "$fgd1"; then
2017 # Then the explicit dependencies listed in the module description.
2018 if ! $modcache; then
2019 func_lookup_file "modules/$1"
2020 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2022 func_cache_lookup_module "$1"
2023 # Output the field's value, including the final newline (if any).
2024 if $have_associative; then
2025 if test -n "${modcache_dependson[$1]+set}"; then
2026 echo "${modcache_dependson[$1]}"
2029 eval "field_set=\"\$${cachevar}_dependson_set\""
2030 if test -n "$field_set"; then
2031 eval "field_value=\"\$${cachevar}_dependson\""
2032 echo "${field_value}"
2038 # func_get_autoconf_early_snippet module
2040 # - local_gnulib_dir from --local-dir
2041 # - modcache true or false, from --cache-modules/--no-cache-modules
2042 func_get_autoconf_early_snippet ()
2044 if ! $modcache; then
2045 func_lookup_file "modules/$1"
2046 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2048 func_cache_lookup_module "$1"
2049 # Output the field's value, including the final newline (if any).
2050 if $have_associative; then
2051 if test -n "${modcache_configureac_early[$1]+set}"; then
2052 echo "${modcache_configureac_early[$1]}"
2055 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2056 if test -n "$field_set"; then
2057 eval "field_value=\"\$${cachevar}_configureac_early\""
2058 echo "${field_value}"
2064 # func_get_autoconf_snippet module
2066 # - local_gnulib_dir from --local-dir
2067 # - modcache true or false, from --cache-modules/--no-cache-modules
2068 func_get_autoconf_snippet ()
2070 if ! $modcache; then
2071 func_lookup_file "modules/$1"
2072 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2074 func_cache_lookup_module "$1"
2075 # Output the field's value, including the final newline (if any).
2076 if $have_associative; then
2077 if test -n "${modcache_configureac[$1]+set}"; then
2078 echo "${modcache_configureac[$1]}"
2081 eval "field_set=\"\$${cachevar}_configureac_set\""
2082 if test -n "$field_set"; then
2083 eval "field_value=\"\$${cachevar}_configureac\""
2084 echo "${field_value}"
2090 # func_get_automake_snippet module
2092 # - local_gnulib_dir from --local-dir
2093 # - modcache true or false, from --cache-modules/--no-cache-modules
2094 func_get_automake_snippet ()
2096 if ! $modcache; then
2097 func_lookup_file "modules/$1"
2098 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2100 func_cache_lookup_module "$1"
2101 # Output the field's value, including the final newline (if any).
2102 if $have_associative; then
2103 if test -n "${modcache_makefile[$1]+set}"; then
2104 echo "${modcache_makefile[$1]}"
2107 eval "field_set=\"\$${cachevar}_makefile_set\""
2108 if test -n "$field_set"; then
2109 eval "field_value=\"\$${cachevar}_makefile\""
2110 echo "${field_value}"
2116 # *-tests module live in tests/, not lib/.
2117 # Synthesize an EXTRA_DIST augmentation.
2118 all_files=`func_get_filelist $1`
2119 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2120 extra_files="$tests_files"
2121 if test -n "$extra_files"; then
2122 echo "EXTRA_DIST +=" $extra_files
2127 # Synthesize an EXTRA_DIST augmentation.
2128 sed_combine_lines='/\\$/{
2135 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2136 already_mentioned_files=` \
2137 { if ! $modcache; then
2138 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2140 if $have_associative; then
2141 if test -n "${modcache_makefile[$1]+set}"; then
2142 echo "${modcache_makefile[$1]}"
2145 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2146 if test -n "$field_set"; then
2147 eval 'field_value="$'"${cachevar}"'_makefile"'
2148 echo "${field_value}"
2153 | sed -e "$sed_combine_lines" \
2154 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2155 all_files=`func_get_filelist $1`
2156 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2157 # Remove $already_mentioned_files from $lib_files.
2158 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2159 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2160 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2161 if test -n "$extra_files"; then
2162 echo "EXTRA_DIST +=" $extra_files
2165 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2166 # This is necessary so that automake can generate the right list of
2168 # A possible approach would be to use autom4te --trace of the redefined
2169 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2170 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2171 # inside autoconf's built-in macros are not missed).
2172 # But it's simpler and more robust to do it here, based on the file list.
2173 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2174 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2175 # automake will generate a useless dependency; this is harmless.
2177 relocatable-prog-wrapper) ;;
2179 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2180 if test -n "$extra_files"; then
2181 echo "EXTRA_lib_SOURCES +=" $extra_files
2186 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2187 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2188 if test -n "$buildaux_files"; then
2189 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2190 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2193 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2194 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2195 if test -n "$top_files"; then
2196 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2197 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2204 # func_get_include_directive module
2206 # - local_gnulib_dir from --local-dir
2207 # - modcache true or false, from --cache-modules/--no-cache-modules
2208 func_get_include_directive ()
2211 if ! $modcache; then
2212 func_lookup_file "modules/$1"
2213 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2215 func_cache_lookup_module "$1"
2216 # Output the field's value, including the final newline (if any).
2217 if $have_associative; then
2218 if test -n "${modcache_include[$1]+set}"; then
2219 echo "${modcache_include[$1]}"
2222 eval "field_set=\"\$${cachevar}_include_set\""
2223 if test -n "$field_set"; then
2224 eval "field_value=\"\$${cachevar}_include\""
2225 echo "${field_value}"
2229 } | sed -e 's/^\(["<]\)/#include \1/'
2232 # func_get_link_directive module
2234 # - local_gnulib_dir from --local-dir
2235 # - modcache true or false, from --cache-modules/--no-cache-modules
2236 func_get_link_directive ()
2238 if ! $modcache; then
2239 func_lookup_file "modules/$1"
2240 sed -n -e "/^Link$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_link[$1]+set}"; then
2246 echo "${modcache_link[$1]}"
2249 eval "field_set=\"\$${cachevar}_link_set\""
2250 if test -n "$field_set"; then
2251 eval "field_value=\"\$${cachevar}_link\""
2252 echo "${field_value}"
2258 # func_get_license module
2260 # - local_gnulib_dir from --local-dir
2261 # - modcache true or false, from --cache-modules/--no-cache-modules
2265 if ! $modcache; then
2266 func_lookup_file "modules/$1"
2267 sed -n -e "/^License$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_license[$1]+set}"; then
2273 echo "${modcache_license[$1]}"
2276 eval "field_set=\"\$${cachevar}_license_set\""
2277 if test -n "$field_set"; then
2278 eval "field_value=\"\$${cachevar}_license\""
2279 echo "${field_value}"
2283 # The default is GPL.
2285 } | sed -e 's,^ *$,,' | sed -e 1q
2288 # func_get_maintainer module
2290 # - local_gnulib_dir from --local-dir
2291 # - modcache true or false, from --cache-modules/--no-cache-modules
2292 func_get_maintainer ()
2294 if ! $modcache; then
2295 func_lookup_file "modules/$1"
2296 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2298 func_cache_lookup_module "$1"
2299 # Output the field's value, including the final newline (if any).
2300 if $have_associative; then
2301 if test -n "${modcache_maintainer[$1]+set}"; then
2302 echo "${modcache_maintainer[$1]}"
2305 eval "field_set=\"\$${cachevar}_maintainer_set\""
2306 if test -n "$field_set"; then
2307 eval "field_value=\"\$${cachevar}_maintainer\""
2308 echo "${field_value}"
2314 # func_get_tests_module module
2316 # - local_gnulib_dir from --local-dir
2317 func_get_tests_module ()
2319 # The naming convention for tests modules is hardwired: ${module}-tests.
2320 if test -f "$gnulib_dir/modules/$1"-tests \
2321 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2322 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2327 # func_acceptable module
2328 # tests whether a module is acceptable.
2330 # - avoidlist list of modules to avoid
2333 for avoid in $avoidlist; do
2334 if test "$avoid" = "$1"; then
2341 # func_modules_transitive_closure
2343 # - local_gnulib_dir from --local-dir
2344 # - modcache true or false, from --cache-modules/--no-cache-modules
2345 # - modules list of specified modules
2346 # - inctests true if tests should be included, blank otherwise
2347 # - incobsolete true if obsolete modules among dependencies should be
2348 # included, blank otherwise
2349 # - inc_cxx_tests true if C++ interoperability tests should be included,
2351 # - inc_longrunning_tests true if long-runnings tests should be included,
2353 # - inc_privileged_tests true if tests that require root privileges should be
2354 # included, blank otherwise
2355 # - inc_unportable_tests true if tests that fail on some platforms should be
2356 # included, blank otherwise
2357 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2358 # the unit tests of the specified modules should be
2359 # included, blank otherwise
2360 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2361 # the unit tests of the dependencies should be
2362 # included, blank otherwise
2363 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2365 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2367 # - excl_privileged_tests true if tests that require root privileges should be
2368 # excluded, blank otherwise
2369 # - excl_unportable_tests true if tests that fail on some platforms should be
2370 # excluded, blank otherwise
2371 # - avoidlist list of modules to avoid
2372 # - tmp pathname of a temporary directory
2374 # - modules list of modules, including dependencies
2375 func_modules_transitive_closure ()
2377 # In order to process every module only once (for speed), process an "input
2378 # list" of modules, producing an "output list" of modules. During each round,
2379 # more modules can be queued in the input list. Once a module on the input
2380 # list has been processed, it is added to the "handled list", so we can avoid
2381 # to process it again.
2383 inmodules="$modules"
2385 fmtc_inc_all_tests="$inc_all_direct_tests"
2386 while test -n "$inmodules"; do
2387 inmodules_this_round="$inmodules"
2388 inmodules= # Accumulator, queue for next round
2389 for module in $inmodules_this_round; do
2391 if test -n "$module"; then
2392 if func_acceptable $module; then
2393 func_append outmodules " $module"
2394 deps=`func_get_dependencies $module`
2395 # Duplicate dependencies are harmless, but Jim wants a warning.
2396 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2397 if test -n "$duplicated_deps"; then
2398 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2400 if test -n "$inctests"; then
2401 testsmodule=`func_get_tests_module $module`
2402 if test -n "$testsmodule"; then
2403 deps="$deps $testsmodule"
2406 for dep in $deps; do
2407 # Determine whether to include the dependency or tests module.
2409 for word in `func_get_status $dep`; do
2412 test -n "$incobsolete" \
2416 test -z "$excl_cxx_tests" \
2418 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2422 test -z "$excl_longrunning_tests" \
2424 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2428 test -z "$excl_privileged_tests" \
2430 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2434 test -z "$excl_unportable_tests" \
2436 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2440 test -n "$fmtc_inc_all_tests" \
2446 func_append inmodules " $dep"
2452 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2453 # Remove $handledmodules from $inmodules.
2454 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2455 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2456 fmtc_inc_all_tests="$inc_all_indirect_tests"
2458 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2459 rm -f "$tmp"/queued-modules
2462 # func_show_module_list
2464 # - specified_modules list of specified modules (one per line, sorted)
2465 # - modules complete list of modules (one per line, sorted)
2466 # - tmp pathname of a temporary directory
2467 func_show_module_list ()
2473 # Assume xterm compatible escape sequences.
2474 bold_on=`printf '\x1b[1m'`
2475 bold_off=`printf '\x1b[0m'`
2480 echo "Module list with included dependencies (indented):"
2481 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2482 echo "$modules" | sed -e '/^$/d' \
2483 | LC_ALL=C join -t '|' -a 2 "$tmp"/specified-modules - \
2484 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2487 # func_modules_add_dummy
2489 # - local_gnulib_dir from --local-dir
2490 # - modcache true or false, from --cache-modules/--no-cache-modules
2491 # - modules list of modules, including dependencies
2493 # - modules list of modules, including 'dummy' if needed
2494 func_modules_add_dummy ()
2496 # Determine whether any module provides a lib_SOURCES augmentation.
2498 sed_remove_backslash_newline=':a
2505 for module in $modules; do
2506 func_verify_nontests_module
2507 if test -n "$module"; then
2508 # Extract the value of "lib_SOURCES += ...".
2509 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2510 # Ignore .h files since they are not compiled.
2514 have_lib_SOURCES=yes
2521 # Add the dummy module, to make sure the library will be non-empty.
2522 if test -z "$have_lib_SOURCES"; then
2523 if func_acceptable "dummy"; then
2524 func_append modules " dummy"
2529 # func_modules_notice
2531 # - local_gnulib_dir from --local-dir
2532 # - modcache true or false, from --cache-modules/--no-cache-modules
2533 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2534 # - modules list of modules, including dependencies
2535 func_modules_notice ()
2537 if test $verbose -ge -1; then
2538 for module in $modules; do
2540 if test -n "$module"; then
2541 msg=`func_get_notice $module`
2542 if test -n "$msg"; then
2543 echo "Notice from module $module:"
2544 echo "$msg" | sed -e 's/^/ /'
2551 # func_modules_to_filelist
2553 # - local_gnulib_dir from --local-dir
2554 # - modcache true or false, from --cache-modules/--no-cache-modules
2555 # - modules list of modules, including dependencies
2557 # - files list of files
2558 func_modules_to_filelist ()
2561 for module in $modules; do
2563 if test -n "$module"; then
2564 fs=`func_get_filelist $module`
2565 func_append files " $fs"
2568 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2571 # func_execute_command command [args...]
2572 # Executes a command.
2573 # Uses also the variables
2574 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2575 func_execute_command ()
2577 if test $verbose -ge 0; then
2581 # Commands like automake produce output to stderr even when they succeed.
2582 # Turn this output off if the command succeeds.
2583 "$@" > "$tmp"/cmdout 2>&1
2585 if test $cmdret = 0; then
2589 cat "$tmp"/cmdout 1>&2
2596 # func_dest_tmpfilename file
2597 # determines the name of a temporary file (file is relative to destdir).
2599 # - destdir target directory
2600 # - doit : if actions shall be executed, false if only to be printed
2601 # - tmp pathname of a temporary directory
2603 # - tmpfile absolute filename of the temporary file
2604 func_dest_tmpfilename ()
2607 # Put the new contents of $file in a file in the same directory (needed
2608 # to guarantee that an 'mv' to "$destdir/$file" works).
2609 tmpfile="$destdir/$1.tmp"
2611 # Put the new contents of $file in a file in a temporary directory
2612 # (because the directory of "$file" might not exist).
2613 tmpfile="$tmp"/`basename "$1"`.tmp
2618 # copies a file from gnulib into the destination directory. The destination
2619 # is known to not exist.
2621 # - destdir target directory
2622 # - local_gnulib_dir from --local-dir
2623 # - modcache true or false, from --cache-modules/--no-cache-modules
2624 # - f the original file name
2625 # - lookedup_file name of the merged (combined) file
2626 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2627 # - g the rewritten file name
2628 # - tmpfile absolute filename of the temporary file
2629 # - doit : if actions shall be executed, false if only to be printed
2630 # - symbolic true if files should be symlinked, copied otherwise
2631 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2636 echo "Copying file $g"
2637 if { test -n "$symbolic" \
2638 || { test -n "$lsymbolic" \
2639 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2640 && test -z "$lookedup_tmp" \
2641 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2642 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2644 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2652 # copies a file from gnulib into the destination directory. The destination
2653 # is known to exist.
2655 # - destdir target directory
2656 # - local_gnulib_dir from --local-dir
2657 # - modcache true or false, from --cache-modules/--no-cache-modules
2658 # - f the original file name
2659 # - lookedup_file name of the merged (combined) file
2660 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2661 # - g the rewritten file name
2662 # - tmpfile absolute filename of the temporary file
2663 # - doit : if actions shall be executed, false if only to be printed
2664 # - symbolic true if files should be symlinked, copied otherwise
2665 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2667 # - already_present nonempty if the file should already exist, empty otherwise
2670 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2671 : # The file has not changed.
2675 if test -n "$already_present"; then
2676 echo "Updating file $g (backup in ${g}~)"
2678 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2680 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2681 if { test -n "$symbolic" \
2682 || { test -n "$lsymbolic" \
2683 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2684 && test -z "$lookedup_tmp" \
2685 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2686 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2688 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2691 if test -n "$already_present"; then
2692 echo "Update file $g (backup in ${g}~)"
2694 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2700 # func_emit_lib_Makefile_am
2701 # emits the contents of library makefile to standard output.
2703 # - local_gnulib_dir from --local-dir
2704 # - modcache true or false, from --cache-modules/--no-cache-modules
2705 # - modules list of modules, including dependencies
2706 # - libname library name
2707 # - pobase directory relative to destdir where to place *.po files
2708 # - auxdir directory relative to destdir where to place build aux files
2709 # - makefile_name from --makefile-name
2710 # - libtool true if libtool will be used, false or blank otherwise
2711 # - macro_prefix prefix of gl_LIBOBJS macros to use
2712 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2713 # - actioncmd (optional) command that will reproduce this invocation
2714 # - for_test true if creating a package for testing, false otherwise
2715 # - destfile filename relative to destdir of makefile being generated
2717 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2718 # list of edits to be done to Makefile.am variables
2720 # - uses_subdirs nonempty if object files in subdirs exist
2721 func_emit_lib_Makefile_am ()
2723 # When creating an includable Makefile.am snippet, augment variables with
2724 # += instead of assigning them.
2725 if test -n "$makefile_name"; then
2730 if test "$libtool" = true; then
2733 sed_eliminate_LDFLAGS="$sed_noop"
2737 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2740 # When creating a package for testing: Attempt to provoke failures,
2741 # especially link errors, already during "make" rather than during
2742 # "make check", because "make check" is not possible in a cross-compiling
2743 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2744 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2746 sed_transform_check_PROGRAMS="$sed_noop"
2748 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2749 echo "## Process this file with automake to produce Makefile.in."
2750 func_emit_copyright_notice
2751 if test -n "$actioncmd"; then
2752 # The maximum line length (excluding the terminating newline) of any file
2753 # that is to be preprocessed by config.status is 3070. config.status uses
2754 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2755 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2756 len=`echo "$actioncmd" | wc -c`
2757 if test -n "$len" && test "$len" -le 3000; then
2758 echo "# Reproduce by: $actioncmd"
2764 for module in $modules; do
2765 func_verify_nontests_module
2766 if test -n "$module"; then
2768 func_get_automake_snippet "$module" |
2770 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2771 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2772 -e "$sed_eliminate_LDFLAGS" \
2773 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2774 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2775 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2776 -e "$sed_transform_check_PROGRAMS"
2777 if test "$module" = 'alloca'; then
2778 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2779 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2781 } > "$tmp"/amsnippet
2782 # Skip the contents if it's entirely empty.
2783 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2784 echo "## begin gnulib module $module"
2786 cat "$tmp"/amsnippet
2787 echo "## end gnulib module $module"
2790 rm -f "$tmp"/amsnippet
2791 # Test whether there are some source files in subdirectories.
2792 for f in `func_get_filelist "$module"`; do
2802 } > "$tmp"/allsnippets
2803 if test -z "$makefile_name"; then
2804 # If there are source files in subdirectories, prevent collision of the
2805 # object files (example: hash.c and libxml/hash.c).
2807 if test -n "$uses_subdirs"; then
2808 subdir_options=' subdir-objects'
2810 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2813 if test -z "$makefile_name"; then
2815 echo "noinst_HEADERS ="
2816 echo "noinst_LIBRARIES ="
2817 echo "noinst_LTLIBRARIES ="
2818 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2819 # if you specify pkgdata_DATA to empty. This is a workaround.
2820 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2821 echo "pkgdata_DATA ="
2824 echo "BUILT_SOURCES ="
2827 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2828 if test -z "$makefile_name"; then
2829 echo "MOSTLYCLEANDIRS ="
2831 echo "DISTCLEANFILES ="
2832 echo "MAINTAINERCLEANFILES ="
2834 # Execute edits that apply to the Makefile.am being generated.
2836 while test $edit != $makefile_am_edits; do
2837 edit=`expr $edit + 1`
2838 eval dir=\"\$makefile_am_edit${edit}_dir\"
2839 eval var=\"\$makefile_am_edit${edit}_var\"
2840 eval val=\"\$makefile_am_edit${edit}_val\"
2841 if test -n "$var"; then
2842 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2843 echo "${var} += ${val}"
2844 eval "makefile_am_edit${edit}_var="
2848 if test -z "$makefile_name"; then
2851 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
2853 echo "AM_CPPFLAGS ="
2858 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2859 || { test -n "$makefile_name" \
2860 && test -f "$sourcebase/Makefile.am" \
2861 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2863 # One of the snippets or the user's Makefile.am already specifies an
2864 # installation location for the library. Don't confuse automake by saying
2865 # it should not be installed.
2868 # By default, the generated library should not be installed.
2869 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2872 echo "${libname}_${libext}_SOURCES ="
2873 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2874 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2875 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2876 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2877 echo "EXTRA_${libname}_${libext}_SOURCES ="
2878 if test "$libtool" = true; then
2879 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2882 if test -n "$pobase"; then
2883 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2886 cat "$tmp"/allsnippets \
2887 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2889 echo "mostlyclean-local: mostlyclean-generic"
2890 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2891 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2892 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2896 rm -f "$tmp"/allsnippets
2899 # func_emit_po_Makevars
2900 # emits the contents of po/ makefile parameterization to standard output.
2902 # - local_gnulib_dir from --local-dir
2903 # - modcache true or false, from --cache-modules/--no-cache-modules
2904 # - sourcebase directory relative to destdir where to place source code
2905 # - pobase directory relative to destdir where to place *.po files
2906 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2907 func_emit_po_Makevars ()
2909 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2910 func_emit_copyright_notice
2912 echo "# Usually the message domain is the same as the package name."
2913 echo "# But here it has a '-gnulib' suffix."
2914 echo "DOMAIN = ${po_domain}-gnulib"
2916 echo "# These two variables depend on the location of this directory."
2917 echo "subdir = ${pobase}"
2918 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2921 # These options get passed to xgettext.
2922 XGETTEXT_OPTIONS = \
2923 --keyword=_ --flag=_:1:pass-c-format \
2924 --keyword=N_ --flag=N_:1:pass-c-format \
2925 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2926 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2927 --flag=error:3:c-format --flag=error_at_line:5:c-format
2929 # This is the copyright holder that gets inserted into the header of the
2930 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2931 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2933 # This is the email address or URL to which the translators shall report
2934 # bugs in the untranslated strings:
2935 # - Strings which are not entire sentences, see the maintainer guidelines
2936 # in the GNU gettext documentation, section 'Preparing Strings'.
2937 # - Strings which use unclear terms or require additional context to be
2939 # - Strings which make invalid assumptions about notation of date, time or
2941 # - Pluralisation problems.
2942 # - Incorrect English spelling.
2943 # - Incorrect formatting.
2944 # It can be your email address, or a mailing list address where translators
2945 # can write to without being subscribed, or the URL of a web page through
2946 # which the translators can contact you.
2947 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2949 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2950 # message catalogs shall be used. It is usually empty.
2951 EXTRA_LOCALE_CATEGORIES =
2953 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2954 # context. Possible values are "yes" and "no". Set this to yes if the
2955 # package uses functions taking also a message context, like pgettext(), or
2956 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2961 # func_emit_po_POTFILES_in
2962 # emits the file list to be passed to xgettext to standard output.
2964 # - local_gnulib_dir from --local-dir
2965 # - modcache true or false, from --cache-modules/--no-cache-modules
2966 # - sourcebase directory relative to destdir where to place source code
2967 # - files list of new files
2968 func_emit_po_POTFILES_in ()
2970 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2971 func_emit_copyright_notice
2973 echo "# List of files which contain translatable strings."
2974 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2977 # func_emit_tests_Makefile_am witness_macro
2978 # emits the contents of tests makefile to standard output.
2980 # - local_gnulib_dir from --local-dir
2981 # - modcache true or false, from --cache-modules/--no-cache-modules
2982 # - modules list of modules, including dependencies
2983 # - libname library name
2984 # - auxdir directory relative to destdir where to place build aux files
2985 # - makefile_name from --makefile-name
2986 # - libtool true if libtool will be used, false or blank otherwise
2987 # - sourcebase relative directory containing lib source code
2988 # - m4base relative directory containing autoconf macros
2989 # - testsbase relative directory containing unit test code
2990 # - macro_prefix prefix of gl_LIBOBJS macros to use
2991 # - for_test true if creating a package for testing, false otherwise
2992 # - use_libtests true if a libtests.a should be built, false otherwise
2993 # - destfile filename relative to destdir of makefile being generated
2995 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2996 # list of edits to be done to Makefile.am variables
2998 # - uses_subdirs nonempty if object files in subdirs exist
2999 func_emit_tests_Makefile_am ()
3002 if test "$libtool" = true; then
3004 sed_eliminate_LDFLAGS="$sed_noop"
3007 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3010 # When creating a package for testing: Attempt to provoke failures,
3011 # especially link errors, already during "make" rather than during
3012 # "make check", because "make check" is not possible in a cross-compiling
3013 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3014 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3016 sed_transform_check_PROGRAMS="$sed_noop"
3018 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3019 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3020 echo "## Process this file with automake to produce Makefile.in."
3021 func_emit_copyright_notice
3025 for module in $modules; do
3027 func_verify_tests_module
3031 if test -n "$module"; then
3033 func_get_automake_snippet "$module" |
3035 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3036 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3037 -e "$sed_eliminate_LDFLAGS" \
3038 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3039 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3040 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3041 -e "$sed_transform_check_PROGRAMS"
3042 if $use_libtests && test "$module" = 'alloca'; then
3043 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3044 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3046 } > "$tmp"/amsnippet
3047 # Skip the contents if it's entirely empty.
3048 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3049 # Mention long-running tests at the end.
3051 for word in `func_get_status "$module"`; do
3052 if test "$word" = 'longrunning-test'; then
3057 { echo "## begin gnulib module $module"
3059 cat "$tmp"/amsnippet
3060 echo "## end gnulib module $module"
3064 rm -f "$tmp"/amsnippet
3065 # Test whether there are some source files in subdirectories.
3066 for f in `func_get_filelist "$module"`; do
3068 lib/*/*.c | tests/*/*.c)
3076 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3077 # Generate dependencies here, since it eases the debugging of test failures.
3078 # If there are source files in subdirectories, prevent collision of the
3079 # object files (example: hash.c and libxml/hash.c).
3081 if test -n "$uses_subdirs"; then
3082 subdir_options=' subdir-objects'
3084 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3087 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3090 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3091 # variable is needed to avoid an error from automake:
3092 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3095 echo "XFAIL_TESTS ="
3096 echo "TESTS_ENVIRONMENT ="
3097 echo "noinst_PROGRAMS ="
3098 if ! $for_test; then
3099 echo "check_PROGRAMS ="
3101 echo "noinst_HEADERS ="
3102 echo "noinst_LIBRARIES ="
3103 if $use_libtests; then
3105 echo "noinst_LIBRARIES += libtests.a"
3107 echo "check_LIBRARIES = libtests.a"
3110 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3111 # if you specify pkgdata_DATA to empty. This is a workaround.
3112 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3113 echo "pkgdata_DATA ="
3116 echo "BUILT_SOURCES ="
3118 echo "MOSTLYCLEANFILES = core *.stackdump"
3119 echo "MOSTLYCLEANDIRS ="
3121 echo "DISTCLEANFILES ="
3122 echo "MAINTAINERCLEANFILES ="
3123 # Execute edits that apply to the Makefile.am being generated.
3125 while test $edit != $makefile_am_edits; do
3126 edit=`expr $edit + 1`
3127 eval dir=\"\$makefile_am_edit${edit}_dir\"
3128 eval var=\"\$makefile_am_edit${edit}_var\"
3129 eval val=\"\$makefile_am_edit${edit}_val\"
3130 if test -n "$var"; then
3131 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3132 echo "${var} += ${val}"
3133 eval "makefile_am_edit${edit}_var="
3138 echo "AM_CPPFLAGS = \\"
3140 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3142 if test -n "${witness_macro}"; then
3143 echo " -D@${witness_macro}@=1 \\"
3145 echo " -I. -I\$(srcdir) \\"
3146 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3147 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3149 local_ldadd_before=''
3150 local_ldadd_after=''
3151 if $use_libtests; then
3152 # All test programs need to be linked with libtests.a.
3153 # It needs to be passed to the linker before ${libname}.${libext}, since
3154 # the tests-related modules depend on the main modules.
3155 # It also needs to be passed to the linker after ${libname}.${libext}
3156 # because the latter might contain incomplete modules (such as the 'error'
3157 # module whose dependency to 'progname' is voluntarily omitted).
3158 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3160 local_ldadd_before=' libtests.a'
3161 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3163 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3165 if $use_libtests; then
3166 echo "libtests_a_SOURCES ="
3167 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3168 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3169 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3170 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3171 echo "EXTRA_libtests_a_SOURCES ="
3172 # The circular dependency in LDADD requires this.
3173 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3176 # Many test scripts use ${EXEEXT} or ${srcdir}.
3177 # EXEEXT is defined by AC_PROG_CC through autoconf.
3178 # srcdir is defined by autoconf and automake.
3179 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3181 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3182 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3183 echo "# Clean up after Solaris cc."
3185 echo " rm -rf SunWS_cache"
3187 echo "mostlyclean-local: mostlyclean-generic"
3188 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3189 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3190 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3194 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3197 # func_emit_initmacro_start macro_prefix
3198 # emits the first few statements of the gl_INIT macro to standard output.
3199 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3200 func_emit_initmacro_start ()
3202 macro_prefix_arg="$1"
3203 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3204 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3205 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3206 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3208 # Furthermore it avoids an automake error like this when a Makefile.am
3209 # that uses pieces of gnulib also uses $(LIBOBJ):
3210 # automatically discovered file `error.c' should not be explicitly mentioned
3211 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3212 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3213 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3214 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3215 # automatically discovered file `error.c' should not be explicitly mentioned
3216 # We let automake know about the files to be distributed through the
3217 # EXTRA_lib_SOURCES variable.
3218 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3219 # Create data variables for checking the presence of files that are mentioned
3220 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3221 # because we want the check to happen when the configure file is created,
3222 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3223 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3224 # in which to expect them.
3225 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3226 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3230 # func_emit_initmacro_end macro_prefix
3231 # emits the last few statements of the gl_INIT macro to standard output.
3232 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3233 func_emit_initmacro_end ()
3235 macro_prefix_arg="$1"
3236 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3237 # The check is performed only when autoconf is run from the directory where
3238 # the configure.ac resides; if it is run from a different directory, the
3240 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3241 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3242 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3243 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3244 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3248 echo " m4_if(m4_sysval, [0], [],"
3249 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3251 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3252 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3253 echo " m4_popdef([AC_LIBSOURCES])"
3254 echo " m4_popdef([AC_REPLACE_FUNCS])"
3255 echo " m4_popdef([AC_LIBOBJ])"
3256 echo " AC_CONFIG_COMMANDS_PRE(["
3257 echo " ${macro_prefix_arg}_libobjs="
3258 echo " ${macro_prefix_arg}_ltlibobjs="
3259 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3260 echo " # Remove the extension."
3261 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3262 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3263 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3264 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3267 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3268 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3272 # func_emit_initmacro_done macro_prefix sourcebase
3273 # emits a few statements after the gl_INIT macro to standard output.
3274 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3275 # - sourcebase directory relative to destdir where to place source code
3276 func_emit_initmacro_done ()
3278 macro_prefix_arg="$1"
3281 echo "# Like AC_LIBOBJ, except that the module name goes"
3282 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3283 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3284 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3285 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3288 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3289 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3290 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3291 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3292 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3295 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3296 echo "# expected is derived from the gnulib-tool parameterization,"
3297 echo "# and alloca is special cased (for the alloca-opt module)."
3298 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3299 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3300 echo " m4_foreach([_gl_NAME], [\$1], ["
3301 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3302 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3303 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3309 # func_import modules
3310 # Uses also the variables
3311 # - destdir target directory
3312 # - local_gnulib_dir from --local-dir
3313 # - modcache true or false, from --cache-modules/--no-cache-modules
3314 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3315 # - libname library name
3316 # - sourcebase directory relative to destdir where to place source code
3317 # - m4base directory relative to destdir where to place *.m4 macros
3318 # - pobase directory relative to destdir where to place *.po files
3319 # - docbase directory relative to destdir where to place doc files
3320 # - testsbase directory relative to destdir where to place unit test code
3321 # - auxdir directory relative to destdir where to place build aux files
3322 # - inctests true if --with-tests was given, blank otherwise
3323 # - incobsolete true if --with-obsolete was given, blank otherwise
3324 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3325 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3327 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3329 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3331 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3332 # - avoidlist list of modules to avoid, from --avoid
3333 # - lgpl yes or a number if library's license shall be LGPL,
3335 # - makefile_name from --makefile-name
3336 # - libtool true if --libtool was given, false if --no-libtool was
3337 # given, blank otherwise
3338 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3339 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3340 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3341 # - vc_files true if --vc-files was given, false if --no-vc-files was
3342 # given, blank otherwise
3343 # - autoconf_minversion minimum supported autoconf version
3344 # - doit : if actions shall be executed, false if only to be printed
3345 # - symbolic true if files should be symlinked, copied otherwise
3346 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3348 # - do_copyrights true if copyright notices in files should be replaced,
3352 # Get the cached settings.
3353 cached_local_gnulib_dir=
3354 cached_specified_modules=
3356 cached_inc_cxx_tests=
3357 cached_inc_longrunning_tests=
3358 cached_inc_privileged_tests=
3359 cached_inc_unportable_tests=
3360 cached_inc_all_tests=
3370 cached_makefile_name=
3372 cached_macro_prefix=
3376 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3377 cached_libtool=false
3383 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3393 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3395 /gl_WITH_OBSOLETE/ {
3396 s,^.*$,cached_incobsolete=true,p
3398 /gl_WITH_CXX_TESTS/ {
3399 s,^.*$,cached_inc_cxx_tests=true,p
3401 /gl_WITH_LONGRUNNING_TESTS/ {
3402 s,^.*$,cached_inc_longrunning_tests=true,p
3404 /gl_WITH_PRIVILEGED_TESTS/ {
3405 s,^.*$,cached_inc_privileged_tests=true,p
3407 /gl_WITH_UNPORTABLE_TESTS/ {
3408 s,^.*$,cached_inc_unportable_tests=true,p
3410 /gl_WITH_ALL_TESTS/ {
3411 s,^.*$,cached_inc_all_tests=true,p
3414 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3417 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3420 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3423 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3426 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3429 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3432 s,^.*$,cached_inctests=true,p
3435 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3438 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3441 s,^.*$,cached_lgpl=yes,p
3443 /gl_MAKEFILE_NAME(/ {
3444 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3447 s,^.*$,cached_libtool=true,p
3449 /gl_MACRO_PREFIX(/ {
3450 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3453 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3456 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3458 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3459 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3464 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3465 s,^.*$,cached_files=",p
3478 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3482 # Merge the cached settings with the specified ones.
3483 # The m4base must be the same as expected from the pathname.
3484 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3485 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3487 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3488 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3489 if test -z "$local_gnulib_dir"; then
3490 if test -n "$cached_local_gnulib_dir"; then
3493 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3495 case "$cached_local_gnulib_dir" in
3497 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3499 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3500 local_gnulib_dir="$relconcat" ;;
3505 # Append the cached and the specified module names. So that
3506 # "gnulib-tool --import foo" means to add the module foo.
3507 specified_modules="$cached_specified_modules $1"
3508 # Included obsolete modules among the dependencies if specified either way.
3509 if test -z "$incobsolete"; then
3510 incobsolete="$cached_incobsolete"
3512 # Included special kinds of tests modules among the dependencies if specified
3514 if test -z "$inc_cxx_tests"; then
3515 inc_cxx_tests="$cached_inc_cxx_tests"
3517 if test -z "$inc_longrunning_tests"; then
3518 inc_longrunning_tests="$cached_inc_longrunning_tests"
3520 if test -z "$inc_privileged_tests"; then
3521 inc_privileged_tests="$cached_inc_privileged_tests"
3523 if test -z "$inc_unportable_tests"; then
3524 inc_unportable_tests="$cached_inc_unportable_tests"
3526 if test -z "$inc_all_tests"; then
3527 inc_all_tests="$cached_inc_all_tests"
3529 # --without-*-tests options are not supported here.
3531 excl_longrunning_tests=
3532 excl_privileged_tests=
3533 excl_unportable_tests=
3534 # Append the cached and the specified avoidlist. This is probably better
3535 # than dropping the cached one when --avoid is specified at least once.
3536 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3537 avoidlist=`echo $avoidlist`
3539 # The sourcebase defaults to the cached one.
3540 if test -z "$sourcebase"; then
3541 sourcebase="$cached_sourcebase"
3542 if test -z "$sourcebase"; then
3543 func_fatal_error "missing --source-base option"
3546 # The pobase defaults to the cached one.
3547 if test -z "$pobase"; then
3548 pobase="$cached_pobase"
3550 # The docbase defaults to the cached one.
3551 if test -z "$docbase"; then
3552 docbase="$cached_docbase"
3553 if test -z "$docbase"; then
3554 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."
3557 # The testsbase defaults to the cached one.
3558 if test -z "$testsbase"; then
3559 testsbase="$cached_testsbase"
3560 if test -z "$testsbase"; then
3561 func_fatal_error "missing --tests-base option"
3564 # Require the tests if specified either way.
3565 if test -z "$inctests"; then
3566 inctests="$cached_inctests"
3568 # The libname defaults to the cached one.
3569 if test -z "$supplied_libname"; then
3570 libname="$cached_libname"
3571 if test -z "$libname"; then
3572 func_fatal_error "missing --lib option"
3575 # Require LGPL if specified either way.
3576 if test -z "$lgpl"; then
3579 # The makefile_name defaults to the cached one.
3580 if test -z "$makefile_name"; then
3581 makefile_name="$cached_makefile_name"
3583 # Use libtool if specified either way, or if guessed.
3584 if test -z "$libtool"; then
3585 if test -n "$cached_m4base"; then
3586 libtool="$cached_libtool"
3588 libtool="$guessed_libtool"
3591 # The macro_prefix defaults to the cached one.
3592 if test -z "$macro_prefix"; then
3593 macro_prefix="$cached_macro_prefix"
3594 if test -z "$macro_prefix"; then
3595 func_fatal_error "missing --macro-prefix option"
3598 # The po_domain defaults to the cached one.
3599 if test -z "$po_domain"; then
3600 po_domain="$cached_po_domain"
3602 # The vc_files defaults to the cached one.
3603 if test -z "$vc_files"; then
3604 vc_files="$cached_vc_files"
3607 # Canonicalize the list of specified modules.
3608 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3610 # Include all kinds of tests modules if --with-all-tests was specified.
3611 inc_all_direct_tests="$inc_all_tests"
3612 inc_all_indirect_tests="$inc_all_tests"
3614 # Determine final module list.
3615 modules="$specified_modules"
3616 func_modules_transitive_closure
3617 if test $verbose -ge 0; then
3618 func_show_module_list
3620 final_modules="$modules"
3622 # Determine main module list and tests-related module list separately.
3623 # The main module list is the transitive closure of the specified modules,
3624 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3625 # is specified, it will consist only of LGPLed source.
3626 # The tests-related module list is the transitive closure of the specified
3627 # modules, including tests modules, minus the main module list excluding
3628 # modules of applicability 'all'. Its lib/* sources (brought in through
3629 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3630 # source, even if --lgpl is specified.
3631 # Determine main module list.
3632 saved_inctests="$inctests"
3634 modules="$specified_modules"
3635 func_modules_transitive_closure
3636 main_modules="$modules"
3637 inctests="$saved_inctests"
3638 if test $verbose -ge 1; then
3639 echo "Main module list:"
3640 echo "$main_modules" | sed -e 's/^/ /'
3642 # Determine tests-related module list.
3643 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3644 testsrelated_modules=`for module in $main_modules; do
3645 if test \`func_get_applicability $module\` = main; then
3649 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3650 if test $verbose -ge 1; then
3651 echo "Tests-related module list:"
3652 echo "$testsrelated_modules" | sed -e 's/^/ /'
3655 # Add the dummy module to the main module list if needed.
3656 modules="$main_modules"
3657 func_modules_add_dummy
3658 main_modules="$modules"
3660 # Determine whether a $testsbase/libtests.a is needed.
3662 for module in $testsrelated_modules; do
3663 func_verify_nontests_module
3664 if test -n "$module"; then
3665 all_files=`func_get_filelist $module`
3666 # Test whether some file in $all_files lies in lib/.
3667 for f in $all_files; do
3678 # Add the dummy module to the tests-related module list if needed.
3679 if $use_libtests; then
3680 modules="$testsrelated_modules"
3681 func_modules_add_dummy
3682 testsrelated_modules="$modules"
3685 # If --lgpl, verify that the licenses of modules are compatible.
3686 if test -n "$lgpl"; then
3687 license_incompatibilities=
3688 for module in $main_modules; do
3689 license=`func_get_license $module`
3691 'GPLed build tool') ;;
3692 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3697 LGPL | LGPLv2+ | LGPLv3+) ;;
3698 *) func_append license_incompatibilities "$module $license$nl" ;;
3704 *) func_append license_incompatibilities "$module $license$nl" ;;
3707 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3712 if test -n "$license_incompatibilities"; then
3713 # Format the license incompatibilities as a table.
3714 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3715 s,^\(.................................................[^ ]*\) *, \1 ,'
3716 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3717 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3721 # Show banner notice of every module.
3722 modules="$main_modules"
3725 # Determine script to apply to imported library files.
3726 sed_transform_lib_file=
3727 for module in $main_modules; do
3728 if test $module = config-h; then
3729 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3730 sed_transform_lib_file=$sed_transform_lib_file'
3731 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3736 sed_transform_main_lib_file="$sed_transform_lib_file"
3737 if test -n "$do_copyrights"; then
3738 if test -n "$lgpl"; then
3742 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3743 s/GNU General/GNU Lesser General/g
3747 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3748 s/GNU General/GNU Lesser General/g
3749 s/version [23]\([ ,]\)/version 2.1\1/g
3752 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3756 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3757 s/GNU Lesser General/GNU General/g
3758 s/GNU Library General/GNU General/g
3759 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3764 # Determine script to apply to auxiliary files that go into $auxdir/.
3765 sed_transform_build_aux_file=
3766 if test -n "$do_copyrights"; then
3768 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3769 s/GNU Lesser General/GNU General/g
3770 s/GNU Library General/GNU General/g
3771 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3775 # Determine script to apply to library files that go into $testsbase/.
3776 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3777 if test -n "$do_copyrights"; then
3779 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3780 s/GNU Lesser General/GNU General/g
3781 s/GNU Library General/GNU General/g
3782 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3786 # Determine the final file lists.
3787 # They must be computed separately, because files in lib/* go into
3788 # $sourcebase/ if they are in the main file list but into $testsbase/
3789 # if they are in the tests-related file list. Furthermore lib/dummy.c
3791 # Determine final main file list.
3792 modules="$main_modules"
3793 func_modules_to_filelist
3795 # Determine final tests-related file list.
3796 modules="$testsrelated_modules"
3797 func_modules_to_filelist
3798 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3799 # Merge both file lists.
3800 sed_remove_empty_lines='/^$/d'
3801 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3802 if test $verbose -ge 0; then
3804 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3805 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3809 || func_fatal_error "refusing to do nothing"
3811 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3812 new_files="$files m4/gnulib-tool.m4"
3813 old_files="$cached_files"
3814 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3815 func_append old_files " m4/gnulib-tool.m4"
3818 rewritten='%REWRITTEN%'
3819 sed_rewrite_old_files="\
3820 s,^build-aux/,$rewritten$auxdir/,
3821 s,^doc/,$rewritten$cached_docbase/,
3822 s,^lib/,$rewritten$cached_sourcebase/,
3823 s,^m4/,$rewritten$cached_m4base/,
3824 s,^tests/,$rewritten$cached_testsbase/,
3825 s,^tests=lib/,$rewritten$cached_testsbase/,
3828 sed_rewrite_new_files="\
3829 s,^build-aux/,$rewritten$auxdir/,
3830 s,^doc/,$rewritten$docbase/,
3831 s,^lib/,$rewritten$sourcebase/,
3832 s,^m4/,$rewritten$m4base/,
3833 s,^tests/,$rewritten$testsbase/,
3834 s,^tests=lib/,$rewritten$testsbase/,
3838 # Create directories.
3839 { echo "$sourcebase"
3841 if test -n "$pobase"; then
3844 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3845 if test -n "$docfiles"; then
3848 if test -n "$inctests"; then
3852 for f in $files; do echo $f; done \
3853 | sed -e "$sed_rewrite_new_files" \
3854 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3857 { # Rearrange file descriptors. Needed because "while ... done < ..."
3858 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3859 exec 5<&0 < "$tmp"/dirs
3861 if test ! -d "$destdir/$d"; then
3863 echo "Creating directory $destdir/$d"
3864 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3866 echo "Create directory $destdir/$d"
3873 # Copy files or make symbolic links. Remove obsolete files.
3877 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3878 # representing the files according to the last gnulib-tool invocation.
3879 for f in $old_files; do echo $f; done \
3880 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3883 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3884 # representing the files after this gnulib-tool invocation.
3885 for f in $new_files; do echo $f; done \
3886 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3889 # First the files that are in old-files, but not in new-files:
3890 sed_take_first_column='s,'"$delimiter"'.*,,'
3891 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3892 # Remove the file. Do nothing if the user already removed it.
3893 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3895 echo "Removing file $g (backup in ${g}~)"
3896 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3898 echo "Remove file $g (backup in ${g}~)"
3900 func_append removed_files "$g$nl"
3903 # func_add_or_update handles a file that ought to be present afterwards.
3905 # - f the original file name
3906 # - g the rewritten file name
3907 # - already_present nonempty if the file should already exist, empty
3909 func_add_or_update ()
3913 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3915 func_dest_tmpfilename "$g"
3916 func_lookup_file "$f"
3917 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3918 if test -n "$sed_transform_main_lib_file"; then
3921 sed -e "$sed_transform_main_lib_file" \
3922 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3926 if test -n "$sed_transform_build_aux_file"; then
3929 sed -e "$sed_transform_build_aux_file" \
3930 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3934 if test -n "$sed_transform_testsrelated_lib_file"; then
3937 sed -e "$sed_transform_testsrelated_lib_file" \
3938 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3942 if test -f "$destdir/$g"; then
3943 # The file already exists.
3947 # Don't protest if the file should be there but isn't: it happens
3948 # frequently that developers don't put autogenerated files into CVS.
3950 func_append added_files "$g$nl"
3954 # Then the files that are in new-files, but not in old-files:
3955 sed_take_last_column='s,^.*'"$delimiter"',,'
3957 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3958 | sed -e "$sed_take_last_column" \
3959 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3960 { # Rearrange file descriptors. Needed because "while ... done < ..."
3961 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3962 exec 5<&0 < "$tmp"/added-files
3968 # Then the files that are in new-files and in old-files:
3969 already_present=true
3970 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3971 | sed -e "$sed_take_last_column" \
3972 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3973 { # Rearrange file descriptors. Needed because "while ... done < ..."
3974 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3975 exec 5<&0 < "$tmp"/kept-files
3982 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3983 actioncmd="gnulib-tool --import"
3984 func_append actioncmd " --dir=$destdir"
3985 if test -n "$local_gnulib_dir"; then
3986 func_append actioncmd " --local-dir=$local_gnulib_dir"
3988 func_append actioncmd " --lib=$libname"
3989 func_append actioncmd " --source-base=$sourcebase"
3990 func_append actioncmd " --m4-base=$m4base"
3991 if test -n "$pobase"; then
3992 func_append actioncmd " --po-base=$pobase"
3994 func_append actioncmd " --doc-base=$docbase"
3995 func_append actioncmd " --tests-base=$testsbase"
3996 func_append actioncmd " --aux-dir=$auxdir"
3997 if test -n "$inctests"; then
3998 func_append actioncmd " --with-tests"
4000 if test -n "$incobsolete"; then
4001 func_append actioncmd " --with-obsolete"
4003 if test -n "$inc_cxx_tests"; then
4004 func_append actioncmd " --with-c++-tests"
4006 if test -n "$inc_longrunning_tests"; then
4007 func_append actioncmd " --with-longrunning-tests"
4009 if test -n "$inc_privileged_tests"; then
4010 func_append actioncmd " --with-privileged-tests"
4012 if test -n "$inc_unportable_tests"; then
4013 func_append actioncmd " --with-unportable-tests"
4015 if test -n "$inc_all_tests"; then
4016 func_append actioncmd " --with-all-tests"
4018 for module in $avoidlist; do
4019 func_append actioncmd " --avoid=$module"
4021 if test -n "$lgpl"; then
4022 if test "$lgpl" = yes; then
4023 func_append actioncmd " --lgpl"
4025 func_append actioncmd " --lgpl=$lgpl"
4028 if test -n "$makefile_name"; then
4029 func_append actioncmd " --makefile-name=$makefile_name"
4031 if test "$libtool" = true; then
4032 func_append actioncmd " --libtool"
4034 func_append actioncmd " --no-libtool"
4036 func_append actioncmd " --macro-prefix=$macro_prefix"
4037 if test -n "$po_domain"; then
4038 func_append actioncmd " --po-domain=$po_domain"
4040 if test -n "$vc_files"; then
4041 if test "$vc_files" = true; then
4042 func_append actioncmd " --vc-files"
4044 func_append actioncmd " --no-vc-files"
4047 func_append actioncmd " `echo $specified_modules`"
4049 # Default the makefile name to Makefile.am.
4050 if test -n "$makefile_name"; then
4051 makefile_am=$makefile_name
4053 makefile_am=Makefile.am
4056 # Create normal Makefile.ams.
4059 # Setup list of Makefile.am edits that are to be performed afterwards.
4060 # Some of these edits apply to files that we will generate; others are
4061 # under the responsibility of the developer.
4063 # func_note_Makefile_am_edit dir var value
4064 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4066 func_note_Makefile_am_edit ()
4068 makefile_am_edits=`expr $makefile_am_edits + 1`
4069 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4070 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4071 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4073 if test "$makefile_am" = Makefile.am; then
4074 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4075 sourcebase_base=`basename "$sourcebase"`
4076 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4078 if test -n "$pobase"; then
4079 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4080 pobase_base=`basename "$pobase"`
4081 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4083 if test -n "$inctests"; then
4084 if test "$makefile_am" = Makefile.am; then
4085 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4086 testsbase_base=`basename "$testsbase"`
4087 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4090 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4092 # Find the first parent directory of $m4base that contains or will contain
4094 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4096 sed_butlast='s,[^/][^/]*//*$,,'
4097 dir1="${m4base}/"; dir2=""
4098 while test -n "$dir1" \
4099 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4100 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4101 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4102 || { test -n "$inctests" \
4103 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4104 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4105 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4106 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4108 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4111 # Create library makefile.
4112 func_dest_tmpfilename $sourcebase/$makefile_am
4113 destfile="$sourcebase/$makefile_am"
4114 modules="$main_modules"
4115 func_emit_lib_Makefile_am > "$tmpfile"
4116 if test -f "$destdir"/$sourcebase/$makefile_am; then
4117 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4121 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4122 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4123 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4125 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4131 echo "Creating $sourcebase/$makefile_am"
4132 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4134 echo "Create $sourcebase/$makefile_am"
4137 func_append added_files "$sourcebase/$makefile_am$nl"
4140 # Create po/ directory.
4141 if test -n "$pobase"; then
4142 # Create po makefile and auxiliary files.
4143 for file in Makefile.in.in remove-potcdate.sin; do
4144 func_dest_tmpfilename $pobase/$file
4145 func_lookup_file build-aux/po/$file
4146 cat "$lookedup_file" > "$tmpfile"
4147 if test -f "$destdir"/$pobase/$file; then
4148 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4152 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4153 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4154 mv -f "$tmpfile" "$destdir"/$pobase/$file
4156 echo "Update $pobase/$file (backup in $pobase/$file~)"
4162 echo "Creating $pobase/$file"
4163 mv -f "$tmpfile" "$destdir"/$pobase/$file
4165 echo "Create $pobase/$file"
4168 func_append added_files "$pobase/$file$nl"
4171 # Create po makefile parameterization, part 1.
4172 func_dest_tmpfilename $pobase/Makevars
4173 func_emit_po_Makevars > "$tmpfile"
4174 if test -f "$destdir"/$pobase/Makevars; then
4175 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4179 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4180 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4181 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4183 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4189 echo "Creating $pobase/Makevars"
4190 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4192 echo "Create $pobase/Makevars"
4195 func_append added_files "$pobase/Makevars$nl"
4197 # Create po makefile parameterization, part 2.
4198 func_dest_tmpfilename $pobase/POTFILES.in
4199 func_emit_po_POTFILES_in > "$tmpfile"
4200 if test -f "$destdir"/$pobase/POTFILES.in; then
4201 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4205 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4206 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4207 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4209 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4215 echo "Creating $pobase/POTFILES.in"
4216 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4218 echo "Create $pobase/POTFILES.in"
4221 func_append added_files "$pobase/POTFILES.in$nl"
4224 TP_URL="http://translationproject.org/latest/"
4225 TP_RSYNC_URI="translationproject.org::tp/latest/"
4227 echo "Fetching gnulib PO files from $TP_URL"
4228 (cd "$destdir"/$pobase \
4229 && { # Prefer rsync over wget if it is available, since it consumes
4230 # less network bandwidth, due to compression.
4231 if type rsync 2>/dev/null | grep / > /dev/null; then
4232 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4234 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4239 echo "Fetch gnulib PO files from $TP_URL"
4241 # Create po/LINGUAS.
4243 func_dest_tmpfilename $pobase/LINGUAS
4244 (cd "$destdir"/$pobase \
4245 && { echo '# Set of available languages.'
4246 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4249 if test -f "$destdir"/$pobase/LINGUAS; then
4250 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4253 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4254 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4255 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4258 echo "Creating $pobase/LINGUAS"
4259 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4260 func_append added_files "$pobase/LINGUAS$nl"
4263 if test -f "$destdir"/$pobase/LINGUAS; then
4264 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4266 echo "Create $pobase/LINGUAS"
4271 # Create m4/gnulib-cache.m4.
4272 func_dest_tmpfilename $m4base/gnulib-cache.m4
4274 func_emit_copyright_notice
4276 echo "# This file represents the specification of how gnulib-tool is used."
4277 echo "# It acts as a cache: It is written and read by gnulib-tool."
4278 echo "# In projects using CVS, this file is meant to be stored in CVS,"
4279 echo "# like the configure.ac and various Makefile.am files."
4282 echo "# Specification in the form of a command-line invocation:"
4285 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4286 # Store the local_gnulib_dir relative to destdir.
4287 case "$local_gnulib_dir" in
4289 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4292 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4294 # destdir, local_gnulib_dir are both relative.
4295 func_relativize "$destdir" "$local_gnulib_dir"
4296 relative_local_gnulib_dir="$reldir" ;;
4299 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4301 echo "$specified_modules" | sed -e 's/^/ /g'
4303 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4304 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4305 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4306 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4307 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4308 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4309 echo "gl_AVOID([$avoidlist])"
4310 echo "gl_SOURCE_BASE([$sourcebase])"
4311 echo "gl_M4_BASE([$m4base])"
4312 echo "gl_PO_BASE([$pobase])"
4313 echo "gl_DOC_BASE([$docbase])"
4314 echo "gl_TESTS_BASE([$testsbase])"
4315 test -z "$inctests" || echo "gl_WITH_TESTS"
4316 echo "gl_LIB([$libname])"
4317 if test -n "$lgpl"; then
4318 if test "$lgpl" = yes; then
4321 echo "gl_LGPL([$lgpl])"
4324 echo "gl_MAKEFILE_NAME([$makefile_name])"
4325 if test "$libtool" = true; then
4328 echo "gl_MACRO_PREFIX([$macro_prefix])"
4329 echo "gl_PO_DOMAIN([$po_domain])"
4330 if test -n "$vc_files"; then
4331 echo "gl_VC_FILES([$vc_files])"
4334 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4335 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4339 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4340 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4341 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4343 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4347 echo "# gnulib-cache.m4 ends here"
4354 echo "Creating $m4base/gnulib-cache.m4"
4355 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4357 echo "Create $m4base/gnulib-cache.m4"
4363 # Create m4/gnulib-comp.m4.
4364 func_dest_tmpfilename $m4base/gnulib-comp.m4
4366 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4367 func_emit_copyright_notice
4369 echo "# This file represents the compiled summary of the specification in"
4370 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4371 echo "# to be invoked from configure.ac."
4372 echo "# In projects using CVS, this file can be treated like other built files."
4375 echo "# This macro should be invoked from $configure_ac, in the section"
4376 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4377 echo "# any checks for libraries, header files, types and library functions."
4378 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4380 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4381 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4382 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4383 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4384 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4385 if test -n "$uses_subdirs"; then
4386 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4388 for module in $final_modules; do
4390 if test -n "$module"; then
4391 echo "# Code from module $module:"
4392 func_get_autoconf_early_snippet "$module"
4395 | sed -e '/^$/d;' -e 's/^/ /'
4398 echo "# This macro should be invoked from $configure_ac, in the section"
4399 echo "# \"Check for header files, types and library functions\"."
4400 echo "AC_DEFUN([${macro_prefix}_INIT],"
4402 if test "$libtool" = true; then
4403 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4404 echo " gl_cond_libtool=true"
4406 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4407 echo " gl_cond_libtool=false"
4409 echo " gl_ltlibdeps="
4411 if test "$auxdir" != "build-aux"; then
4412 sed_replace_build_aux='
4414 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4415 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4419 sed_replace_build_aux="$sed_noop"
4421 echo " gl_m4_base='$m4base'"
4422 func_emit_initmacro_start $macro_prefix
4423 echo " gl_source_base='$sourcebase'"
4424 for module in $main_modules; do
4426 if test -n "$module"; then
4427 echo " # Code from module $module:"
4428 func_get_autoconf_snippet "$module" \
4429 | sed -e '/^$/d;' -e 's/^/ /' \
4430 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4431 -e "$sed_replace_build_aux"
4432 if test "$module" = 'alloca' && test "$libtool" = true; then
4433 echo 'changequote(,)dnl'
4434 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4435 echo 'changequote([, ])dnl'
4436 echo 'AC_SUBST([LTALLOCA])'
4440 echo " # End of code from modules"
4441 func_emit_initmacro_end $macro_prefix
4442 echo " gltests_libdeps="
4443 echo " gltests_ltlibdeps="
4444 func_emit_initmacro_start ${macro_prefix}tests
4445 echo " gl_source_base='$testsbase'"
4446 # Define a tests witness macro that depends on the package.
4447 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4448 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4449 echo "changequote(,)dnl"
4450 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"
4451 echo "changequote([, ])dnl"
4452 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4453 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4454 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4455 for module in $testsrelated_modules; do
4457 if test -n "$module"; then
4458 func_get_autoconf_snippet "$module" \
4459 | sed -e '/^$/d;' -e 's/^/ /' \
4460 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4461 -e "$sed_replace_build_aux" \
4462 -e 's/\$gl_cond_libtool/false/g' \
4463 -e 's/gl_libdeps/gltests_libdeps/g' \
4464 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4467 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4468 func_emit_initmacro_end ${macro_prefix}tests
4469 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4470 # created using libtool, because libtool already handles the dependencies.
4471 if test "$libtool" != true; then
4472 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4473 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4474 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4475 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4476 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4478 if $use_libtests; then
4479 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4480 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4483 func_emit_initmacro_done $macro_prefix $sourcebase
4484 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4486 echo "# This macro records the list of files which have been installed by"
4487 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4488 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4489 echo "$files" | sed -e 's,^, ,'
4492 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4493 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4497 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4498 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4499 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4501 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4505 echo "# gnulib-comp.m4 ends here"
4512 echo "Creating $m4base/gnulib-comp.m4"
4513 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4515 echo "Create $m4base/gnulib-comp.m4"
4521 if test -n "$inctests"; then
4522 # Create tests makefile.
4523 func_dest_tmpfilename $testsbase/$makefile_am
4524 destfile="$testsbase/$makefile_am"
4525 modules="$testsrelated_modules"
4526 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4527 if test -f "$destdir"/$testsbase/$makefile_am; then
4528 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4532 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4533 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4534 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4536 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4542 echo "Creating $testsbase/$makefile_am"
4543 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4545 echo "Create $testsbase/$makefile_am"
4548 func_append added_files "$testsbase/$makefile_am$nl"
4552 if test "$vc_files" != false; then
4553 # Update the .cvsignore and .gitignore files.
4554 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4555 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4556 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4557 echo "$m4base/|A|gnulib-comp.m4"
4558 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4559 { # Rearrange file descriptors. Needed because "while ... done < ..."
4560 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4561 exec 5<&0 < "$tmp"/fileset-changes
4562 func_update_ignorelist ()
4565 if test "$ignore" = .gitignore; then
4566 # In a .gitignore file, "foo" applies to the current directory and all
4567 # subdirectories, whereas "/foo" applies to the current directory only.
4570 doubly_escaped_anchor='\\/'
4574 doubly_escaped_anchor=''
4576 if test -f "$destdir/$dir$ignore"; then
4577 if test -n "$dir_added" || test -n "$dir_removed"; then
4578 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4579 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4580 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4581 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4582 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4584 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4586 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4587 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4588 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4589 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4590 } > "$tmp"/sed-ignore-removed
4591 { cat "$destdir/$dir$ignore"~
4592 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4593 } | sed -f "$tmp"/sed-ignore-removed \
4594 > "$destdir/$dir$ignore"
4596 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4601 if test -n "$dir_added"; then
4603 echo "Creating $destdir/$dir$ignore"
4605 if test "$ignore" = .cvsignore; then
4607 # Automake generates Makefile rules that create .dirstamp files.
4610 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4611 } > "$destdir/$dir$ignore"
4613 echo "Create $destdir/$dir$ignore"
4623 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4624 func_update_ignorelist .cvsignore
4626 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4627 func_update_ignorelist .gitignore
4634 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4635 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4636 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4637 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4638 if test "$next_dir" != "$last_dir"; then
4639 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4640 last_dir="$next_dir"
4645 A) func_append last_dir_added "$file$nl";;
4646 R) func_append last_dir_removed "$file$nl";;
4649 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4656 echo "You may need to add #include directives for the following .h files."
4657 # Intersect $specified_modules and $main_modules
4658 # (since $specified_modules is not necessarily of subset of $main_modules
4659 # - some may have been skipped through --avoid, and since the elements of
4660 # $main_modules but not in $specified_modules can go away without explicit
4661 # notice - through changes in the module dependencies).
4662 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4663 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4664 # First the #include <...> directives without #ifs, sorted for convenience,
4665 # then the #include "..." directives without #ifs, sorted for convenience,
4666 # then the #include directives that are surrounded by #ifs. Not sorted.
4667 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4668 include_directive=`func_get_include_directive "$module"`
4669 case "$nl$include_directive" in
4671 echo "$include_directive" 1>&5
4674 echo "$include_directive" | grep -v 'include "' 1>&6
4675 echo "$include_directive" | grep 'include "' 1>&7
4678 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4680 LC_ALL=C sort -u "$tmp"/include-angles
4681 LC_ALL=C sort -u "$tmp"/include-quotes
4682 cat "$tmp"/include-if
4683 ) | sed -e '/^$/d' -e 's/^/ /'
4684 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4686 for module in $main_modules; do
4687 func_get_link_directive "$module"
4689 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4690 if test `wc -l < "$tmp"/link` != 0; then
4692 echo "You may need to use the following Makefile variables when linking."
4693 echo "Use them in <program>_LDADD when linking a program, or"
4694 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4700 echo "Don't forget to"
4701 if test "$makefile_am" = Makefile.am; then
4702 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4704 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4706 if test -n "$pobase"; then
4707 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4709 if test -n "$inctests"; then
4710 if test "$makefile_am" = Makefile.am; then
4711 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4713 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4717 while test $edit != $makefile_am_edits; do
4718 edit=`expr $edit + 1`
4719 eval dir=\"\$makefile_am_edit${edit}_dir\"
4720 eval var=\"\$makefile_am_edit${edit}_var\"
4721 eval val=\"\$makefile_am_edit${edit}_val\"
4722 if test -n "$var"; then
4723 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4726 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4727 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4730 # func_create_testdir testdir modules
4732 # - local_gnulib_dir from --local-dir
4733 # - modcache true or false, from --cache-modules/--no-cache-modules
4734 # - auxdir directory relative to destdir where to place build aux files
4735 # - inctests true if tests should be included, blank otherwise
4736 # - incobsolete true if obsolete modules among dependencies should be
4737 # included, blank otherwise
4738 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
4740 # - excl_longrunning_tests true if long-runnings tests should be excluded,
4742 # - excl_privileged_tests true if tests that require root privileges should be
4743 # excluded, blank otherwise
4744 # - excl_unportable_tests true if tests that fail on some platforms should be
4745 # excluded, blank otherwise
4746 # - avoidlist list of modules to avoid
4747 # - libtool true if --libtool was given, false if --no-libtool was
4748 # given, blank otherwise
4749 # - symbolic true if files should be symlinked, copied otherwise
4750 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4752 func_create_testdir ()
4756 if test -z "$modules"; then
4757 # All modules together.
4758 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4759 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4760 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4761 modules=`func_all_modules`
4762 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4764 specified_modules="$modules"
4766 # Canonicalize the list of specified modules.
4767 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4769 # Unlike in func_import, here we want to include all kinds of tests for the
4770 # directly specified modules, but not for dependencies.
4771 inc_all_direct_tests=true
4772 inc_all_indirect_tests="$inc_all_tests"
4774 # Check that the license of every module is consistent with the license of
4776 saved_inctests="$inctests"
4777 # When computing transitive closures, don't consider $module to depend on
4778 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4779 # on GPL modules - therefore we don't want a warning in this case.
4781 for requested_module in $specified_modules; do
4782 requested_license=`func_get_license "$requested_module"`
4783 if test "$requested_license" != GPL; then
4784 # Here we use func_modules_transitive_closure, not just
4785 # func_get_dependencies, so that we also detect weird situations like
4786 # an LGPL module which depends on a GPLed build tool module which depends
4788 modules="$requested_module"
4789 func_modules_transitive_closure
4790 for module in $modules; do
4791 license=`func_get_license "$module"`
4793 'GPLed build tool') ;;
4794 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4796 case "$requested_license" in
4799 GPLv2+ | LGPLv2+) ;;
4800 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4806 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4812 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4821 inctests="$saved_inctests"
4823 # Subdirectory names.
4833 # Determine final module list.
4834 modules="$specified_modules"
4835 func_modules_transitive_closure
4836 if test $verbose -ge 0; then
4837 func_show_module_list
4840 # Add the dummy module if needed.
4841 func_modules_add_dummy
4843 # Show banner notice of every module.
4846 # Determine final file list.
4847 func_modules_to_filelist
4848 if test $verbose -ge 0; then
4850 echo "$files" | sed -e 's/^/ /'
4853 rewritten='%REWRITTEN%'
4854 sed_rewrite_files="\
4855 s,^build-aux/,$rewritten$auxdir/,
4856 s,^doc/,$rewritten$docbase/,
4857 s,^lib/,$rewritten$sourcebase/,
4858 s,^m4/,$rewritten$m4base/,
4859 s,^tests/,$rewritten$testsbase/,
4863 # Create directories.
4864 for f in $files; do echo $f; done \
4865 | sed -e "$sed_rewrite_files" \
4866 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4867 | LC_ALL=C sort -u \
4869 { # Rearrange file descriptors. Needed because "while ... done < ..."
4870 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4871 exec 5<&0 < "$tmp"/dirs
4873 mkdir -p "$testdir/$d"
4878 # Copy files or make symbolic links.
4880 for f in $files; do echo $f; done \
4881 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4884 { # Rearrange file descriptors. Needed because "while ... done < ..."
4885 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4886 exec 5<&0 < "$tmp"/files
4888 func_lookup_file "$f"
4889 if test -n "$lookedup_tmp"; then
4890 cp -p "$lookedup_file" "$testdir/$g"
4892 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4893 if { test -n "$symbolic" \
4894 || { test -n "$lsymbolic" \
4895 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4896 func_ln "$lookedup_file" "$testdir/$g"
4898 cp -p "$lookedup_file" "$testdir/$g"
4905 # Create Makefile.ams that are for testing.
4908 # No special edits are needed.
4911 # Create $sourcebase/Makefile.am.
4912 mkdir -p "$testdir/$sourcebase"
4913 destfile="$sourcebase/Makefile.am"
4914 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4915 any_uses_subdirs="$uses_subdirs"
4917 # Create $m4base/Makefile.am.
4918 mkdir -p "$testdir/$m4base"
4919 (echo "## Process this file with automake to produce Makefile.in."
4925 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4928 ) > "$testdir/$m4base/Makefile.am"
4930 subdirs="$sourcebase $m4base"
4931 subdirs_with_configure_ac=""
4933 if false && test -f "$testdir"/$m4base/gettext.m4; then
4934 # Avoid stupid error message from automake:
4935 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4936 mkdir -p "$testdir/po"
4937 (echo "## Process this file with automake to produce Makefile.in."
4938 ) > "$testdir/po/Makefile.am"
4939 func_append subdirs " po"
4942 if test -n "$inctests"; then
4943 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4944 # Viewed from the $testsbase subdirectory, $auxdir is different.
4945 saved_auxdir="$auxdir"
4946 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4947 # Create $testsbase/Makefile.am.
4949 destfile="$testsbase/Makefile.am"
4950 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
4951 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4952 # Create $testsbase/configure.ac.
4953 (echo "# Process this file with autoconf to produce a configure script."
4954 echo "AC_INIT([dummy], [0])"
4955 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4956 echo "AM_INIT_AUTOMAKE"
4958 echo "AC_CONFIG_HEADERS([config.h])"
4961 echo "AC_PROG_INSTALL"
4962 echo "AC_PROG_MAKE_SET"
4963 echo "AC_PROG_RANLIB"
4965 if test -n "$uses_subdirs"; then
4966 echo "AM_PROG_CC_C_O"
4969 for module in $modules; do
4971 if test -n "$module"; then
4973 gnumakefile | maintainer-makefile)
4974 # These modules are meant to be used only in the top-level directory.
4977 func_get_autoconf_early_snippet "$module"
4982 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4983 if test "$libtool" = true; then
4984 echo "LT_INIT([win32-dll])"
4985 echo "LT_LANG([C++])"
4986 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4987 echo "gl_cond_libtool=true"
4989 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4990 echo "gl_cond_libtool=false"
4992 echo "gl_ltlibdeps="
4994 # Wrap the set of autoconf snippets into an autoconf macro that is then
4995 # invoked. This is needed because autoconf does not support AC_REQUIRE
4997 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4998 # but we want the AC_REQUIRE to have its normal meaning (provide one
4999 # expansion of the required macro before the current point, and only one
5001 echo "AC_DEFUN([gl_INIT], ["
5002 sed_replace_build_aux='
5004 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5005 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5008 echo "gl_m4_base='../$m4base'"
5009 func_emit_initmacro_start $macro_prefix
5010 # We don't have explicit ordering constraints between the various
5011 # autoconf snippets. It's cleanest to put those of the library before
5012 # those of the tests.
5013 echo "gl_source_base='../$sourcebase'"
5014 for module in $modules; do
5015 func_verify_nontests_module
5016 if test -n "$module"; then
5018 gnumakefile | maintainer-makefile)
5019 # These modules are meant to be used only in the top-level directory.
5022 func_get_autoconf_snippet "$module" \
5023 | sed -e "$sed_replace_build_aux"
5028 echo "gl_source_base='.'"
5029 for module in $modules; do
5030 func_verify_tests_module
5031 if test -n "$module"; then
5032 func_get_autoconf_snippet "$module" \
5033 | sed -e "$sed_replace_build_aux"
5036 func_emit_initmacro_end $macro_prefix
5037 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5038 # created using libtool, because libtool already handles the dependencies.
5039 if test "$libtool" != true; then
5040 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5041 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5042 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5043 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5044 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5047 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5051 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5052 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5053 echo "AH_TOP([#include \"../config.h\"])"
5055 echo "AC_CONFIG_FILES([Makefile])"
5057 ) > "$testdir/$testsbase/configure.ac"
5058 auxdir="$saved_auxdir"
5059 func_append subdirs " $testsbase"
5060 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5063 # Create Makefile.am.
5064 (echo "## Process this file with automake to produce Makefile.in."
5066 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5068 echo "SUBDIRS = $subdirs"
5070 echo "ACLOCAL_AMFLAGS = -I $m4base"
5071 ) > "$testdir/Makefile.am"
5073 # Create configure.ac.
5074 (echo "# Process this file with autoconf to produce a configure script."
5075 echo "AC_INIT([dummy], [0])"
5076 if test "$auxdir" != "."; then
5077 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5079 echo "AM_INIT_AUTOMAKE"
5081 echo "AC_CONFIG_HEADERS([config.h])"
5084 echo "AC_PROG_INSTALL"
5085 echo "AC_PROG_MAKE_SET"
5087 echo "# For autobuild."
5088 echo "AC_CANONICAL_BUILD"
5089 echo "AC_CANONICAL_HOST"
5091 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5092 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5093 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5094 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5096 echo "AC_PROG_RANLIB"
5098 if test -n "$any_uses_subdirs"; then
5099 echo "AM_PROG_CC_C_O"
5102 for module in $modules; do
5103 func_verify_nontests_module
5104 if test -n "$module"; then
5105 func_get_autoconf_early_snippet "$module"
5108 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5109 if test "$libtool" = true; then
5110 echo "LT_INIT([win32-dll])"
5111 echo "LT_LANG([C++])"
5112 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5113 echo "gl_cond_libtool=true"
5115 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5116 echo "gl_cond_libtool=false"
5118 echo "gl_ltlibdeps="
5120 # Wrap the set of autoconf snippets into an autoconf macro that is then
5121 # invoked. This is needed because autoconf does not support AC_REQUIRE
5123 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5124 # but we want the AC_REQUIRE to have its normal meaning (provide one
5125 # expansion of the required macro before the current point, and only one
5127 echo "AC_DEFUN([gl_INIT], ["
5128 if test "$auxdir" != "build-aux"; then
5129 sed_replace_build_aux='
5131 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5132 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5136 sed_replace_build_aux="$sed_noop"
5138 echo "gl_m4_base='$m4base'"
5139 func_emit_initmacro_start $macro_prefix
5140 echo "gl_source_base='$sourcebase'"
5141 for module in $modules; do
5142 func_verify_nontests_module
5143 if test -n "$module"; then
5144 func_get_autoconf_snippet "$module" \
5145 | sed -e "$sed_replace_build_aux"
5148 func_emit_initmacro_end $macro_prefix
5149 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5150 # created using libtool, because libtool already handles the dependencies.
5151 if test "$libtool" != true; then
5152 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5153 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5154 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5155 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5156 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5159 func_emit_initmacro_done $macro_prefix $sourcebase
5163 if test -n "$subdirs_with_configure_ac"; then
5164 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5166 makefiles="Makefile"
5167 for d in $subdirs; do
5168 # For subdirs that have a configure.ac by their own, it's the subdir's
5169 # configure.ac which creates the subdir's Makefile.am, not this one.
5170 case " $subdirs_with_configure_ac " in
5172 *) func_append makefiles " $d/Makefile" ;;
5175 echo "AC_CONFIG_FILES([$makefiles])"
5177 ) > "$testdir/configure.ac"
5179 # Create autogenerated files.
5181 # Do not use "${AUTORECONF} --force --install", because it may invoke
5182 # autopoint, which brings in older versions of some of our .m4 files.
5183 if test -f $m4base/gettext.m4; then
5184 func_execute_command ${AUTOPOINT} --force || func_exit 1
5185 for f in $m4base/*.m4~; do
5187 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5191 if test "$libtool" = true; then
5192 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5194 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5195 if ! test -d build-aux; then
5196 func_execute_command mkdir build-aux || func_exit 1
5198 func_execute_command ${AUTOCONF} || func_exit 1
5199 func_execute_command ${AUTOHEADER} || func_exit 1
5200 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5202 if test -n "$inctests"; then
5203 # Create autogenerated files.
5204 (cd "$testdir/$testsbase" || func_exit 1
5205 # Do not use "${AUTORECONF} --force --install", because it may invoke
5206 # autopoint, which brings in older versions of some of our .m4 files.
5207 if test -f ../$m4base/gettext.m4; then
5208 func_execute_command ${AUTOPOINT} --force || func_exit 1
5209 for f in ../$m4base/*.m4~; do
5211 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5215 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5216 if ! test -d ../build-aux; then
5217 func_execute_command mkdir ../build-aux
5219 func_execute_command ${AUTOCONF} || func_exit 1
5220 func_execute_command ${AUTOHEADER} || func_exit 1
5221 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5224 # Need to run configure and make once, to create built files that are to be
5225 # distributed (such as getdate.c).
5226 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5227 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5228 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5229 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5230 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5231 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5232 # such $(FOO_H) because they don't refer to distributed files.
5233 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5234 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5235 | sed -e "$sed_remove_make_variables"`
5236 distributed_built_sources=`for file in $built_sources; do
5237 case "$cleaned_files" in
5242 tests_distributed_built_sources=
5243 if test -n "$inctests"; then
5244 # Likewise for built files in the $testsbase directory.
5245 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5246 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5247 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5248 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5249 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5250 | sed -e "$sed_remove_make_variables"`
5251 tests_distributed_built_sources=`for file in $tests_built_sources; do
5252 case "$tests_cleaned_files" in
5258 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5260 ./configure || func_exit 1
5261 if test -n "$distributed_built_sources"; then
5263 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5264 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5269 if test -n "$tests_distributed_built_sources"; then
5271 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5272 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5277 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5284 # func_create_megatestdir megatestdir allmodules
5286 # - local_gnulib_dir from --local-dir
5287 # - modcache true or false, from --cache-modules/--no-cache-modules
5288 # - auxdir directory relative to destdir where to place build aux files
5289 func_create_megatestdir ()
5293 if test -z "$allmodules"; then
5294 allmodules=`func_all_modules`
5298 # First, all modules one by one.
5299 for onemodule in $allmodules; do
5300 func_create_testdir "$megatestdir/$onemodule" $onemodule
5301 func_append megasubdirs "$onemodule "
5303 # Then, all modules all together.
5304 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5305 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5306 func_create_testdir "$megatestdir/ALL" "$allmodules"
5307 func_append megasubdirs "ALL"
5310 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5311 vc_witness="$gnulib_dir/CVS/Entries"; \
5313 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5315 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5316 | sed -e 's,January,01,' -e 's,Jan,01,' \
5317 -e 's,February,02,' -e 's,Feb,02,' \
5318 -e 's,March,03,' -e 's,Mar,03,' \
5319 -e 's,April,04,' -e 's,Apr,04,' \
5321 -e 's,June,06,' -e 's,Jun,06,' \
5322 -e 's,July,07,' -e 's,Jul,07,' \
5323 -e 's,August,08,' -e 's,Aug,08,' \
5324 -e 's,September,09,' -e 's,Sep,09,' \
5325 -e 's,October,10,' -e 's,Oct,10,' \
5326 -e 's,November,11,' -e 's,Nov,11,' \
5327 -e 's,December,12,' -e 's,Dec,12,' \
5328 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5329 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5331 echo "CVSDATE=$cvsdate"
5332 echo ": \${MAKE=make}"
5333 echo "test -d logs || mkdir logs"
5334 echo "for module in $megasubdirs; do"
5335 echo " echo \"Working on module \$module...\""
5336 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5337 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5340 echo " : autobuild project... \$module"
5341 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5342 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5343 echo " : autobuild hostname... \`hostname\`"
5344 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5346 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5348 ) > "$megatestdir/do-autobuild"
5349 chmod a+x "$megatestdir/do-autobuild"
5351 # Create Makefile.am.
5352 (echo "## Process this file with automake to produce Makefile.in."
5354 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5356 echo "SUBDIRS = $megasubdirs"
5358 echo "EXTRA_DIST = do-autobuild"
5359 ) > "$megatestdir/Makefile.am"
5361 # Create configure.ac.
5362 (echo "# Process this file with autoconf to produce a configure script."
5363 echo "AC_INIT([dummy], [0])"
5364 if test "$auxdir" != "."; then
5365 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5367 echo "AM_INIT_AUTOMAKE"
5369 echo "AC_PROG_MAKE_SET"
5371 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5372 echo "AC_CONFIG_FILES([Makefile])"
5374 ) > "$megatestdir/configure.ac"
5376 # Create autogenerated files.
5378 # Do not use "${AUTORECONF} --install", because autoreconf operates
5379 # recursively, but the subdirectories are already finished, therefore
5380 # calling autoreconf here would only waste lots of CPU time.
5381 func_execute_command ${ACLOCAL} || func_exit 1
5382 func_execute_command mkdir build-aux
5383 func_execute_command ${AUTOCONF} || func_exit 1
5384 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5390 func_fatal_error "no mode specified" ;;
5397 # sed expression that converts a literal to a basic regular expression.
5398 # Needs to handle . [ \ * ^ $.
5399 sed_literal_to_basic_regex='s/\\/\\\\/g
5405 if test -f "$gnulib_dir/$filename" \
5406 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5407 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5408 filename_line_regex='^'"$filename_anywhere_regex"'$'
5411 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5412 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5413 (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$,,')
5416 | func_sanitize_modulelist \
5419 for module in $module_candidates; do
5420 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5425 func_warning "file $filename does not exist"
5433 if test -z "$destdir"; then
5436 test -d "$destdir" \
5437 || func_fatal_error "destination directory does not exist: $destdir"
5439 # Prefer configure.ac to configure.in.
5440 if test -f "$destdir"/configure.ac; then
5441 configure_ac="$destdir/configure.ac"
5443 if test -f "$destdir"/configure.in; then
5444 configure_ac="$destdir/configure.in"
5446 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5450 # Analyze configure.ac.
5452 guessed_libtool=false
5457 /AC_CONFIG_AUX_DIR/ {
5458 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5460 /A[CM]_PROG_LIBTOOL/ {
5461 s,^.*$,guessed_libtool=true,p
5463 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5465 if test -z "$auxdir"; then
5466 auxdir="$guessed_auxdir"
5469 # Determine where to apply func_import.
5470 if test -n "$m4base"; then
5471 # Apply func_import to a particular gnulib directory.
5472 # Any number of additional modules can be given.
5473 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5474 # First use of gnulib in the given m4base.
5475 test -n "$supplied_libname" || supplied_libname=true
5476 test -n "$sourcebase" || sourcebase="lib"
5477 test -n "$docbase" || docbase="doc"
5478 test -n "$testsbase" || testsbase="tests"
5479 test -n "$macro_prefix" || macro_prefix="gl"
5483 # Apply func_import to all gnulib directories.
5484 # To get this list of directories, look at Makefile.am. (Not at
5485 # configure, because it may be omitted from CVS. Also, don't run
5486 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5489 if test -f "$destdir"/Makefile.am; then
5490 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5492 for arg in $aclocal_amflags; do
5493 if test -n "$m4dir_is_next"; then
5494 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5498 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5499 func_append m4dirs " $arg"
5500 m4dirs_count=`expr $m4dirs_count + 1`
5506 if test "X$arg" = "X-I"; then
5514 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5515 if test -f "$destdir"/aclocal.m4; then
5516 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5517 sedexpr2='s,^[^/]*$,.,'
5518 sedexpr3='s,/[^/]*$,,'
5519 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5520 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5523 if test $m4dirs_count = 0; then
5524 # First use of gnulib in a package.
5525 # Any number of additional modules can be given.
5526 test -n "$supplied_libname" || supplied_libname=true
5527 test -n "$sourcebase" || sourcebase="lib"
5529 test -n "$docbase" || docbase="doc"
5530 test -n "$testsbase" || testsbase="tests"
5531 test -n "$macro_prefix" || macro_prefix="gl"
5534 if test $m4dirs_count = 1; then
5535 # There's only one use of gnulib here. Assume the user means it.
5536 # Any number of additional modules can be given.
5537 for m4base in $m4dirs; do
5541 # Ambiguous - guess what the user meant.
5542 if test $# = 0; then
5543 # No further arguments. Guess the user wants to update all of them.
5544 for m4base in $m4dirs; do
5545 # Perform func_import in a subshell, so that variable values
5547 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5548 # inc_longrunning_tests, inc_privileged_tests,
5549 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5550 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5551 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5552 # don't propagate from one directory to another.
5553 (func_import) || func_exit 1
5557 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5565 if test -z "$destdir"; then
5566 func_fatal_error "please specify --dir option"
5569 test -d "$destdir" \
5570 || func_fatal_error "could not create destination directory"
5571 test -n "$auxdir" || auxdir="build-aux"
5572 func_create_testdir "$destdir" "$*"
5575 create-megatestdir )
5576 if test -z "$destdir"; then
5577 func_fatal_error "please specify --dir option"
5579 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5580 test -n "$auxdir" || auxdir="build-aux"
5581 func_create_megatestdir "$destdir" "$*"
5585 test -n "$destdir" || destdir=testdir$$
5586 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5587 test -n "$auxdir" || auxdir="build-aux"
5588 func_create_testdir "$destdir" "$*"
5592 ../configure || func_exit 1
5593 $MAKE || func_exit 1
5594 $MAKE check || func_exit 1
5595 $MAKE distclean || func_exit 1
5596 remaining=`find . -type f -print`
5597 if test -n "$remaining"; then
5598 echo "Remaining files:" $remaining 1>&2
5599 echo "gnulib-tool: *** Stop." 1>&2
5608 test -n "$destdir" || destdir=testdir$$
5609 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5610 test -n "$auxdir" || auxdir="build-aux"
5611 func_create_megatestdir "$destdir" "$*"
5619 remaining=`find . -type f -print`
5620 if test -n "$remaining"; then
5621 echo "Remaining files:" $remaining 1>&2
5622 echo "gnulib-tool: *** Stop." 1>&2
5630 extract-description )
5634 if test -n "$module"; then
5635 func_get_description "$module"
5644 if test -n "$module"; then
5645 func_get_comment "$module"
5654 if test -n "$module"; then
5655 func_get_status "$module"
5664 if test -n "$module"; then
5665 func_get_notice "$module"
5670 extract-applicability )
5674 if test -n "$module"; then
5675 func_get_applicability "$module"
5684 if test -n "$module"; then
5685 func_get_filelist "$module"
5690 extract-dependencies )
5694 if test -n "$module"; then
5695 func_get_dependencies "$module"
5700 extract-autoconf-snippet )
5704 if test -n "$module"; then
5705 func_get_autoconf_snippet "$module"
5710 extract-automake-snippet )
5714 if test -n "$module"; then
5715 func_get_automake_snippet "$module"
5720 extract-include-directive )
5724 if test -n "$module"; then
5725 func_get_include_directive "$module"
5730 extract-link-directive )
5734 if test -n "$module"; then
5735 func_get_link_directive "$module"
5744 if test -n "$module"; then
5745 func_get_license "$module"
5750 extract-maintainer )
5754 if test -n "$module"; then
5755 func_get_maintainer "$module"
5760 extract-tests-module )
5764 if test -n "$module"; then
5765 func_get_tests_module "$module"
5771 # Verify the number of arguments.
5772 if test $# -lt 1 || test $# -gt 2; then
5773 func_fatal_error "invalid number of arguments for --$mode"
5776 # The first argument is the file to be copied.
5778 # Verify the file exists.
5779 func_lookup_file "$f"
5781 # The second argument is the destination; either a directory ot a file.
5782 # It defaults to the current directory.
5784 test -n "$dest" || dest='.'
5785 test -n "$sourcebase" || sourcebase="lib"
5786 test -n "$m4base" || m4base="m4"
5787 test -n "$docbase" || docbase="doc"
5788 test -n "$testsbase" || testsbase="tests"
5789 test -n "$auxdir" || auxdir="build-aux"
5790 rewritten='%REWRITTEN%'
5791 sed_rewrite_files="\
5792 s,^build-aux/,$rewritten$auxdir/,
5793 s,^doc/,$rewritten$docbase/,
5794 s,^lib/,$rewritten$sourcebase/,
5795 s,^m4/,$rewritten$m4base/,
5796 s,^tests/,$rewritten$testsbase/,
5799 if test -d "$dest"; then
5801 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5803 destdir=`dirname "$dest"`
5804 g=`basename "$dest"`
5807 # Create the directory for destfile.
5808 d=`dirname "$destdir/$g"`
5810 if test -n "$d" && test ! -d "$d"; then
5811 mkdir -p "$d" || func_fatal_error "failed"
5815 func_dest_tmpfilename "$g"
5816 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5817 already_present=true
5818 if test -f "$destdir/$g"; then
5819 # The file already exists.
5823 # Don't protest if the file should be there but isn't: it happens
5824 # frequently that developers don't put autogenerated files into CVS.
5831 func_fatal_error "unknown operation mode --$mode" ;;
5835 # Undo the effect of the previous 'trap' command. Some shellology:
5836 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5837 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5838 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5839 # 128 + signal number and is set before the trap-registered command is run.
5841 trap 'func_exit $?' 1 2 3 13 15
5846 # indent-tabs-mode: nil
5847 # whitespace-check-buffer-indent: nil