3 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
126 # This use of bold display can be removed on 2011-01-01.
131 # Assume xterm compatible escape sequences.
132 bold_on=`printf '\x1b[1m'`
133 bold_off=`printf '\x1b[0m'`
139 Usage: gnulib-tool --list
140 gnulib-tool --find filename${bold_on}
141 gnulib-tool --import [module1 ... moduleN]
142 gnulib-tool --add-import [module1 ... moduleN]
143 gnulib-tool --remove-import [module1 ... moduleN]${bold_off}
145 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
146 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
147 gnulib-tool --test --dir=directory module1 ... moduleN
148 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
149 gnulib-tool --extract-description module
150 gnulib-tool --extract-comment module
151 gnulib-tool --extract-status module
152 gnulib-tool --extract-notice module
153 gnulib-tool --extract-applicability module
154 gnulib-tool --extract-filelist module
155 gnulib-tool --extract-dependencies module
156 gnulib-tool --extract-autoconf-snippet module
157 gnulib-tool --extract-automake-snippet module
158 gnulib-tool --extract-include-directive module
159 gnulib-tool --extract-link-directive module
160 gnulib-tool --extract-license module
161 gnulib-tool --extract-maintainer module
162 gnulib-tool --extract-tests-module module
163 gnulib-tool --copy-file file [destination]
167 --list print the available module names
168 --find find the modules which contain the specified file${bold_on}
169 --import import the given modules into the current package
170 --add-import augment the list of imports from gnulib into the
171 current package, by adding the given modules;
172 if no modules are specified, update the current
173 package from the current gnulib
174 --remove-import reduce the list of imports from gnulib into the
175 current package, by removing the given modules${bold_off}
176 --update update the current package, restore files omitted
178 --create-testdir create a scratch package with the given modules
179 --create-megatestdir create a mega scratch package with the given modules
180 one by one and all together
181 --test test the combination of the given modules
182 (recommended to use CC=\"gcc -Wall\" here)
183 --megatest test the given modules one by one and all together
184 (recommended to use CC=\"gcc -Wall\" here)
185 --extract-description extract the description
186 --extract-comment extract the comment
187 --extract-status extract the status (obsolete etc.)
188 --extract-notice extract the notice or banner
189 --extract-applicability extract the applicability
190 --extract-filelist extract the list of files
191 --extract-dependencies extract the dependencies
192 --extract-autoconf-snippet extract the snippet for configure.ac
193 --extract-automake-snippet extract the snippet for library makefile
194 --extract-include-directive extract the #include directive
195 --extract-link-directive extract the linker directive
196 --extract-license report the license terms of the source files
198 --extract-maintainer report the maintainer(s) inside gnulib
199 --extract-tests-module report the unit test module, if it exists
200 --copy-file copy a file that is not part of any module
204 --dir=DIRECTORY Specify the target directory.
205 For --import, this specifies where your
206 configure.ac can be found. Defaults to current
208 --local-dir=DIRECTORY Specify a local override directory where to look
209 up files before looking in gnulib's directory.
210 --cache-modules Enable module caching optimization.
211 --no-cache-modules Disable module caching optimization.
212 --verbose Increase verbosity. May be repeated.
213 --quiet Decrease verbosity. May be repeated.
215 Options for --import, --add/remove-import, --update:
217 --dry-run Only print what would have been done.
219 Options for --import, --add/remove-import,
220 --create-[mega]testdir, --[mega]test:
222 --with-tests Include unit tests for the included modules.
223 --with-obsolete Include obsolete modules when they occur among the
224 dependencies. By default, dependencies to obsolete
226 --with-c++-tests Include even unit tests for C++ interoperability.
227 --with-longrunning-tests
228 Include even unit tests that are long-runners.
229 --with-privileged-tests
230 Include even unit tests that require root
232 --with-unportable-tests
233 Include even unit tests that fail on some platforms.
234 --with-all-tests Include all kinds of problematic unit tests.
235 --avoid=MODULE Avoid including the given MODULE. Useful if you
236 have code that provides equivalent functionality.
237 This option can be repeated.
238 --libtool Use libtool rules.
239 --no-libtool Don't use libtool rules.
241 Options for --import, --add/remove-import:
243 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
244 --source-base=DIRECTORY
245 Directory relative to --dir where source code is
246 placed (default \"lib\").
247 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
248 placed (default \"m4\").
249 --po-base=DIRECTORY Directory relative to --dir where *.po files are
250 placed (default \"po\").
251 --doc-base=DIRECTORY Directory relative to --dir where doc files are
252 placed (default \"doc\").
253 --tests-base=DIRECTORY
254 Directory relative to --dir where unit tests are
255 placed (default \"tests\").
256 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
257 tools are placed (default comes from configure.ac).
258 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
259 Also modify license template from GPL to LGPL.
260 The version number of the LGPL can be specified;
261 the default is currently LGPLv3.
262 --makefile-name=NAME Name of makefile in automake syntax in the
263 source-base and tests-base directories
264 (default \"Makefile.am\").
265 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
266 'gl_INIT'. Default is 'gl'.
267 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
268 the package name. A suffix '-gnulib' is appended.
269 --vc-files Update version control related files.
270 --no-vc-files Don't update version control related files
271 (.gitignore and/or .cvsignore).
272 --no-changelog Don't update or create ChangeLog files.
274 Options for --create-[mega]testdir, --[mega]test:
276 --without-c++-tests Exclude unit tests for C++ interoperability.
277 --without-longrunning-tests
278 Exclude unit tests that are long-runners.
279 --without-privileged-tests
280 Exclude unit tests that require root privileges.
281 --without-unportable-tests
282 Exclude unit tests that fail on some platforms.
284 Options for --import, --add/remove-import, --update,
285 --create-[mega]testdir, --[mega]test:
287 -s, --symbolic, --symlink Make symbolic links instead of copying files.
288 --local-symlink Make symbolic links instead of copying files, only
289 for files from the local override directory.
291 Options for --import, --add/remove-import, --update:
293 -S, --more-symlinks Make symbolic links instead of copying files, and
294 don't replace copyright notices.
296 Report bugs to <bug-gnulib@gnu.org>."
300 # outputs to stdout the --version message.
304 if test -d "$gnulib_dir"/.git \
305 && (git --version) >/dev/null 2>/dev/null \
306 && (date --version) >/dev/null 2>/dev/null; then
307 # gnulib checked out from git.
308 sed_extract_first_date='/^Date/{
312 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
313 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
314 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
315 date=`echo "$date" | sed -e "$sed_year_before_time"`
316 # Use GNU date to compute the time in GMT.
317 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
318 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
320 if test -d "$gnulib_dir"/CVS \
321 && (cvs --version) >/dev/null 2>/dev/null; then
322 # gnulib checked out from CVS.
323 sed_extract_first_date='/^date: /{
324 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
327 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
329 # gnulib copy without versioning information.
330 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
334 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
336 gnulib-tool (GNU $package $date)$version
337 Copyright (C) $year Free Software Foundation, Inc.
338 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
339 This is free software: you are free to change and redistribute it.
340 There is NO WARRANTY, to the extent permitted by law.
342 Written by" "Bruno Haible" "and" "Simon Josefsson"
345 # func_emit_copyright_notice
346 # outputs to stdout a header for a generated file.
347 func_emit_copyright_notice ()
349 sed -n -e '/Copyright/ {
352 }' < "$self_abspathname"
354 echo "# This file is free software, distributed under the terms of the GNU"
355 echo "# General Public License. As a special exception to the GNU General"
356 echo "# Public License, this file may be distributed as part of a program"
357 echo "# that contains a configuration script generated by Autoconf, under"
358 echo "# the same distribution terms as the rest of that program."
360 echo "# Generated by gnulib-tool."
364 # exits with a given status.
365 # This function needs to be used, rather than 'exit', when a 'trap' handler is
366 # in effect that refers to $?.
373 # locates the directory where the gnulib repository lives
375 # - progname name of this program
377 # - self_abspathname absolute pathname of gnulib-tool
378 # - gnulib_dir absolute pathname of gnulib repository
382 /*) self_abspathname="$progname" ;;
383 */*) self_abspathname=`pwd`/"$progname" ;;
386 # Iterate through the elements of $PATH.
387 # We use IFS=: instead of
388 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
389 # because the latter does not work when some PATH element contains spaces.
390 # We use a canonicalized $pathx instead of $PATH, because empty PATH
391 # elements are by definition equivalent to '.', however field splitting
392 # according to IFS=: loses empty fields in many shells:
393 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
394 # beginning, at the end, and in the middle),
395 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
396 # at the beginning and at the end,
397 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
398 # Solaris lose empty fields at the end.
399 # The 'case' statement is an optimization, to avoid evaluating the
400 # explicit canonicalization command when $PATH contains no empty fields.
402 if test "${PATH_SEPARATOR+set}" != set; then
403 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
404 # contains only /bin. Note that ksh looks also at the FPATH variable,
405 # so we have to set that as well for the test.
407 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
408 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
409 || PATH_SEPARATOR=';'
412 if test "$PATH_SEPARATOR" = ";"; then
413 # On Windows, programs are searched in "." before $PATH.
416 # On Unix, we have to convert empty PATH elements to ".".
420 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
425 IFS="$PATH_SEPARATOR"
429 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
430 self_abspathname="$d/$progname"
435 if test -z "$self_abspathname"; then
436 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
440 while test -h "$self_abspathname"; do
441 # Resolve symbolic link.
442 linkval=`func_readlink "$self_abspathname"`
443 test -n "$linkval" || break
445 /* ) self_abspathname="$linkval" ;;
446 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
449 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
453 # creates a temporary directory.
455 # - progname name of this program
457 # - tmp pathname of freshly created temporary directory
460 # Use the environment variable TMPDIR, falling back to /tmp. This allows
461 # users to specify a different temporary directory, for example, if their
462 # /tmp is filled up or too small.
465 # Use the mktemp program if available. If not available, hide the error
467 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
468 test -n "$tmp" && test -d "$tmp"
471 # Use a simple mkdir command. It is guaranteed to fail if the directory
472 # already exists. $RANDOM is bash specific and expands to empty in shells
473 # other than bash, ksh and zsh. Its use does not increase security;
474 # rather, it minimizes the probability of failure in a very cluttered /tmp
476 tmp=$TMPDIR/gl$$-$RANDOM
477 (umask 077 && mkdir "$tmp")
480 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
485 # func_append var value
486 # appends the given value to the shell variable var.
487 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
488 # Use bash's += operator. It reduces complexity of appending repeatedly to
489 # a single variable from O(n^2) to O(n).
494 fast_func_append=true
498 eval "$1=\"\$$1\$2\""
500 fast_func_append=false
503 # func_remove_prefix var prefix
504 # removes the given prefix 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 # prefix should not contain the characters "$`\{}[]^|.
508 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
509 func_remove_prefix ()
513 fast_func_remove_prefix=true
515 func_remove_prefix ()
517 eval "value=\"\$$1\""
521 sed_escape_dots='s/\([.]\)/\\\1/g'
522 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
525 value=`echo "$value" | sed -e "s|^${prefix}||"`
526 eval "$1=\"\$value\""
528 fast_func_remove_prefix=false
531 # func_remove_suffix var suffix
532 # removes the given suffix from the value of the shell variable var.
533 # var should be the name of a shell variable.
534 # Its value should not contain a newline and not start or end with whitespace.
535 # suffix should not contain the characters "$`\{}[]^|.
536 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
537 func_remove_suffix ()
541 fast_func_remove_suffix=true
543 func_remove_suffix ()
545 eval "value=\"\$$1\""
549 sed_escape_dots='s/\([.]\)/\\\1/g'
550 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
553 value=`echo "$value" | sed -e "s|${suffix}\$||"`
554 eval "$1=\"\$value\""
556 fast_func_remove_suffix=false
559 # func_fatal_error message
560 # outputs to stderr a fatal error message, and terminates the program.
562 # - progname name of this program
565 echo "$progname: *** $1" 1>&2
566 echo "$progname: *** Stop." 1>&2
570 # func_warning message
571 # Outputs to stderr a warning message,
574 echo "gnulib-tool: warning: $1" 1>&2
577 # func_readlink SYMLINK
578 # outputs the target of the given symlink.
579 if (type -p readlink) > /dev/null 2>&1; then
582 # Use the readlink program from GNU coreutils.
588 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
589 # would do the wrong thing if the link target contains " -> ".
590 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
594 # func_relativize DIR1 DIR2
595 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
597 # - DIR1 relative pathname, relative to the current directory
598 # - DIR2 relative pathname, relative to the current directory
600 # - reldir relative pathname of DIR2, relative to DIR1
606 sed_first='s,^\([^/]*\)/.*$,\1,'
607 sed_rest='s,^[^/]*/*,,'
608 sed_last='s,^.*/\([^/]*\)$,\1,'
609 sed_butlast='s,/*[^/]*$,,'
610 while test -n "$dir1"; do
611 first=`echo "$dir1" | sed -e "$sed_first"`
612 if test "$first" != "."; then
613 if test "$first" = ".."; then
614 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
615 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
617 first2=`echo "$dir2" | sed -e "$sed_first"`
618 if test "$first2" = "$first"; then
619 dir2=`echo "$dir2" | sed -e "$sed_rest"`
623 dir0="$dir0"/"$first"
626 dir1=`echo "$dir1" | sed -e "$sed_rest"`
631 # func_relconcat DIR1 DIR2
632 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
634 # - DIR1 relative pathname, relative to the current directory
635 # - DIR2 relative pathname, relative to DIR1
637 # - relconcat DIR1/DIR2, relative to the current directory
642 sed_first='s,^\([^/]*\)/.*$,\1,'
643 sed_rest='s,^[^/]*/*,,'
644 sed_last='s,^.*/\([^/]*\)$,\1,'
645 sed_butlast='s,/*[^/]*$,,'
647 first=`echo "$dir2" | sed -e "$sed_first"`
648 if test "$first" = "."; then
649 dir2=`echo "$dir2" | sed -e "$sed_rest"`
650 if test -z "$dir2"; then
655 last=`echo "$dir1" | sed -e "$sed_last"`
656 while test "$last" = "."; do
657 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
658 last=`echo "$dir1" | sed -e "$sed_last"`
660 if test -z "$dir1"; then
664 if test "$first" = ".."; then
665 if test "$last" = ".."; then
666 relconcat="$dir1/$dir2"
669 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
670 dir2=`echo "$dir2" | sed -e "$sed_rest"`
671 if test -z "$dir1"; then
675 if test -z "$dir2"; then
680 relconcat="$dir1/$dir2"
688 # Like ln -s, except that SRC is given relative to the current directory (or
689 # absolute), not given relative to the directory of DEST.
695 *) # SRC is relative.
698 ln -s "`pwd`/$1" "$2" ;;
699 *) # DEST is relative too.
700 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
701 test -n "$ln_destdir" || ln_destdir="."
702 func_relativize "$ln_destdir" "$1"
710 # func_ln_if_changed SRC DEST
711 # Like func_ln, but avoids munging timestamps if the link is correct.
712 func_ln_if_changed ()
714 if test $# -ne 2; then
715 echo "usage: func_ln_if_changed SRC DEST" >&2
717 ln_target=`func_readlink "$2"`
718 if test -h "$2" && test "$1" = "$ln_target"; then
726 # Ensure an 'echo' command that
727 # 1. does not interpret backslashes and
728 # 2. does not print an error message "broken pipe" when writing into a pipe
731 # Test cases for problem 1:
732 # echo '\n' | wc -l prints 1 when OK, 2 when KO
733 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
734 # Test cases for problem 2:
735 # echo hi | true frequently prints
736 # "bash: echo: write error: Broken pipe"
737 # to standard error in bash 3.2.
739 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
740 # BSD echo interprets '-n' as an option, which is also not desirable).
741 # Nowadays the problem occurs in 4 situations:
742 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
743 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
744 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
745 # - in zsh, when sh-emulation is not set,
746 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
747 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
748 # - in Solaris /bin/sh and OSF/1 /bin/sh.
749 # We try the following workarounds:
750 # - for all: respawn using $CONFIG_SHELL if that is set and works.
751 # - for bash >= 2.04: unset the shell option xpg_echo.
752 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
753 # - for bash < 2.0: define echo to a function that uses cat of a here document.
754 # - for zsh: turn sh-emulation on.
755 # - for ksh: alias echo to 'print -r'.
756 # - for ksh: alias echo to a function that uses cat of a here document.
757 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
758 # the ksh workaround.
759 # - otherwise: respawn using /bin/sh and rely on the workarounds.
760 # When respawning, we pass --no-reexec as first argument, so as to avoid
761 # turning this script into a fork bomb in unlucky situations.
763 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
764 # the 'printf' built-in. See
765 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
766 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
767 # The workaround is: define echo to a function that uses the printf built-in.
769 if echo '\t' | grep t > /dev/null; then
770 have_echo=yes # Lucky!
772 # Try the workarounds.
773 # Respawn using $CONFIG_SHELL if that is set and works.
774 if test -z "$have_echo" \
775 && test "X$1" != "X--no-reexec" \
776 && test -n "$CONFIG_SHELL" \
777 && test -f "$CONFIG_SHELL" \
778 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
779 exec $CONFIG_SHELL "$0" --no-reexec "$@"
782 # For bash >= 2.04: unset the shell option xpg_echo.
783 if test -z "$have_echo" \
784 && test -n "$BASH_VERSION" \
785 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
789 # For bash >= 2.0: define echo to a function that uses the printf built-in.
790 # For bash < 2.0: define echo to a function that uses cat of a here document.
791 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
792 # Also handle problem 2, specific to bash 3.2, here.
793 if { test -z "$have_echo" \
794 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
796 && test -n "$BASH_VERSION"; then \
797 if type printf 2>/dev/null | grep / > /dev/null; then
798 # 'printf' is not a shell built-in.
806 # 'printf' is a shell built-in.
812 if echo '\t' | grep t > /dev/null; then
816 # For zsh: turn sh-emulation on.
817 if test -z "$have_echo" \
818 && test -n "$ZSH_VERSION" \
819 && (emulate sh) >/dev/null 2>&1; then
822 # For ksh: alias echo to 'print -r'.
823 if test -z "$have_echo" \
824 && (type print) >/dev/null 2>&1; then
825 # A 'print' command exists.
826 if type print 2>/dev/null | grep / > /dev/null; then
829 # 'print' is a shell built-in.
830 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
831 # 'print' is the ksh shell built-in.
832 alias echo='print -r'
836 if test -z "$have_echo" \
837 && echo '\t' | grep t > /dev/null; then
840 # For ksh: alias echo to a function that uses cat of a here document.
841 # The ksh manual page says:
842 # "Aliasing is performed when scripts are read, not while they are executed.
843 # Therefore, for an alias to take effect, the alias definition command has
844 # to be executed before the command which references the alias is read."
845 # Because of this, we have to play strange tricks with have_echo, to ensure
846 # that the top-level statement containing the test starts after the 'alias'
848 if test -z "$have_echo"; then
855 if (alias echo=bsd_echo) 2>/dev/null; then
856 alias echo=bsd_echo 2>/dev/null
859 if test -z "$have_echo" \
860 && echo '\t' | grep t > /dev/null; then
863 if test -z "$have_echo"; then
864 if (alias echo=bsd_echo) 2>/dev/null; then
865 unalias echo 2>/dev/null
868 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
869 if test -z "$have_echo" \
870 && test "X$1" != "X--no-reexec" \
871 && test -f /bin/ksh; then
872 exec /bin/ksh "$0" --no-reexec "$@"
875 # Otherwise: respawn using /bin/sh.
876 if test -z "$have_echo" \
877 && test "X$1" != "X--no-reexec" \
878 && test -f /bin/sh; then
879 exec /bin/sh "$0" --no-reexec "$@"
882 if test -z "$have_echo"; then
883 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
885 if echo '\t' | grep t > /dev/null; then
888 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
890 if test "X$1" = "X--no-reexec"; then
894 # Command-line option processing.
895 # Removes the OPTIONS from the arguments. Sets the variables:
896 # - mode list or import or add-import or remove-import or update
897 # or create-testdir or create-megatestdir
898 # - destdir from --dir
899 # - local_gnulib_dir from --local-dir
900 # - modcache true or false, from --cache-modules/--no-cache-modules
901 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
902 # - libname, supplied_libname from --lib
903 # - sourcebase from --source-base
904 # - m4base from --m4-base
905 # - pobase from --po-base
906 # - docbase from --doc-base
907 # - testsbase from --tests-base
908 # - auxdir from --aux-dir
909 # - inctests true if --with-tests was given, blank otherwise
910 # - incobsolete true if --with-obsolete was given, blank otherwise
911 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
912 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
914 # - inc_privileged_tests true if --with-privileged-tests was given, blank
916 # - inc_unportable_tests true if --with-unportable-tests was given, blank
918 # - inc_all_tests true if --with-all-tests was given, blank otherwise
919 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
920 # - excl_longrunning_tests true if --without-longrunning-tests was given,
922 # - excl_privileged_tests true if --without-privileged-tests was given, blank
924 # - excl_unportable_tests true if --without-unportable-tests was given, blank
926 # - avoidlist list of modules to avoid, from --avoid
927 # - lgpl yes or a number if --lgpl was given, blank otherwise
928 # - makefile_name from --makefile-name
929 # - libtool true if --libtool was given, false if --no-libtool was
930 # given, blank otherwise
931 # - macro_prefix from --macro-prefix
932 # - po_domain from --po-domain
933 # - vc_files true if --vc-files was given, false if --no-vc-files was
934 # given, blank otherwise
935 # - autoconf_minversion minimum supported autoconf version
936 # - do_changelog false if --no-changelog was given, : otherwise
937 # - doit : if actions shall be executed, false if only to be printed
938 # - symbolic true if --symlink or --more-symlinks was given, blank
940 # - lsymbolic true if --local-symlink was given, blank otherwise
941 # - do_copyrights blank if --more-symlinks was given, true otherwise
959 inc_longrunning_tests=
960 inc_privileged_tests=
961 inc_unportable_tests=
964 excl_longrunning_tests=
965 excl_privileged_tests=
966 excl_unportable_tests=
982 while test $# -gt 0; do
987 --find | --fin | --fi | --f )
990 --import | --impor | --impo | --imp | --im | --i )
993 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
996 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
999 --update | --updat | --upda | --upd | --up | --u )
1002 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1005 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1006 mode=create-megatestdir
1008 --test | --tes | --te | --t )
1011 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1015 mode=`echo "X$1" | sed -e 's/^X--//'`
1017 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
1022 if test $# = 0; then
1023 func_fatal_error "missing argument for --dir"
1028 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1032 if test $# = 0; then
1033 func_fatal_error "missing argument for --local-dir"
1038 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1040 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1043 --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 )
1046 --verbose | --verbos | --verbo | --verb )
1047 verbose=`expr $verbose + 1`
1049 --quiet | --quie | --qui | --qu | --q )
1050 verbose=`expr $verbose - 1`
1054 if test $# = 0; then
1055 func_fatal_error "missing argument for --lib"
1058 supplied_libname=true
1061 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1062 supplied_libname=true
1066 if test $# = 0; then
1067 func_fatal_error "missing argument for --source-base"
1072 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1076 if test $# = 0; then
1077 func_fatal_error "missing argument for --m4-base"
1082 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1086 if test $# = 0; then
1087 func_fatal_error "missing argument for --po-base"
1092 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1096 if test $# = 0; then
1097 func_fatal_error "missing argument for --doc-base"
1102 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1106 if test $# = 0; then
1107 func_fatal_error "missing argument for --tests-base"
1112 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1116 if test $# = 0; then
1117 func_fatal_error "missing argument for --aux-dir"
1122 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1124 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1127 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1130 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1133 --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)
1134 inc_longrunning_tests=true
1136 --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)
1137 inc_privileged_tests=true
1139 --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)
1140 inc_unportable_tests=true
1142 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1145 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1148 --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)
1149 excl_longrunning_tests=true
1151 --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)
1152 excl_privileged_tests=true
1154 --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)
1155 excl_unportable_tests=true
1159 if test $# = 0; then
1160 func_fatal_error "missing argument for --avoid"
1162 func_append avoidlist " $1"
1165 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1166 func_append avoidlist " $arg"
1172 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1175 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1181 if test $# = 0; then
1182 func_fatal_error "missing argument for --makefile-name"
1187 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1197 if test $# = 0; then
1198 func_fatal_error "missing argument for --macro-prefix"
1203 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1207 if test $# = 0; then
1208 func_fatal_error "missing argument for --po-domain"
1213 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1221 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1227 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1230 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1233 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1237 --help | --hel | --he | --h )
1240 --version | --versio | --versi | --vers )
1244 # Stop option processing
1248 echo "gnulib-tool: unknown option $1" 1>&2
1249 echo "Try 'gnulib-tool --help' for more information." 1>&2
1256 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1257 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1258 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then
1259 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1260 echo "Try 'gnulib-tool --help' for more information." 1>&2
1264 # This code helps migrating from --import to --add-import or --update. It can
1265 # be removed on 2012-01-01.
1266 if test "$mode" = import && test $# = 0; then
1267 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1268 echo "The meaning of the option '--import' has changed." 1>&2
1269 echo "See the documentation at" 1>&2
1270 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1271 echo "For updating to a newer version of gnulib, use" 1>&2
1272 echo " gnulib-tool --add-import" 1>&2
1273 echo "For restoring files that were omitted from version control, use" 1>&2
1274 echo " gnulib-tool --update" 1>&2
1277 if test "$mode" = update; then
1278 if test $# != 0; then
1279 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1280 echo "Try 'gnulib-tool --help' for more information." 1>&2
1281 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1282 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1285 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1286 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1287 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1288 || test -n "$inctests" || test -n "$incobsolete" \
1289 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1290 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1291 || test -n "$inc_all_tests" \
1292 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1293 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1294 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1295 || test -n "$macro_prefix" || test -n "$po_domain" \
1296 || test -n "$vc_files"; then
1297 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1298 echo "Try 'gnulib-tool --help' for more information." 1>&2
1299 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1300 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1305 if test -n "$pobase" && test -z "$po_domain"; then
1306 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1307 echo "Try 'gnulib-tool --help' for more information." 1>&2
1310 if test -z "$pobase" && test -n "$po_domain"; then
1311 func_warning "--po-domain has no effect without a --po-base option"
1314 # Determine the minimum supported autoconf version from the project's
1316 DEFAULT_AUTOCONF_MINVERSION="2.59"
1317 autoconf_minversion=
1319 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1320 && test -n "$destdir"; then
1321 if test -f "$destdir"/configure.ac; then
1322 configure_ac="$destdir/configure.ac"
1324 if test -f "$destdir"/configure.in; then
1325 configure_ac="$destdir/configure.in"
1329 if test -f configure.ac; then
1330 configure_ac="configure.ac"
1332 if test -f configure.in; then
1333 configure_ac="configure.in"
1337 if test -n "$configure_ac"; then
1338 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1339 # because when some m4 files are omitted from a version control repository,
1340 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1341 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1342 # autom4te: m4 failed with exit status: 1
1349 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1351 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1352 if test -n "$prereqs"; then
1353 autoconf_minversion=`
1354 for version in $prereqs; do echo $version; done |
1355 LC_ALL=C sort -nru | sed -e 1q
1359 if test -z "$autoconf_minversion"; then
1360 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1362 case "$autoconf_minversion" in
1363 1.* | 2.[0-4]* | 2.5[0-8]*)
1364 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1367 # Remove trailing slashes from the directory names. This is necessary for
1368 # m4base (to avoid an error in func_import) and optional for the others.
1369 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1370 case "$local_gnulib_dir" in
1371 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1373 case "$sourcebase" in
1374 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1377 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1380 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1383 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1385 case "$testsbase" in
1386 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1389 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1395 trap 'exit_status=$?
1396 if test "$signal" != 0; then
1397 echo "caught signal $signal" >&2
1400 exit $exit_status' 0
1401 for signal in 1 2 3 13 15; do
1402 trap '{ signal='$signal'; func_exit 1; }' $signal
1406 # Note: The 'eval' silences stderr output in dash.
1407 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1408 # Zsh 4 and Bash 4 have associative arrays.
1409 have_associative=true
1411 # For other shells, use 'eval' with computed shell variable names.
1412 have_associative=false
1415 # func_lookup_file file
1416 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1419 # - local_gnulib_dir from --local-dir
1421 # - lookedup_file name of the merged (combined) file
1422 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1426 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1427 lookedup_file="$local_gnulib_dir/$lkfile"
1430 if test -f "$gnulib_dir/$lkfile"; then
1431 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1432 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1433 rm -f "$tmp/$lkbase"
1434 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1435 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1436 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1437 lookedup_file="$tmp/$lkbase"
1440 lookedup_file="$gnulib_dir/$lkfile"
1444 func_fatal_error "file $gnulib_dir/$lkfile not found"
1449 # func_sanitize_modulelist
1450 # receives a list of possible module names on standard input, one per line.
1451 # It removes those which are just file names unrelated to modules, and outputs
1452 # the resulting list to standard output, one per line.
1453 func_sanitize_modulelist ()
1455 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1456 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1457 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1458 -e '/^README$/d' -e '/\/README$/d' \
1459 -e '/^TEMPLATE$/d' \
1460 -e '/^TEMPLATE-EXTENDED$/d' \
1461 -e '/^TEMPLATE-TESTS$/d' \
1468 # - local_gnulib_dir from --local-dir
1471 # Filter out metainformation files like README, which are not modules.
1472 # Filter out unit test modules; they can be retrieved through
1473 # --extract-tests-module if desired.
1475 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1476 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1477 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1480 | func_sanitize_modulelist \
1481 | sed -e '/-tests$/d' \
1485 # func_exists_module module
1486 # tests whether a module, given by name, exists
1488 # - local_gnulib_dir from --local-dir
1489 func_exists_module ()
1491 { test -f "$gnulib_dir/modules/$1" \
1492 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1493 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1494 && test "CVS" != "$1" \
1495 && test "ChangeLog" != "$1" \
1496 && test "COPYING" != "$1" \
1497 && test "README" != "$1" \
1498 && test "TEMPLATE" != "$1" \
1499 && test "TEMPLATE-EXTENDED" != "$1" \
1500 && test "TEMPLATE-TESTS" != "$1"
1503 # func_verify_module
1504 # verifies a module name
1506 # - local_gnulib_dir from --local-dir
1507 # - module module name argument
1508 func_verify_module ()
1510 if func_exists_module "$module"; then
1511 # OK, $module is a correct module name.
1512 # Verify that building the module description with 'patch' succeeds.
1513 func_lookup_file "modules/$module"
1515 func_warning "module $module doesn't exist"
1520 # func_verify_nontests_module
1521 # verifies a module name, excluding tests modules
1523 # - local_gnulib_dir from --local-dir
1524 # - module module name argument
1525 func_verify_nontests_module ()
1528 *-tests ) module= ;;
1529 * ) func_verify_module ;;
1533 # func_verify_tests_module
1534 # verifies a module name, considering only tests modules
1536 # - local_gnulib_dir from --local-dir
1537 # - module module name argument
1538 func_verify_tests_module ()
1541 *-tests ) func_verify_module ;;
1546 # Suffix of a sed expression that extracts a particular field from a
1547 # module description.
1548 # A field starts with a line that contains a keyword, such as 'Description',
1549 # followed by a colon and optional whitespace. All following lines, up to
1550 # the next field (or end of file if there is none) form the contents of the
1552 # An absent field is equivalent to a field with empty contents.
1553 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1554 sed_extract_prog=':[ ]*$/ {
1557 s/^Description:[ ]*$//
1561 s/^Applicability:[ ]*$//
1563 s/^Depends-on:[ ]*$//
1564 s/^configure\.ac-early:[ ]*$//
1565 s/^configure\.ac:[ ]*$//
1566 s/^Makefile\.am:[ ]*$//
1570 s/^Maintainer:[ ]*$//
1577 # Piece of a sed expression that converts a field header line to a shell
1579 # NOTE: Keep this in sync with sed_extract_prog above!
1580 sed_extract_field_header='
1581 s/^Description:[ ]*$/description/
1582 s/^Comment:[ ]*$/comment/
1583 s/^Status:[ ]*$/status/
1584 s/^Notice:[ ]*$/notice/
1585 s/^Applicability:[ ]*$/applicability/
1586 s/^Files:[ ]*$/files/
1587 s/^Depends-on:[ ]*$/dependson/
1588 s/^configure\.ac-early:[ ]*$/configureac_early/
1589 s/^configure\.ac:[ ]*$/configureac/
1590 s/^Makefile\.am:[ ]*$/makefile/
1591 s/^Include:[ ]*$/include/
1593 s/^License:[ ]*$/license/
1594 s/^Maintainer:[ ]*$/maintainer/'
1598 if $have_associative; then
1600 # Declare the associative arrays.
1601 declare -A modcache_cached
1602 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1603 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1604 eval "$declare_script"
1608 # func_cache_var module
1609 # computes the cache variable name corresponding to $module.
1610 # Note: This computation can map different module names to the same
1611 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1612 # to protect against this case.
1614 # - cachevar a shell variable name
1615 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1616 # Bash 2.0 and newer, ksh, and zsh support the syntax
1617 # ${param//pattern/replacement}
1618 # as a shorthand for
1619 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1620 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1621 eval 'func_cache_var ()
1623 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1630 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1639 # func_init_sed_convert_to_cache_statements
1641 # - modcachevar_assignment
1643 # - sed_convert_to_cache_statements
1644 func_init_sed_convert_to_cache_statements ()
1646 # 'sed' script that turns a module description into shell script
1647 # assignments, suitable to be eval'ed. All active characters are escaped.
1650 # Some module's description
1655 # modcache_description[$1]=\
1656 # 'Some module'"'"'s description
1658 # modcache_files[$1]=\
1661 # c_MODULE_description_set=set; c_MODULE_description=\
1662 # 'Some module'"'"'s description
1664 # c_MODULE_files_set=set; c_MODULE_files=\
1666 # The script consists of two parts:
1667 # 1) Ignore the lines before the first field header.
1668 # 2) A loop, treating non-field-header lines by escaping single quotes
1669 # and adding a closing quote in the last line,
1670 sed_convert_to_cache_statements="
1672 # Here we have not yet seen a field header.
1674 # See if the current line contains a field header.
1677 ${sed_extract_field_header}
1680 # No field header. Ignore the line.
1682 # Read the next line. Upon EOF, just exit.
1687 # The current line contains a field header.
1689 # Turn it into the beginning of an assignment.
1690 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1692 # Move it to the hold space. Don't print it yet,
1693 # because we want no assignment if the field is empty.
1696 # Read the next line.
1697 # Upon EOF, the field was empty. Print no assignment. Just exit.
1700 # See if the current line contains a field header.
1703 ${sed_extract_field_header}
1704 # If it is, the previous field was empty. Print no assignment.
1707 # Not a field header.
1709 # Print the previous line, held in the hold space.
1714 # Transform single quotes.
1717 # Prepend a single quote.
1722 # Move it to the hold space.
1725 # Read the next line.
1732 # See if the current line contains a field header.
1735 ${sed_extract_field_header}
1738 # Print the previous line, held in the hold space.
1743 # Transform single quotes.
1750 # Print the previous line, held in the hold space, with a single quote
1751 # to end the assignment.
1761 # Print the previous line, held in the hold space, with a single quote
1762 # to end the assignment.
1769 if ! $sed_comments; then
1771 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1772 | sed -e 's/^ *//' -e 's/^#.*//'`
1776 if $have_associative; then
1777 # sed_convert_to_cache_statements does not depend on the module.
1778 modcachevar_assignment='modcache_\1[$1]='
1779 func_init_sed_convert_to_cache_statements
1782 # func_cache_lookup_module module
1784 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1785 # of its relevant data in a cache in the memory of the processing shell. If
1786 # already cached, it does not look it up again, thus saving file access time.
1788 # - module non-empty string
1789 # Output if $have_associative:
1790 # - modcache_cached[$module] set to yes
1791 # - modcache_description[$module] ==
1792 # - modcache_status[$module] \ set to the field's value, minus the
1793 # - ... / final newline,
1794 # - modcache_maintainer[$module] == or unset if the field's value is empty
1795 # Output if ! $have_associative:
1796 # - cachevar a shell variable name
1797 # - ${cachevar}_cached set to $module
1798 # - ${cachevar}_description ==
1799 # - ${cachevar}_status \ set to the field's value, minus the
1800 # - ... / final newline,
1801 # - ${cachevar}_maintainer == or unset if the field's value is empty
1802 # - ${cachevar}_description_set ==
1803 # - ${cachevar}_status_set \ set to non-empty if the field's value
1804 # - ... / is non-empty,
1805 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1806 func_cache_lookup_module ()
1808 if $have_associative; then
1809 eval 'cached=${modcache_cached[$1]}'
1812 eval "cached=\"\$${cachevar}_cached\""
1814 if test -z "$cached"; then
1815 # Not found in cache. Look it up on the file system.
1816 func_lookup_file "modules/$1"
1817 if $have_associative; then
1818 eval 'modcache_cached[$1]=yes'
1820 eval "${cachevar}_cached=\"\$1\""
1822 if ! $have_associative; then
1823 # sed_convert_to_cache_statements depends on the module.
1824 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1825 func_init_sed_convert_to_cache_statements
1827 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1828 eval "$cache_statements"
1830 if ! $have_associative; then
1831 if test "$1" != "$cached"; then
1832 func_fatal_error "cache variable collision between $1 and $cached"
1840 # func_get_description module
1842 # - local_gnulib_dir from --local-dir
1843 # - modcache true or false, from --cache-modules/--no-cache-modules
1844 func_get_description ()
1846 if ! $modcache; then
1847 func_lookup_file "modules/$1"
1848 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1850 func_cache_lookup_module "$1"
1851 # Output the field's value, including the final newline (if any).
1852 if $have_associative; then
1853 if eval 'test -n "${modcache_description[$1]+set}"'; then
1854 eval 'echo "${modcache_description[$1]}"'
1857 eval "field_set=\"\$${cachevar}_description_set\""
1858 if test -n "$field_set"; then
1859 eval "field_value=\"\$${cachevar}_description\""
1860 echo "${field_value}"
1866 # func_get_comment module
1868 # - local_gnulib_dir from --local-dir
1869 # - modcache true or false, from --cache-modules/--no-cache-modules
1872 if ! $modcache; then
1873 func_lookup_file "modules/$1"
1874 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1876 func_cache_lookup_module "$1"
1877 # Output the field's value, including the final newline (if any).
1878 if $have_associative; then
1879 if eval 'test -n "${modcache_comment[$1]+set}"'; then
1880 eval 'echo "${modcache_comment[$1]}"'
1883 eval "field_set=\"\$${cachevar}_comment_set\""
1884 if test -n "$field_set"; then
1885 eval "field_value=\"\$${cachevar}_comment\""
1886 echo "${field_value}"
1892 # func_get_status module
1894 # - local_gnulib_dir from --local-dir
1895 # - modcache true or false, from --cache-modules/--no-cache-modules
1898 if ! $modcache; then
1899 func_lookup_file "modules/$1"
1900 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1902 func_cache_lookup_module "$1"
1903 # Output the field's value, including the final newline (if any).
1904 if $have_associative; then
1905 if eval 'test -n "${modcache_status[$1]+set}"'; then
1906 eval 'echo "${modcache_status[$1]}"'
1909 eval "field_set=\"\$${cachevar}_status_set\""
1910 if test -n "$field_set"; then
1911 eval "field_value=\"\$${cachevar}_status\""
1912 echo "${field_value}"
1918 # func_get_notice module
1920 # - local_gnulib_dir from --local-dir
1921 # - modcache true or false, from --cache-modules/--no-cache-modules
1924 if ! $modcache; then
1925 func_lookup_file "modules/$1"
1926 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1928 func_cache_lookup_module "$1"
1929 # Output the field's value, including the final newline (if any).
1930 if $have_associative; then
1931 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1932 eval 'echo "${modcache_notice[$1]}"'
1935 eval "field_set=\"\$${cachevar}_notice_set\""
1936 if test -n "$field_set"; then
1937 eval "field_value=\"\$${cachevar}_notice\""
1938 echo "${field_value}"
1944 # func_get_applicability module
1946 # - local_gnulib_dir from --local-dir
1947 # - modcache true or false, from --cache-modules/--no-cache-modules
1948 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1949 func_get_applicability ()
1951 if ! $modcache; then
1952 func_lookup_file "modules/$1"
1953 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1955 func_cache_lookup_module "$1"
1956 # Get the field's value, without the final newline.
1957 if $have_associative; then
1958 eval 'my_applicability="${modcache_applicability[$1]}"'
1960 eval "my_applicability=\"\$${cachevar}_applicability\""
1963 if test -n "$my_applicability"; then
1964 echo $my_applicability
1966 # The default is 'main' or 'tests', depending on the module's name.
1968 *-tests) echo "tests";;
1974 # func_get_filelist module
1976 # - local_gnulib_dir from --local-dir
1977 # - modcache true or false, from --cache-modules/--no-cache-modules
1978 func_get_filelist ()
1980 if ! $modcache; then
1981 func_lookup_file "modules/$1"
1982 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1984 func_cache_lookup_module "$1"
1985 # Output the field's value, including the final newline (if any).
1986 if $have_associative; then
1987 if eval 'test -n "${modcache_files[$1]+set}"'; then
1988 eval 'echo "${modcache_files[$1]}"'
1991 eval "field_set=\"\$${cachevar}_files_set\""
1992 if test -n "$field_set"; then
1993 eval "field_value=\"\$${cachevar}_files\""
1994 echo "${field_value}"
1999 echo m4/gnulib-common.m4
2000 case "$autoconf_minversion" in
2007 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2008 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2009 # elements starting with prefix and ending with suffix are considered.
2010 # Processing: removed_prefix and removed_suffix are removed from each element,
2011 # added_prefix and added_suffix are added to each element.
2012 # prefix, suffix should not contain shell-special characters.
2013 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2014 # added_prefix, added_suffix should not contain the characters \|&.
2015 func_filter_filelist ()
2017 if test "$2" != "$nl" \
2018 || { $fast_func_append \
2019 && { test -z "$6" || $fast_func_remove_prefix; } \
2020 && { test -z "$7" || $fast_func_remove_suffix; }; \
2024 # Do not quote possibly-empty parameters in case patterns,
2025 # AIX and HP-UX ksh won't match them if they are empty.
2028 if test -n "$6"; then
2029 func_remove_prefix fff "$6"
2031 if test -n "$7"; then
2032 func_remove_suffix fff "$7"
2035 if test -z "$ffflist"; then
2038 func_append ffflist "$2${fff}"
2044 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2045 ffflist=`for fff in $3; do
2047 $4*$5) echo "$fff" ;;
2049 done | sed -e "$sed_fff_filter"`
2051 eval "$1=\"\$ffflist\""
2054 # func_get_dependencies module
2056 # - local_gnulib_dir from --local-dir
2057 # - modcache true or false, from --cache-modules/--no-cache-modules
2058 func_get_dependencies ()
2060 # ${module}-tests implicitly depends on ${module}, if that module exists.
2064 func_remove_suffix fgd1 '-tests'
2065 if func_exists_module "$fgd1"; then
2070 # Then the explicit dependencies listed in the module description.
2071 if ! $modcache; then
2072 func_lookup_file "modules/$1"
2073 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2075 func_cache_lookup_module "$1"
2076 # Output the field's value, including the final newline (if any).
2077 if $have_associative; then
2078 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2079 eval 'echo "${modcache_dependson[$1]}"'
2082 eval "field_set=\"\$${cachevar}_dependson_set\""
2083 if test -n "$field_set"; then
2084 eval "field_value=\"\$${cachevar}_dependson\""
2085 echo "${field_value}"
2091 # func_get_autoconf_early_snippet module
2093 # - local_gnulib_dir from --local-dir
2094 # - modcache true or false, from --cache-modules/--no-cache-modules
2095 func_get_autoconf_early_snippet ()
2097 if ! $modcache; then
2098 func_lookup_file "modules/$1"
2099 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2101 func_cache_lookup_module "$1"
2102 # Output the field's value, including the final newline (if any).
2103 if $have_associative; then
2104 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2105 eval 'echo "${modcache_configureac_early[$1]}"'
2108 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2109 if test -n "$field_set"; then
2110 eval "field_value=\"\$${cachevar}_configureac_early\""
2111 echo "${field_value}"
2117 # func_get_autoconf_snippet module
2119 # - local_gnulib_dir from --local-dir
2120 # - modcache true or false, from --cache-modules/--no-cache-modules
2121 func_get_autoconf_snippet ()
2123 if ! $modcache; then
2124 func_lookup_file "modules/$1"
2125 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2127 func_cache_lookup_module "$1"
2128 # Output the field's value, including the final newline (if any).
2129 if $have_associative; then
2130 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2131 eval 'echo "${modcache_configureac[$1]}"'
2134 eval "field_set=\"\$${cachevar}_configureac_set\""
2135 if test -n "$field_set"; then
2136 eval "field_value=\"\$${cachevar}_configureac\""
2137 echo "${field_value}"
2143 # func_get_automake_snippet module
2145 # - local_gnulib_dir from --local-dir
2146 # - modcache true or false, from --cache-modules/--no-cache-modules
2147 func_get_automake_snippet ()
2149 if ! $modcache; then
2150 func_lookup_file "modules/$1"
2151 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2153 func_cache_lookup_module "$1"
2154 # Output the field's value, including the final newline (if any).
2155 if $have_associative; then
2156 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2157 eval 'echo "${modcache_makefile[$1]}"'
2160 eval "field_set=\"\$${cachevar}_makefile_set\""
2161 if test -n "$field_set"; then
2162 eval "field_value=\"\$${cachevar}_makefile\""
2163 echo "${field_value}"
2169 # *-tests module live in tests/, not lib/.
2170 # Synthesize an EXTRA_DIST augmentation.
2171 all_files=`func_get_filelist $1`
2172 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2173 extra_files="$tests_files"
2174 if test -n "$extra_files"; then
2175 echo "EXTRA_DIST +=" $extra_files
2180 # Synthesize an EXTRA_DIST augmentation.
2181 sed_combine_lines='/\\$/{
2188 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2189 already_mentioned_files=` \
2190 { if ! $modcache; then
2191 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2193 if $have_associative; then
2194 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2195 eval 'echo "${modcache_makefile[$1]}"'
2198 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2199 if test -n "$field_set"; then
2200 eval 'field_value="$'"${cachevar}"'_makefile"'
2201 echo "${field_value}"
2206 | sed -e "$sed_combine_lines" \
2207 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2208 all_files=`func_get_filelist $1`
2209 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2210 # Remove $already_mentioned_files from $lib_files.
2211 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2212 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2213 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2214 if test -n "$extra_files"; then
2215 echo "EXTRA_DIST +=" $extra_files
2218 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2219 # This is necessary so that automake can generate the right list of
2221 # A possible approach would be to use autom4te --trace of the redefined
2222 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2223 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2224 # inside autoconf's built-in macros are not missed).
2225 # But it's simpler and more robust to do it here, based on the file list.
2226 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2227 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2228 # automake will generate a useless dependency; this is harmless.
2230 relocatable-prog-wrapper) ;;
2232 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2233 if test -n "$extra_files"; then
2234 echo "EXTRA_lib_SOURCES +=" $extra_files
2239 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2240 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2241 if test -n "$buildaux_files"; then
2242 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2243 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2246 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2247 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2248 if test -n "$top_files"; then
2249 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2250 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2257 # func_get_include_directive module
2259 # - local_gnulib_dir from --local-dir
2260 # - modcache true or false, from --cache-modules/--no-cache-modules
2261 func_get_include_directive ()
2264 if ! $modcache; then
2265 func_lookup_file "modules/$1"
2266 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2268 func_cache_lookup_module "$1"
2269 # Output the field's value, including the final newline (if any).
2270 if $have_associative; then
2271 if eval 'test -n "${modcache_include[$1]+set}"'; then
2272 eval 'echo "${modcache_include[$1]}"'
2275 eval "field_set=\"\$${cachevar}_include_set\""
2276 if test -n "$field_set"; then
2277 eval "field_value=\"\$${cachevar}_include\""
2278 echo "${field_value}"
2282 } | sed -e 's/^\(["<]\)/#include \1/'
2285 # func_get_link_directive module
2287 # - local_gnulib_dir from --local-dir
2288 # - modcache true or false, from --cache-modules/--no-cache-modules
2289 func_get_link_directive ()
2291 if ! $modcache; then
2292 func_lookup_file "modules/$1"
2293 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2295 func_cache_lookup_module "$1"
2296 # Output the field's value, including the final newline (if any).
2297 if $have_associative; then
2298 if eval 'test -n "${modcache_link[$1]+set}"'; then
2299 eval 'echo "${modcache_link[$1]}"'
2302 eval "field_set=\"\$${cachevar}_link_set\""
2303 if test -n "$field_set"; then
2304 eval "field_value=\"\$${cachevar}_link\""
2305 echo "${field_value}"
2311 # func_get_license module
2313 # - local_gnulib_dir from --local-dir
2314 # - modcache true or false, from --cache-modules/--no-cache-modules
2318 if ! $modcache; then
2319 func_lookup_file "modules/$1"
2320 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2322 func_cache_lookup_module "$1"
2323 # Output the field's value, including the final newline (if any).
2324 if $have_associative; then
2325 if eval 'test -n "${modcache_license[$1]+set}"'; then
2326 eval 'echo "${modcache_license[$1]}"'
2329 eval "field_set=\"\$${cachevar}_license_set\""
2330 if test -n "$field_set"; then
2331 eval "field_value=\"\$${cachevar}_license\""
2332 echo "${field_value}"
2336 # The default is GPL.
2338 } | sed -e 's,^ *$,,' | sed -e 1q
2341 # func_get_maintainer module
2343 # - local_gnulib_dir from --local-dir
2344 # - modcache true or false, from --cache-modules/--no-cache-modules
2345 func_get_maintainer ()
2347 if ! $modcache; then
2348 func_lookup_file "modules/$1"
2349 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2351 func_cache_lookup_module "$1"
2352 # Output the field's value, including the final newline (if any).
2353 if $have_associative; then
2354 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2355 eval 'echo "${modcache_maintainer[$1]}"'
2358 eval "field_set=\"\$${cachevar}_maintainer_set\""
2359 if test -n "$field_set"; then
2360 eval "field_value=\"\$${cachevar}_maintainer\""
2361 echo "${field_value}"
2367 # func_get_tests_module module
2369 # - local_gnulib_dir from --local-dir
2370 func_get_tests_module ()
2372 # The naming convention for tests modules is hardwired: ${module}-tests.
2373 if test -f "$gnulib_dir/modules/$1"-tests \
2374 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2375 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2380 # func_acceptable module
2381 # tests whether a module is acceptable.
2383 # - avoidlist list of modules to avoid
2386 for avoid in $avoidlist; do
2387 if test "$avoid" = "$1"; then
2394 # func_modules_transitive_closure
2396 # - local_gnulib_dir from --local-dir
2397 # - modcache true or false, from --cache-modules/--no-cache-modules
2398 # - modules list of specified modules
2399 # - inctests true if tests should be included, blank otherwise
2400 # - incobsolete true if obsolete modules among dependencies should be
2401 # included, blank otherwise
2402 # - inc_cxx_tests true if C++ interoperability tests should be included,
2404 # - inc_longrunning_tests true if long-runnings tests should be included,
2406 # - inc_privileged_tests true if tests that require root privileges should be
2407 # included, blank otherwise
2408 # - inc_unportable_tests true if tests that fail on some platforms should be
2409 # included, blank otherwise
2410 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2411 # the unit tests of the specified modules should be
2412 # included, blank otherwise
2413 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2414 # the unit tests of the dependencies should be
2415 # included, blank otherwise
2416 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2418 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2420 # - excl_privileged_tests true if tests that require root privileges should be
2421 # excluded, blank otherwise
2422 # - excl_unportable_tests true if tests that fail on some platforms should be
2423 # excluded, blank otherwise
2424 # - avoidlist list of modules to avoid
2425 # - tmp pathname of a temporary directory
2427 # - modules list of modules, including dependencies
2428 func_modules_transitive_closure ()
2430 # In order to process every module only once (for speed), process an "input
2431 # list" of modules, producing an "output list" of modules. During each round,
2432 # more modules can be queued in the input list. Once a module on the input
2433 # list has been processed, it is added to the "handled list", so we can avoid
2434 # to process it again.
2436 inmodules="$modules"
2438 fmtc_inc_all_tests="$inc_all_direct_tests"
2439 while test -n "$inmodules"; do
2440 inmodules_this_round="$inmodules"
2441 inmodules= # Accumulator, queue for next round
2442 for module in $inmodules_this_round; do
2444 if test -n "$module"; then
2445 if func_acceptable $module; then
2446 func_append outmodules " $module"
2447 deps=`func_get_dependencies $module`
2448 # Duplicate dependencies are harmless, but Jim wants a warning.
2449 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2450 if test -n "$duplicated_deps"; then
2451 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2453 if test -n "$inctests"; then
2454 testsmodule=`func_get_tests_module $module`
2455 if test -n "$testsmodule"; then
2456 deps="$deps $testsmodule"
2459 for dep in $deps; do
2460 # Determine whether to include the dependency or tests module.
2462 for word in `func_get_status $dep`; do
2465 test -n "$incobsolete" \
2469 test -z "$excl_cxx_tests" \
2471 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2475 test -z "$excl_longrunning_tests" \
2477 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2481 test -z "$excl_privileged_tests" \
2483 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2487 test -z "$excl_unportable_tests" \
2489 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2493 test -n "$fmtc_inc_all_tests" \
2499 func_append inmodules " $dep"
2505 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2506 # Remove $handledmodules from $inmodules.
2507 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2508 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2509 fmtc_inc_all_tests="$inc_all_indirect_tests"
2511 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2512 rm -f "$tmp"/queued-modules
2515 # func_show_module_list
2517 # - specified_modules list of specified modules (one per line, sorted)
2518 # - modules complete list of modules (one per line, sorted)
2519 # - tmp pathname of a temporary directory
2520 func_show_module_list ()
2526 # Assume xterm compatible escape sequences.
2527 bold_on=`printf '\x1b[1m'`
2528 bold_off=`printf '\x1b[0m'`
2533 echo "Module list with included dependencies (indented):"
2534 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2535 echo "$modules" | sed -e '/^$/d' \
2536 | LC_ALL=C join -t '|' -a 2 "$tmp"/specified-modules - \
2537 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2540 # func_modules_add_dummy
2542 # - local_gnulib_dir from --local-dir
2543 # - modcache true or false, from --cache-modules/--no-cache-modules
2544 # - modules list of modules, including dependencies
2546 # - modules list of modules, including 'dummy' if needed
2547 func_modules_add_dummy ()
2549 # Determine whether any module provides a lib_SOURCES augmentation.
2551 sed_remove_backslash_newline=':a
2558 for module in $modules; do
2559 func_verify_nontests_module
2560 if test -n "$module"; then
2561 # Extract the value of "lib_SOURCES += ...".
2562 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2563 # Ignore .h files since they are not compiled.
2567 have_lib_SOURCES=yes
2574 # Add the dummy module, to make sure the library will be non-empty.
2575 if test -z "$have_lib_SOURCES"; then
2576 if func_acceptable "dummy"; then
2577 func_append modules " dummy"
2582 # func_modules_notice
2584 # - local_gnulib_dir from --local-dir
2585 # - modcache true or false, from --cache-modules/--no-cache-modules
2586 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2587 # - modules list of modules, including dependencies
2588 func_modules_notice ()
2590 if test $verbose -ge -1; then
2591 for module in $modules; do
2593 if test -n "$module"; then
2594 msg=`func_get_notice $module`
2595 if test -n "$msg"; then
2596 echo "Notice from module $module:"
2597 echo "$msg" | sed -e 's/^/ /'
2604 # func_modules_to_filelist
2606 # - local_gnulib_dir from --local-dir
2607 # - modcache true or false, from --cache-modules/--no-cache-modules
2608 # - modules list of modules, including dependencies
2610 # - files list of files
2611 func_modules_to_filelist ()
2614 for module in $modules; do
2616 if test -n "$module"; then
2617 fs=`func_get_filelist $module`
2618 func_append files " $fs"
2621 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2624 # func_execute_command command [args...]
2625 # Executes a command.
2626 # Uses also the variables
2627 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2628 func_execute_command ()
2630 if test $verbose -ge 0; then
2634 # Commands like automake produce output to stderr even when they succeed.
2635 # Turn this output off if the command succeeds.
2636 "$@" > "$tmp"/cmdout 2>&1
2638 if test $cmdret = 0; then
2642 cat "$tmp"/cmdout 1>&2
2649 # func_dest_tmpfilename file
2650 # determines the name of a temporary file (file is relative to destdir).
2652 # - destdir target directory
2653 # - doit : if actions shall be executed, false if only to be printed
2654 # - tmp pathname of a temporary directory
2656 # - tmpfile absolute filename of the temporary file
2657 func_dest_tmpfilename ()
2660 # Put the new contents of $file in a file in the same directory (needed
2661 # to guarantee that an 'mv' to "$destdir/$file" works).
2662 tmpfile="$destdir/$1.tmp"
2664 # Put the new contents of $file in a file in a temporary directory
2665 # (because the directory of "$file" might not exist).
2666 tmpfile="$tmp"/`basename "$1"`.tmp
2671 # copies a file from gnulib into the destination directory. The destination
2672 # is known to not exist.
2674 # - destdir target directory
2675 # - local_gnulib_dir from --local-dir
2676 # - modcache true or false, from --cache-modules/--no-cache-modules
2677 # - f the original file name
2678 # - lookedup_file name of the merged (combined) file
2679 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2680 # - g the rewritten file name
2681 # - tmpfile absolute filename of the temporary file
2682 # - doit : if actions shall be executed, false if only to be printed
2683 # - symbolic true if files should be symlinked, copied otherwise
2684 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2689 echo "Copying file $g"
2690 if { test -n "$symbolic" \
2691 || { test -n "$lsymbolic" \
2692 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2693 && test -z "$lookedup_tmp" \
2694 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2695 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2697 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2705 # copies a file from gnulib into the destination directory. The destination
2706 # is known to exist.
2708 # - destdir target directory
2709 # - local_gnulib_dir from --local-dir
2710 # - modcache true or false, from --cache-modules/--no-cache-modules
2711 # - f the original file name
2712 # - lookedup_file name of the merged (combined) file
2713 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2714 # - g the rewritten file name
2715 # - tmpfile absolute filename of the temporary file
2716 # - doit : if actions shall be executed, false if only to be printed
2717 # - symbolic true if files should be symlinked, copied otherwise
2718 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2720 # - already_present nonempty if the file should already exist, empty otherwise
2723 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2724 : # The file has not changed.
2728 if test -n "$already_present"; then
2729 echo "Updating file $g (backup in ${g}~)"
2731 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2733 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2734 if { test -n "$symbolic" \
2735 || { test -n "$lsymbolic" \
2736 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2737 && test -z "$lookedup_tmp" \
2738 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2739 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2741 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2744 if test -n "$already_present"; then
2745 echo "Update file $g (backup in ${g}~)"
2747 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2753 # func_emit_lib_Makefile_am
2754 # emits the contents of library makefile to standard output.
2756 # - local_gnulib_dir from --local-dir
2757 # - modcache true or false, from --cache-modules/--no-cache-modules
2758 # - modules list of modules, including dependencies
2759 # - libname library name
2760 # - pobase directory relative to destdir where to place *.po files
2761 # - auxdir directory relative to destdir where to place build aux files
2762 # - makefile_name from --makefile-name
2763 # - libtool true if libtool will be used, false or blank otherwise
2764 # - macro_prefix prefix of gl_LIBOBJS macros to use
2765 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2766 # - actioncmd (optional) command that will reproduce this invocation
2767 # - for_test true if creating a package for testing, false otherwise
2768 # - destfile filename relative to destdir of makefile being generated
2770 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2771 # list of edits to be done to Makefile.am variables
2773 # - uses_subdirs nonempty if object files in subdirs exist
2774 func_emit_lib_Makefile_am ()
2776 # When creating an includable Makefile.am snippet, augment variables with
2777 # += instead of assigning them.
2778 if test -n "$makefile_name"; then
2783 if test "$libtool" = true; then
2786 sed_eliminate_LDFLAGS="$sed_noop"
2790 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2793 # When creating a package for testing: Attempt to provoke failures,
2794 # especially link errors, already during "make" rather than during
2795 # "make check", because "make check" is not possible in a cross-compiling
2796 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2797 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2799 sed_transform_check_PROGRAMS="$sed_noop"
2801 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2802 echo "## Process this file with automake to produce Makefile.in."
2803 func_emit_copyright_notice
2804 if test -n "$actioncmd"; then
2805 # The maximum line length (excluding the terminating newline) of any file
2806 # that is to be preprocessed by config.status is 3070. config.status uses
2807 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2808 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2809 len=`echo "$actioncmd" | wc -c`
2810 if test -n "$len" && test "$len" -le 3000; then
2811 echo "# Reproduce by: $actioncmd"
2817 for module in $modules; do
2818 func_verify_nontests_module
2819 if test -n "$module"; then
2821 func_get_automake_snippet "$module" |
2823 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2824 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2825 -e "$sed_eliminate_LDFLAGS" \
2826 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2827 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2828 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2829 -e "$sed_transform_check_PROGRAMS"
2830 if test "$module" = 'alloca'; then
2831 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2832 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2834 } > "$tmp"/amsnippet
2835 # Skip the contents if it's entirely empty.
2836 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2837 echo "## begin gnulib module $module"
2839 cat "$tmp"/amsnippet
2840 echo "## end gnulib module $module"
2843 rm -f "$tmp"/amsnippet
2844 # Test whether there are some source files in subdirectories.
2845 for f in `func_get_filelist "$module"`; do
2855 } > "$tmp"/allsnippets
2856 if test -z "$makefile_name"; then
2857 # If there are source files in subdirectories, prevent collision of the
2858 # object files (example: hash.c and libxml/hash.c).
2860 if test -n "$uses_subdirs"; then
2861 subdir_options=' subdir-objects'
2863 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2866 if test -z "$makefile_name"; then
2868 echo "noinst_HEADERS ="
2869 echo "noinst_LIBRARIES ="
2870 echo "noinst_LTLIBRARIES ="
2871 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2872 # if you specify pkgdata_DATA to empty. This is a workaround.
2873 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2874 echo "pkgdata_DATA ="
2877 echo "BUILT_SOURCES ="
2880 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2881 if test -z "$makefile_name"; then
2882 echo "MOSTLYCLEANDIRS ="
2884 echo "DISTCLEANFILES ="
2885 echo "MAINTAINERCLEANFILES ="
2887 # Execute edits that apply to the Makefile.am being generated.
2889 while test $edit != $makefile_am_edits; do
2890 edit=`expr $edit + 1`
2891 eval dir=\"\$makefile_am_edit${edit}_dir\"
2892 eval var=\"\$makefile_am_edit${edit}_var\"
2893 eval val=\"\$makefile_am_edit${edit}_val\"
2894 if test -n "$var"; then
2895 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2896 echo "${var} += ${val}"
2897 eval "makefile_am_edit${edit}_var="
2901 if test -z "$makefile_name"; then
2904 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
2906 echo "AM_CPPFLAGS ="
2911 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2912 || { test -n "$makefile_name" \
2913 && test -f "$sourcebase/Makefile.am" \
2914 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2916 # One of the snippets or the user's Makefile.am already specifies an
2917 # installation location for the library. Don't confuse automake by saying
2918 # it should not be installed.
2921 # By default, the generated library should not be installed.
2922 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2925 echo "${libname}_${libext}_SOURCES ="
2926 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2927 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2928 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2929 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2930 echo "EXTRA_${libname}_${libext}_SOURCES ="
2931 if test "$libtool" = true; then
2932 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2935 if test -n "$pobase"; then
2936 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2939 cat "$tmp"/allsnippets \
2940 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2942 echo "mostlyclean-local: mostlyclean-generic"
2943 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2944 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2945 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2949 rm -f "$tmp"/allsnippets
2952 # func_emit_po_Makevars
2953 # emits the contents of po/ makefile parameterization to standard output.
2955 # - local_gnulib_dir from --local-dir
2956 # - modcache true or false, from --cache-modules/--no-cache-modules
2957 # - sourcebase directory relative to destdir where to place source code
2958 # - pobase directory relative to destdir where to place *.po files
2959 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2960 func_emit_po_Makevars ()
2962 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2963 func_emit_copyright_notice
2965 echo "# Usually the message domain is the same as the package name."
2966 echo "# But here it has a '-gnulib' suffix."
2967 echo "DOMAIN = ${po_domain}-gnulib"
2969 echo "# These two variables depend on the location of this directory."
2970 echo "subdir = ${pobase}"
2971 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2974 # These options get passed to xgettext.
2975 XGETTEXT_OPTIONS = \
2976 --keyword=_ --flag=_:1:pass-c-format \
2977 --keyword=N_ --flag=N_:1:pass-c-format \
2978 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2979 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2980 --flag=error:3:c-format --flag=error_at_line:5:c-format
2982 # This is the copyright holder that gets inserted into the header of the
2983 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2984 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2986 # This is the email address or URL to which the translators shall report
2987 # bugs in the untranslated strings:
2988 # - Strings which are not entire sentences, see the maintainer guidelines
2989 # in the GNU gettext documentation, section 'Preparing Strings'.
2990 # - Strings which use unclear terms or require additional context to be
2992 # - Strings which make invalid assumptions about notation of date, time or
2994 # - Pluralisation problems.
2995 # - Incorrect English spelling.
2996 # - Incorrect formatting.
2997 # It can be your email address, or a mailing list address where translators
2998 # can write to without being subscribed, or the URL of a web page through
2999 # which the translators can contact you.
3000 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3002 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3003 # message catalogs shall be used. It is usually empty.
3004 EXTRA_LOCALE_CATEGORIES =
3006 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3007 # context. Possible values are "yes" and "no". Set this to yes if the
3008 # package uses functions taking also a message context, like pgettext(), or
3009 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3014 # func_emit_po_POTFILES_in
3015 # emits the file list to be passed to xgettext to standard output.
3017 # - local_gnulib_dir from --local-dir
3018 # - modcache true or false, from --cache-modules/--no-cache-modules
3019 # - sourcebase directory relative to destdir where to place source code
3020 # - files list of new files
3021 func_emit_po_POTFILES_in ()
3023 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3024 func_emit_copyright_notice
3026 echo "# List of files which contain translatable strings."
3027 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3030 # func_emit_tests_Makefile_am witness_macro
3031 # emits the contents of tests makefile to standard output.
3033 # - local_gnulib_dir from --local-dir
3034 # - modcache true or false, from --cache-modules/--no-cache-modules
3035 # - modules list of modules, including dependencies
3036 # - libname library name
3037 # - auxdir directory relative to destdir where to place build aux files
3038 # - makefile_name from --makefile-name
3039 # - libtool true if libtool will be used, false or blank otherwise
3040 # - sourcebase relative directory containing lib source code
3041 # - m4base relative directory containing autoconf macros
3042 # - testsbase relative directory containing unit test code
3043 # - macro_prefix prefix of gl_LIBOBJS macros to use
3044 # - for_test true if creating a package for testing, false otherwise
3045 # - use_libtests true if a libtests.a should be built, false otherwise
3046 # - destfile filename relative to destdir of makefile being generated
3048 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3049 # list of edits to be done to Makefile.am variables
3051 # - uses_subdirs nonempty if object files in subdirs exist
3052 func_emit_tests_Makefile_am ()
3055 if test "$libtool" = true; then
3057 sed_eliminate_LDFLAGS="$sed_noop"
3060 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3063 # When creating a package for testing: Attempt to provoke failures,
3064 # especially link errors, already during "make" rather than during
3065 # "make check", because "make check" is not possible in a cross-compiling
3066 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3067 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3069 sed_transform_check_PROGRAMS="$sed_noop"
3071 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3072 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3073 echo "## Process this file with automake to produce Makefile.in."
3074 func_emit_copyright_notice
3078 for module in $modules; do
3080 func_verify_tests_module
3084 if test -n "$module"; then
3086 func_get_automake_snippet "$module" |
3088 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3089 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3090 -e "$sed_eliminate_LDFLAGS" \
3091 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3092 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3093 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3094 -e "$sed_transform_check_PROGRAMS"
3095 if $use_libtests && test "$module" = 'alloca'; then
3096 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3097 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3099 } > "$tmp"/amsnippet
3100 # Skip the contents if it's entirely empty.
3101 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3102 # Mention long-running tests at the end.
3104 for word in `func_get_status "$module"`; do
3105 if test "$word" = 'longrunning-test'; then
3110 { echo "## begin gnulib module $module"
3112 cat "$tmp"/amsnippet
3113 echo "## end gnulib module $module"
3117 rm -f "$tmp"/amsnippet
3118 # Test whether there are some source files in subdirectories.
3119 for f in `func_get_filelist "$module"`; do
3121 lib/*/*.c | tests/*/*.c)
3129 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3130 # Generate dependencies here, since it eases the debugging of test failures.
3131 # If there are source files in subdirectories, prevent collision of the
3132 # object files (example: hash.c and libxml/hash.c).
3134 if test -n "$uses_subdirs"; then
3135 subdir_options=' subdir-objects'
3137 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3140 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3143 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3144 # variable is needed to avoid an error from automake:
3145 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3148 echo "XFAIL_TESTS ="
3149 echo "TESTS_ENVIRONMENT ="
3150 echo "noinst_PROGRAMS ="
3151 if ! $for_test; then
3152 echo "check_PROGRAMS ="
3154 echo "noinst_HEADERS ="
3155 echo "noinst_LIBRARIES ="
3156 if $use_libtests; then
3158 echo "noinst_LIBRARIES += libtests.a"
3160 echo "check_LIBRARIES = libtests.a"
3163 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3164 # if you specify pkgdata_DATA to empty. This is a workaround.
3165 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3166 echo "pkgdata_DATA ="
3169 echo "BUILT_SOURCES ="
3171 echo "MOSTLYCLEANFILES = core *.stackdump"
3172 echo "MOSTLYCLEANDIRS ="
3174 echo "DISTCLEANFILES ="
3175 echo "MAINTAINERCLEANFILES ="
3176 # Execute edits that apply to the Makefile.am being generated.
3178 while test $edit != $makefile_am_edits; do
3179 edit=`expr $edit + 1`
3180 eval dir=\"\$makefile_am_edit${edit}_dir\"
3181 eval var=\"\$makefile_am_edit${edit}_var\"
3182 eval val=\"\$makefile_am_edit${edit}_val\"
3183 if test -n "$var"; then
3184 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3185 echo "${var} += ${val}"
3186 eval "makefile_am_edit${edit}_var="
3191 echo "AM_CPPFLAGS = \\"
3193 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3195 if test -n "${witness_macro}"; then
3196 echo " -D@${witness_macro}@=1 \\"
3198 echo " -I. -I\$(srcdir) \\"
3199 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3200 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3202 local_ldadd_before=''
3203 local_ldadd_after=''
3204 if $use_libtests; then
3205 # All test programs need to be linked with libtests.a.
3206 # It needs to be passed to the linker before ${libname}.${libext}, since
3207 # the tests-related modules depend on the main modules.
3208 # It also needs to be passed to the linker after ${libname}.${libext}
3209 # because the latter might contain incomplete modules (such as the 'error'
3210 # module whose dependency to 'progname' is voluntarily omitted).
3211 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3213 local_ldadd_before=' libtests.a'
3214 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3216 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3218 if $use_libtests; then
3219 echo "libtests_a_SOURCES ="
3220 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3221 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3222 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3223 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3224 echo "EXTRA_libtests_a_SOURCES ="
3225 # The circular dependency in LDADD requires this.
3226 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3229 # Many test scripts use ${EXEEXT} or ${srcdir}.
3230 # EXEEXT is defined by AC_PROG_CC through autoconf.
3231 # srcdir is defined by autoconf and automake.
3232 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3234 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3235 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3236 echo "# Clean up after Solaris cc."
3238 echo " rm -rf SunWS_cache"
3240 echo "mostlyclean-local: mostlyclean-generic"
3241 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3242 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3243 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3247 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3250 # func_emit_initmacro_start macro_prefix
3251 # emits the first few statements of the gl_INIT macro to standard output.
3252 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3253 func_emit_initmacro_start ()
3255 macro_prefix_arg="$1"
3256 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3257 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3258 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3259 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3261 # Furthermore it avoids an automake error like this when a Makefile.am
3262 # that uses pieces of gnulib also uses $(LIBOBJ):
3263 # automatically discovered file `error.c' should not be explicitly mentioned
3264 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3265 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3266 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3267 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3268 # automatically discovered file `error.c' should not be explicitly mentioned
3269 # We let automake know about the files to be distributed through the
3270 # EXTRA_lib_SOURCES variable.
3271 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3272 # Create data variables for checking the presence of files that are mentioned
3273 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3274 # because we want the check to happen when the configure file is created,
3275 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3276 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3277 # in which to expect them.
3278 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3279 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3283 # func_emit_initmacro_end macro_prefix
3284 # emits the last few statements of the gl_INIT macro to standard output.
3285 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3286 func_emit_initmacro_end ()
3288 macro_prefix_arg="$1"
3289 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3290 # The check is performed only when autoconf is run from the directory where
3291 # the configure.ac resides; if it is run from a different directory, the
3293 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3294 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3295 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3296 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3297 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3301 echo " m4_if(m4_sysval, [0], [],"
3302 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3304 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3305 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3306 echo " m4_popdef([AC_LIBSOURCES])"
3307 echo " m4_popdef([AC_REPLACE_FUNCS])"
3308 echo " m4_popdef([AC_LIBOBJ])"
3309 echo " AC_CONFIG_COMMANDS_PRE(["
3310 echo " ${macro_prefix_arg}_libobjs="
3311 echo " ${macro_prefix_arg}_ltlibobjs="
3312 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3313 echo " # Remove the extension."
3314 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3315 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3316 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3317 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3320 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3321 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3325 # func_emit_initmacro_done macro_prefix sourcebase
3326 # emits a few statements after the gl_INIT macro to standard output.
3327 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3328 # - sourcebase directory relative to destdir where to place source code
3329 func_emit_initmacro_done ()
3331 macro_prefix_arg="$1"
3334 echo "# Like AC_LIBOBJ, except that the module name goes"
3335 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3336 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3337 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3338 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3341 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3342 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3343 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3344 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3345 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3348 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3349 echo "# expected is derived from the gnulib-tool parameterization,"
3350 echo "# and alloca is special cased (for the alloca-opt module)."
3351 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3352 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3353 echo " m4_foreach([_gl_NAME], [\$1], ["
3354 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3355 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3356 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3362 # func_import modules
3363 # Uses also the variables
3364 # - mode import or add-import or remove-import or update
3365 # - destdir target directory
3366 # - local_gnulib_dir from --local-dir
3367 # - modcache true or false, from --cache-modules/--no-cache-modules
3368 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3369 # - libname library name
3370 # - supplied_libname true if --lib was given, blank otherwise
3371 # - sourcebase directory relative to destdir where to place source code
3372 # - m4base directory relative to destdir where to place *.m4 macros
3373 # - pobase directory relative to destdir where to place *.po files
3374 # - docbase directory relative to destdir where to place doc files
3375 # - testsbase directory relative to destdir where to place unit test code
3376 # - auxdir directory relative to destdir where to place build aux files
3377 # - inctests true if --with-tests was given, blank otherwise
3378 # - incobsolete true if --with-obsolete was given, blank otherwise
3379 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3380 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3382 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3384 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3386 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3387 # - avoidlist list of modules to avoid, from --avoid
3388 # - lgpl yes or a number if library's license shall be LGPL,
3390 # - makefile_name from --makefile-name
3391 # - libtool true if --libtool was given, false if --no-libtool was
3392 # given, blank otherwise
3393 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3394 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3395 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3396 # - vc_files true if --vc-files was given, false if --no-vc-files was
3397 # given, blank otherwise
3398 # - autoconf_minversion minimum supported autoconf version
3399 # - doit : if actions shall be executed, false if only to be printed
3400 # - symbolic true if files should be symlinked, copied otherwise
3401 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3403 # - do_copyrights true if copyright notices in files should be replaced,
3407 # Get the cached settings.
3408 # In 'import' mode, we read them only for the purpose of knowing the old
3409 # installed file list, and don't use them as defaults.
3410 cached_local_gnulib_dir=
3411 cached_specified_modules=
3413 cached_inc_cxx_tests=
3414 cached_inc_longrunning_tests=
3415 cached_inc_privileged_tests=
3416 cached_inc_unportable_tests=
3417 cached_inc_all_tests=
3427 cached_makefile_name=
3429 cached_macro_prefix=
3433 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3434 cached_libtool=false
3440 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3450 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3452 /gl_WITH_OBSOLETE/ {
3453 s,^.*$,cached_incobsolete=true,p
3455 /gl_WITH_CXX_TESTS/ {
3456 s,^.*$,cached_inc_cxx_tests=true,p
3458 /gl_WITH_LONGRUNNING_TESTS/ {
3459 s,^.*$,cached_inc_longrunning_tests=true,p
3461 /gl_WITH_PRIVILEGED_TESTS/ {
3462 s,^.*$,cached_inc_privileged_tests=true,p
3464 /gl_WITH_UNPORTABLE_TESTS/ {
3465 s,^.*$,cached_inc_unportable_tests=true,p
3467 /gl_WITH_ALL_TESTS/ {
3468 s,^.*$,cached_inc_all_tests=true,p
3471 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3474 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3477 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3480 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3483 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3486 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3489 s,^.*$,cached_inctests=true,p
3492 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3495 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3498 s,^.*$,cached_lgpl=yes,p
3500 /gl_MAKEFILE_NAME(/ {
3501 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3504 s,^.*$,cached_libtool=true,p
3506 /gl_MACRO_PREFIX(/ {
3507 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3510 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3513 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3515 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3516 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3521 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3522 s,^.*$,cached_files=",p
3535 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3539 if test "$mode" = import; then
3540 # In 'import' mode, the new set of specified modules overrides the cached
3541 # set of modules. Ignore the cached settings.
3542 specified_modules="$1"
3544 # Merge the cached settings with the specified ones.
3545 # The m4base must be the same as expected from the pathname.
3546 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3547 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3549 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3550 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3551 if test -z "$local_gnulib_dir"; then
3552 if test -n "$cached_local_gnulib_dir"; then
3555 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3557 case "$cached_local_gnulib_dir" in
3559 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3561 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3562 local_gnulib_dir="$relconcat" ;;
3569 # Append the cached and the specified module names. So that
3570 # "gnulib-tool --add-import foo" means to add the module foo.
3571 specified_modules="$cached_specified_modules $1"
3574 # Take the cached module names, minus the specified module names.
3576 if $have_associative; then
3577 # Use an associative array, for O(N) worst-case run time.
3578 declare -A to_remove
3580 eval 'to_remove[$m]=yes'
3582 for module in $cached_specified_modules; do
3583 if eval 'test -z "${to_remove[$module]}"'; then
3584 func_append specified_modules "$module "
3588 # This loop has O(N²) worst-case run time.
3589 for module in $cached_specified_modules; do
3592 if test "$m" = "$module"; then
3597 if test -z "$to_remove"; then
3598 func_append specified_modules "$module "
3604 # Take the cached module names. There are no specified module names.
3605 specified_modules="$cached_specified_modules"
3608 # Included obsolete modules among the dependencies if specified either way.
3609 if test -z "$incobsolete"; then
3610 incobsolete="$cached_incobsolete"
3612 # Included special kinds of tests modules among the dependencies if specified
3614 if test -z "$inc_cxx_tests"; then
3615 inc_cxx_tests="$cached_inc_cxx_tests"
3617 if test -z "$inc_longrunning_tests"; then
3618 inc_longrunning_tests="$cached_inc_longrunning_tests"
3620 if test -z "$inc_privileged_tests"; then
3621 inc_privileged_tests="$cached_inc_privileged_tests"
3623 if test -z "$inc_unportable_tests"; then
3624 inc_unportable_tests="$cached_inc_unportable_tests"
3626 if test -z "$inc_all_tests"; then
3627 inc_all_tests="$cached_inc_all_tests"
3629 # Append the cached and the specified avoidlist. This is probably better
3630 # than dropping the cached one when --avoid is specified at least once.
3631 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3632 avoidlist=`echo $avoidlist`
3634 # The sourcebase defaults to the cached one.
3635 if test -z "$sourcebase"; then
3636 sourcebase="$cached_sourcebase"
3637 if test -z "$sourcebase"; then
3638 func_fatal_error "missing --source-base option"
3641 # The pobase defaults to the cached one.
3642 if test -z "$pobase"; then
3643 pobase="$cached_pobase"
3645 # The docbase defaults to the cached one.
3646 if test -z "$docbase"; then
3647 docbase="$cached_docbase"
3648 if test -z "$docbase"; then
3649 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."
3652 # The testsbase defaults to the cached one.
3653 if test -z "$testsbase"; then
3654 testsbase="$cached_testsbase"
3655 if test -z "$testsbase"; then
3656 func_fatal_error "missing --tests-base option"
3659 # Require the tests if specified either way.
3660 if test -z "$inctests"; then
3661 inctests="$cached_inctests"
3663 # The libname defaults to the cached one.
3664 if test -z "$supplied_libname"; then
3665 libname="$cached_libname"
3666 if test -z "$libname"; then
3667 func_fatal_error "missing --lib option"
3670 # Require LGPL if specified either way.
3671 if test -z "$lgpl"; then
3674 # The makefile_name defaults to the cached one.
3675 if test -z "$makefile_name"; then
3676 makefile_name="$cached_makefile_name"
3678 # Use libtool if specified either way, or if guessed.
3679 if test -z "$libtool"; then
3680 if test -n "$cached_m4base"; then
3681 libtool="$cached_libtool"
3683 libtool="$guessed_libtool"
3686 # The macro_prefix defaults to the cached one.
3687 if test -z "$macro_prefix"; then
3688 macro_prefix="$cached_macro_prefix"
3689 if test -z "$macro_prefix"; then
3690 func_fatal_error "missing --macro-prefix option"
3693 # The po_domain defaults to the cached one.
3694 if test -z "$po_domain"; then
3695 po_domain="$cached_po_domain"
3697 # The vc_files defaults to the cached one.
3698 if test -z "$vc_files"; then
3699 vc_files="$cached_vc_files"
3702 # --without-*-tests options are not supported here.
3704 excl_longrunning_tests=
3705 excl_privileged_tests=
3706 excl_unportable_tests=
3708 # Canonicalize the list of specified modules.
3709 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3711 # Include all kinds of tests modules if --with-all-tests was specified.
3712 inc_all_direct_tests="$inc_all_tests"
3713 inc_all_indirect_tests="$inc_all_tests"
3715 # Determine final module list.
3716 modules="$specified_modules"
3717 func_modules_transitive_closure
3718 if test $verbose -ge 0; then
3719 func_show_module_list
3721 final_modules="$modules"
3723 # Determine main module list and tests-related module list separately.
3724 # The main module list is the transitive closure of the specified modules,
3725 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3726 # is specified, it will consist only of LGPLed source.
3727 # The tests-related module list is the transitive closure of the specified
3728 # modules, including tests modules, minus the main module list excluding
3729 # modules of applicability 'all'. Its lib/* sources (brought in through
3730 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3731 # source, even if --lgpl is specified.
3732 # Determine main module list.
3733 saved_inctests="$inctests"
3735 modules="$specified_modules"
3736 func_modules_transitive_closure
3737 main_modules="$modules"
3738 inctests="$saved_inctests"
3739 if test $verbose -ge 1; then
3740 echo "Main module list:"
3741 echo "$main_modules" | sed -e 's/^/ /'
3743 # Determine tests-related module list.
3744 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3745 testsrelated_modules=`for module in $main_modules; do
3746 if test \`func_get_applicability $module\` = main; then
3750 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3751 if test $verbose -ge 1; then
3752 echo "Tests-related module list:"
3753 echo "$testsrelated_modules" | sed -e 's/^/ /'
3756 # Add the dummy module to the main module list if needed.
3757 modules="$main_modules"
3758 func_modules_add_dummy
3759 main_modules="$modules"
3761 # Determine whether a $testsbase/libtests.a is needed.
3763 for module in $testsrelated_modules; do
3764 func_verify_nontests_module
3765 if test -n "$module"; then
3766 all_files=`func_get_filelist $module`
3767 # Test whether some file in $all_files lies in lib/.
3768 for f in $all_files; do
3779 # Add the dummy module to the tests-related module list if needed.
3780 if $use_libtests; then
3781 modules="$testsrelated_modules"
3782 func_modules_add_dummy
3783 testsrelated_modules="$modules"
3786 # If --lgpl, verify that the licenses of modules are compatible.
3787 if test -n "$lgpl"; then
3788 license_incompatibilities=
3789 for module in $main_modules; do
3790 license=`func_get_license $module`
3792 'GPLed build tool') ;;
3793 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3798 LGPL | LGPLv2+ | LGPLv3+) ;;
3799 *) func_append license_incompatibilities "$module $license$nl" ;;
3805 *) func_append license_incompatibilities "$module $license$nl" ;;
3808 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3813 if test -n "$license_incompatibilities"; then
3814 # Format the license incompatibilities as a table.
3815 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3816 s,^\(.................................................[^ ]*\) *, \1 ,'
3817 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3818 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3822 # Show banner notice of every module.
3823 modules="$main_modules"
3826 # Determine script to apply to imported library files.
3827 sed_transform_lib_file=
3828 for module in $main_modules; do
3829 if test $module = config-h; then
3830 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3831 sed_transform_lib_file=$sed_transform_lib_file'
3832 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3837 sed_transform_main_lib_file="$sed_transform_lib_file"
3838 if test -n "$do_copyrights"; then
3839 if test -n "$lgpl"; then
3843 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3844 s/GNU General/GNU Lesser General/g
3848 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3849 s/GNU General/GNU Lesser General/g
3850 s/version [23]\([ ,]\)/version 2.1\1/g
3853 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3857 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3858 s/GNU Lesser General/GNU General/g
3859 s/GNU Library General/GNU General/g
3860 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3865 # Determine script to apply to auxiliary files that go into $auxdir/.
3866 sed_transform_build_aux_file=
3867 if test -n "$do_copyrights"; then
3869 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3870 s/GNU Lesser General/GNU General/g
3871 s/GNU Library General/GNU General/g
3872 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3876 # Determine script to apply to library files that go into $testsbase/.
3877 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3878 if test -n "$do_copyrights"; then
3880 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3881 s/GNU Lesser General/GNU General/g
3882 s/GNU Library General/GNU General/g
3883 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3887 # Determine the final file lists.
3888 # They must be computed separately, because files in lib/* go into
3889 # $sourcebase/ if they are in the main file list but into $testsbase/
3890 # if they are in the tests-related file list. Furthermore lib/dummy.c
3892 # Determine final main file list.
3893 modules="$main_modules"
3894 func_modules_to_filelist
3896 # Determine final tests-related file list.
3897 modules="$testsrelated_modules"
3898 func_modules_to_filelist
3899 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3900 # Merge both file lists.
3901 sed_remove_empty_lines='/^$/d'
3902 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3903 if test $verbose -ge 0; then
3905 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3906 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3910 || func_fatal_error "refusing to do nothing"
3912 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3913 new_files="$files m4/gnulib-tool.m4"
3914 old_files="$cached_files"
3915 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3916 func_append old_files " m4/gnulib-tool.m4"
3919 rewritten='%REWRITTEN%'
3920 sed_rewrite_old_files="\
3921 s,^build-aux/,$rewritten$auxdir/,
3922 s,^doc/,$rewritten$cached_docbase/,
3923 s,^lib/,$rewritten$cached_sourcebase/,
3924 s,^m4/,$rewritten$cached_m4base/,
3925 s,^tests/,$rewritten$cached_testsbase/,
3926 s,^tests=lib/,$rewritten$cached_testsbase/,
3929 sed_rewrite_new_files="\
3930 s,^build-aux/,$rewritten$auxdir/,
3931 s,^doc/,$rewritten$docbase/,
3932 s,^lib/,$rewritten$sourcebase/,
3933 s,^m4/,$rewritten$m4base/,
3934 s,^tests/,$rewritten$testsbase/,
3935 s,^tests=lib/,$rewritten$testsbase/,
3939 # Create directories.
3940 { echo "$sourcebase"
3942 if test -n "$pobase"; then
3945 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3946 if test -n "$docfiles"; then
3949 if test -n "$inctests"; then
3953 for f in $files; do echo $f; done \
3954 | sed -e "$sed_rewrite_new_files" \
3955 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3958 { # Rearrange file descriptors. Needed because "while ... done < ..."
3959 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3960 exec 5<&0 < "$tmp"/dirs
3962 if test ! -d "$destdir/$d"; then
3964 echo "Creating directory $destdir/$d"
3965 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3967 echo "Create directory $destdir/$d"
3974 # Copy files or make symbolic links. Remove obsolete files.
3978 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3979 # representing the files according to the last gnulib-tool invocation.
3980 for f in $old_files; do echo $f; done \
3981 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3984 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3985 # representing the files after this gnulib-tool invocation.
3986 for f in $new_files; do echo $f; done \
3987 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3990 # First the files that are in old-files, but not in new-files:
3991 sed_take_first_column='s,'"$delimiter"'.*,,'
3992 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3993 # Remove the file. Do nothing if the user already removed it.
3994 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3996 echo "Removing file $g (backup in ${g}~)"
3997 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3999 echo "Remove file $g (backup in ${g}~)"
4001 func_append removed_files "$g$nl"
4004 # func_add_or_update handles a file that ought to be present afterwards.
4006 # - f the original file name
4007 # - g the rewritten file name
4008 # - already_present nonempty if the file should already exist, empty
4010 func_add_or_update ()
4014 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4016 func_dest_tmpfilename "$g"
4017 func_lookup_file "$f"
4018 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4019 if test -n "$sed_transform_main_lib_file"; then
4022 sed -e "$sed_transform_main_lib_file" \
4023 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4027 if test -n "$sed_transform_build_aux_file"; then
4030 sed -e "$sed_transform_build_aux_file" \
4031 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4035 if test -n "$sed_transform_testsrelated_lib_file"; then
4038 sed -e "$sed_transform_testsrelated_lib_file" \
4039 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4043 if test -f "$destdir/$g"; then
4044 # The file already exists.
4048 # Don't protest if the file should be there but isn't: it happens
4049 # frequently that developers don't put autogenerated files under version control.
4051 func_append added_files "$g$nl"
4055 # Then the files that are in new-files, but not in old-files:
4056 sed_take_last_column='s,^.*'"$delimiter"',,'
4058 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4059 | sed -e "$sed_take_last_column" \
4060 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4061 { # Rearrange file descriptors. Needed because "while ... done < ..."
4062 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4063 exec 5<&0 < "$tmp"/added-files
4069 # Then the files that are in new-files and in old-files:
4070 already_present=true
4071 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4072 | sed -e "$sed_take_last_column" \
4073 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4074 { # Rearrange file descriptors. Needed because "while ... done < ..."
4075 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4076 exec 5<&0 < "$tmp"/kept-files
4083 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4084 actioncmd="gnulib-tool --import"
4085 func_append actioncmd " --dir=$destdir"
4086 if test -n "$local_gnulib_dir"; then
4087 func_append actioncmd " --local-dir=$local_gnulib_dir"
4089 func_append actioncmd " --lib=$libname"
4090 func_append actioncmd " --source-base=$sourcebase"
4091 func_append actioncmd " --m4-base=$m4base"
4092 if test -n "$pobase"; then
4093 func_append actioncmd " --po-base=$pobase"
4095 func_append actioncmd " --doc-base=$docbase"
4096 func_append actioncmd " --tests-base=$testsbase"
4097 func_append actioncmd " --aux-dir=$auxdir"
4098 if test -n "$inctests"; then
4099 func_append actioncmd " --with-tests"
4101 if test -n "$incobsolete"; then
4102 func_append actioncmd " --with-obsolete"
4104 if test -n "$inc_cxx_tests"; then
4105 func_append actioncmd " --with-c++-tests"
4107 if test -n "$inc_longrunning_tests"; then
4108 func_append actioncmd " --with-longrunning-tests"
4110 if test -n "$inc_privileged_tests"; then
4111 func_append actioncmd " --with-privileged-tests"
4113 if test -n "$inc_unportable_tests"; then
4114 func_append actioncmd " --with-unportable-tests"
4116 if test -n "$inc_all_tests"; then
4117 func_append actioncmd " --with-all-tests"
4119 for module in $avoidlist; do
4120 func_append actioncmd " --avoid=$module"
4122 if test -n "$lgpl"; then
4123 if test "$lgpl" = yes; then
4124 func_append actioncmd " --lgpl"
4126 func_append actioncmd " --lgpl=$lgpl"
4129 if test -n "$makefile_name"; then
4130 func_append actioncmd " --makefile-name=$makefile_name"
4132 if test "$libtool" = true; then
4133 func_append actioncmd " --libtool"
4135 func_append actioncmd " --no-libtool"
4137 func_append actioncmd " --macro-prefix=$macro_prefix"
4138 if test -n "$po_domain"; then
4139 func_append actioncmd " --po-domain=$po_domain"
4141 if test -n "$vc_files"; then
4142 if test "$vc_files" = true; then
4143 func_append actioncmd " --vc-files"
4145 func_append actioncmd " --no-vc-files"
4148 func_append actioncmd " `echo $specified_modules`"
4150 # Default the makefile name to Makefile.am.
4151 if test -n "$makefile_name"; then
4152 makefile_am=$makefile_name
4154 makefile_am=Makefile.am
4157 # Create normal Makefile.ams.
4160 # Setup list of Makefile.am edits that are to be performed afterwards.
4161 # Some of these edits apply to files that we will generate; others are
4162 # under the responsibility of the developer.
4164 # func_note_Makefile_am_edit dir var value
4165 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4167 func_note_Makefile_am_edit ()
4169 makefile_am_edits=`expr $makefile_am_edits + 1`
4170 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4171 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4172 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4174 if test "$makefile_am" = Makefile.am; then
4175 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4176 sourcebase_base=`basename "$sourcebase"`
4177 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4179 if test -n "$pobase"; then
4180 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4181 pobase_base=`basename "$pobase"`
4182 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4184 if test -n "$inctests"; then
4185 if test "$makefile_am" = Makefile.am; then
4186 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4187 testsbase_base=`basename "$testsbase"`
4188 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4191 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4193 # Find the first parent directory of $m4base that contains or will contain
4195 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4197 sed_butlast='s,[^/][^/]*//*$,,'
4198 dir1="${m4base}/"; dir2=""
4199 while test -n "$dir1" \
4200 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4201 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4202 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4203 || { test -n "$inctests" \
4204 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4205 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4206 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4207 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4209 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4212 # Create library makefile.
4213 func_dest_tmpfilename $sourcebase/$makefile_am
4214 destfile="$sourcebase/$makefile_am"
4215 modules="$main_modules"
4216 func_emit_lib_Makefile_am > "$tmpfile"
4217 if test -f "$destdir"/$sourcebase/$makefile_am; then
4218 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4222 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4223 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4224 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4226 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4232 echo "Creating $sourcebase/$makefile_am"
4233 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4235 echo "Create $sourcebase/$makefile_am"
4238 func_append added_files "$sourcebase/$makefile_am$nl"
4241 # Create po/ directory.
4242 if test -n "$pobase"; then
4243 # Create po makefile and auxiliary files.
4244 for file in Makefile.in.in remove-potcdate.sin; do
4245 func_dest_tmpfilename $pobase/$file
4246 func_lookup_file build-aux/po/$file
4247 cat "$lookedup_file" > "$tmpfile"
4248 if test -f "$destdir"/$pobase/$file; then
4249 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4253 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4254 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4255 mv -f "$tmpfile" "$destdir"/$pobase/$file
4257 echo "Update $pobase/$file (backup in $pobase/$file~)"
4263 echo "Creating $pobase/$file"
4264 mv -f "$tmpfile" "$destdir"/$pobase/$file
4266 echo "Create $pobase/$file"
4269 func_append added_files "$pobase/$file$nl"
4272 # Create po makefile parameterization, part 1.
4273 func_dest_tmpfilename $pobase/Makevars
4274 func_emit_po_Makevars > "$tmpfile"
4275 if test -f "$destdir"/$pobase/Makevars; then
4276 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4280 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4281 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4282 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4284 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4290 echo "Creating $pobase/Makevars"
4291 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4293 echo "Create $pobase/Makevars"
4296 func_append added_files "$pobase/Makevars$nl"
4298 # Create po makefile parameterization, part 2.
4299 func_dest_tmpfilename $pobase/POTFILES.in
4300 func_emit_po_POTFILES_in > "$tmpfile"
4301 if test -f "$destdir"/$pobase/POTFILES.in; then
4302 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4306 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4307 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4308 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4310 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4316 echo "Creating $pobase/POTFILES.in"
4317 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4319 echo "Create $pobase/POTFILES.in"
4322 func_append added_files "$pobase/POTFILES.in$nl"
4325 TP_URL="http://translationproject.org/latest/"
4326 TP_RSYNC_URI="translationproject.org::tp/latest/"
4328 echo "Fetching gnulib PO files from $TP_URL"
4329 (cd "$destdir"/$pobase \
4330 && { # Prefer rsync over wget if it is available, since it consumes
4331 # less network bandwidth, due to compression.
4332 if type rsync 2>/dev/null | grep / > /dev/null; then
4333 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4335 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4340 echo "Fetch gnulib PO files from $TP_URL"
4342 # Create po/LINGUAS.
4344 func_dest_tmpfilename $pobase/LINGUAS
4345 (cd "$destdir"/$pobase \
4346 && { echo '# Set of available languages.'
4347 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4350 if test -f "$destdir"/$pobase/LINGUAS; then
4351 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4354 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4355 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4356 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4359 echo "Creating $pobase/LINGUAS"
4360 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4361 func_append added_files "$pobase/LINGUAS$nl"
4364 if test -f "$destdir"/$pobase/LINGUAS; then
4365 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4367 echo "Create $pobase/LINGUAS"
4372 # Create m4/gnulib-cache.m4.
4373 func_dest_tmpfilename $m4base/gnulib-cache.m4
4375 func_emit_copyright_notice
4377 echo "# This file represents the specification of how gnulib-tool is used."
4378 echo "# It acts as a cache: It is written and read by gnulib-tool."
4379 echo "# In projects that use version control, this file is meant to be put under"
4380 echo "# version control, like the configure.ac and various Makefile.am files."
4383 echo "# Specification in the form of a command-line invocation:"
4386 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4387 # Store the local_gnulib_dir relative to destdir.
4388 case "$local_gnulib_dir" in
4390 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4393 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4395 # destdir, local_gnulib_dir are both relative.
4396 func_relativize "$destdir" "$local_gnulib_dir"
4397 relative_local_gnulib_dir="$reldir" ;;
4400 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4402 echo "$specified_modules" | sed -e 's/^/ /g'
4404 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4405 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4406 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4407 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4408 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4409 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4410 echo "gl_AVOID([$avoidlist])"
4411 echo "gl_SOURCE_BASE([$sourcebase])"
4412 echo "gl_M4_BASE([$m4base])"
4413 echo "gl_PO_BASE([$pobase])"
4414 echo "gl_DOC_BASE([$docbase])"
4415 echo "gl_TESTS_BASE([$testsbase])"
4416 test -z "$inctests" || echo "gl_WITH_TESTS"
4417 echo "gl_LIB([$libname])"
4418 if test -n "$lgpl"; then
4419 if test "$lgpl" = yes; then
4422 echo "gl_LGPL([$lgpl])"
4425 echo "gl_MAKEFILE_NAME([$makefile_name])"
4426 if test "$libtool" = true; then
4429 echo "gl_MACRO_PREFIX([$macro_prefix])"
4430 echo "gl_PO_DOMAIN([$po_domain])"
4431 if test -n "$vc_files"; then
4432 echo "gl_VC_FILES([$vc_files])"
4435 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4436 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4440 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4441 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4442 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4444 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4448 echo "# gnulib-cache.m4 ends here"
4455 echo "Creating $m4base/gnulib-cache.m4"
4456 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4458 echo "Create $m4base/gnulib-cache.m4"
4464 # Create m4/gnulib-comp.m4.
4465 func_dest_tmpfilename $m4base/gnulib-comp.m4
4467 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4468 func_emit_copyright_notice
4470 echo "# This file represents the compiled summary of the specification in"
4471 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4472 echo "# to be invoked from configure.ac."
4473 echo "# In projects that use version control, this file can be treated like"
4474 echo "# other built files."
4477 echo "# This macro should be invoked from $configure_ac, in the section"
4478 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4479 echo "# any checks for libraries, header files, types and library functions."
4480 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4482 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4483 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4484 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4485 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4486 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4487 if test -n "$uses_subdirs"; then
4488 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4490 for module in $final_modules; do
4492 if test -n "$module"; then
4493 echo "# Code from module $module:"
4494 func_get_autoconf_early_snippet "$module"
4497 | sed -e '/^$/d;' -e 's/^/ /'
4500 echo "# This macro should be invoked from $configure_ac, in the section"
4501 echo "# \"Check for header files, types and library functions\"."
4502 echo "AC_DEFUN([${macro_prefix}_INIT],"
4504 if test "$libtool" = true; then
4505 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4506 echo " gl_cond_libtool=true"
4508 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4509 echo " gl_cond_libtool=false"
4511 echo " gl_ltlibdeps="
4513 if test "$auxdir" != "build-aux"; then
4514 sed_replace_build_aux='
4516 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4517 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4521 sed_replace_build_aux="$sed_noop"
4523 echo " gl_m4_base='$m4base'"
4524 func_emit_initmacro_start $macro_prefix
4525 echo " gl_source_base='$sourcebase'"
4526 for module in $main_modules; do
4528 if test -n "$module"; then
4529 echo " # Code from module $module:"
4530 func_get_autoconf_snippet "$module" \
4531 | sed -e '/^$/d;' -e 's/^/ /' \
4532 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4533 -e "$sed_replace_build_aux"
4534 if test "$module" = 'alloca' && test "$libtool" = true; then
4535 echo 'changequote(,)dnl'
4536 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4537 echo 'changequote([, ])dnl'
4538 echo 'AC_SUBST([LTALLOCA])'
4542 echo " # End of code from modules"
4543 func_emit_initmacro_end $macro_prefix
4544 echo " gltests_libdeps="
4545 echo " gltests_ltlibdeps="
4546 func_emit_initmacro_start ${macro_prefix}tests
4547 echo " gl_source_base='$testsbase'"
4548 # Define a tests witness macro that depends on the package.
4549 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4550 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4551 echo "changequote(,)dnl"
4552 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"
4553 echo "changequote([, ])dnl"
4554 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4555 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4556 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4557 for module in $testsrelated_modules; do
4559 if test -n "$module"; then
4560 func_get_autoconf_snippet "$module" \
4561 | sed -e '/^$/d;' -e 's/^/ /' \
4562 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4563 -e "$sed_replace_build_aux" \
4564 -e 's/\$gl_cond_libtool/false/g' \
4565 -e 's/gl_libdeps/gltests_libdeps/g' \
4566 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4569 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4570 func_emit_initmacro_end ${macro_prefix}tests
4571 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4572 # created using libtool, because libtool already handles the dependencies.
4573 if test "$libtool" != true; then
4574 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4575 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4576 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4577 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4578 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4580 if $use_libtests; then
4581 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4582 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4585 func_emit_initmacro_done $macro_prefix $sourcebase
4586 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4588 echo "# This macro records the list of files which have been installed by"
4589 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4590 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4591 echo "$files" | sed -e 's,^, ,'
4594 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4595 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4599 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4600 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4601 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4603 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4607 echo "# gnulib-comp.m4 ends here"
4614 echo "Creating $m4base/gnulib-comp.m4"
4615 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4617 echo "Create $m4base/gnulib-comp.m4"
4623 if test -n "$inctests"; then
4624 # Create tests makefile.
4625 func_dest_tmpfilename $testsbase/$makefile_am
4626 destfile="$testsbase/$makefile_am"
4627 modules="$testsrelated_modules"
4628 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4629 if test -f "$destdir"/$testsbase/$makefile_am; then
4630 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4634 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4635 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4636 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4638 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4644 echo "Creating $testsbase/$makefile_am"
4645 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4647 echo "Create $testsbase/$makefile_am"
4650 func_append added_files "$testsbase/$makefile_am$nl"
4654 if test "$vc_files" != false; then
4655 # Update the .cvsignore and .gitignore files.
4656 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4657 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4658 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4659 echo "$m4base/|A|gnulib-comp.m4"
4660 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4661 { # Rearrange file descriptors. Needed because "while ... done < ..."
4662 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4663 exec 5<&0 < "$tmp"/fileset-changes
4664 func_update_ignorelist ()
4667 if test "$ignore" = .gitignore; then
4668 # In a .gitignore file, "foo" applies to the current directory and all
4669 # subdirectories, whereas "/foo" applies to the current directory only.
4672 doubly_escaped_anchor='\\/'
4676 doubly_escaped_anchor=''
4678 if test -f "$destdir/$dir$ignore"; then
4679 if test -n "$dir_added" || test -n "$dir_removed"; then
4680 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4681 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4682 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4683 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4684 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4686 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4688 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4689 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4690 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4691 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4692 } > "$tmp"/sed-ignore-removed
4693 { cat "$destdir/$dir$ignore"~
4694 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4695 } | sed -f "$tmp"/sed-ignore-removed \
4696 > "$destdir/$dir$ignore"
4698 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4703 if test -n "$dir_added"; then
4705 echo "Creating $destdir/$dir$ignore"
4707 if test "$ignore" = .cvsignore; then
4709 # Automake generates Makefile rules that create .dirstamp files.
4712 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4713 } > "$destdir/$dir$ignore"
4715 echo "Create $destdir/$dir$ignore"
4725 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4726 func_update_ignorelist .cvsignore
4728 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4729 func_update_ignorelist .gitignore
4736 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4737 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4738 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4739 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4740 if test "$next_dir" != "$last_dir"; then
4741 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4742 last_dir="$next_dir"
4747 A) func_append last_dir_added "$file$nl";;
4748 R) func_append last_dir_removed "$file$nl";;
4751 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4758 echo "You may need to add #include directives for the following .h files."
4759 # Intersect $specified_modules and $main_modules
4760 # (since $specified_modules is not necessarily of subset of $main_modules
4761 # - some may have been skipped through --avoid, and since the elements of
4762 # $main_modules but not in $specified_modules can go away without explicit
4763 # notice - through changes in the module dependencies).
4764 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4765 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4766 # First the #include <...> directives without #ifs, sorted for convenience,
4767 # then the #include "..." directives without #ifs, sorted for convenience,
4768 # then the #include directives that are surrounded by #ifs. Not sorted.
4769 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4770 include_directive=`func_get_include_directive "$module"`
4771 case "$nl$include_directive" in
4773 echo "$include_directive" 1>&5
4776 echo "$include_directive" | grep -v 'include "' 1>&6
4777 echo "$include_directive" | grep 'include "' 1>&7
4780 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4782 LC_ALL=C sort -u "$tmp"/include-angles
4783 LC_ALL=C sort -u "$tmp"/include-quotes
4784 cat "$tmp"/include-if
4785 ) | sed -e '/^$/d' -e 's/^/ /'
4786 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4788 for module in $main_modules; do
4789 func_get_link_directive "$module"
4791 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4792 if test `wc -l < "$tmp"/link` != 0; then
4794 echo "You may need to use the following Makefile variables when linking."
4795 echo "Use them in <program>_LDADD when linking a program, or"
4796 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4802 echo "Don't forget to"
4803 if test "$makefile_am" = Makefile.am; then
4804 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4806 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4808 if test -n "$pobase"; then
4809 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4811 if test -n "$inctests"; then
4812 if test "$makefile_am" = Makefile.am; then
4813 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4815 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4819 while test $edit != $makefile_am_edits; do
4820 edit=`expr $edit + 1`
4821 eval dir=\"\$makefile_am_edit${edit}_dir\"
4822 eval var=\"\$makefile_am_edit${edit}_var\"
4823 eval val=\"\$makefile_am_edit${edit}_val\"
4824 if test -n "$var"; then
4825 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4828 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4829 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4832 # func_create_testdir testdir modules
4834 # - local_gnulib_dir from --local-dir
4835 # - modcache true or false, from --cache-modules/--no-cache-modules
4836 # - auxdir directory relative to destdir where to place build aux files
4837 # - inctests true if tests should be included, blank otherwise
4838 # - incobsolete true if obsolete modules among dependencies should be
4839 # included, blank otherwise
4840 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
4842 # - excl_longrunning_tests true if long-runnings tests should be excluded,
4844 # - excl_privileged_tests true if tests that require root privileges should be
4845 # excluded, blank otherwise
4846 # - excl_unportable_tests true if tests that fail on some platforms should be
4847 # excluded, blank otherwise
4848 # - avoidlist list of modules to avoid
4849 # - libtool true if --libtool was given, false if --no-libtool was
4850 # given, blank otherwise
4851 # - symbolic true if files should be symlinked, copied otherwise
4852 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4854 func_create_testdir ()
4858 if test -z "$modules"; then
4859 # All modules together.
4860 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4861 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4862 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4863 modules=`func_all_modules`
4864 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4866 specified_modules="$modules"
4868 # Canonicalize the list of specified modules.
4869 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4871 # Unlike in func_import, here we want to include all kinds of tests for the
4872 # directly specified modules, but not for dependencies.
4873 inc_all_direct_tests=true
4874 inc_all_indirect_tests="$inc_all_tests"
4876 # Check that the license of every module is consistent with the license of
4878 saved_inctests="$inctests"
4879 # When computing transitive closures, don't consider $module to depend on
4880 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4881 # on GPL modules - therefore we don't want a warning in this case.
4883 for requested_module in $specified_modules; do
4884 requested_license=`func_get_license "$requested_module"`
4885 if test "$requested_license" != GPL; then
4886 # Here we use func_modules_transitive_closure, not just
4887 # func_get_dependencies, so that we also detect weird situations like
4888 # an LGPL module which depends on a GPLed build tool module which depends
4890 modules="$requested_module"
4891 func_modules_transitive_closure
4892 for module in $modules; do
4893 license=`func_get_license "$module"`
4895 'GPLed build tool') ;;
4896 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4898 case "$requested_license" in
4901 GPLv2+ | LGPLv2+) ;;
4902 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4908 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4914 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4923 inctests="$saved_inctests"
4925 # Subdirectory names.
4935 # Determine final module list.
4936 modules="$specified_modules"
4937 func_modules_transitive_closure
4938 if test $verbose -ge 0; then
4939 func_show_module_list
4942 # Add the dummy module if needed.
4943 func_modules_add_dummy
4945 # Show banner notice of every module.
4948 # Determine final file list.
4949 func_modules_to_filelist
4950 if test $verbose -ge 0; then
4952 echo "$files" | sed -e 's/^/ /'
4954 # Add files for which the copy in gnulib is newer than the one that
4955 # "automake --add-missing --copy" would provide.
4956 files="$files build-aux/config.guess"
4957 files="$files build-aux/config.sub"
4958 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
4960 rewritten='%REWRITTEN%'
4961 sed_rewrite_files="\
4962 s,^build-aux/,$rewritten$auxdir/,
4963 s,^doc/,$rewritten$docbase/,
4964 s,^lib/,$rewritten$sourcebase/,
4965 s,^m4/,$rewritten$m4base/,
4966 s,^tests/,$rewritten$testsbase/,
4970 # Create directories.
4971 for f in $files; do echo $f; done \
4972 | sed -e "$sed_rewrite_files" \
4973 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4974 | LC_ALL=C sort -u \
4976 { # Rearrange file descriptors. Needed because "while ... done < ..."
4977 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4978 exec 5<&0 < "$tmp"/dirs
4980 mkdir -p "$testdir/$d"
4985 # Copy files or make symbolic links.
4987 for f in $files; do echo $f; done \
4988 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4991 { # Rearrange file descriptors. Needed because "while ... done < ..."
4992 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4993 exec 5<&0 < "$tmp"/files
4995 func_lookup_file "$f"
4996 if test -n "$lookedup_tmp"; then
4997 cp -p "$lookedup_file" "$testdir/$g"
4999 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5000 if { test -n "$symbolic" \
5001 || { test -n "$lsymbolic" \
5002 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5003 func_ln "$lookedup_file" "$testdir/$g"
5005 cp -p "$lookedup_file" "$testdir/$g"
5012 # Create Makefile.ams that are for testing.
5015 # No special edits are needed.
5018 # Create $sourcebase/Makefile.am.
5019 mkdir -p "$testdir/$sourcebase"
5020 destfile="$sourcebase/Makefile.am"
5021 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5022 any_uses_subdirs="$uses_subdirs"
5024 # Create $m4base/Makefile.am.
5025 mkdir -p "$testdir/$m4base"
5026 (echo "## Process this file with automake to produce Makefile.in."
5032 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5035 ) > "$testdir/$m4base/Makefile.am"
5037 subdirs="$sourcebase $m4base"
5038 subdirs_with_configure_ac=""
5040 if false && test -f "$testdir"/$m4base/gettext.m4; then
5041 # Avoid stupid error message from automake:
5042 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5043 mkdir -p "$testdir/po"
5044 (echo "## Process this file with automake to produce Makefile.in."
5045 ) > "$testdir/po/Makefile.am"
5046 func_append subdirs " po"
5049 if test -n "$inctests"; then
5050 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5051 # Viewed from the $testsbase subdirectory, $auxdir is different.
5052 saved_auxdir="$auxdir"
5053 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5054 # Create $testsbase/Makefile.am.
5056 destfile="$testsbase/Makefile.am"
5057 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5058 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5059 # Create $testsbase/configure.ac.
5060 (echo "# Process this file with autoconf to produce a configure script."
5061 echo "AC_INIT([dummy], [0])"
5062 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5063 echo "AM_INIT_AUTOMAKE"
5065 echo "AC_CONFIG_HEADERS([config.h])"
5068 echo "AC_PROG_INSTALL"
5069 echo "AC_PROG_MAKE_SET"
5070 echo "AC_PROG_RANLIB"
5072 if test -n "$uses_subdirs"; then
5073 echo "AM_PROG_CC_C_O"
5076 for module in $modules; do
5078 if test -n "$module"; then
5080 gnumakefile | maintainer-makefile)
5081 # These modules are meant to be used only in the top-level directory.
5084 func_get_autoconf_early_snippet "$module"
5089 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5090 if test "$libtool" = true; then
5091 echo "LT_INIT([win32-dll])"
5092 echo "LT_LANG([C++])"
5093 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5094 echo "gl_cond_libtool=true"
5096 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5097 echo "gl_cond_libtool=false"
5099 echo "gl_ltlibdeps="
5101 # Wrap the set of autoconf snippets into an autoconf macro that is then
5102 # invoked. This is needed because autoconf does not support AC_REQUIRE
5104 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5105 # but we want the AC_REQUIRE to have its normal meaning (provide one
5106 # expansion of the required macro before the current point, and only one
5108 echo "AC_DEFUN([gl_INIT], ["
5109 sed_replace_build_aux='
5111 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5112 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5115 echo "gl_m4_base='../$m4base'"
5116 func_emit_initmacro_start $macro_prefix
5117 # We don't have explicit ordering constraints between the various
5118 # autoconf snippets. It's cleanest to put those of the library before
5119 # those of the tests.
5120 echo "gl_source_base='../$sourcebase'"
5121 for module in $modules; do
5122 func_verify_nontests_module
5123 if test -n "$module"; then
5125 gnumakefile | maintainer-makefile)
5126 # These modules are meant to be used only in the top-level directory.
5129 func_get_autoconf_snippet "$module" \
5130 | sed -e "$sed_replace_build_aux"
5135 echo "gl_source_base='.'"
5136 for module in $modules; do
5137 func_verify_tests_module
5138 if test -n "$module"; then
5139 func_get_autoconf_snippet "$module" \
5140 | sed -e "$sed_replace_build_aux"
5143 func_emit_initmacro_end $macro_prefix
5144 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5145 # created using libtool, because libtool already handles the dependencies.
5146 if test "$libtool" != true; then
5147 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5148 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5149 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5150 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5151 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5154 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5158 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5159 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5160 echo "AH_TOP([#include \"../config.h\"])"
5162 echo "AC_CONFIG_FILES([Makefile])"
5164 ) > "$testdir/$testsbase/configure.ac"
5165 auxdir="$saved_auxdir"
5166 func_append subdirs " $testsbase"
5167 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5170 # Create Makefile.am.
5171 (echo "## Process this file with automake to produce Makefile.in."
5173 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5175 echo "SUBDIRS = $subdirs"
5177 echo "ACLOCAL_AMFLAGS = -I $m4base"
5178 ) > "$testdir/Makefile.am"
5180 # Create configure.ac.
5181 (echo "# Process this file with autoconf to produce a configure script."
5182 echo "AC_INIT([dummy], [0])"
5183 if test "$auxdir" != "."; then
5184 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5186 echo "AM_INIT_AUTOMAKE"
5188 echo "AC_CONFIG_HEADERS([config.h])"
5191 echo "AC_PROG_INSTALL"
5192 echo "AC_PROG_MAKE_SET"
5194 echo "# For autobuild."
5195 echo "AC_CANONICAL_BUILD"
5196 echo "AC_CANONICAL_HOST"
5198 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5199 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5200 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5201 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5203 echo "AC_PROG_RANLIB"
5205 if test -n "$any_uses_subdirs"; then
5206 echo "AM_PROG_CC_C_O"
5209 for module in $modules; do
5210 func_verify_nontests_module
5211 if test -n "$module"; then
5212 func_get_autoconf_early_snippet "$module"
5215 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5216 if test "$libtool" = true; then
5217 echo "LT_INIT([win32-dll])"
5218 echo "LT_LANG([C++])"
5219 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5220 echo "gl_cond_libtool=true"
5222 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5223 echo "gl_cond_libtool=false"
5225 echo "gl_ltlibdeps="
5227 # Wrap the set of autoconf snippets into an autoconf macro that is then
5228 # invoked. This is needed because autoconf does not support AC_REQUIRE
5230 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5231 # but we want the AC_REQUIRE to have its normal meaning (provide one
5232 # expansion of the required macro before the current point, and only one
5234 echo "AC_DEFUN([gl_INIT], ["
5235 if test "$auxdir" != "build-aux"; then
5236 sed_replace_build_aux='
5238 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5239 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5243 sed_replace_build_aux="$sed_noop"
5245 echo "gl_m4_base='$m4base'"
5246 func_emit_initmacro_start $macro_prefix
5247 echo "gl_source_base='$sourcebase'"
5248 for module in $modules; do
5249 func_verify_nontests_module
5250 if test -n "$module"; then
5251 func_get_autoconf_snippet "$module" \
5252 | sed -e "$sed_replace_build_aux"
5255 func_emit_initmacro_end $macro_prefix
5256 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5257 # created using libtool, because libtool already handles the dependencies.
5258 if test "$libtool" != true; then
5259 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5260 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5261 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5262 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5263 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5266 func_emit_initmacro_done $macro_prefix $sourcebase
5270 if test -n "$subdirs_with_configure_ac"; then
5271 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5273 makefiles="Makefile"
5274 for d in $subdirs; do
5275 # For subdirs that have a configure.ac by their own, it's the subdir's
5276 # configure.ac which creates the subdir's Makefile.am, not this one.
5277 case " $subdirs_with_configure_ac " in
5279 *) func_append makefiles " $d/Makefile" ;;
5282 echo "AC_CONFIG_FILES([$makefiles])"
5284 ) > "$testdir/configure.ac"
5286 # Create autogenerated files.
5288 # Do not use "${AUTORECONF} --force --install", because it may invoke
5289 # autopoint, which brings in older versions of some of our .m4 files.
5290 if test -f $m4base/gettext.m4; then
5291 func_execute_command ${AUTOPOINT} --force || func_exit 1
5292 for f in $m4base/*.m4~; do
5294 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5298 if test "$libtool" = true; then
5299 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5301 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5302 if ! test -d build-aux; then
5303 func_execute_command mkdir build-aux || func_exit 1
5305 func_execute_command ${AUTOCONF} || func_exit 1
5306 func_execute_command ${AUTOHEADER} || func_exit 1
5307 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5309 if test -n "$inctests"; then
5310 # Create autogenerated files.
5311 (cd "$testdir/$testsbase" || func_exit 1
5312 # Do not use "${AUTORECONF} --force --install", because it may invoke
5313 # autopoint, which brings in older versions of some of our .m4 files.
5314 if test -f ../$m4base/gettext.m4; then
5315 func_execute_command ${AUTOPOINT} --force || func_exit 1
5316 for f in ../$m4base/*.m4~; do
5318 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5322 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5323 if ! test -d ../build-aux; then
5324 func_execute_command mkdir ../build-aux
5326 func_execute_command ${AUTOCONF} || func_exit 1
5327 func_execute_command ${AUTOHEADER} || func_exit 1
5328 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5331 # Need to run configure and make once, to create built files that are to be
5332 # distributed (such as get_date.c).
5333 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5334 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5335 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5336 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5337 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5338 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5339 # such $(FOO_H) because they don't refer to distributed files.
5340 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5341 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5342 | sed -e "$sed_remove_make_variables"`
5343 distributed_built_sources=`for file in $built_sources; do
5344 case "$cleaned_files" in
5349 tests_distributed_built_sources=
5350 if test -n "$inctests"; then
5351 # Likewise for built files in the $testsbase directory.
5352 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5353 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5354 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5355 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5356 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5357 | sed -e "$sed_remove_make_variables"`
5358 tests_distributed_built_sources=`for file in $tests_built_sources; do
5359 case "$tests_cleaned_files" in
5365 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5367 ./configure || func_exit 1
5368 if test -n "$distributed_built_sources"; then
5370 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5371 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5376 if test -n "$tests_distributed_built_sources"; then
5378 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5379 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5384 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5391 # func_create_megatestdir megatestdir allmodules
5393 # - local_gnulib_dir from --local-dir
5394 # - modcache true or false, from --cache-modules/--no-cache-modules
5395 # - auxdir directory relative to destdir where to place build aux files
5396 func_create_megatestdir ()
5400 if test -z "$allmodules"; then
5401 allmodules=`func_all_modules`
5405 # First, all modules one by one.
5406 for onemodule in $allmodules; do
5407 func_create_testdir "$megatestdir/$onemodule" $onemodule
5408 func_append megasubdirs "$onemodule "
5410 # Then, all modules all together.
5411 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5412 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5413 func_create_testdir "$megatestdir/ALL" "$allmodules"
5414 func_append megasubdirs "ALL"
5417 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5418 vc_witness="$gnulib_dir/CVS/Entries"; \
5420 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5422 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5423 | sed -e 's,January,01,' -e 's,Jan,01,' \
5424 -e 's,February,02,' -e 's,Feb,02,' \
5425 -e 's,March,03,' -e 's,Mar,03,' \
5426 -e 's,April,04,' -e 's,Apr,04,' \
5428 -e 's,June,06,' -e 's,Jun,06,' \
5429 -e 's,July,07,' -e 's,Jul,07,' \
5430 -e 's,August,08,' -e 's,Aug,08,' \
5431 -e 's,September,09,' -e 's,Sep,09,' \
5432 -e 's,October,10,' -e 's,Oct,10,' \
5433 -e 's,November,11,' -e 's,Nov,11,' \
5434 -e 's,December,12,' -e 's,Dec,12,' \
5435 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5436 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5438 echo "CVSDATE=$cvsdate"
5439 echo ": \${MAKE=make}"
5440 echo "test -d logs || mkdir logs"
5441 echo "for module in $megasubdirs; do"
5442 echo " echo \"Working on module \$module...\""
5443 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5444 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5447 echo " : autobuild project... \$module"
5448 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5449 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5450 echo " : autobuild hostname... \`hostname\`"
5451 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5453 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5455 ) > "$megatestdir/do-autobuild"
5456 chmod a+x "$megatestdir/do-autobuild"
5458 # Create Makefile.am.
5459 (echo "## Process this file with automake to produce Makefile.in."
5461 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5463 echo "SUBDIRS = $megasubdirs"
5465 echo "EXTRA_DIST = do-autobuild"
5466 ) > "$megatestdir/Makefile.am"
5468 # Create configure.ac.
5469 (echo "# Process this file with autoconf to produce a configure script."
5470 echo "AC_INIT([dummy], [0])"
5471 if test "$auxdir" != "."; then
5472 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5474 echo "AM_INIT_AUTOMAKE"
5476 echo "AC_PROG_MAKE_SET"
5478 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5479 echo "AC_CONFIG_FILES([Makefile])"
5481 ) > "$megatestdir/configure.ac"
5483 # Create autogenerated files.
5485 # Do not use "${AUTORECONF} --install", because autoreconf operates
5486 # recursively, but the subdirectories are already finished, therefore
5487 # calling autoreconf here would only waste lots of CPU time.
5488 func_execute_command ${ACLOCAL} || func_exit 1
5489 func_execute_command mkdir build-aux
5490 func_execute_command ${AUTOCONF} || func_exit 1
5491 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5497 func_fatal_error "no mode specified" ;;
5504 # sed expression that converts a literal to a basic regular expression.
5505 # Needs to handle . [ \ * ^ $.
5506 sed_literal_to_basic_regex='s/\\/\\\\/g
5512 if test -f "$gnulib_dir/$filename" \
5513 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5514 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5515 filename_line_regex='^'"$filename_anywhere_regex"'$'
5518 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5519 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5520 (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$,,')
5523 | func_sanitize_modulelist \
5526 for module in $module_candidates; do
5527 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5532 func_warning "file $filename does not exist"
5537 import | add-import | remove-import | update )
5540 if test -z "$destdir"; then
5543 test -d "$destdir" \
5544 || func_fatal_error "destination directory does not exist: $destdir"
5546 # Prefer configure.ac to configure.in.
5547 if test -f "$destdir"/configure.ac; then
5548 configure_ac="$destdir/configure.ac"
5550 if test -f "$destdir"/configure.in; then
5551 configure_ac="$destdir/configure.in"
5553 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5557 # Analyze configure.ac.
5559 guessed_libtool=false
5564 /AC_CONFIG_AUX_DIR/ {
5565 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5567 /A[CM]_PROG_LIBTOOL/ {
5568 s,^.*$,guessed_libtool=true,p
5570 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5572 if test -z "$auxdir"; then
5573 auxdir="$guessed_auxdir"
5576 # Determine where to apply func_import.
5577 if test "$mode" = import; then
5578 # Apply func_import to a particular gnulib directory.
5579 # The command line contains the complete specification; don't look at
5580 # the contents of gnulib-cache.m4.
5581 test -n "$supplied_libname" || supplied_libname=true
5582 test -n "$sourcebase" || sourcebase="lib"
5583 test -n "$m4base" || m4base="m4"
5584 test -n "$docbase" || docbase="doc"
5585 test -n "$testsbase" || testsbase="tests"
5586 test -n "$macro_prefix" || macro_prefix="gl"
5589 if test -n "$m4base"; then
5590 # Apply func_import to a particular gnulib directory.
5591 # Any number of additional modules can be given.
5592 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5593 # First use of gnulib in the given m4base.
5594 test -n "$supplied_libname" || supplied_libname=true
5595 test -n "$sourcebase" || sourcebase="lib"
5596 test -n "$docbase" || docbase="doc"
5597 test -n "$testsbase" || testsbase="tests"
5598 test -n "$macro_prefix" || macro_prefix="gl"
5602 # Apply func_import to all gnulib directories.
5603 # To get this list of directories, look at Makefile.am. (Not at
5604 # configure, because it may be omitted from version control. Also,
5605 # don't run "find $destdir -name gnulib-cache.m4", as it might be
5609 if test -f "$destdir"/Makefile.am; then
5610 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5612 for arg in $aclocal_amflags; do
5613 if test -n "$m4dir_is_next"; then
5614 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5618 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5619 func_append m4dirs " $arg"
5620 m4dirs_count=`expr $m4dirs_count + 1`
5626 if test "X$arg" = "X-I"; then
5634 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5635 if test -f "$destdir"/aclocal.m4; then
5636 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5637 sedexpr2='s,^[^/]*$,.,'
5638 sedexpr3='s,/[^/]*$,,'
5639 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5640 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
5641 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
5644 if test $m4dirs_count = 0; then
5645 # First use of gnulib in a package.
5646 # Any number of additional modules can be given.
5647 test -n "$supplied_libname" || supplied_libname=true
5648 test -n "$sourcebase" || sourcebase="lib"
5650 test -n "$docbase" || docbase="doc"
5651 test -n "$testsbase" || testsbase="tests"
5652 test -n "$macro_prefix" || macro_prefix="gl"
5655 if test $m4dirs_count = 1; then
5656 # There's only one use of gnulib here. Assume the user means it.
5657 # Any number of additional modules can be given.
5658 for m4base in $m4dirs; do
5662 # Ambiguous - guess what the user meant.
5663 if test $# = 0; then
5664 # No further arguments. Guess the user wants to update all of them.
5665 for m4base in $m4dirs; do
5666 # Perform func_import in a subshell, so that variable values
5668 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5669 # inc_longrunning_tests, inc_privileged_tests,
5670 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5671 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5672 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5673 # don't propagate from one directory to another.
5674 (func_import) || func_exit 1
5678 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5687 if test -z "$destdir"; then
5688 func_fatal_error "please specify --dir option"
5691 test -d "$destdir" \
5692 || func_fatal_error "could not create destination directory"
5693 test -n "$auxdir" || auxdir="build-aux"
5694 func_create_testdir "$destdir" "$*"
5697 create-megatestdir )
5698 if test -z "$destdir"; then
5699 func_fatal_error "please specify --dir option"
5701 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5702 test -n "$auxdir" || auxdir="build-aux"
5703 func_create_megatestdir "$destdir" "$*"
5707 test -n "$destdir" || destdir=testdir$$
5708 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5709 test -n "$auxdir" || auxdir="build-aux"
5710 func_create_testdir "$destdir" "$*"
5714 ../configure || func_exit 1
5715 $MAKE || func_exit 1
5716 $MAKE check || func_exit 1
5717 $MAKE distclean || func_exit 1
5718 remaining=`find . -type f -print`
5719 if test -n "$remaining"; then
5720 echo "Remaining files:" $remaining 1>&2
5721 echo "gnulib-tool: *** Stop." 1>&2
5730 test -n "$destdir" || destdir=testdir$$
5731 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5732 test -n "$auxdir" || auxdir="build-aux"
5733 func_create_megatestdir "$destdir" "$*"
5741 remaining=`find . -type f -print`
5742 if test -n "$remaining"; then
5743 echo "Remaining files:" $remaining 1>&2
5744 echo "gnulib-tool: *** Stop." 1>&2
5752 extract-description )
5756 if test -n "$module"; then
5757 func_get_description "$module"
5766 if test -n "$module"; then
5767 func_get_comment "$module"
5776 if test -n "$module"; then
5777 func_get_status "$module"
5786 if test -n "$module"; then
5787 func_get_notice "$module"
5792 extract-applicability )
5796 if test -n "$module"; then
5797 func_get_applicability "$module"
5806 if test -n "$module"; then
5807 func_get_filelist "$module"
5812 extract-dependencies )
5816 if test -n "$module"; then
5817 func_get_dependencies "$module"
5822 extract-autoconf-snippet )
5826 if test -n "$module"; then
5827 func_get_autoconf_snippet "$module"
5832 extract-automake-snippet )
5836 if test -n "$module"; then
5837 func_get_automake_snippet "$module"
5842 extract-include-directive )
5846 if test -n "$module"; then
5847 func_get_include_directive "$module"
5852 extract-link-directive )
5856 if test -n "$module"; then
5857 func_get_link_directive "$module"
5866 if test -n "$module"; then
5867 func_get_license "$module"
5872 extract-maintainer )
5876 if test -n "$module"; then
5877 func_get_maintainer "$module"
5882 extract-tests-module )
5886 if test -n "$module"; then
5887 func_get_tests_module "$module"
5893 # Verify the number of arguments.
5894 if test $# -lt 1 || test $# -gt 2; then
5895 func_fatal_error "invalid number of arguments for --$mode"
5898 # The first argument is the file to be copied.
5900 # Verify the file exists.
5901 func_lookup_file "$f"
5903 # The second argument is the destination; either a directory ot a file.
5904 # It defaults to the current directory.
5906 test -n "$dest" || dest='.'
5907 test -n "$sourcebase" || sourcebase="lib"
5908 test -n "$m4base" || m4base="m4"
5909 test -n "$docbase" || docbase="doc"
5910 test -n "$testsbase" || testsbase="tests"
5911 test -n "$auxdir" || auxdir="build-aux"
5912 rewritten='%REWRITTEN%'
5913 sed_rewrite_files="\
5914 s,^build-aux/,$rewritten$auxdir/,
5915 s,^doc/,$rewritten$docbase/,
5916 s,^lib/,$rewritten$sourcebase/,
5917 s,^m4/,$rewritten$m4base/,
5918 s,^tests/,$rewritten$testsbase/,
5921 if test -d "$dest"; then
5923 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5925 destdir=`dirname "$dest"`
5926 g=`basename "$dest"`
5929 # Create the directory for destfile.
5930 d=`dirname "$destdir/$g"`
5932 if test -n "$d" && test ! -d "$d"; then
5933 mkdir -p "$d" || func_fatal_error "failed"
5937 func_dest_tmpfilename "$g"
5938 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5939 already_present=true
5940 if test -f "$destdir/$g"; then
5941 # The file already exists.
5945 # Don't protest if the file should be there but isn't: it happens
5946 # frequently that developers don't put autogenerated files under version
5954 func_fatal_error "unknown operation mode --$mode" ;;
5958 # Undo the effect of the previous 'trap' command. Some shellology:
5959 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5960 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5961 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5962 # 128 + signal number and is set before the trap-registered command is run.
5964 trap 'func_exit $?' 1 2 3 13 15
5969 # indent-tabs-mode: nil
5970 # whitespace-check-buffer-indent: nil