3 # Copyright (C) 2002-2011 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) ;;
2233 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2234 if test -n "$extra_files"; then
2235 echo "EXTRA_lib_SOURCES +=" $extra_files
2240 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2241 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2242 if test -n "$buildaux_files"; then
2243 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2244 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2247 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2248 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2249 if test -n "$top_files"; then
2250 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2251 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2258 # func_get_include_directive module
2260 # - local_gnulib_dir from --local-dir
2261 # - modcache true or false, from --cache-modules/--no-cache-modules
2262 func_get_include_directive ()
2265 if ! $modcache; then
2266 func_lookup_file "modules/$1"
2267 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2269 func_cache_lookup_module "$1"
2270 # Output the field's value, including the final newline (if any).
2271 if $have_associative; then
2272 if eval 'test -n "${modcache_include[$1]+set}"'; then
2273 eval 'echo "${modcache_include[$1]}"'
2276 eval "field_set=\"\$${cachevar}_include_set\""
2277 if test -n "$field_set"; then
2278 eval "field_value=\"\$${cachevar}_include\""
2279 echo "${field_value}"
2283 } | sed -e 's/^\(["<]\)/#include \1/'
2286 # func_get_link_directive module
2288 # - local_gnulib_dir from --local-dir
2289 # - modcache true or false, from --cache-modules/--no-cache-modules
2290 func_get_link_directive ()
2292 if ! $modcache; then
2293 func_lookup_file "modules/$1"
2294 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2296 func_cache_lookup_module "$1"
2297 # Output the field's value, including the final newline (if any).
2298 if $have_associative; then
2299 if eval 'test -n "${modcache_link[$1]+set}"'; then
2300 eval 'echo "${modcache_link[$1]}"'
2303 eval "field_set=\"\$${cachevar}_link_set\""
2304 if test -n "$field_set"; then
2305 eval "field_value=\"\$${cachevar}_link\""
2306 echo "${field_value}"
2312 # func_get_license module
2314 # - local_gnulib_dir from --local-dir
2315 # - modcache true or false, from --cache-modules/--no-cache-modules
2319 if ! $modcache; then
2320 func_lookup_file "modules/$1"
2321 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2323 func_cache_lookup_module "$1"
2324 # Output the field's value, including the final newline (if any).
2325 if $have_associative; then
2326 if eval 'test -n "${modcache_license[$1]+set}"'; then
2327 eval 'echo "${modcache_license[$1]}"'
2330 eval "field_set=\"\$${cachevar}_license_set\""
2331 if test -n "$field_set"; then
2332 eval "field_value=\"\$${cachevar}_license\""
2333 echo "${field_value}"
2337 # The default is GPL.
2339 } | sed -e 's,^ *$,,' | sed -e 1q
2342 # func_get_maintainer module
2344 # - local_gnulib_dir from --local-dir
2345 # - modcache true or false, from --cache-modules/--no-cache-modules
2346 func_get_maintainer ()
2348 if ! $modcache; then
2349 func_lookup_file "modules/$1"
2350 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2352 func_cache_lookup_module "$1"
2353 # Output the field's value, including the final newline (if any).
2354 if $have_associative; then
2355 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2356 eval 'echo "${modcache_maintainer[$1]}"'
2359 eval "field_set=\"\$${cachevar}_maintainer_set\""
2360 if test -n "$field_set"; then
2361 eval "field_value=\"\$${cachevar}_maintainer\""
2362 echo "${field_value}"
2368 # func_get_tests_module module
2370 # - local_gnulib_dir from --local-dir
2371 func_get_tests_module ()
2373 # The naming convention for tests modules is hardwired: ${module}-tests.
2374 if test -f "$gnulib_dir/modules/$1"-tests \
2375 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2376 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2381 # func_acceptable module
2382 # tests whether a module is acceptable.
2384 # - avoidlist list of modules to avoid
2387 for avoid in $avoidlist; do
2388 if test "$avoid" = "$1"; then
2395 # func_modules_transitive_closure
2397 # - local_gnulib_dir from --local-dir
2398 # - modcache true or false, from --cache-modules/--no-cache-modules
2399 # - modules list of specified modules
2400 # - inctests true if tests should be included, blank otherwise
2401 # - incobsolete true if obsolete modules among dependencies should be
2402 # included, blank otherwise
2403 # - inc_cxx_tests true if C++ interoperability tests should be included,
2405 # - inc_longrunning_tests true if long-runnings tests should be included,
2407 # - inc_privileged_tests true if tests that require root privileges should be
2408 # included, blank otherwise
2409 # - inc_unportable_tests true if tests that fail on some platforms should be
2410 # included, blank otherwise
2411 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2412 # the unit tests of the specified modules should be
2413 # included, blank otherwise
2414 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2415 # the unit tests of the dependencies should be
2416 # included, blank otherwise
2417 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2419 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2421 # - excl_privileged_tests true if tests that require root privileges should be
2422 # excluded, blank otherwise
2423 # - excl_unportable_tests true if tests that fail on some platforms should be
2424 # excluded, blank otherwise
2425 # - avoidlist list of modules to avoid
2426 # - tmp pathname of a temporary directory
2428 # - modules list of modules, including dependencies
2429 func_modules_transitive_closure ()
2431 # In order to process every module only once (for speed), process an "input
2432 # list" of modules, producing an "output list" of modules. During each round,
2433 # more modules can be queued in the input list. Once a module on the input
2434 # list has been processed, it is added to the "handled list", so we can avoid
2435 # to process it again.
2437 inmodules="$modules"
2439 fmtc_inc_all_tests="$inc_all_direct_tests"
2440 while test -n "$inmodules"; do
2441 inmodules_this_round="$inmodules"
2442 inmodules= # Accumulator, queue for next round
2443 for module in $inmodules_this_round; do
2445 if test -n "$module"; then
2446 if func_acceptable $module; then
2447 func_append outmodules " $module"
2448 deps=`func_get_dependencies $module`
2449 # Duplicate dependencies are harmless, but Jim wants a warning.
2450 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2451 if test -n "$duplicated_deps"; then
2452 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2454 if test -n "$inctests"; then
2455 testsmodule=`func_get_tests_module $module`
2456 if test -n "$testsmodule"; then
2457 deps="$deps $testsmodule"
2460 for dep in $deps; do
2461 # Determine whether to include the dependency or tests module.
2463 for word in `func_get_status $dep`; do
2466 test -n "$incobsolete" \
2470 test -z "$excl_cxx_tests" \
2472 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2476 test -z "$excl_longrunning_tests" \
2478 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2482 test -z "$excl_privileged_tests" \
2484 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2488 test -z "$excl_unportable_tests" \
2490 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2494 test -n "$fmtc_inc_all_tests" \
2500 func_append inmodules " $dep"
2506 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2507 # Remove $handledmodules from $inmodules.
2508 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2509 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2510 fmtc_inc_all_tests="$inc_all_indirect_tests"
2512 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2513 rm -f "$tmp"/queued-modules
2516 # func_show_module_list
2518 # - specified_modules list of specified modules (one per line, sorted)
2519 # - modules complete list of modules (one per line, sorted)
2520 # - tmp pathname of a temporary directory
2521 func_show_module_list ()
2527 # Assume xterm compatible escape sequences.
2528 bold_on=`printf '\x1b[1m'`
2529 bold_off=`printf '\x1b[0m'`
2534 echo "Module list with included dependencies (indented):"
2535 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2536 echo "$modules" | sed -e '/^$/d' \
2537 | LC_ALL=C join -t '|' -a 2 "$tmp"/specified-modules - \
2538 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2541 # func_modules_add_dummy
2543 # - local_gnulib_dir from --local-dir
2544 # - modcache true or false, from --cache-modules/--no-cache-modules
2545 # - modules list of modules, including dependencies
2547 # - modules list of modules, including 'dummy' if needed
2548 func_modules_add_dummy ()
2550 # Determine whether any module provides a lib_SOURCES augmentation.
2552 sed_remove_backslash_newline=':a
2559 for module in $modules; do
2560 func_verify_nontests_module
2561 if test -n "$module"; then
2562 # Extract the value of "lib_SOURCES += ...".
2563 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2564 # Ignore .h files since they are not compiled.
2568 have_lib_SOURCES=yes
2575 # Add the dummy module, to make sure the library will be non-empty.
2576 if test -z "$have_lib_SOURCES"; then
2577 if func_acceptable "dummy"; then
2578 func_append modules " dummy"
2583 # func_modules_notice
2585 # - local_gnulib_dir from --local-dir
2586 # - modcache true or false, from --cache-modules/--no-cache-modules
2587 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2588 # - modules list of modules, including dependencies
2589 func_modules_notice ()
2591 if test $verbose -ge -1; then
2592 for module in $modules; do
2594 if test -n "$module"; then
2595 msg=`func_get_notice $module`
2596 if test -n "$msg"; then
2597 echo "Notice from module $module:"
2598 echo "$msg" | sed -e 's/^/ /'
2605 # func_modules_to_filelist
2607 # - local_gnulib_dir from --local-dir
2608 # - modcache true or false, from --cache-modules/--no-cache-modules
2609 # - modules list of modules, including dependencies
2611 # - files list of files
2612 func_modules_to_filelist ()
2615 for module in $modules; do
2617 if test -n "$module"; then
2618 fs=`func_get_filelist $module`
2619 func_append files " $fs"
2622 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2625 # func_execute_command command [args...]
2626 # Executes a command.
2627 # Uses also the variables
2628 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2629 func_execute_command ()
2631 if test $verbose -ge 0; then
2635 # Commands like automake produce output to stderr even when they succeed.
2636 # Turn this output off if the command succeeds.
2637 "$@" > "$tmp"/cmdout 2>&1
2639 if test $cmdret = 0; then
2643 cat "$tmp"/cmdout 1>&2
2650 # func_dest_tmpfilename file
2651 # determines the name of a temporary file (file is relative to destdir).
2653 # - destdir target directory
2654 # - doit : if actions shall be executed, false if only to be printed
2655 # - tmp pathname of a temporary directory
2657 # - tmpfile absolute filename of the temporary file
2658 func_dest_tmpfilename ()
2661 # Put the new contents of $file in a file in the same directory (needed
2662 # to guarantee that an 'mv' to "$destdir/$file" works).
2663 tmpfile="$destdir/$1.tmp"
2665 # Put the new contents of $file in a file in a temporary directory
2666 # (because the directory of "$file" might not exist).
2667 tmpfile="$tmp"/`basename "$1"`.tmp
2672 # copies a file from gnulib into the destination directory. The destination
2673 # is known to not exist.
2675 # - destdir target directory
2676 # - local_gnulib_dir from --local-dir
2677 # - modcache true or false, from --cache-modules/--no-cache-modules
2678 # - f the original file name
2679 # - lookedup_file name of the merged (combined) file
2680 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2681 # - g the rewritten file name
2682 # - tmpfile absolute filename of the temporary file
2683 # - doit : if actions shall be executed, false if only to be printed
2684 # - symbolic true if files should be symlinked, copied otherwise
2685 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2690 echo "Copying file $g"
2691 if { test -n "$symbolic" \
2692 || { test -n "$lsymbolic" \
2693 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2694 && test -z "$lookedup_tmp" \
2695 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2696 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2698 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2706 # copies a file from gnulib into the destination directory. The destination
2707 # is known to exist.
2709 # - destdir target directory
2710 # - local_gnulib_dir from --local-dir
2711 # - modcache true or false, from --cache-modules/--no-cache-modules
2712 # - f the original file name
2713 # - lookedup_file name of the merged (combined) file
2714 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2715 # - g the rewritten file name
2716 # - tmpfile absolute filename of the temporary file
2717 # - doit : if actions shall be executed, false if only to be printed
2718 # - symbolic true if files should be symlinked, copied otherwise
2719 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2721 # - already_present nonempty if the file should already exist, empty otherwise
2724 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2725 : # The file has not changed.
2729 if test -n "$already_present"; then
2730 echo "Updating file $g (backup in ${g}~)"
2732 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2734 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2735 if { test -n "$symbolic" \
2736 || { test -n "$lsymbolic" \
2737 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2738 && test -z "$lookedup_tmp" \
2739 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2740 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2742 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2745 if test -n "$already_present"; then
2746 echo "Update file $g (backup in ${g}~)"
2748 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2754 # func_emit_lib_Makefile_am
2755 # emits the contents of library makefile to standard output.
2757 # - local_gnulib_dir from --local-dir
2758 # - modcache true or false, from --cache-modules/--no-cache-modules
2759 # - modules list of modules, including dependencies
2760 # - libname library name
2761 # - pobase directory relative to destdir where to place *.po files
2762 # - auxdir directory relative to destdir where to place build aux files
2763 # - makefile_name from --makefile-name
2764 # - libtool true if libtool will be used, false or blank otherwise
2765 # - macro_prefix prefix of gl_LIBOBJS macros to use
2766 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2767 # - actioncmd (optional) command that will reproduce this invocation
2768 # - for_test true if creating a package for testing, false otherwise
2769 # - destfile filename relative to destdir of makefile being generated
2771 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2772 # list of edits to be done to Makefile.am variables
2774 # - uses_subdirs nonempty if object files in subdirs exist
2775 func_emit_lib_Makefile_am ()
2777 # When creating an includable Makefile.am snippet, augment variables with
2778 # += instead of assigning them.
2779 if test -n "$makefile_name"; then
2784 if test "$libtool" = true; then
2787 sed_eliminate_LDFLAGS="$sed_noop"
2791 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2794 # When creating a package for testing: Attempt to provoke failures,
2795 # especially link errors, already during "make" rather than during
2796 # "make check", because "make check" is not possible in a cross-compiling
2797 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2798 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2800 sed_transform_check_PROGRAMS="$sed_noop"
2802 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2803 echo "## Process this file with automake to produce Makefile.in."
2804 func_emit_copyright_notice
2805 if test -n "$actioncmd"; then
2806 # The maximum line length (excluding the terminating newline) of any file
2807 # that is to be preprocessed by config.status is 3070. config.status uses
2808 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2809 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2810 len=`echo "$actioncmd" | wc -c`
2811 if test -n "$len" && test "$len" -le 3000; then
2812 echo "# Reproduce by: $actioncmd"
2818 if test false = "$libtool"; then
2819 sed_transform_libgnu_a="s, libgnu\\.a, $libname.a,g"
2821 sed_transform_libgnu_a="s, libgnu\\.a, $libname.la,g"
2823 for module in $modules; do
2824 func_verify_nontests_module
2825 if test -n "$module"; then
2827 func_get_automake_snippet "$module" |
2829 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2830 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2831 -e "$sed_eliminate_LDFLAGS" \
2832 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2833 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2834 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2835 -e "$sed_transform_libgnu_a" \
2836 -e "$sed_transform_check_PROGRAMS"
2837 if test "$module" = 'alloca'; then
2838 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2839 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2841 } > "$tmp"/amsnippet
2842 # Skip the contents if it's entirely empty.
2843 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2844 echo "## begin gnulib module $module"
2846 cat "$tmp"/amsnippet
2847 echo "## end gnulib module $module"
2850 rm -f "$tmp"/amsnippet
2851 # Test whether there are some source files in subdirectories.
2852 for f in `func_get_filelist "$module"`; do
2862 } > "$tmp"/allsnippets
2863 if test -z "$makefile_name"; then
2864 # If there are source files in subdirectories, prevent collision of the
2865 # object files (example: hash.c and libxml/hash.c).
2867 if test -n "$uses_subdirs"; then
2868 subdir_options=' subdir-objects'
2870 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2873 if test -z "$makefile_name"; then
2875 echo "nodist_pkginclude_HEADERS ="
2876 echo "nobase_nodist_pkginclude_HEADERS ="
2877 echo "noinst_HEADERS ="
2878 echo "noinst_LIBRARIES ="
2879 echo "noinst_LTLIBRARIES ="
2880 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2881 # if you specify pkgdata_DATA to empty. This is a workaround.
2882 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2883 echo "pkgdata_DATA ="
2886 echo "EXTRA_HEADERS ="
2887 echo "BUILT_SOURCES ="
2890 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2891 if test -z "$makefile_name"; then
2892 echo "MOSTLYCLEANDIRS ="
2894 echo "DISTCLEANFILES ="
2895 echo "MAINTAINERCLEANFILES ="
2897 # Execute edits that apply to the Makefile.am being generated.
2899 while test $edit != $makefile_am_edits; do
2900 edit=`expr $edit + 1`
2901 eval dir=\"\$makefile_am_edit${edit}_dir\"
2902 eval var=\"\$makefile_am_edit${edit}_var\"
2903 eval val=\"\$makefile_am_edit${edit}_val\"
2904 if test -n "$var"; then
2905 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2906 echo "${var} += ${val}"
2907 eval "makefile_am_edit${edit}_var="
2911 if test -z "$makefile_name"; then
2914 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
2916 echo "AM_CPPFLAGS ="
2921 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2922 || { test -n "$makefile_name" \
2923 && test -f "$sourcebase/Makefile.am" \
2924 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2926 # Install associated header files, per module Makefile.am snippets.
2927 sed_transform_HEADERS_primaries="$sed_noop"
2928 # One of the snippets or the user's Makefile.am already specifies an
2929 # installation location for the library. Don't confuse automake by saying
2930 # it should not be installed.
2933 # Don't install header files when generated library is not installed.
2934 sed_transform_HEADERS_primaries="\
2935 /^\(nobase_\)\{0,1\}nodist_pkginclude_HEADERS *=.*$/d
2936 /^EXTRA_HEADERS *=.*$/d
2938 # By default, the generated library should not be installed.
2939 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2942 echo "${libname}_${libext}_SOURCES ="
2943 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2944 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2945 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2946 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2947 echo "EXTRA_${libname}_${libext}_SOURCES ="
2948 if test "$libtool" = true; then
2949 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2950 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
2951 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
2952 # the link dependencies of all modules.
2953 for module in $modules; do
2954 func_verify_nontests_module
2955 if test -n "$module"; then
2956 func_get_link_directive "$module"
2959 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
2960 | LC_ALL=C sort -u \
2961 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
2964 if test -n "$pobase"; then
2965 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2968 cat "$tmp"/allsnippets \
2969 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g' \
2970 -e "$sed_transform_HEADERS_primaries"
2972 echo "mostlyclean-local: mostlyclean-generic"
2973 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2974 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2975 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2979 rm -f "$tmp"/allsnippets
2982 # func_emit_po_Makevars
2983 # emits the contents of po/ makefile parameterization to standard output.
2985 # - local_gnulib_dir from --local-dir
2986 # - modcache true or false, from --cache-modules/--no-cache-modules
2987 # - sourcebase directory relative to destdir where to place source code
2988 # - pobase directory relative to destdir where to place *.po files
2989 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2990 func_emit_po_Makevars ()
2992 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2993 func_emit_copyright_notice
2995 echo "# Usually the message domain is the same as the package name."
2996 echo "# But here it has a '-gnulib' suffix."
2997 echo "DOMAIN = ${po_domain}-gnulib"
2999 echo "# These two variables depend on the location of this directory."
3000 echo "subdir = ${pobase}"
3001 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3004 # These options get passed to xgettext.
3005 XGETTEXT_OPTIONS = \
3006 --keyword=_ --flag=_:1:pass-c-format \
3007 --keyword=N_ --flag=N_:1:pass-c-format \
3008 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3009 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3010 --flag=error:3:c-format --flag=error_at_line:5:c-format
3012 # This is the copyright holder that gets inserted into the header of the
3013 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3014 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3016 # This is the email address or URL to which the translators shall report
3017 # bugs in the untranslated strings:
3018 # - Strings which are not entire sentences, see the maintainer guidelines
3019 # in the GNU gettext documentation, section 'Preparing Strings'.
3020 # - Strings which use unclear terms or require additional context to be
3022 # - Strings which make invalid assumptions about notation of date, time or
3024 # - Pluralisation problems.
3025 # - Incorrect English spelling.
3026 # - Incorrect formatting.
3027 # It can be your email address, or a mailing list address where translators
3028 # can write to without being subscribed, or the URL of a web page through
3029 # which the translators can contact you.
3030 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3032 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3033 # message catalogs shall be used. It is usually empty.
3034 EXTRA_LOCALE_CATEGORIES =
3036 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3037 # context. Possible values are "yes" and "no". Set this to yes if the
3038 # package uses functions taking also a message context, like pgettext(), or
3039 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3044 # func_emit_po_POTFILES_in
3045 # emits the file list to be passed to xgettext to standard output.
3047 # - local_gnulib_dir from --local-dir
3048 # - modcache true or false, from --cache-modules/--no-cache-modules
3049 # - sourcebase directory relative to destdir where to place source code
3050 # - files list of new files
3051 func_emit_po_POTFILES_in ()
3053 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3054 func_emit_copyright_notice
3056 echo "# List of files which contain translatable strings."
3057 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3060 # func_emit_tests_Makefile_am witness_macro
3061 # emits the contents of tests makefile to standard output.
3063 # - local_gnulib_dir from --local-dir
3064 # - modcache true or false, from --cache-modules/--no-cache-modules
3065 # - modules list of modules, including dependencies
3066 # - libname library name
3067 # - auxdir directory relative to destdir where to place build aux files
3068 # - makefile_name from --makefile-name
3069 # - libtool true if libtool will be used, false or blank otherwise
3070 # - sourcebase relative directory containing lib source code
3071 # - m4base relative directory containing autoconf macros
3072 # - testsbase relative directory containing unit test code
3073 # - macro_prefix prefix of gl_LIBOBJS macros to use
3074 # - for_test true if creating a package for testing, false otherwise
3075 # - use_libtests true if a libtests.a should be built, false otherwise
3076 # - destfile filename relative to destdir of makefile being generated
3078 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3079 # list of edits to be done to Makefile.am variables
3081 # - uses_subdirs nonempty if object files in subdirs exist
3082 func_emit_tests_Makefile_am ()
3085 if test "$libtool" = true; then
3087 sed_eliminate_LDFLAGS="$sed_noop"
3090 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3093 # When creating a package for testing: Attempt to provoke failures,
3094 # especially link errors, already during "make" rather than during
3095 # "make check", because "make check" is not possible in a cross-compiling
3096 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3097 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3099 sed_transform_check_PROGRAMS="$sed_noop"
3101 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3102 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3103 echo "## Process this file with automake to produce Makefile.in."
3104 func_emit_copyright_notice
3108 for module in $modules; do
3110 func_verify_tests_module
3114 if test -n "$module"; then
3116 func_get_automake_snippet "$module" |
3118 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3119 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3120 -e "$sed_eliminate_LDFLAGS" \
3121 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3122 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3123 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3124 -e "$sed_transform_check_PROGRAMS"
3125 if $use_libtests && test "$module" = 'alloca'; then
3126 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3127 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3129 } > "$tmp"/amsnippet
3130 # Skip the contents if it's entirely empty.
3131 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3132 # Mention long-running tests at the end.
3134 for word in `func_get_status "$module"`; do
3135 if test "$word" = 'longrunning-test'; then
3140 { echo "## begin gnulib module $module"
3142 cat "$tmp"/amsnippet
3143 echo "## end gnulib module $module"
3147 rm -f "$tmp"/amsnippet
3148 # Test whether there are some source files in subdirectories.
3149 for f in `func_get_filelist "$module"`; do
3151 lib/*/*.c | tests/*/*.c)
3159 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3160 # Generate dependencies here, since it eases the debugging of test failures.
3161 # If there are source files in subdirectories, prevent collision of the
3162 # object files (example: hash.c and libxml/hash.c).
3164 if test -n "$uses_subdirs"; then
3165 subdir_options=' subdir-objects'
3167 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3170 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3173 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3174 # variable is needed to avoid an error from automake:
3175 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3178 echo "XFAIL_TESTS ="
3179 echo "TESTS_ENVIRONMENT ="
3180 echo "noinst_PROGRAMS ="
3181 if ! $for_test; then
3182 echo "check_PROGRAMS ="
3184 echo "nodist_pkginclude_HEADERS ="
3185 echo "nobase_nodist_pkginclude_HEADERS ="
3186 echo "noinst_HEADERS ="
3187 echo "noinst_LIBRARIES ="
3188 if $use_libtests; then
3190 echo "noinst_LIBRARIES += libtests.a"
3192 echo "check_LIBRARIES = libtests.a"
3195 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3196 # if you specify pkgdata_DATA to empty. This is a workaround.
3197 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3198 echo "pkgdata_DATA ="
3201 echo "EXTRA_HEADERS ="
3202 echo "BUILT_SOURCES ="
3204 echo "MOSTLYCLEANFILES = core *.stackdump"
3205 echo "MOSTLYCLEANDIRS ="
3207 echo "DISTCLEANFILES ="
3208 echo "MAINTAINERCLEANFILES ="
3209 # Execute edits that apply to the Makefile.am being generated.
3211 while test $edit != $makefile_am_edits; do
3212 edit=`expr $edit + 1`
3213 eval dir=\"\$makefile_am_edit${edit}_dir\"
3214 eval var=\"\$makefile_am_edit${edit}_var\"
3215 eval val=\"\$makefile_am_edit${edit}_val\"
3216 if test -n "$var"; then
3217 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3218 echo "${var} += ${val}"
3219 eval "makefile_am_edit${edit}_var="
3224 echo "AM_CPPFLAGS = \\"
3226 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3228 if test -n "${witness_macro}"; then
3229 echo " -D@${witness_macro}@=1 \\"
3231 echo " -I. -I\$(srcdir) \\"
3232 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3233 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3235 local_ldadd_before=''
3236 local_ldadd_after=''
3237 if $use_libtests; then
3238 # All test programs need to be linked with libtests.a.
3239 # It needs to be passed to the linker before ${libname}.${libext}, since
3240 # the tests-related modules depend on the main modules.
3241 # It also needs to be passed to the linker after ${libname}.${libext}
3242 # because the latter might contain incomplete modules (such as the 'error'
3243 # module whose dependency to 'progname' is voluntarily omitted).
3244 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3246 local_ldadd_before=' libtests.a'
3247 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3249 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3251 if $use_libtests; then
3252 echo "libtests_a_SOURCES ="
3253 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3254 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3255 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3256 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3257 echo "EXTRA_libtests_a_SOURCES ="
3258 # The circular dependency in LDADD requires this.
3259 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3262 # Many test scripts use ${EXEEXT} or ${srcdir}.
3263 # EXEEXT is defined by AC_PROG_CC through autoconf.
3264 # srcdir is defined by autoconf and automake.
3265 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3267 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3268 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3269 echo "# Clean up after Solaris cc."
3271 echo " rm -rf SunWS_cache"
3273 echo "mostlyclean-local: mostlyclean-generic"
3274 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3275 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3276 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3280 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3283 # func_emit_initmacro_start macro_prefix
3284 # emits the first 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_start ()
3288 macro_prefix_arg="$1"
3289 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3290 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3291 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3292 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3294 # Furthermore it avoids an automake error like this when a Makefile.am
3295 # that uses pieces of gnulib also uses $(LIBOBJ):
3296 # automatically discovered file `error.c' should not be explicitly mentioned
3297 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3298 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3299 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3300 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3301 # automatically discovered file `error.c' should not be explicitly mentioned
3302 # We let automake know about the files to be distributed through the
3303 # EXTRA_lib_SOURCES variable.
3304 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3305 # Create data variables for checking the presence of files that are mentioned
3306 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3307 # because we want the check to happen when the configure file is created,
3308 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3309 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3310 # in which to expect them.
3311 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3312 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3316 # func_emit_initmacro_end macro_prefix
3317 # emits the last few statements of the gl_INIT macro to standard output.
3318 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3319 func_emit_initmacro_end ()
3321 macro_prefix_arg="$1"
3322 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3323 # The check is performed only when autoconf is run from the directory where
3324 # the configure.ac resides; if it is run from a different directory, the
3326 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3327 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3328 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3329 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3330 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3334 echo " m4_if(m4_sysval, [0], [],"
3335 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3337 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3338 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3339 echo " m4_popdef([AC_LIBSOURCES])"
3340 echo " m4_popdef([AC_REPLACE_FUNCS])"
3341 echo " m4_popdef([AC_LIBOBJ])"
3342 echo " AC_CONFIG_COMMANDS_PRE(["
3343 echo " ${macro_prefix_arg}_libobjs="
3344 echo " ${macro_prefix_arg}_ltlibobjs="
3345 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3346 echo " # Remove the extension."
3347 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3348 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3349 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3350 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3353 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3354 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3358 # func_emit_initmacro_done macro_prefix sourcebase
3359 # emits a few statements after the gl_INIT macro to standard output.
3360 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3361 # - sourcebase directory relative to destdir where to place source code
3362 func_emit_initmacro_done ()
3364 macro_prefix_arg="$1"
3367 echo "# Like AC_LIBOBJ, except that the module name goes"
3368 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3369 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3370 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3371 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3374 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3375 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3376 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3377 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3378 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3381 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3382 echo "# expected is derived from the gnulib-tool parameterization,"
3383 echo "# and alloca is special cased (for the alloca-opt module)."
3384 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3385 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3386 echo " m4_foreach([_gl_NAME], [\$1], ["
3387 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3388 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3389 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3395 # func_import modules
3396 # Uses also the variables
3397 # - mode import or add-import or remove-import or update
3398 # - destdir target directory
3399 # - local_gnulib_dir from --local-dir
3400 # - modcache true or false, from --cache-modules/--no-cache-modules
3401 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3402 # - libname library name
3403 # - supplied_libname true if --lib was given, blank otherwise
3404 # - sourcebase directory relative to destdir where to place source code
3405 # - m4base directory relative to destdir where to place *.m4 macros
3406 # - pobase directory relative to destdir where to place *.po files
3407 # - docbase directory relative to destdir where to place doc files
3408 # - testsbase directory relative to destdir where to place unit test code
3409 # - auxdir directory relative to destdir where to place build aux files
3410 # - inctests true if --with-tests was given, blank otherwise
3411 # - incobsolete true if --with-obsolete was given, blank otherwise
3412 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3413 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3415 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3417 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3419 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3420 # - avoidlist list of modules to avoid, from --avoid
3421 # - lgpl yes or a number if library's license shall be LGPL,
3423 # - makefile_name from --makefile-name
3424 # - libtool true if --libtool was given, false if --no-libtool was
3425 # given, blank otherwise
3426 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3427 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3428 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3429 # - vc_files true if --vc-files was given, false if --no-vc-files was
3430 # given, blank otherwise
3431 # - autoconf_minversion minimum supported autoconf version
3432 # - doit : if actions shall be executed, false if only to be printed
3433 # - symbolic true if files should be symlinked, copied otherwise
3434 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3436 # - do_copyrights true if copyright notices in files should be replaced,
3440 # Get the cached settings.
3441 # In 'import' mode, we read them only for the purpose of knowing the old
3442 # installed file list, and don't use them as defaults.
3443 cached_local_gnulib_dir=
3444 cached_specified_modules=
3446 cached_inc_cxx_tests=
3447 cached_inc_longrunning_tests=
3448 cached_inc_privileged_tests=
3449 cached_inc_unportable_tests=
3450 cached_inc_all_tests=
3460 cached_makefile_name=
3462 cached_macro_prefix=
3466 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3467 cached_libtool=false
3473 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3483 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3485 /gl_WITH_OBSOLETE/ {
3486 s,^.*$,cached_incobsolete=true,p
3488 /gl_WITH_CXX_TESTS/ {
3489 s,^.*$,cached_inc_cxx_tests=true,p
3491 /gl_WITH_LONGRUNNING_TESTS/ {
3492 s,^.*$,cached_inc_longrunning_tests=true,p
3494 /gl_WITH_PRIVILEGED_TESTS/ {
3495 s,^.*$,cached_inc_privileged_tests=true,p
3497 /gl_WITH_UNPORTABLE_TESTS/ {
3498 s,^.*$,cached_inc_unportable_tests=true,p
3500 /gl_WITH_ALL_TESTS/ {
3501 s,^.*$,cached_inc_all_tests=true,p
3504 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3507 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3510 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3513 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3516 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3519 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3522 s,^.*$,cached_inctests=true,p
3525 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3528 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3531 s,^.*$,cached_lgpl=yes,p
3533 /gl_MAKEFILE_NAME(/ {
3534 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3537 s,^.*$,cached_libtool=true,p
3539 /gl_MACRO_PREFIX(/ {
3540 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3543 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3546 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3548 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3549 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3554 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3555 s,^.*$,cached_files=",p
3568 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3572 if test "$mode" = import; then
3573 # In 'import' mode, the new set of specified modules overrides the cached
3574 # set of modules. Ignore the cached settings.
3575 specified_modules="$1"
3577 # Merge the cached settings with the specified ones.
3578 # The m4base must be the same as expected from the pathname.
3579 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3580 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3582 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3583 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3584 if test -z "$local_gnulib_dir"; then
3585 if test -n "$cached_local_gnulib_dir"; then
3588 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3590 case "$cached_local_gnulib_dir" in
3592 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3594 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3595 local_gnulib_dir="$relconcat" ;;
3602 # Append the cached and the specified module names. So that
3603 # "gnulib-tool --add-import foo" means to add the module foo.
3604 specified_modules="$cached_specified_modules $1"
3607 # Take the cached module names, minus the specified module names.
3609 if $have_associative; then
3610 # Use an associative array, for O(N) worst-case run time.
3611 declare -A to_remove
3613 eval 'to_remove[$m]=yes'
3615 for module in $cached_specified_modules; do
3616 if eval 'test -z "${to_remove[$module]}"'; then
3617 func_append specified_modules "$module "
3621 # This loop has O(N²) worst-case run time.
3622 for module in $cached_specified_modules; do
3625 if test "$m" = "$module"; then
3630 if test -z "$to_remove"; then
3631 func_append specified_modules "$module "
3637 # Take the cached module names. There are no specified module names.
3638 specified_modules="$cached_specified_modules"
3641 # Included obsolete modules among the dependencies if specified either way.
3642 if test -z "$incobsolete"; then
3643 incobsolete="$cached_incobsolete"
3645 # Included special kinds of tests modules among the dependencies if specified
3647 if test -z "$inc_cxx_tests"; then
3648 inc_cxx_tests="$cached_inc_cxx_tests"
3650 if test -z "$inc_longrunning_tests"; then
3651 inc_longrunning_tests="$cached_inc_longrunning_tests"
3653 if test -z "$inc_privileged_tests"; then
3654 inc_privileged_tests="$cached_inc_privileged_tests"
3656 if test -z "$inc_unportable_tests"; then
3657 inc_unportable_tests="$cached_inc_unportable_tests"
3659 if test -z "$inc_all_tests"; then
3660 inc_all_tests="$cached_inc_all_tests"
3662 # Append the cached and the specified avoidlist. This is probably better
3663 # than dropping the cached one when --avoid is specified at least once.
3664 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3665 avoidlist=`echo $avoidlist`
3667 # The sourcebase defaults to the cached one.
3668 if test -z "$sourcebase"; then
3669 sourcebase="$cached_sourcebase"
3670 if test -z "$sourcebase"; then
3671 func_fatal_error "missing --source-base option"
3674 # The pobase defaults to the cached one.
3675 if test -z "$pobase"; then
3676 pobase="$cached_pobase"
3678 # The docbase defaults to the cached one.
3679 if test -z "$docbase"; then
3680 docbase="$cached_docbase"
3681 if test -z "$docbase"; then
3682 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."
3685 # The testsbase defaults to the cached one.
3686 if test -z "$testsbase"; then
3687 testsbase="$cached_testsbase"
3688 if test -z "$testsbase"; then
3689 func_fatal_error "missing --tests-base option"
3692 # Require the tests if specified either way.
3693 if test -z "$inctests"; then
3694 inctests="$cached_inctests"
3696 # The libname defaults to the cached one.
3697 if test -z "$supplied_libname"; then
3698 libname="$cached_libname"
3699 if test -z "$libname"; then
3700 func_fatal_error "missing --lib option"
3703 # Require LGPL if specified either way.
3704 if test -z "$lgpl"; then
3707 # The makefile_name defaults to the cached one.
3708 if test -z "$makefile_name"; then
3709 makefile_name="$cached_makefile_name"
3711 # Use libtool if specified either way, or if guessed.
3712 if test -z "$libtool"; then
3713 if test -n "$cached_m4base"; then
3714 libtool="$cached_libtool"
3716 libtool="$guessed_libtool"
3719 # The macro_prefix defaults to the cached one.
3720 if test -z "$macro_prefix"; then
3721 macro_prefix="$cached_macro_prefix"
3722 if test -z "$macro_prefix"; then
3723 func_fatal_error "missing --macro-prefix option"
3726 # The po_domain defaults to the cached one.
3727 if test -z "$po_domain"; then
3728 po_domain="$cached_po_domain"
3730 # The vc_files defaults to the cached one.
3731 if test -z "$vc_files"; then
3732 vc_files="$cached_vc_files"
3735 # --without-*-tests options are not supported here.
3737 excl_longrunning_tests=
3738 excl_privileged_tests=
3739 excl_unportable_tests=
3741 # Canonicalize the list of specified modules.
3742 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3744 # Include all kinds of tests modules if --with-all-tests was specified.
3745 inc_all_direct_tests="$inc_all_tests"
3746 inc_all_indirect_tests="$inc_all_tests"
3748 # Determine final module list.
3749 modules="$specified_modules"
3750 func_modules_transitive_closure
3751 if test $verbose -ge 0; then
3752 func_show_module_list
3754 final_modules="$modules"
3756 # Determine main module list and tests-related module list separately.
3757 # The main module list is the transitive closure of the specified modules,
3758 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3759 # is specified, it will consist only of LGPLed source.
3760 # The tests-related module list is the transitive closure of the specified
3761 # modules, including tests modules, minus the main module list excluding
3762 # modules of applicability 'all'. Its lib/* sources (brought in through
3763 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3764 # source, even if --lgpl is specified.
3765 # Determine main module list.
3766 saved_inctests="$inctests"
3768 modules="$specified_modules"
3769 func_modules_transitive_closure
3770 main_modules="$modules"
3771 inctests="$saved_inctests"
3772 if test $verbose -ge 1; then
3773 echo "Main module list:"
3774 echo "$main_modules" | sed -e 's/^/ /'
3776 # Determine tests-related module list.
3777 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3778 testsrelated_modules=`for module in $main_modules; do
3779 if test \`func_get_applicability $module\` = main; then
3783 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3784 if test $verbose -ge 1; then
3785 echo "Tests-related module list:"
3786 echo "$testsrelated_modules" | sed -e 's/^/ /'
3789 # Add the dummy module to the main module list if needed.
3790 modules="$main_modules"
3791 func_modules_add_dummy
3792 main_modules="$modules"
3794 # Determine whether a $testsbase/libtests.a is needed.
3796 for module in $testsrelated_modules; do
3797 func_verify_nontests_module
3798 if test -n "$module"; then
3799 all_files=`func_get_filelist $module`
3800 # Test whether some file in $all_files lies in lib/.
3801 for f in $all_files; do
3812 # Add the dummy module to the tests-related module list if needed.
3813 if $use_libtests; then
3814 modules="$testsrelated_modules"
3815 func_modules_add_dummy
3816 testsrelated_modules="$modules"
3819 # If --lgpl, verify that the licenses of modules are compatible.
3820 if test -n "$lgpl"; then
3821 license_incompatibilities=
3822 for module in $main_modules; do
3823 license=`func_get_license $module`
3825 'GPLed build tool') ;;
3826 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3831 LGPL | LGPLv2+ | LGPLv3+) ;;
3832 *) func_append license_incompatibilities "$module $license$nl" ;;
3838 *) func_append license_incompatibilities "$module $license$nl" ;;
3841 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3846 if test -n "$license_incompatibilities"; then
3847 # Format the license incompatibilities as a table.
3848 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3849 s,^\(.................................................[^ ]*\) *, \1 ,'
3850 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3851 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3855 # Show banner notice of every module.
3856 modules="$main_modules"
3859 # Determine script to apply to imported library files.
3860 sed_transform_lib_file=
3861 for module in $main_modules; do
3862 if test $module = config-h; then
3863 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3864 sed_transform_lib_file=$sed_transform_lib_file'
3865 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3870 test -n "${macro_prefix}" && sed_transform_lib_file=$sed_transform_lib_file"
3871 s/_GL_\(.*\)_H/_${macro_prefix}_GL_\1_H/g
3873 sed_transform_main_lib_file="$sed_transform_lib_file"
3874 if test -n "$do_copyrights"; then
3875 if test -n "$lgpl"; then
3879 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3880 s/GNU General/GNU Lesser General/g
3884 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3885 s/GNU General/GNU Lesser General/g
3886 s/version [23]\([ ,]\)/version 2.1\1/g
3889 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3893 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3894 s/GNU Lesser General/GNU General/g
3895 s/GNU Library General/GNU General/g
3896 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3901 # Determine script to apply to auxiliary files that go into $auxdir/.
3902 sed_transform_build_aux_file=
3903 if test -n "$do_copyrights"; then
3905 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3906 s/GNU Lesser General/GNU General/g
3907 s/GNU Library General/GNU General/g
3908 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3911 test -n "${macro_prefix}" \
3912 && sed_transform_build_aux_file=$sed_transform_build_aux_file"
3913 s/_GL_\(.*\)_H/_${macro_prefix}_GL_\1_H/g
3916 # Determine script to apply to library files that go into $testsbase/.
3917 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3918 if test -n "$do_copyrights"; then
3920 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3921 s/GNU Lesser General/GNU General/g
3922 s/GNU Library General/GNU General/g
3923 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3927 # Determine the final file lists.
3928 # They must be computed separately, because files in lib/* go into
3929 # $sourcebase/ if they are in the main file list but into $testsbase/
3930 # if they are in the tests-related file list. Furthermore lib/dummy.c
3932 # Determine final main file list.
3933 modules="$main_modules"
3934 func_modules_to_filelist
3936 # Determine final tests-related file list.
3937 modules="$testsrelated_modules"
3938 func_modules_to_filelist
3939 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3940 # Merge both file lists.
3941 sed_remove_empty_lines='/^$/d'
3942 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3943 if test $verbose -ge 0; then
3945 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3946 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3950 || func_fatal_error "refusing to do nothing"
3952 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3953 new_files="$files m4/gnulib-tool.m4"
3954 old_files="$cached_files"
3955 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3956 func_append old_files " m4/gnulib-tool.m4"
3959 rewritten='%REWRITTEN%'
3960 sed_rewrite_old_files="\
3961 s,^build-aux/,$rewritten$auxdir/,
3962 s,^doc/,$rewritten$cached_docbase/,
3963 s,^lib/,$rewritten$cached_sourcebase/,
3964 s,^m4/,$rewritten$cached_m4base/,
3965 s,^tests/,$rewritten$cached_testsbase/,
3966 s,^tests=lib/,$rewritten$cached_testsbase/,
3969 sed_rewrite_new_files="\
3970 s,^build-aux/,$rewritten$auxdir/,
3971 s,^doc/,$rewritten$docbase/,
3972 s,^lib/,$rewritten$sourcebase/,
3973 s,^m4/,$rewritten$m4base/,
3974 s,^tests/,$rewritten$testsbase/,
3975 s,^tests=lib/,$rewritten$testsbase/,
3979 # Create directories.
3980 { echo "$sourcebase"
3982 if test -n "$pobase"; then
3985 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3986 if test -n "$docfiles"; then
3989 if test -n "$inctests"; then
3993 for f in $files; do echo $f; done \
3994 | sed -e "$sed_rewrite_new_files" \
3995 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3998 { # Rearrange file descriptors. Needed because "while ... done < ..."
3999 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4000 exec 5<&0 < "$tmp"/dirs
4002 if test ! -d "$destdir/$d"; then
4004 echo "Creating directory $destdir/$d"
4005 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4007 echo "Create directory $destdir/$d"
4014 # Copy files or make symbolic links. Remove obsolete files.
4018 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4019 # representing the files according to the last gnulib-tool invocation.
4020 for f in $old_files; do echo $f; done \
4021 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4024 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4025 # representing the files after this gnulib-tool invocation.
4026 for f in $new_files; do echo $f; done \
4027 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4030 # First the files that are in old-files, but not in new-files:
4031 sed_take_first_column='s,'"$delimiter"'.*,,'
4032 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4033 # Remove the file. Do nothing if the user already removed it.
4034 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4036 echo "Removing file $g (backup in ${g}~)"
4037 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4039 echo "Remove file $g (backup in ${g}~)"
4041 func_append removed_files "$g$nl"
4044 # func_add_or_update handles a file that ought to be present afterwards.
4046 # - f the original file name
4047 # - g the rewritten file name
4048 # - already_present nonempty if the file should already exist, empty
4050 func_add_or_update ()
4054 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4056 func_dest_tmpfilename "$g"
4057 func_lookup_file "$f"
4058 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4059 if test -n "$sed_transform_main_lib_file"; then
4062 sed -e "$sed_transform_main_lib_file" \
4063 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4067 if test -n "$sed_transform_build_aux_file"; then
4070 sed -e "$sed_transform_build_aux_file" \
4071 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4075 if test -n "$sed_transform_testsrelated_lib_file"; then
4078 sed -e "$sed_transform_testsrelated_lib_file" \
4079 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4083 if test -f "$destdir/$g"; then
4084 # The file already exists.
4088 # Don't protest if the file should be there but isn't: it happens
4089 # frequently that developers don't put autogenerated files under version control.
4091 func_append added_files "$g$nl"
4095 # Then the files that are in new-files, but not in old-files:
4096 sed_take_last_column='s,^.*'"$delimiter"',,'
4098 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4099 | sed -e "$sed_take_last_column" \
4100 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4101 { # Rearrange file descriptors. Needed because "while ... done < ..."
4102 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4103 exec 5<&0 < "$tmp"/added-files
4109 # Then the files that are in new-files and in old-files:
4110 already_present=true
4111 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4112 | sed -e "$sed_take_last_column" \
4113 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4114 { # Rearrange file descriptors. Needed because "while ... done < ..."
4115 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4116 exec 5<&0 < "$tmp"/kept-files
4123 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4124 actioncmd="gnulib-tool --import"
4125 func_append actioncmd " --dir=$destdir"
4126 if test -n "$local_gnulib_dir"; then
4127 func_append actioncmd " --local-dir=$local_gnulib_dir"
4129 func_append actioncmd " --lib=$libname"
4130 func_append actioncmd " --source-base=$sourcebase"
4131 func_append actioncmd " --m4-base=$m4base"
4132 if test -n "$pobase"; then
4133 func_append actioncmd " --po-base=$pobase"
4135 func_append actioncmd " --doc-base=$docbase"
4136 func_append actioncmd " --tests-base=$testsbase"
4137 func_append actioncmd " --aux-dir=$auxdir"
4138 if test -n "$inctests"; then
4139 func_append actioncmd " --with-tests"
4141 if test -n "$incobsolete"; then
4142 func_append actioncmd " --with-obsolete"
4144 if test -n "$inc_cxx_tests"; then
4145 func_append actioncmd " --with-c++-tests"
4147 if test -n "$inc_longrunning_tests"; then
4148 func_append actioncmd " --with-longrunning-tests"
4150 if test -n "$inc_privileged_tests"; then
4151 func_append actioncmd " --with-privileged-tests"
4153 if test -n "$inc_unportable_tests"; then
4154 func_append actioncmd " --with-unportable-tests"
4156 if test -n "$inc_all_tests"; then
4157 func_append actioncmd " --with-all-tests"
4159 for module in $avoidlist; do
4160 func_append actioncmd " --avoid=$module"
4162 if test -n "$lgpl"; then
4163 if test "$lgpl" = yes; then
4164 func_append actioncmd " --lgpl"
4166 func_append actioncmd " --lgpl=$lgpl"
4169 if test -n "$makefile_name"; then
4170 func_append actioncmd " --makefile-name=$makefile_name"
4172 if test "$libtool" = true; then
4173 func_append actioncmd " --libtool"
4175 func_append actioncmd " --no-libtool"
4177 func_append actioncmd " --macro-prefix=$macro_prefix"
4178 if test -n "$po_domain"; then
4179 func_append actioncmd " --po-domain=$po_domain"
4181 if test -n "$vc_files"; then
4182 if test "$vc_files" = true; then
4183 func_append actioncmd " --vc-files"
4185 func_append actioncmd " --no-vc-files"
4188 func_append actioncmd " `echo $specified_modules`"
4190 # Default the makefile name to Makefile.am.
4191 if test -n "$makefile_name"; then
4192 makefile_am=$makefile_name
4194 makefile_am=Makefile.am
4197 # Create normal Makefile.ams.
4200 # Setup list of Makefile.am edits that are to be performed afterwards.
4201 # Some of these edits apply to files that we will generate; others are
4202 # under the responsibility of the developer.
4204 # func_note_Makefile_am_edit dir var value
4205 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4207 func_note_Makefile_am_edit ()
4209 makefile_am_edits=`expr $makefile_am_edits + 1`
4210 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4211 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4212 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4214 if test "$makefile_am" = Makefile.am; then
4215 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4216 sourcebase_base=`basename "$sourcebase"`
4217 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4219 if test -n "$pobase"; then
4220 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4221 pobase_base=`basename "$pobase"`
4222 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4224 if test -n "$inctests"; then
4225 if test "$makefile_am" = Makefile.am; then
4226 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4227 testsbase_base=`basename "$testsbase"`
4228 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4231 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4233 # Find the first parent directory of $m4base that contains or will contain
4235 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4237 sed_butlast='s,[^/][^/]*//*$,,'
4238 dir1="${m4base}/"; dir2=""
4239 while test -n "$dir1" \
4240 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4241 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4242 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4243 || { test -n "$inctests" \
4244 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4245 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4246 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4247 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4249 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4252 # Create library makefile.
4253 func_dest_tmpfilename $sourcebase/$makefile_am
4254 destfile="$sourcebase/$makefile_am"
4255 modules="$main_modules"
4256 func_emit_lib_Makefile_am > "$tmpfile"
4257 if test -f "$destdir"/$sourcebase/$makefile_am; then
4258 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4262 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4263 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4264 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4266 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4272 echo "Creating $sourcebase/$makefile_am"
4273 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4275 echo "Create $sourcebase/$makefile_am"
4278 func_append added_files "$sourcebase/$makefile_am$nl"
4281 # Create po/ directory.
4282 if test -n "$pobase"; then
4283 # Create po makefile and auxiliary files.
4284 for file in Makefile.in.in remove-potcdate.sin; do
4285 func_dest_tmpfilename $pobase/$file
4286 func_lookup_file build-aux/po/$file
4287 cat "$lookedup_file" > "$tmpfile"
4288 if test -f "$destdir"/$pobase/$file; then
4289 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4293 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4294 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4295 mv -f "$tmpfile" "$destdir"/$pobase/$file
4297 echo "Update $pobase/$file (backup in $pobase/$file~)"
4303 echo "Creating $pobase/$file"
4304 mv -f "$tmpfile" "$destdir"/$pobase/$file
4306 echo "Create $pobase/$file"
4309 func_append added_files "$pobase/$file$nl"
4312 # Create po makefile parameterization, part 1.
4313 func_dest_tmpfilename $pobase/Makevars
4314 func_emit_po_Makevars > "$tmpfile"
4315 if test -f "$destdir"/$pobase/Makevars; then
4316 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4320 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4321 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4322 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4324 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4330 echo "Creating $pobase/Makevars"
4331 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4333 echo "Create $pobase/Makevars"
4336 func_append added_files "$pobase/Makevars$nl"
4338 # Create po makefile parameterization, part 2.
4339 func_dest_tmpfilename $pobase/POTFILES.in
4340 func_emit_po_POTFILES_in > "$tmpfile"
4341 if test -f "$destdir"/$pobase/POTFILES.in; then
4342 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4346 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4347 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4348 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4350 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4356 echo "Creating $pobase/POTFILES.in"
4357 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4359 echo "Create $pobase/POTFILES.in"
4362 func_append added_files "$pobase/POTFILES.in$nl"
4365 TP_URL="http://translationproject.org/latest/"
4366 TP_RSYNC_URI="translationproject.org::tp/latest/"
4368 echo "Fetching gnulib PO files from $TP_URL"
4369 (cd "$destdir"/$pobase \
4370 && { # Prefer rsync over wget if it is available, since it consumes
4371 # less network bandwidth, due to compression.
4372 if type rsync 2>/dev/null | grep / > /dev/null; then
4373 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4375 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4380 echo "Fetch gnulib PO files from $TP_URL"
4382 # Create po/LINGUAS.
4384 func_dest_tmpfilename $pobase/LINGUAS
4385 (cd "$destdir"/$pobase \
4386 && { echo '# Set of available languages.'
4387 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4390 if test -f "$destdir"/$pobase/LINGUAS; then
4391 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4394 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4395 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4396 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4399 echo "Creating $pobase/LINGUAS"
4400 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4401 func_append added_files "$pobase/LINGUAS$nl"
4404 if test -f "$destdir"/$pobase/LINGUAS; then
4405 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4407 echo "Create $pobase/LINGUAS"
4412 # Create m4/gnulib-cache.m4.
4413 func_dest_tmpfilename $m4base/gnulib-cache.m4
4415 func_emit_copyright_notice
4417 echo "# This file represents the specification of how gnulib-tool is used."
4418 echo "# It acts as a cache: It is written and read by gnulib-tool."
4419 echo "# In projects that use version control, this file is meant to be put under"
4420 echo "# version control, like the configure.ac and various Makefile.am files."
4423 echo "# Specification in the form of a command-line invocation:"
4426 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4427 # Store the local_gnulib_dir relative to destdir.
4428 case "$local_gnulib_dir" in
4430 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4433 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4435 # destdir, local_gnulib_dir are both relative.
4436 func_relativize "$destdir" "$local_gnulib_dir"
4437 relative_local_gnulib_dir="$reldir" ;;
4440 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4442 echo "$specified_modules" | sed -e 's/^/ /g'
4444 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4445 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4446 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4447 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4448 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4449 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4450 echo "gl_AVOID([$avoidlist])"
4451 echo "gl_SOURCE_BASE([$sourcebase])"
4452 echo "gl_M4_BASE([$m4base])"
4453 echo "gl_PO_BASE([$pobase])"
4454 echo "gl_DOC_BASE([$docbase])"
4455 echo "gl_TESTS_BASE([$testsbase])"
4456 test -z "$inctests" || echo "gl_WITH_TESTS"
4457 echo "gl_LIB([$libname])"
4458 if test -n "$lgpl"; then
4459 if test "$lgpl" = yes; then
4462 echo "gl_LGPL([$lgpl])"
4465 echo "gl_MAKEFILE_NAME([$makefile_name])"
4466 if test "$libtool" = true; then
4469 echo "gl_MACRO_PREFIX([$macro_prefix])"
4470 echo "gl_PO_DOMAIN([$po_domain])"
4471 if test -n "$vc_files"; then
4472 echo "gl_VC_FILES([$vc_files])"
4475 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4476 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4480 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4481 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4482 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4484 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4488 echo "# gnulib-cache.m4 ends here"
4495 echo "Creating $m4base/gnulib-cache.m4"
4496 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4498 echo "Create $m4base/gnulib-cache.m4"
4504 # Create m4/gnulib-comp.m4.
4505 func_dest_tmpfilename $m4base/gnulib-comp.m4
4507 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4508 func_emit_copyright_notice
4510 echo "# This file represents the compiled summary of the specification in"
4511 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4512 echo "# to be invoked from configure.ac."
4513 echo "# In projects that use version control, this file can be treated like"
4514 echo "# other built files."
4517 echo "# This macro should be invoked from $configure_ac, in the section"
4518 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4519 echo "# any checks for libraries, header files, types and library functions."
4520 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4522 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4523 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4524 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4525 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4526 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4527 if test -n "$uses_subdirs"; then
4528 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4530 for module in $final_modules; do
4532 if test -n "$module"; then
4533 echo "# Code from module $module:"
4534 func_get_autoconf_early_snippet "$module"
4537 | sed -e '/^$/d;' -e 's/^/ /'
4540 echo "# This macro should be invoked from $configure_ac, in the section"
4541 echo "# \"Check for header files, types and library functions\"."
4542 echo "AC_DEFUN([${macro_prefix}_INIT],"
4544 if test "$libtool" = true; then
4545 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4546 echo " gl_cond_libtool=true"
4548 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4549 echo " gl_cond_libtool=false"
4551 echo " gl_ltlibdeps="
4553 if test "$auxdir" != "build-aux"; then
4554 sed_replace_build_aux='
4556 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4557 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4561 sed_replace_build_aux="$sed_noop"
4563 echo " gl_m4_base='$m4base'"
4564 func_emit_initmacro_start $macro_prefix
4565 echo " gl_source_base='$sourcebase'"
4566 for module in $main_modules; do
4568 if test -n "$module"; then
4569 echo " # Code from module $module:"
4570 func_get_autoconf_snippet "$module" \
4571 | sed -e '/^$/d;' -e 's/^/ /' \
4572 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4573 -e "$sed_replace_build_aux"
4574 if test "$module" = 'alloca' && test "$libtool" = true; then
4575 echo 'changequote(,)dnl'
4576 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4577 echo 'changequote([, ])dnl'
4578 echo 'AC_SUBST([LTALLOCA])'
4582 echo " # End of code from modules"
4583 func_emit_initmacro_end $macro_prefix
4584 echo " gltests_libdeps="
4585 echo " gltests_ltlibdeps="
4586 func_emit_initmacro_start ${macro_prefix}tests
4587 echo " gl_source_base='$testsbase'"
4588 # Define a tests witness macro that depends on the package.
4589 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4590 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4591 echo "changequote(,)dnl"
4592 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"
4593 echo "changequote([, ])dnl"
4594 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4595 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4596 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4597 for module in $testsrelated_modules; do
4599 if test -n "$module"; then
4600 func_get_autoconf_snippet "$module" \
4601 | sed -e '/^$/d;' -e 's/^/ /' \
4602 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4603 -e "$sed_replace_build_aux" \
4604 -e 's/\$gl_cond_libtool/false/g' \
4605 -e 's/gl_libdeps/gltests_libdeps/g' \
4606 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4609 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4610 func_emit_initmacro_end ${macro_prefix}tests
4611 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4612 # created using libtool, because libtool already handles the dependencies.
4613 if test "$libtool" != true; then
4614 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
4615 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4616 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4617 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4618 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4620 if $use_libtests; then
4621 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4622 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4625 func_emit_initmacro_done $macro_prefix $sourcebase
4626 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4628 echo "# This macro records the list of files which have been installed by"
4629 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4630 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4631 echo "$files" | sed -e 's,^, ,'
4634 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4635 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4639 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4640 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4641 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4643 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4647 echo "# gnulib-comp.m4 ends here"
4654 echo "Creating $m4base/gnulib-comp.m4"
4655 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4657 echo "Create $m4base/gnulib-comp.m4"
4663 if test -n "$inctests"; then
4664 # Create tests makefile.
4665 func_dest_tmpfilename $testsbase/$makefile_am
4666 destfile="$testsbase/$makefile_am"
4667 modules="$testsrelated_modules"
4668 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4669 if test -f "$destdir"/$testsbase/$makefile_am; then
4670 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4674 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4675 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4676 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4678 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4684 echo "Creating $testsbase/$makefile_am"
4685 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4687 echo "Create $testsbase/$makefile_am"
4690 func_append added_files "$testsbase/$makefile_am$nl"
4694 if test "$vc_files" != false; then
4695 # Update the .cvsignore and .gitignore files.
4696 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4697 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4698 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4699 echo "$m4base/|A|gnulib-comp.m4"
4700 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4701 { # Rearrange file descriptors. Needed because "while ... done < ..."
4702 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4703 exec 5<&0 < "$tmp"/fileset-changes
4704 func_update_ignorelist ()
4707 if test "$ignore" = .gitignore; then
4708 # In a .gitignore file, "foo" applies to the current directory and all
4709 # subdirectories, whereas "/foo" applies to the current directory only.
4712 doubly_escaped_anchor='\\/'
4716 doubly_escaped_anchor=''
4718 if test -f "$destdir/$dir$ignore"; then
4719 if test -n "$dir_added" || test -n "$dir_removed"; then
4720 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4721 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4722 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4723 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4724 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4726 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4728 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4729 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4730 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4731 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4732 } > "$tmp"/sed-ignore-removed
4733 { cat "$destdir/$dir$ignore"~
4734 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4735 } | sed -f "$tmp"/sed-ignore-removed \
4736 > "$destdir/$dir$ignore"
4738 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4743 if test -n "$dir_added"; then
4745 echo "Creating $destdir/$dir$ignore"
4747 if test "$ignore" = .cvsignore; then
4749 # Automake generates Makefile rules that create .dirstamp files.
4752 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4753 } > "$destdir/$dir$ignore"
4755 echo "Create $destdir/$dir$ignore"
4765 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4766 func_update_ignorelist .cvsignore
4768 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4769 func_update_ignorelist .gitignore
4776 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4777 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4778 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4779 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4780 if test "$next_dir" != "$last_dir"; then
4781 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4782 last_dir="$next_dir"
4787 A) func_append last_dir_added "$file$nl";;
4788 R) func_append last_dir_removed "$file$nl";;
4791 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4798 echo "You may need to add #include directives for the following .h files."
4799 # Intersect $specified_modules and $main_modules
4800 # (since $specified_modules is not necessarily of subset of $main_modules
4801 # - some may have been skipped through --avoid, and since the elements of
4802 # $main_modules but not in $specified_modules can go away without explicit
4803 # notice - through changes in the module dependencies).
4804 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4805 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4806 # First the #include <...> directives without #ifs, sorted for convenience,
4807 # then the #include "..." directives without #ifs, sorted for convenience,
4808 # then the #include directives that are surrounded by #ifs. Not sorted.
4809 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4810 include_directive=`func_get_include_directive "$module"`
4811 case "$nl$include_directive" in
4813 echo "$include_directive" 1>&5
4816 echo "$include_directive" | grep -v 'include "' 1>&6
4817 echo "$include_directive" | grep 'include "' 1>&7
4820 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4822 LC_ALL=C sort -u "$tmp"/include-angles
4823 LC_ALL=C sort -u "$tmp"/include-quotes
4824 cat "$tmp"/include-if
4825 ) | sed -e '/^$/d' -e 's/^/ /'
4826 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4828 for module in $main_modules; do
4829 func_get_link_directive "$module"
4831 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4832 if test `wc -l < "$tmp"/link` != 0; then
4834 echo "You may need to use the following Makefile variables when linking."
4835 echo "Use them in <program>_LDADD when linking a program, or"
4836 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4842 echo "Don't forget to"
4843 if test "$makefile_am" = Makefile.am; then
4844 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4846 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4848 if test -n "$pobase"; then
4849 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4851 if test -n "$inctests"; then
4852 if test "$makefile_am" = Makefile.am; then
4853 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4855 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4859 while test $edit != $makefile_am_edits; do
4860 edit=`expr $edit + 1`
4861 eval dir=\"\$makefile_am_edit${edit}_dir\"
4862 eval var=\"\$makefile_am_edit${edit}_var\"
4863 eval val=\"\$makefile_am_edit${edit}_val\"
4864 if test -n "$var"; then
4865 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4868 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4869 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4872 # func_create_testdir testdir modules
4874 # - local_gnulib_dir from --local-dir
4875 # - modcache true or false, from --cache-modules/--no-cache-modules
4876 # - auxdir directory relative to destdir where to place build aux files
4877 # - inctests true if tests should be included, blank otherwise
4878 # - incobsolete true if obsolete modules among dependencies should be
4879 # included, blank otherwise
4880 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
4882 # - excl_longrunning_tests true if long-runnings tests should be excluded,
4884 # - excl_privileged_tests true if tests that require root privileges should be
4885 # excluded, blank otherwise
4886 # - excl_unportable_tests true if tests that fail on some platforms should be
4887 # excluded, blank otherwise
4888 # - avoidlist list of modules to avoid
4889 # - libtool true if --libtool was given, false if --no-libtool was
4890 # given, blank otherwise
4891 # - symbolic true if files should be symlinked, copied otherwise
4892 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4894 func_create_testdir ()
4898 if test -z "$modules"; then
4899 # All modules together.
4900 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4901 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4902 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4903 modules=`func_all_modules`
4904 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4906 specified_modules="$modules"
4908 # Canonicalize the list of specified modules.
4909 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4911 # Unlike in func_import, here we want to include all kinds of tests for the
4912 # directly specified modules, but not for dependencies.
4913 inc_all_direct_tests=true
4914 inc_all_indirect_tests="$inc_all_tests"
4916 # Check that the license of every module is consistent with the license of
4918 saved_inctests="$inctests"
4919 # When computing transitive closures, don't consider $module to depend on
4920 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4921 # on GPL modules - therefore we don't want a warning in this case.
4923 for requested_module in $specified_modules; do
4924 requested_license=`func_get_license "$requested_module"`
4925 if test "$requested_license" != GPL; then
4926 # Here we use func_modules_transitive_closure, not just
4927 # func_get_dependencies, so that we also detect weird situations like
4928 # an LGPL module which depends on a GPLed build tool module which depends
4930 modules="$requested_module"
4931 func_modules_transitive_closure
4932 for module in $modules; do
4933 license=`func_get_license "$module"`
4935 'GPLed build tool') ;;
4936 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4938 case "$requested_license" in
4941 GPLv2+ | LGPLv2+) ;;
4942 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4948 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4954 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4963 inctests="$saved_inctests"
4965 # Subdirectory names.
4975 # Determine final module list.
4976 modules="$specified_modules"
4977 func_modules_transitive_closure
4978 if test $verbose -ge 0; then
4979 func_show_module_list
4982 # Add the dummy module if needed.
4983 func_modules_add_dummy
4985 # Show banner notice of every module.
4988 # Determine final file list.
4989 func_modules_to_filelist
4990 if test $verbose -ge 0; then
4992 echo "$files" | sed -e 's/^/ /'
4994 # Add files for which the copy in gnulib is newer than the one that
4995 # "automake --add-missing --copy" would provide.
4996 files="$files build-aux/config.guess"
4997 files="$files build-aux/config.sub"
4998 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5000 rewritten='%REWRITTEN%'
5001 sed_rewrite_files="\
5002 s,^build-aux/,$rewritten$auxdir/,
5003 s,^doc/,$rewritten$docbase/,
5004 s,^lib/,$rewritten$sourcebase/,
5005 s,^m4/,$rewritten$m4base/,
5006 s,^tests/,$rewritten$testsbase/,
5010 # Create directories.
5011 for f in $files; do echo $f; done \
5012 | sed -e "$sed_rewrite_files" \
5013 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5014 | LC_ALL=C sort -u \
5016 { # Rearrange file descriptors. Needed because "while ... done < ..."
5017 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5018 exec 5<&0 < "$tmp"/dirs
5020 mkdir -p "$testdir/$d"
5025 # Copy files or make symbolic links.
5027 for f in $files; do echo $f; done \
5028 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5031 { # Rearrange file descriptors. Needed because "while ... done < ..."
5032 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5033 exec 5<&0 < "$tmp"/files
5035 func_lookup_file "$f"
5036 if test -n "$lookedup_tmp"; then
5037 cp -p "$lookedup_file" "$testdir/$g"
5039 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5040 if { test -n "$symbolic" \
5041 || { test -n "$lsymbolic" \
5042 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5043 func_ln "$lookedup_file" "$testdir/$g"
5045 cp -p "$lookedup_file" "$testdir/$g"
5052 # Create Makefile.ams that are for testing.
5055 # No special edits are needed.
5058 # Create $sourcebase/Makefile.am.
5059 mkdir -p "$testdir/$sourcebase"
5060 destfile="$sourcebase/Makefile.am"
5061 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5062 any_uses_subdirs="$uses_subdirs"
5064 # Create $m4base/Makefile.am.
5065 mkdir -p "$testdir/$m4base"
5066 (echo "## Process this file with automake to produce Makefile.in."
5072 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5075 ) > "$testdir/$m4base/Makefile.am"
5077 subdirs="$sourcebase $m4base"
5078 subdirs_with_configure_ac=""
5080 if false && test -f "$testdir"/$m4base/gettext.m4; then
5081 # Avoid stupid error message from automake:
5082 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5083 mkdir -p "$testdir/po"
5084 (echo "## Process this file with automake to produce Makefile.in."
5085 ) > "$testdir/po/Makefile.am"
5086 func_append subdirs " po"
5089 if test -n "$inctests"; then
5090 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5091 # Viewed from the $testsbase subdirectory, $auxdir is different.
5092 saved_auxdir="$auxdir"
5093 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5094 # Create $testsbase/Makefile.am.
5096 destfile="$testsbase/Makefile.am"
5097 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5098 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5099 # Create $testsbase/configure.ac.
5100 (echo "# Process this file with autoconf to produce a configure script."
5101 echo "AC_INIT([dummy], [0])"
5102 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5103 echo "AM_INIT_AUTOMAKE"
5105 echo "AC_CONFIG_HEADERS([config.h])"
5108 echo "AC_PROG_INSTALL"
5109 echo "AC_PROG_MAKE_SET"
5110 echo "AC_PROG_RANLIB"
5112 if test -n "$uses_subdirs"; then
5113 echo "AM_PROG_CC_C_O"
5116 for module in $modules; do
5118 if test -n "$module"; then
5120 gnumakefile | maintainer-makefile)
5121 # These modules are meant to be used only in the top-level directory.
5124 func_get_autoconf_early_snippet "$module"
5129 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5130 if test "$libtool" = true; then
5131 echo "LT_INIT([win32-dll])"
5132 echo "LT_LANG([C++])"
5133 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5134 echo "gl_cond_libtool=true"
5136 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5137 echo "gl_cond_libtool=false"
5139 echo "gl_ltlibdeps="
5141 # Wrap the set of autoconf snippets into an autoconf macro that is then
5142 # invoked. This is needed because autoconf does not support AC_REQUIRE
5144 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5145 # but we want the AC_REQUIRE to have its normal meaning (provide one
5146 # expansion of the required macro before the current point, and only one
5148 echo "AC_DEFUN([gl_INIT], ["
5149 sed_replace_build_aux='
5151 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5152 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5155 echo "gl_m4_base='../$m4base'"
5156 func_emit_initmacro_start $macro_prefix
5157 # We don't have explicit ordering constraints between the various
5158 # autoconf snippets. It's cleanest to put those of the library before
5159 # those of the tests.
5160 echo "gl_source_base='../$sourcebase'"
5161 for module in $modules; do
5162 func_verify_nontests_module
5163 if test -n "$module"; then
5165 gnumakefile | maintainer-makefile)
5166 # These modules are meant to be used only in the top-level directory.
5169 func_get_autoconf_snippet "$module" \
5170 | sed -e "$sed_replace_build_aux"
5171 if test "$module" = 'alloca' && test "$libtool" = true; then
5172 echo 'changequote(,)dnl'
5173 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
5174 echo 'changequote([, ])dnl'
5175 echo 'AC_SUBST([LTALLOCA])'
5181 echo "gl_source_base='.'"
5182 for module in $modules; do
5183 func_verify_tests_module
5184 if test -n "$module"; then
5185 func_get_autoconf_snippet "$module" \
5186 | sed -e "$sed_replace_build_aux"
5189 func_emit_initmacro_end $macro_prefix
5190 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5191 # created using libtool, because libtool already handles the dependencies.
5192 if test "$libtool" != true; then
5193 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5194 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5195 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5196 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5197 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5200 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5204 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5205 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5206 echo "AH_TOP([#include \"../config.h\"])"
5208 echo "AC_CONFIG_FILES([Makefile])"
5210 ) > "$testdir/$testsbase/configure.ac"
5211 auxdir="$saved_auxdir"
5212 func_append subdirs " $testsbase"
5213 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5216 # Create Makefile.am.
5217 (echo "## Process this file with automake to produce Makefile.in."
5219 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5221 echo "SUBDIRS = $subdirs"
5223 echo "ACLOCAL_AMFLAGS = -I $m4base"
5224 ) > "$testdir/Makefile.am"
5226 # Create configure.ac.
5227 (echo "# Process this file with autoconf to produce a configure script."
5228 echo "AC_INIT([dummy], [0])"
5229 if test "$auxdir" != "."; then
5230 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5232 echo "AM_INIT_AUTOMAKE"
5234 echo "AC_CONFIG_HEADERS([config.h])"
5237 echo "AC_PROG_INSTALL"
5238 echo "AC_PROG_MAKE_SET"
5240 echo "# For autobuild."
5241 echo "AC_CANONICAL_BUILD"
5242 echo "AC_CANONICAL_HOST"
5244 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5245 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5246 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5247 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5249 echo "AC_PROG_RANLIB"
5251 if test -n "$any_uses_subdirs"; then
5252 echo "AM_PROG_CC_C_O"
5255 for module in $modules; do
5256 func_verify_nontests_module
5257 if test -n "$module"; then
5258 func_get_autoconf_early_snippet "$module"
5261 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5262 if test "$libtool" = true; then
5263 echo "LT_INIT([win32-dll])"
5264 echo "LT_LANG([C++])"
5265 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5266 echo "gl_cond_libtool=true"
5268 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5269 echo "gl_cond_libtool=false"
5271 echo "gl_ltlibdeps="
5273 # Wrap the set of autoconf snippets into an autoconf macro that is then
5274 # invoked. This is needed because autoconf does not support AC_REQUIRE
5276 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5277 # but we want the AC_REQUIRE to have its normal meaning (provide one
5278 # expansion of the required macro before the current point, and only one
5280 echo "AC_DEFUN([gl_INIT], ["
5281 if test "$auxdir" != "build-aux"; then
5282 sed_replace_build_aux='
5284 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5285 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5289 sed_replace_build_aux="$sed_noop"
5291 echo "gl_m4_base='$m4base'"
5292 func_emit_initmacro_start $macro_prefix
5293 echo "gl_source_base='$sourcebase'"
5294 for module in $modules; do
5295 func_verify_nontests_module
5296 if test -n "$module"; then
5297 func_get_autoconf_snippet "$module" \
5298 | sed -e "$sed_replace_build_aux"
5299 if test "$module" = 'alloca' && test "$libtool" = true; then
5300 echo 'changequote(,)dnl'
5301 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
5302 echo 'changequote([, ])dnl'
5303 echo 'AC_SUBST([LTALLOCA])'
5307 func_emit_initmacro_end $macro_prefix
5308 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5309 # created using libtool, because libtool already handles the dependencies.
5310 if test "$libtool" != true; then
5311 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5312 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5313 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5314 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5315 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5318 func_emit_initmacro_done $macro_prefix $sourcebase
5322 if test -n "$subdirs_with_configure_ac"; then
5323 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5325 makefiles="Makefile"
5326 for d in $subdirs; do
5327 # For subdirs that have a configure.ac by their own, it's the subdir's
5328 # configure.ac which creates the subdir's Makefile.am, not this one.
5329 case " $subdirs_with_configure_ac " in
5331 *) func_append makefiles " $d/Makefile" ;;
5334 echo "AC_CONFIG_FILES([$makefiles])"
5336 ) > "$testdir/configure.ac"
5338 # Create autogenerated files.
5340 # Do not use "${AUTORECONF} --force --install", because it may invoke
5341 # autopoint, which brings in older versions of some of our .m4 files.
5342 if test -f $m4base/gettext.m4; then
5343 func_execute_command ${AUTOPOINT} --force || func_exit 1
5344 for f in $m4base/*.m4~; do
5346 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5350 if test "$libtool" = true; then
5351 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5353 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5354 if ! test -d build-aux; then
5355 func_execute_command mkdir build-aux || func_exit 1
5357 func_execute_command ${AUTOCONF} || func_exit 1
5358 func_execute_command ${AUTOHEADER} || func_exit 1
5359 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5361 if test -n "$inctests"; then
5362 # Create autogenerated files.
5363 (cd "$testdir/$testsbase" || func_exit 1
5364 # Do not use "${AUTORECONF} --force --install", because it may invoke
5365 # autopoint, which brings in older versions of some of our .m4 files.
5366 if test -f ../$m4base/gettext.m4; then
5367 func_execute_command ${AUTOPOINT} --force || func_exit 1
5368 for f in ../$m4base/*.m4~; do
5370 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5374 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5375 if ! test -d ../build-aux; then
5376 func_execute_command mkdir ../build-aux
5378 func_execute_command ${AUTOCONF} || func_exit 1
5379 func_execute_command ${AUTOHEADER} || func_exit 1
5380 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5383 # Need to run configure and make once, to create built files that are to be
5384 # distributed (such as parse-datetime.c).
5385 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5386 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5387 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5388 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5389 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5390 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5391 # such $(FOO_H) because they don't refer to distributed files.
5392 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5393 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5394 | sed -e "$sed_remove_make_variables"`
5395 distributed_built_sources=`for file in $built_sources; do
5396 case "$cleaned_files" in
5401 tests_distributed_built_sources=
5402 if test -n "$inctests"; then
5403 # Likewise for built files in the $testsbase directory.
5404 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5405 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5406 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5407 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5408 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5409 | sed -e "$sed_remove_make_variables"`
5410 tests_distributed_built_sources=`for file in $tests_built_sources; do
5411 case "$tests_cleaned_files" in
5417 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5419 ./configure || func_exit 1
5420 if test -n "$distributed_built_sources"; then
5422 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5423 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5428 if test -n "$tests_distributed_built_sources"; then
5430 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5431 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5436 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5443 # func_create_megatestdir megatestdir allmodules
5445 # - local_gnulib_dir from --local-dir
5446 # - modcache true or false, from --cache-modules/--no-cache-modules
5447 # - auxdir directory relative to destdir where to place build aux files
5448 func_create_megatestdir ()
5452 if test -z "$allmodules"; then
5453 allmodules=`func_all_modules`
5457 # First, all modules one by one.
5458 for onemodule in $allmodules; do
5459 func_create_testdir "$megatestdir/$onemodule" $onemodule
5460 func_append megasubdirs "$onemodule "
5462 # Then, all modules all together.
5463 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5464 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5465 func_create_testdir "$megatestdir/ALL" "$allmodules"
5466 func_append megasubdirs "ALL"
5469 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5470 vc_witness="$gnulib_dir/CVS/Entries"; \
5472 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5474 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5475 | sed -e 's,January,01,' -e 's,Jan,01,' \
5476 -e 's,February,02,' -e 's,Feb,02,' \
5477 -e 's,March,03,' -e 's,Mar,03,' \
5478 -e 's,April,04,' -e 's,Apr,04,' \
5480 -e 's,June,06,' -e 's,Jun,06,' \
5481 -e 's,July,07,' -e 's,Jul,07,' \
5482 -e 's,August,08,' -e 's,Aug,08,' \
5483 -e 's,September,09,' -e 's,Sep,09,' \
5484 -e 's,October,10,' -e 's,Oct,10,' \
5485 -e 's,November,11,' -e 's,Nov,11,' \
5486 -e 's,December,12,' -e 's,Dec,12,' \
5487 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5488 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5490 echo "CVSDATE=$cvsdate"
5491 echo ": \${MAKE=make}"
5492 echo "test -d logs || mkdir logs"
5493 echo "for module in $megasubdirs; do"
5494 echo " echo \"Working on module \$module...\""
5495 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5496 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5499 echo " : autobuild project... \$module"
5500 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5501 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5502 echo " : autobuild hostname... \`hostname\`"
5503 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5505 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5507 ) > "$megatestdir/do-autobuild"
5508 chmod a+x "$megatestdir/do-autobuild"
5510 # Create Makefile.am.
5511 (echo "## Process this file with automake to produce Makefile.in."
5513 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5515 echo "SUBDIRS = $megasubdirs"
5517 echo "EXTRA_DIST = do-autobuild"
5518 ) > "$megatestdir/Makefile.am"
5520 # Create configure.ac.
5521 (echo "# Process this file with autoconf to produce a configure script."
5522 echo "AC_INIT([dummy], [0])"
5523 if test "$auxdir" != "."; then
5524 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5526 echo "AM_INIT_AUTOMAKE"
5528 echo "AC_PROG_MAKE_SET"
5530 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5531 echo "AC_CONFIG_FILES([Makefile])"
5533 ) > "$megatestdir/configure.ac"
5535 # Create autogenerated files.
5537 # Do not use "${AUTORECONF} --install", because autoreconf operates
5538 # recursively, but the subdirectories are already finished, therefore
5539 # calling autoreconf here would only waste lots of CPU time.
5540 func_execute_command ${ACLOCAL} || func_exit 1
5541 func_execute_command mkdir build-aux
5542 func_execute_command ${AUTOCONF} || func_exit 1
5543 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5549 func_fatal_error "no mode specified" ;;
5556 # sed expression that converts a literal to a basic regular expression.
5557 # Needs to handle . [ \ * ^ $.
5558 sed_literal_to_basic_regex='s/\\/\\\\/g
5564 if test -f "$gnulib_dir/$filename" \
5565 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5566 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5567 filename_line_regex='^'"$filename_anywhere_regex"'$'
5570 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5571 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5572 (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$,,')
5575 | func_sanitize_modulelist \
5578 for module in $module_candidates; do
5579 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5584 func_warning "file $filename does not exist"
5589 import | add-import | remove-import | update )
5592 if test -z "$destdir"; then
5595 test -d "$destdir" \
5596 || func_fatal_error "destination directory does not exist: $destdir"
5598 # Prefer configure.ac to configure.in.
5599 if test -f "$destdir"/configure.ac; then
5600 configure_ac="$destdir/configure.ac"
5602 if test -f "$destdir"/configure.in; then
5603 configure_ac="$destdir/configure.in"
5605 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5609 # Analyze configure.ac.
5611 guessed_libtool=false
5616 /AC_CONFIG_AUX_DIR/ {
5617 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5619 /A[CM]_PROG_LIBTOOL/ {
5620 s,^.*$,guessed_libtool=true,p
5622 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5624 if test -z "$auxdir"; then
5625 auxdir="$guessed_auxdir"
5628 # Determine where to apply func_import.
5629 if test "$mode" = import; then
5630 # Apply func_import to a particular gnulib directory.
5631 # The command line contains the complete specification; don't look at
5632 # the contents of gnulib-cache.m4.
5633 test -n "$supplied_libname" || supplied_libname=true
5634 test -n "$sourcebase" || sourcebase="lib"
5635 test -n "$m4base" || m4base="m4"
5636 test -n "$docbase" || docbase="doc"
5637 test -n "$testsbase" || testsbase="tests"
5638 test -n "$macro_prefix" || macro_prefix="gl"
5641 if test -n "$m4base"; then
5642 # Apply func_import to a particular gnulib directory.
5643 # Any number of additional modules can be given.
5644 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5645 # First use of gnulib in the given m4base.
5646 test -n "$supplied_libname" || supplied_libname=true
5647 test -n "$sourcebase" || sourcebase="lib"
5648 test -n "$docbase" || docbase="doc"
5649 test -n "$testsbase" || testsbase="tests"
5650 test -n "$macro_prefix" || macro_prefix="gl"
5654 # Apply func_import to all gnulib directories.
5655 # To get this list of directories, look at Makefile.am. (Not at
5656 # configure, because it may be omitted from version control. Also,
5657 # don't run "find $destdir -name gnulib-cache.m4", as it might be
5661 if test -f "$destdir"/Makefile.am; then
5662 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5664 for arg in $aclocal_amflags; do
5665 if test -n "$m4dir_is_next"; then
5666 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5670 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5671 func_append m4dirs " $arg"
5672 m4dirs_count=`expr $m4dirs_count + 1`
5678 if test "X$arg" = "X-I"; then
5686 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5687 if test -f "$destdir"/aclocal.m4; then
5688 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5689 sedexpr2='s,^[^/]*$,.,'
5690 sedexpr3='s,/[^/]*$,,'
5691 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5692 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
5693 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
5696 if test $m4dirs_count = 0; then
5697 # First use of gnulib in a package.
5698 # Any number of additional modules can be given.
5699 test -n "$supplied_libname" || supplied_libname=true
5700 test -n "$sourcebase" || sourcebase="lib"
5702 test -n "$docbase" || docbase="doc"
5703 test -n "$testsbase" || testsbase="tests"
5704 test -n "$macro_prefix" || macro_prefix="gl"
5707 if test $m4dirs_count = 1; then
5708 # There's only one use of gnulib here. Assume the user means it.
5709 # Any number of additional modules can be given.
5710 for m4base in $m4dirs; do
5714 # Ambiguous - guess what the user meant.
5715 if test $# = 0; then
5716 # No further arguments. Guess the user wants to update all of them.
5717 for m4base in $m4dirs; do
5718 # Perform func_import in a subshell, so that variable values
5720 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5721 # inc_longrunning_tests, inc_privileged_tests,
5722 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5723 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5724 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5725 # don't propagate from one directory to another.
5726 (func_import) || func_exit 1
5730 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5739 if test -z "$destdir"; then
5740 func_fatal_error "please specify --dir option"
5743 test -d "$destdir" \
5744 || func_fatal_error "could not create destination directory"
5745 test -n "$auxdir" || auxdir="build-aux"
5746 func_create_testdir "$destdir" "$*"
5749 create-megatestdir )
5750 if test -z "$destdir"; then
5751 func_fatal_error "please specify --dir option"
5753 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5754 test -n "$auxdir" || auxdir="build-aux"
5755 func_create_megatestdir "$destdir" "$*"
5759 test -n "$destdir" || destdir=testdir$$
5760 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5761 test -n "$auxdir" || auxdir="build-aux"
5762 func_create_testdir "$destdir" "$*"
5766 ../configure || func_exit 1
5767 $MAKE || func_exit 1
5768 $MAKE check || func_exit 1
5769 $MAKE distclean || func_exit 1
5770 remaining=`find . -type f -print`
5771 if test -n "$remaining"; then
5772 echo "Remaining files:" $remaining 1>&2
5773 echo "gnulib-tool: *** Stop." 1>&2
5782 test -n "$destdir" || destdir=testdir$$
5783 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5784 test -n "$auxdir" || auxdir="build-aux"
5785 func_create_megatestdir "$destdir" "$*"
5793 remaining=`find . -type f -print`
5794 if test -n "$remaining"; then
5795 echo "Remaining files:" $remaining 1>&2
5796 echo "gnulib-tool: *** Stop." 1>&2
5804 extract-description )
5808 if test -n "$module"; then
5809 func_get_description "$module"
5818 if test -n "$module"; then
5819 func_get_comment "$module"
5828 if test -n "$module"; then
5829 func_get_status "$module"
5838 if test -n "$module"; then
5839 func_get_notice "$module"
5844 extract-applicability )
5848 if test -n "$module"; then
5849 func_get_applicability "$module"
5858 if test -n "$module"; then
5859 func_get_filelist "$module"
5864 extract-dependencies )
5868 if test -n "$module"; then
5869 func_get_dependencies "$module"
5874 extract-autoconf-snippet )
5878 if test -n "$module"; then
5879 func_get_autoconf_snippet "$module"
5884 extract-automake-snippet )
5888 if test -n "$module"; then
5889 func_get_automake_snippet "$module"
5894 extract-include-directive )
5898 if test -n "$module"; then
5899 func_get_include_directive "$module"
5904 extract-link-directive )
5908 if test -n "$module"; then
5909 func_get_link_directive "$module"
5918 if test -n "$module"; then
5919 func_get_license "$module"
5924 extract-maintainer )
5928 if test -n "$module"; then
5929 func_get_maintainer "$module"
5934 extract-tests-module )
5938 if test -n "$module"; then
5939 func_get_tests_module "$module"
5945 # Verify the number of arguments.
5946 if test $# -lt 1 || test $# -gt 2; then
5947 func_fatal_error "invalid number of arguments for --$mode"
5950 # The first argument is the file to be copied.
5952 # Verify the file exists.
5953 func_lookup_file "$f"
5955 # The second argument is the destination; either a directory ot a file.
5956 # It defaults to the current directory.
5958 test -n "$dest" || dest='.'
5959 test -n "$sourcebase" || sourcebase="lib"
5960 test -n "$m4base" || m4base="m4"
5961 test -n "$docbase" || docbase="doc"
5962 test -n "$testsbase" || testsbase="tests"
5963 test -n "$auxdir" || auxdir="build-aux"
5964 rewritten='%REWRITTEN%'
5965 sed_rewrite_files="\
5966 s,^build-aux/,$rewritten$auxdir/,
5967 s,^doc/,$rewritten$docbase/,
5968 s,^lib/,$rewritten$sourcebase/,
5969 s,^m4/,$rewritten$m4base/,
5970 s,^tests/,$rewritten$testsbase/,
5973 if test -d "$dest"; then
5975 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5977 destdir=`dirname "$dest"`
5978 g=`basename "$dest"`
5981 # Create the directory for destfile.
5982 d=`dirname "$destdir/$g"`
5984 if test -n "$d" && test ! -d "$d"; then
5985 mkdir -p "$d" || func_fatal_error "failed"
5989 func_dest_tmpfilename "$g"
5990 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5991 already_present=true
5992 if test -f "$destdir/$g"; then
5993 # The file already exists.
5997 # Don't protest if the file should be there but isn't: it happens
5998 # frequently that developers don't put autogenerated files under version
6006 func_fatal_error "unknown operation mode --$mode" ;;
6010 # Undo the effect of the previous 'trap' command. Some shellology:
6011 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6012 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6013 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6014 # 128 + signal number and is set before the trap-registered command is run.
6016 trap 'func_exit $?' 1 2 3 13 15
6021 # indent-tabs-mode: nil
6022 # whitespace-check-buffer-indent: nil