3 # Copyright (C) 2002-2012 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
130 gnulib-tool --add-import [module1 ... moduleN]
131 gnulib-tool --remove-import [module1 ... moduleN]
133 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
134 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
135 gnulib-tool --test --dir=directory module1 ... moduleN
136 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
137 gnulib-tool --extract-description module
138 gnulib-tool --extract-comment module
139 gnulib-tool --extract-status module
140 gnulib-tool --extract-notice module
141 gnulib-tool --extract-applicability module
142 gnulib-tool --extract-filelist module
143 gnulib-tool --extract-dependencies module
144 gnulib-tool --extract-autoconf-snippet module
145 gnulib-tool --extract-automake-snippet module
146 gnulib-tool --extract-include-directive module
147 gnulib-tool --extract-link-directive module
148 gnulib-tool --extract-license module
149 gnulib-tool --extract-maintainer module
150 gnulib-tool --extract-tests-module module
151 gnulib-tool --copy-file file [destination]
155 --list print the available module names
156 --find find the modules which contain the specified file
157 --import import the given modules into the current package
158 --add-import augment the list of imports from gnulib into the
159 current package, by adding the given modules;
160 if no modules are specified, update the current
161 package from the current gnulib
162 --remove-import reduce the list of imports from gnulib into the
163 current package, by removing the given modules
164 --update update the current package, restore files omitted
166 --create-testdir create a scratch package with the given modules
167 --create-megatestdir create a mega scratch package with the given modules
168 one by one and all together
169 --test test the combination of the given modules
170 (recommended to use CC=\"gcc -Wall\" here)
171 --megatest test the given modules one by one and all together
172 (recommended to use CC=\"gcc -Wall\" here)
173 --extract-description extract the description
174 --extract-comment extract the comment
175 --extract-status extract the status (obsolete etc.)
176 --extract-notice extract the notice or banner
177 --extract-applicability extract the applicability
178 --extract-filelist extract the list of files
179 --extract-dependencies extract the dependencies
180 --extract-autoconf-snippet extract the snippet for configure.ac
181 --extract-automake-snippet extract the snippet for library makefile
182 --extract-include-directive extract the #include directive
183 --extract-link-directive extract the linker directive
184 --extract-license report the license terms of the source files
186 --extract-maintainer report the maintainer(s) inside gnulib
187 --extract-tests-module report the unit test module, if it exists
188 --copy-file copy a file that is not part of any module
189 --help Show this help text.
190 --version Show version and authorship information.
194 --dir=DIRECTORY Specify the target directory.
195 For --import, this specifies where your
196 configure.ac can be found. Defaults to current
198 --local-dir=DIRECTORY Specify a local override directory where to look
199 up files before looking in gnulib's directory.
200 --cache-modules Enable module caching optimization.
201 --no-cache-modules Disable module caching optimization.
202 --verbose Increase verbosity. May be repeated.
203 --quiet Decrease verbosity. May be repeated.
205 Options for --import, --add/remove-import, --update:
207 --dry-run Only print what would have been done.
209 Options for --import, --add/remove-import:
211 --with-tests Include unit tests for the included modules.
213 Options for --create-[mega]testdir, --[mega]test:
215 --without-tests Don't include unit tests for the included modules.
217 Options for --import, --add/remove-import,
218 --create-[mega]testdir, --[mega]test:
220 --with-obsolete Include obsolete modules when they occur among the
221 dependencies. By default, dependencies to obsolete
223 --with-c++-tests Include even unit tests for C++ interoperability.
224 --without-c++-tests Exclude unit tests for C++ interoperability.
225 --with-longrunning-tests
226 Include even unit tests that are long-runners.
227 --without-longrunning-tests
228 Exclude unit tests that are long-runners.
229 --with-privileged-tests
230 Include even unit tests that require root
232 --without-privileged-tests
233 Exclude unit tests that require root privileges.
234 --with-unportable-tests
235 Include even unit tests that fail on some platforms.
236 --without-unportable-tests
237 Exclude unit tests that fail on some platforms.
238 --with-all-tests Include all kinds of problematic unit tests.
239 --avoid=MODULE Avoid including the given MODULE. Useful if you
240 have code that provides equivalent functionality.
241 This option can be repeated.
242 --conditional-dependencies
243 Support conditional dependencies (may save configure
244 time and object code).
245 --no-conditional-dependencies
246 Don't use conditional dependencies.
247 --libtool Use libtool rules.
248 --no-libtool Don't use libtool rules.
250 Options for --import, --add/remove-import:
252 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
253 --source-base=DIRECTORY
254 Directory relative to --dir where source code is
255 placed (default \"lib\").
256 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
257 placed (default \"m4\").
258 --po-base=DIRECTORY Directory relative to --dir where *.po files are
259 placed (default \"po\").
260 --doc-base=DIRECTORY Directory relative to --dir where doc files are
261 placed (default \"doc\").
262 --tests-base=DIRECTORY
263 Directory relative to --dir where unit tests are
264 placed (default \"tests\").
265 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
266 tools are placed (default comes from configure.ac).
267 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
268 Also modify license template from GPL to LGPL.
269 The version number of the LGPL can be specified;
270 the default is currently LGPLv3.
271 --makefile-name=NAME Name of makefile in automake syntax in the
272 source-base and tests-base directories
273 (default \"Makefile.am\").
274 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
275 'gl_INIT'. Default is 'gl'.
276 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
277 the package name. A suffix '-gnulib' is appended.
278 --witness-c-macro=NAME Specify the C macro that is defined when the
279 sources in this directory are compiled or used.
280 --vc-files Update version control related files.
281 --no-vc-files Don't update version control related files
282 (.gitignore and/or .cvsignore).
284 Options for --create-[mega]testdir, --[mega]test:
286 --single-configure Generate a single configure file, not a separate
287 configure file for the tests directory.
289 Options for --import, --add/remove-import, --update,
290 --create-[mega]testdir, --[mega]test:
292 -s, --symbolic, --symlink Make symbolic links instead of copying files.
293 --local-symlink Make symbolic links instead of copying files, only
294 for files from the local override directory.
296 Options for --import, --add/remove-import, --update:
298 -S, --more-symlinks Make symbolic links instead of copying files, and
299 don't replace copyright notices.
301 Report bugs to <bug-gnulib@gnu.org>."
305 # outputs to stdout the --version message.
309 if test -d "$gnulib_dir"/.git \
310 && (git --version) >/dev/null 2>/dev/null \
311 && (date --version) >/dev/null 2>/dev/null; then
312 # gnulib checked out from git.
313 sed_extract_first_date='/^Date/{
317 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
318 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
319 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
320 date=`echo "$date" | sed -e "$sed_year_before_time"`
321 # Use GNU date to compute the time in GMT.
322 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
323 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
325 if test -d "$gnulib_dir"/CVS \
326 && (cvs --version) >/dev/null 2>/dev/null; then
327 # gnulib checked out from CVS.
328 sed_extract_first_date='/^date: /{
329 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
332 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
334 # gnulib copy without versioning information.
335 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
339 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
341 gnulib-tool (GNU $package $date)$version
342 Copyright (C) $year Free Software Foundation, Inc.
343 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
344 This is free software: you are free to change and redistribute it.
345 There is NO WARRANTY, to the extent permitted by law.
347 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
350 # func_emit_copyright_notice
351 # outputs to stdout a header for a generated file.
352 func_emit_copyright_notice ()
354 sed -n -e '/Copyright/ {
357 }' < "$self_abspathname"
359 echo "# This file is free software; you can redistribute it and/or modify"
360 echo "# it under the terms of the GNU General Public License as published by"
361 echo "# the Free Software Foundation; either version 3 of the License, or"
362 echo "# (at your option) any later version."
364 echo "# This file is distributed in the hope that it will be useful,"
365 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
366 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
367 echo "# GNU General Public License for more details."
369 echo "# You should have received a copy of the GNU General Public License"
370 echo "# along with this file. If not, see <http://www.gnu.org/licenses/>."
372 echo "# As a special exception to the GNU General Public License,"
373 echo "# this file may be distributed as part of a program that"
374 echo "# contains a configuration script generated by Autoconf, under"
375 echo "# the same distribution terms as the rest of that program."
377 echo "# Generated by gnulib-tool."
381 # exits with a given status.
382 # This function needs to be used, rather than 'exit', when a 'trap' handler is
383 # in effect that refers to $?.
390 # locates the directory where the gnulib repository lives
392 # - progname name of this program
394 # - self_abspathname absolute pathname of gnulib-tool
395 # - gnulib_dir absolute pathname of gnulib repository
399 /*) self_abspathname="$progname" ;;
400 */*) self_abspathname=`pwd`/"$progname" ;;
403 # Iterate through the elements of $PATH.
404 # We use IFS=: instead of
405 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
406 # because the latter does not work when some PATH element contains spaces.
407 # We use a canonicalized $pathx instead of $PATH, because empty PATH
408 # elements are by definition equivalent to '.', however field splitting
409 # according to IFS=: loses empty fields in many shells:
410 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
411 # beginning, at the end, and in the middle),
412 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
413 # at the beginning and at the end,
414 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
415 # Solaris lose empty fields at the end.
416 # The 'case' statement is an optimization, to avoid evaluating the
417 # explicit canonicalization command when $PATH contains no empty fields.
419 if test "${PATH_SEPARATOR+set}" != set; then
420 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
421 # contains only /bin. Note that ksh looks also at the FPATH variable,
422 # so we have to set that as well for the test.
424 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
425 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
426 || PATH_SEPARATOR=';'
429 if test "$PATH_SEPARATOR" = ";"; then
430 # On Windows, programs are searched in "." before $PATH.
433 # On Unix, we have to convert empty PATH elements to ".".
437 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
442 IFS="$PATH_SEPARATOR"
446 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
447 self_abspathname="$d/$progname"
452 if test -z "$self_abspathname"; then
453 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
457 while test -h "$self_abspathname"; do
458 # Resolve symbolic link.
459 linkval=`func_readlink "$self_abspathname"`
460 test -n "$linkval" || break
462 /* ) self_abspathname="$linkval" ;;
463 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
466 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
470 # creates a temporary directory.
472 # - progname name of this program
474 # - tmp pathname of freshly created temporary directory
477 # Use the environment variable TMPDIR, falling back to /tmp. This allows
478 # users to specify a different temporary directory, for example, if their
479 # /tmp is filled up or too small.
482 # Use the mktemp program if available. If not available, hide the error
484 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
485 test -n "$tmp" && test -d "$tmp"
488 # Use a simple mkdir command. It is guaranteed to fail if the directory
489 # already exists. $RANDOM is bash specific and expands to empty in shells
490 # other than bash, ksh and zsh. Its use does not increase security;
491 # rather, it minimizes the probability of failure in a very cluttered /tmp
493 tmp=$TMPDIR/gl$$-$RANDOM
494 (umask 077 && mkdir "$tmp")
497 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
502 # func_append var value
503 # appends the given value to the shell variable var.
504 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
505 # Use bash's += operator. It reduces complexity of appending repeatedly to
506 # a single variable from O(n^2) to O(n).
511 fast_func_append=true
515 eval "$1=\"\$$1\$2\""
517 fast_func_append=false
520 # func_remove_prefix var prefix
521 # removes the given prefix from the value of the shell variable var.
522 # var should be the name of a shell variable.
523 # Its value should not contain a newline and not start or end with whitespace.
524 # prefix should not contain the characters "$`\{}[]^|.
525 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
526 func_remove_prefix ()
530 fast_func_remove_prefix=true
532 func_remove_prefix ()
534 eval "value=\"\$$1\""
538 sed_escape_dots='s/\([.]\)/\\\1/g'
539 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
542 value=`echo "$value" | sed -e "s|^${prefix}||"`
543 eval "$1=\"\$value\""
545 fast_func_remove_prefix=false
548 # func_remove_suffix var suffix
549 # removes the given suffix from the value of the shell variable var.
550 # var should be the name of a shell variable.
551 # Its value should not contain a newline and not start or end with whitespace.
552 # suffix should not contain the characters "$`\{}[]^|.
553 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
554 func_remove_suffix ()
558 fast_func_remove_suffix=true
560 func_remove_suffix ()
562 eval "value=\"\$$1\""
566 sed_escape_dots='s/\([.]\)/\\\1/g'
567 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
570 value=`echo "$value" | sed -e "s|${suffix}\$||"`
571 eval "$1=\"\$value\""
573 fast_func_remove_suffix=false
576 # func_fatal_error message
577 # outputs to stderr a fatal error message, and terminates the program.
579 # - progname name of this program
582 echo "$progname: *** $1" 1>&2
583 echo "$progname: *** Stop." 1>&2
587 # func_warning message
588 # Outputs to stderr a warning message,
591 echo "gnulib-tool: warning: $1" 1>&2
594 # func_readlink SYMLINK
595 # outputs the target of the given symlink.
596 if (type readlink) > /dev/null 2>&1; then
599 # Use the readlink program from GNU coreutils.
605 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
606 # would do the wrong thing if the link target contains " -> ".
607 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
611 # func_relativize DIR1 DIR2
612 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
614 # - DIR1 relative pathname, relative to the current directory
615 # - DIR2 relative pathname, relative to the current directory
617 # - reldir relative pathname of DIR2, relative to DIR1
623 sed_first='s,^\([^/]*\)/.*$,\1,'
624 sed_rest='s,^[^/]*/*,,'
625 sed_last='s,^.*/\([^/]*\)$,\1,'
626 sed_butlast='s,/*[^/]*$,,'
627 while test -n "$dir1"; do
628 first=`echo "$dir1" | sed -e "$sed_first"`
629 if test "$first" != "."; then
630 if test "$first" = ".."; then
631 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
632 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
634 first2=`echo "$dir2" | sed -e "$sed_first"`
635 if test "$first2" = "$first"; then
636 dir2=`echo "$dir2" | sed -e "$sed_rest"`
640 dir0="$dir0"/"$first"
643 dir1=`echo "$dir1" | sed -e "$sed_rest"`
648 # func_relconcat DIR1 DIR2
649 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
651 # - DIR1 relative pathname, relative to the current directory
652 # - DIR2 relative pathname, relative to DIR1
654 # - relconcat DIR1/DIR2, relative to the current directory
659 sed_first='s,^\([^/]*\)/.*$,\1,'
660 sed_rest='s,^[^/]*/*,,'
661 sed_last='s,^.*/\([^/]*\)$,\1,'
662 sed_butlast='s,/*[^/]*$,,'
664 first=`echo "$dir2" | sed -e "$sed_first"`
665 if test "$first" = "."; then
666 dir2=`echo "$dir2" | sed -e "$sed_rest"`
667 if test -z "$dir2"; then
672 last=`echo "$dir1" | sed -e "$sed_last"`
673 while test "$last" = "."; do
674 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
675 last=`echo "$dir1" | sed -e "$sed_last"`
677 if test -z "$dir1"; then
681 if test "$first" = ".."; then
682 if test "$last" = ".."; then
683 relconcat="$dir1/$dir2"
686 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
687 dir2=`echo "$dir2" | sed -e "$sed_rest"`
688 if test -z "$dir1"; then
692 if test -z "$dir2"; then
697 relconcat="$dir1/$dir2"
705 # Like ln -s, except that SRC is given relative to the current directory (or
706 # absolute), not given relative to the directory of DEST.
712 *) # SRC is relative.
715 ln -s "`pwd`/$1" "$2" ;;
716 *) # DEST is relative too.
717 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
718 test -n "$ln_destdir" || ln_destdir="."
719 func_relativize "$ln_destdir" "$1"
727 # func_ln_if_changed SRC DEST
728 # Like func_ln, but avoids munging timestamps if the link is correct.
729 func_ln_if_changed ()
731 if test $# -ne 2; then
732 echo "usage: func_ln_if_changed SRC DEST" >&2
734 ln_target=`func_readlink "$2"`
735 if test -h "$2" && test "$1" = "$ln_target"; then
743 # Ensure an 'echo' command that
744 # 1. does not interpret backslashes and
745 # 2. does not print an error message "broken pipe" when writing into a pipe
748 # Test cases for problem 1:
749 # echo '\n' | wc -l prints 1 when OK, 2 when KO
750 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
751 # Test cases for problem 2:
752 # echo hi | true frequently prints
753 # "bash: echo: write error: Broken pipe"
754 # to standard error in bash 3.2.
756 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
757 # BSD echo interprets '-n' as an option, which is also not desirable).
758 # Nowadays the problem occurs in 4 situations:
759 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
760 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
761 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
762 # - in zsh, when sh-emulation is not set,
763 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
764 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
765 # - in Solaris /bin/sh and OSF/1 /bin/sh.
766 # We try the following workarounds:
767 # - for all: respawn using $CONFIG_SHELL if that is set and works.
768 # - for bash >= 2.04: unset the shell option xpg_echo.
769 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
770 # - for bash < 2.0: define echo to a function that uses cat of a here document.
771 # - for zsh: turn sh-emulation on.
772 # - for ksh: alias echo to 'print -r'.
773 # - for ksh: alias echo to a function that uses cat of a here document.
774 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
775 # the ksh workaround.
776 # - otherwise: respawn using /bin/sh and rely on the workarounds.
777 # When respawning, we pass --no-reexec as first argument, so as to avoid
778 # turning this script into a fork bomb in unlucky situations.
780 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
781 # the 'printf' built-in. See
782 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
783 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
784 # The workaround is: define echo to a function that uses the printf built-in.
786 if echo '\t' | grep t > /dev/null; then
787 have_echo=yes # Lucky!
789 # Try the workarounds.
790 # Respawn using $CONFIG_SHELL if that is set and works.
791 if test -z "$have_echo" \
792 && test "X$1" != "X--no-reexec" \
793 && test -n "$CONFIG_SHELL" \
794 && test -f "$CONFIG_SHELL" \
795 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
796 exec $CONFIG_SHELL "$0" --no-reexec "$@"
799 # For bash >= 2.04: unset the shell option xpg_echo.
800 if test -z "$have_echo" \
801 && test -n "$BASH_VERSION" \
802 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
806 # For bash >= 2.0: define echo to a function that uses the printf built-in.
807 # For bash < 2.0: define echo to a function that uses cat of a here document.
808 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
809 # Also handle problem 2, specific to bash 3.2, here.
810 if { test -z "$have_echo" \
811 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
813 && test -n "$BASH_VERSION"; then \
814 if type printf 2>/dev/null | grep / > /dev/null; then
815 # 'printf' is not a shell built-in.
823 # 'printf' is a shell built-in.
829 if echo '\t' | grep t > /dev/null; then
833 # For zsh: turn sh-emulation on.
834 if test -z "$have_echo" \
835 && test -n "$ZSH_VERSION" \
836 && (emulate sh) >/dev/null 2>&1; then
839 # For ksh: alias echo to 'print -r'.
840 if test -z "$have_echo" \
841 && (type print) >/dev/null 2>&1; then
842 # A 'print' command exists.
843 if type print 2>/dev/null | grep / > /dev/null; then
846 # 'print' is a shell built-in.
847 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
848 # 'print' is the ksh shell built-in.
849 alias echo='print -r'
853 if test -z "$have_echo" \
854 && echo '\t' | grep t > /dev/null; then
857 # For ksh: alias echo to a function that uses cat of a here document.
858 # The ksh manual page says:
859 # "Aliasing is performed when scripts are read, not while they are executed.
860 # Therefore, for an alias to take effect, the alias definition command has
861 # to be executed before the command which references the alias is read."
862 # Because of this, we have to play strange tricks with have_echo, to ensure
863 # that the top-level statement containing the test starts after the 'alias'
865 if test -z "$have_echo"; then
872 if (alias echo=bsd_echo) 2>/dev/null; then
873 alias echo=bsd_echo 2>/dev/null
876 if test -z "$have_echo" \
877 && echo '\t' | grep t > /dev/null; then
880 if test -z "$have_echo"; then
881 if (alias echo=bsd_echo) 2>/dev/null; then
882 unalias echo 2>/dev/null
885 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
886 if test -z "$have_echo" \
887 && test "X$1" != "X--no-reexec" \
888 && test -f /bin/ksh; then
889 exec /bin/ksh "$0" --no-reexec "$@"
892 # Otherwise: respawn using /bin/sh.
893 if test -z "$have_echo" \
894 && test "X$1" != "X--no-reexec" \
895 && test -f /bin/sh; then
896 exec /bin/sh "$0" --no-reexec "$@"
899 if test -z "$have_echo"; then
900 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
902 if echo '\t' | grep t > /dev/null; then
905 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
907 if test "X$1" = "X--no-reexec"; then
911 # Command-line option processing.
912 # Removes the OPTIONS from the arguments. Sets the variables:
913 # - mode one of: list, find, import, add-import, remove-import,
914 # update, create-testdir, create-megatestdir, test, megatest,
916 # - destdir from --dir
917 # - local_gnulib_dir from --local-dir
918 # - modcache true or false, from --cache-modules/--no-cache-modules
919 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
920 # - libname, supplied_libname from --lib
921 # - sourcebase from --source-base
922 # - m4base from --m4-base
923 # - pobase from --po-base
924 # - docbase from --doc-base
925 # - testsbase from --tests-base
926 # - auxdir from --aux-dir
927 # - inctests true if --with-tests was given, false if --without-tests
928 # was given, blank otherwise
929 # - incobsolete true if --with-obsolete was given, blank otherwise
930 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
931 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
933 # - inc_privileged_tests true if --with-privileged-tests was given, blank
935 # - inc_unportable_tests true if --with-unportable-tests was given, blank
937 # - inc_all_tests true if --with-all-tests was given, blank otherwise
938 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
939 # - excl_longrunning_tests true if --without-longrunning-tests was given,
941 # - excl_privileged_tests true if --without-privileged-tests was given, blank
943 # - excl_unportable_tests true if --without-unportable-tests was given, blank
945 # - single_configure true if --single-configure was given, false otherwise
946 # - avoidlist list of modules to avoid, from --avoid
947 # - cond_dependencies true if --conditional-dependencies was given, false if
948 # --no-conditional-dependencies was given, blank otherwise
949 # - lgpl yes or a number if --lgpl was given, blank otherwise
950 # - makefile_name from --makefile-name
951 # - libtool true if --libtool was given, false if --no-libtool was
952 # given, blank otherwise
953 # - macro_prefix from --macro-prefix
954 # - po_domain from --po-domain
955 # - witness_c_macro from --witness-c-macro
956 # - vc_files true if --vc-files was given, false if --no-vc-files was
957 # given, blank otherwise
958 # - autoconf_minversion minimum supported autoconf version
959 # - doit : if actions shall be executed, false if only to be printed
960 # - symbolic true if --symlink or --more-symlinks was given, blank
962 # - lsymbolic true if --local-symlink was given, blank otherwise
963 # - do_copyrights blank if --more-symlinks was given, true otherwise
981 inc_longrunning_tests=
982 inc_privileged_tests=
983 inc_unportable_tests=
986 excl_longrunning_tests=
987 excl_privileged_tests=
988 excl_unportable_tests=
989 single_configure=false
1006 while test $# -gt 0; do
1011 --find | --fin | --fi | --f )
1014 --import | --impor | --impo | --imp | --im | --i )
1017 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1020 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1023 --update | --updat | --upda | --upd | --up | --u )
1026 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1029 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1030 mode=create-megatestdir
1032 --test | --tes | --te | --t )
1035 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1039 mode=`echo "X$1" | sed -e 's/^X--//'`
1041 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1046 if test $# = 0; then
1047 func_fatal_error "missing argument for --dir"
1052 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1056 if test $# = 0; then
1057 func_fatal_error "missing argument for --local-dir"
1062 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1064 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1067 --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 )
1070 --verbose | --verbos | --verbo | --verb )
1071 verbose=`expr $verbose + 1`
1073 --quiet | --quie | --qui | --qu | --q )
1074 verbose=`expr $verbose - 1`
1078 if test $# = 0; then
1079 func_fatal_error "missing argument for --lib"
1082 supplied_libname=true
1085 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1086 supplied_libname=true
1090 if test $# = 0; then
1091 func_fatal_error "missing argument for --source-base"
1096 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1100 if test $# = 0; then
1101 func_fatal_error "missing argument for --m4-base"
1106 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1110 if test $# = 0; then
1111 func_fatal_error "missing argument for --po-base"
1116 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1120 if test $# = 0; then
1121 func_fatal_error "missing argument for --doc-base"
1126 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1130 if test $# = 0; then
1131 func_fatal_error "missing argument for --tests-base"
1136 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1140 if test $# = 0; then
1141 func_fatal_error "missing argument for --aux-dir"
1146 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1148 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1151 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1154 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1157 --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)
1158 inc_longrunning_tests=true
1160 --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)
1161 inc_privileged_tests=true
1163 --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)
1164 inc_unportable_tests=true
1166 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1169 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1172 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1175 --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)
1176 excl_longrunning_tests=true
1178 --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)
1179 excl_privileged_tests=true
1181 --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)
1182 excl_unportable_tests=true
1184 --single-configure | --single-configur | --single-configu | --single-config | --single-confi | --single-conf | --single-con | --single-con | --single-co | --single-c | --single- | --single | --singl | --sing | --sin | --si)
1185 single_configure=true
1189 if test $# = 0; then
1190 func_fatal_error "missing argument for --avoid"
1192 func_append avoidlist " $1"
1195 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1196 func_append avoidlist " $arg"
1198 --conditional-dependencies | --conditional-dependencie | --conditional-dependenci | --conditional-dependenc | --conditional-dependen | --conditional-depende | --conditional-depend | --conditional-depen | --conditional-depe | --conditional-dep | --conditional-de | --conditional-d | --conditional- | --conditional | --conditiona | --condition | --conditio | --conditi | --condit | --condi | --cond | --con)
1199 cond_dependencies=true
1201 --no-conditional-dependencies | --no-conditional-dependencie | --no-conditional-dependenci | --no-conditional-dependenc | --no-conditional-dependen | --no-conditional-depende | --no-conditional-depend | --no-conditional-depen | --no-conditional-depe | --no-conditional-dep | --no-conditional-de | --no-conditional-d | --no-conditional- | --no-conditional | --no-conditiona | --no-condition | --no-conditio | --no-conditi | --no-condit | --no-condi | --no-cond | --no-con | --no-co)
1202 cond_dependencies=false
1208 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1211 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1217 if test $# = 0; then
1218 func_fatal_error "missing argument for --makefile-name"
1223 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1233 if test $# = 0; then
1234 func_fatal_error "missing argument for --macro-prefix"
1239 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1243 if test $# = 0; then
1244 func_fatal_error "missing argument for --po-domain"
1249 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1253 if test $# = 0; then
1254 func_fatal_error "missing argument for --witness-c-macro"
1256 witness_c_macro="$1"
1258 --witness-c-macro=* )
1259 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1267 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1268 # A no-op for backward compatibility.
1273 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1276 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1279 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1283 --help | --hel | --he | --h )
1286 --version | --versio | --versi | --vers )
1290 # Stop option processing
1294 echo "gnulib-tool: unknown option $1" 1>&2
1295 echo "Try 'gnulib-tool --help' for more information." 1>&2
1302 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1303 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1304 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1305 || test "$single_configure" != false; then
1306 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1307 echo "Try 'gnulib-tool --help' for more information." 1>&2
1311 if test "$mode" = update; then
1312 if test $# != 0; then
1313 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1314 echo "Try 'gnulib-tool --help' for more information." 1>&2
1315 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1316 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1319 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1320 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1321 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1322 || test -n "$inctests" || test -n "$incobsolete" \
1323 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1324 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1325 || test -n "$inc_all_tests" \
1326 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1327 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1328 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1329 || test -n "$macro_prefix" || test -n "$po_domain" \
1330 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1331 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1332 echo "Try 'gnulib-tool --help' for more information." 1>&2
1333 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1334 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1338 if test -n "$pobase" && test -z "$po_domain"; then
1339 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1340 echo "Try 'gnulib-tool --help' for more information." 1>&2
1343 if test -z "$pobase" && test -n "$po_domain"; then
1344 func_warning "--po-domain has no effect without a --po-base option"
1346 # Canonicalize the inctests variable.
1348 import | add-import | remove-import | update)
1349 if test -z "$inctests"; then
1353 create-testdir | create-megatestdir | test | megatest)
1354 if test -z "$inctests"; then
1359 # Now the only possible values of "$inctests" are true and false
1360 # (or blank but then it is irrelevant).
1361 if test "$cond_dependencies" = true && test "$inctests" = true; then
1362 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1366 # Determine the minimum supported autoconf version from the project's
1368 DEFAULT_AUTOCONF_MINVERSION="2.59"
1369 autoconf_minversion=
1371 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1372 && test -n "$destdir"; then
1373 if test -f "$destdir"/configure.ac; then
1374 configure_ac="$destdir/configure.ac"
1376 if test -f "$destdir"/configure.in; then
1377 configure_ac="$destdir/configure.in"
1381 if test -f configure.ac; then
1382 configure_ac="configure.ac"
1384 if test -f configure.in; then
1385 configure_ac="configure.in"
1389 if test -n "$configure_ac"; then
1390 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1391 # because when some m4 files are omitted from a version control repository,
1392 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1393 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1394 # autom4te: m4 failed with exit status: 1
1401 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1403 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1404 if test -n "$prereqs"; then
1405 autoconf_minversion=`
1406 for version in $prereqs; do echo $version; done |
1407 LC_ALL=C sort -nru | sed -e 1q
1411 if test -z "$autoconf_minversion"; then
1412 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1414 case "$autoconf_minversion" in
1415 1.* | 2.[0-4]* | 2.5[0-8]*)
1416 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1419 # Remove trailing slashes from the directory names. This is necessary for
1420 # m4base (to avoid an error in func_import) and optional for the others.
1421 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1422 case "$local_gnulib_dir" in
1423 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1425 case "$sourcebase" in
1426 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1429 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1432 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1435 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1437 case "$testsbase" in
1438 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1441 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1447 trap 'exit_status=$?
1448 if test "$signal" != 0; then
1449 echo "caught signal $signal" >&2
1452 exit $exit_status' 0
1453 for signal in 1 2 3 13 15; do
1454 trap '{ signal='$signal'; func_exit 1; }' $signal
1458 # Note: The 'eval' silences stderr output in dash.
1459 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1460 # Zsh 4 and Bash 4 have associative arrays.
1461 have_associative=true
1463 # For other shells, use 'eval' with computed shell variable names.
1464 have_associative=false
1467 # func_lookup_file file
1468 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1471 # - local_gnulib_dir from --local-dir
1473 # - lookedup_file name of the merged (combined) file
1474 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1478 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1479 lookedup_file="$local_gnulib_dir/$lkfile"
1482 if test -f "$gnulib_dir/$lkfile"; then
1483 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1484 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1485 rm -f "$tmp/$lkbase"
1486 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1487 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1488 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1489 lookedup_file="$tmp/$lkbase"
1492 lookedup_file="$gnulib_dir/$lkfile"
1496 func_fatal_error "file $gnulib_dir/$lkfile not found"
1501 # func_sanitize_modulelist
1502 # receives a list of possible module names on standard input, one per line.
1503 # It removes those which are just file names unrelated to modules, and outputs
1504 # the resulting list to standard output, one per line.
1505 func_sanitize_modulelist ()
1507 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1508 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1509 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1510 -e '/^README$/d' -e '/\/README$/d' \
1511 -e '/^TEMPLATE$/d' \
1512 -e '/^TEMPLATE-EXTENDED$/d' \
1513 -e '/^TEMPLATE-TESTS$/d' \
1520 # - local_gnulib_dir from --local-dir
1523 # Filter out metainformation files like README, which are not modules.
1524 # Filter out unit test modules; they can be retrieved through
1525 # --extract-tests-module if desired.
1527 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1528 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1529 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1532 | func_sanitize_modulelist \
1533 | sed -e '/-tests$/d' \
1537 # func_exists_module module
1538 # tests whether a module, given by name, exists
1540 # - local_gnulib_dir from --local-dir
1541 func_exists_module ()
1543 { test -f "$gnulib_dir/modules/$1" \
1544 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1545 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1546 && test "CVS" != "$1" \
1547 && test "ChangeLog" != "$1" \
1548 && test "COPYING" != "$1" \
1549 && test "README" != "$1" \
1550 && test "TEMPLATE" != "$1" \
1551 && test "TEMPLATE-EXTENDED" != "$1" \
1552 && test "TEMPLATE-TESTS" != "$1"
1555 # func_verify_module
1556 # verifies a module name
1558 # - local_gnulib_dir from --local-dir
1559 # - module module name argument
1560 func_verify_module ()
1562 if func_exists_module "$module"; then
1563 # OK, $module is a correct module name.
1564 # Verify that building the module description with 'patch' succeeds.
1565 func_lookup_file "modules/$module"
1567 func_warning "module $module doesn't exist"
1572 # func_verify_nontests_module
1573 # verifies a module name, excluding tests modules
1575 # - local_gnulib_dir from --local-dir
1576 # - module module name argument
1577 func_verify_nontests_module ()
1580 *-tests ) module= ;;
1581 * ) func_verify_module ;;
1585 # func_verify_tests_module
1586 # verifies a module name, considering only tests modules
1588 # - local_gnulib_dir from --local-dir
1589 # - module module name argument
1590 func_verify_tests_module ()
1593 *-tests ) func_verify_module ;;
1598 # Suffix of a sed expression that extracts a particular field from a
1599 # module description.
1600 # A field starts with a line that contains a keyword, such as 'Description',
1601 # followed by a colon and optional whitespace. All following lines, up to
1602 # the next field (or end of file if there is none) form the contents of the
1604 # An absent field is equivalent to a field with empty contents.
1605 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1606 sed_extract_prog=':[ ]*$/ {
1609 s/^Description:[ ]*$//
1613 s/^Applicability:[ ]*$//
1615 s/^Depends-on:[ ]*$//
1616 s/^configure\.ac-early:[ ]*$//
1617 s/^configure\.ac:[ ]*$//
1618 s/^Makefile\.am:[ ]*$//
1622 s/^Maintainer:[ ]*$//
1629 # Piece of a sed expression that converts a field header line to a shell
1631 # NOTE: Keep this in sync with sed_extract_prog above!
1632 sed_extract_field_header='
1633 s/^Description:[ ]*$/description/
1634 s/^Comment:[ ]*$/comment/
1635 s/^Status:[ ]*$/status/
1636 s/^Notice:[ ]*$/notice/
1637 s/^Applicability:[ ]*$/applicability/
1638 s/^Files:[ ]*$/files/
1639 s/^Depends-on:[ ]*$/dependson/
1640 s/^configure\.ac-early:[ ]*$/configureac_early/
1641 s/^configure\.ac:[ ]*$/configureac/
1642 s/^Makefile\.am:[ ]*$/makefile/
1643 s/^Include:[ ]*$/include/
1645 s/^License:[ ]*$/license/
1646 s/^Maintainer:[ ]*$/maintainer/'
1650 if $have_associative; then
1652 # Declare the associative arrays.
1653 declare -A modcache_cached
1654 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1655 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1656 eval "$declare_script"
1660 # func_cache_var module
1661 # computes the cache variable name corresponding to $module.
1662 # Note: This computation can map different module names to the same
1663 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1664 # to protect against this case.
1666 # - cachevar a shell variable name
1667 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1668 # Bash 2.0 and newer, ksh, and zsh support the syntax
1669 # ${param//pattern/replacement}
1670 # as a shorthand for
1671 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1672 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1673 eval 'func_cache_var ()
1675 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1682 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1691 # func_init_sed_convert_to_cache_statements
1693 # - modcachevar_assignment
1695 # - sed_convert_to_cache_statements
1696 func_init_sed_convert_to_cache_statements ()
1698 # 'sed' script that turns a module description into shell script
1699 # assignments, suitable to be eval'ed. All active characters are escaped.
1702 # Some module's description
1707 # modcache_description[$1]=\
1708 # 'Some module'"'"'s description
1710 # modcache_files[$1]=\
1713 # c_MODULE_description_set=set; c_MODULE_description=\
1714 # 'Some module'"'"'s description
1716 # c_MODULE_files_set=set; c_MODULE_files=\
1718 # The script consists of two parts:
1719 # 1) Ignore the lines before the first field header.
1720 # 2) A loop, treating non-field-header lines by escaping single quotes
1721 # and adding a closing quote in the last line,
1722 sed_convert_to_cache_statements="
1724 # Here we have not yet seen a field header.
1726 # See if the current line contains a field header.
1729 ${sed_extract_field_header}
1732 # No field header. Ignore the line.
1734 # Read the next line. Upon EOF, just exit.
1739 # The current line contains a field header.
1741 # Turn it into the beginning of an assignment.
1742 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1744 # Move it to the hold space. Don't print it yet,
1745 # because we want no assignment if the field is empty.
1748 # Read the next line.
1749 # Upon EOF, the field was empty. Print no assignment. Just exit.
1752 # See if the current line contains a field header.
1755 ${sed_extract_field_header}
1756 # If it is, the previous field was empty. Print no assignment.
1759 # Not a field header.
1761 # Print the previous line, held in the hold space.
1766 # Transform single quotes.
1769 # Prepend a single quote.
1774 # Move it to the hold space.
1777 # Read the next line.
1784 # See if the current line contains a field header.
1787 ${sed_extract_field_header}
1790 # Print the previous line, held in the hold space.
1795 # Transform single quotes.
1802 # Print the previous line, held in the hold space, with a single quote
1803 # to end the assignment.
1813 # Print the previous line, held in the hold space, with a single quote
1814 # to end the assignment.
1821 if ! $sed_comments; then
1823 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1824 | sed -e 's/^ *//' -e 's/^#.*//'`
1828 if $have_associative; then
1829 # sed_convert_to_cache_statements does not depend on the module.
1830 modcachevar_assignment='modcache_\1[$1]='
1831 func_init_sed_convert_to_cache_statements
1834 # func_cache_lookup_module module
1836 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1837 # of its relevant data in a cache in the memory of the processing shell. If
1838 # already cached, it does not look it up again, thus saving file access time.
1840 # - module non-empty string
1841 # Output if $have_associative:
1842 # - modcache_cached[$module] set to yes
1843 # - modcache_description[$module] ==
1844 # - modcache_status[$module] \ set to the field's value, minus the
1845 # - ... / final newline,
1846 # - modcache_maintainer[$module] == or unset if the field's value is empty
1847 # Output if ! $have_associative:
1848 # - cachevar a shell variable name
1849 # - ${cachevar}_cached set to $module
1850 # - ${cachevar}_description ==
1851 # - ${cachevar}_status \ set to the field's value, minus the
1852 # - ... / final newline,
1853 # - ${cachevar}_maintainer == or unset if the field's value is empty
1854 # - ${cachevar}_description_set ==
1855 # - ${cachevar}_status_set \ set to non-empty if the field's value
1856 # - ... / is non-empty,
1857 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1858 func_cache_lookup_module ()
1860 if $have_associative; then
1861 eval 'cached=${modcache_cached[$1]}'
1864 eval "cached=\"\$${cachevar}_cached\""
1866 if test -z "$cached"; then
1867 # Not found in cache. Look it up on the file system.
1868 func_lookup_file "modules/$1"
1869 if $have_associative; then
1870 eval 'modcache_cached[$1]=yes'
1872 eval "${cachevar}_cached=\"\$1\""
1874 if ! $have_associative; then
1875 # sed_convert_to_cache_statements depends on the module.
1876 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1877 func_init_sed_convert_to_cache_statements
1879 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1880 eval "$cache_statements"
1882 if ! $have_associative; then
1883 if test "$1" != "$cached"; then
1884 func_fatal_error "cache variable collision between $1 and $cached"
1892 # func_get_description module
1894 # - local_gnulib_dir from --local-dir
1895 # - modcache true or false, from --cache-modules/--no-cache-modules
1896 func_get_description ()
1898 if ! $modcache; then
1899 func_lookup_file "modules/$1"
1900 sed -n -e "/^Description$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_description[$1]+set}"'; then
1906 eval 'echo "${modcache_description[$1]}"'
1909 eval "field_set=\"\$${cachevar}_description_set\""
1910 if test -n "$field_set"; then
1911 eval "field_value=\"\$${cachevar}_description\""
1912 echo "${field_value}"
1918 # func_get_comment 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 "/^Comment$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_comment[$1]+set}"'; then
1932 eval 'echo "${modcache_comment[$1]}"'
1935 eval "field_set=\"\$${cachevar}_comment_set\""
1936 if test -n "$field_set"; then
1937 eval "field_value=\"\$${cachevar}_comment\""
1938 echo "${field_value}"
1944 # func_get_status module
1946 # - local_gnulib_dir from --local-dir
1947 # - modcache true or false, from --cache-modules/--no-cache-modules
1950 if ! $modcache; then
1951 func_lookup_file "modules/$1"
1952 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1954 func_cache_lookup_module "$1"
1955 # Output the field's value, including the final newline (if any).
1956 if $have_associative; then
1957 if eval 'test -n "${modcache_status[$1]+set}"'; then
1958 eval 'echo "${modcache_status[$1]}"'
1961 eval "field_set=\"\$${cachevar}_status_set\""
1962 if test -n "$field_set"; then
1963 eval "field_value=\"\$${cachevar}_status\""
1964 echo "${field_value}"
1970 # func_get_notice module
1972 # - local_gnulib_dir from --local-dir
1973 # - modcache true or false, from --cache-modules/--no-cache-modules
1976 if ! $modcache; then
1977 func_lookup_file "modules/$1"
1978 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1980 func_cache_lookup_module "$1"
1981 # Output the field's value, including the final newline (if any).
1982 if $have_associative; then
1983 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1984 eval 'echo "${modcache_notice[$1]}"'
1987 eval "field_set=\"\$${cachevar}_notice_set\""
1988 if test -n "$field_set"; then
1989 eval "field_value=\"\$${cachevar}_notice\""
1990 echo "${field_value}"
1996 # func_get_applicability module
1998 # - local_gnulib_dir from --local-dir
1999 # - modcache true or false, from --cache-modules/--no-cache-modules
2000 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2001 func_get_applicability ()
2003 if ! $modcache; then
2004 func_lookup_file "modules/$1"
2005 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2007 func_cache_lookup_module "$1"
2008 # Get the field's value, without the final newline.
2009 if $have_associative; then
2010 eval 'my_applicability="${modcache_applicability[$1]}"'
2012 eval "my_applicability=\"\$${cachevar}_applicability\""
2015 if test -n "$my_applicability"; then
2016 echo $my_applicability
2018 # The default is 'main' or 'tests', depending on the module's name.
2020 *-tests) echo "tests";;
2026 # func_get_filelist module
2028 # - local_gnulib_dir from --local-dir
2029 # - modcache true or false, from --cache-modules/--no-cache-modules
2030 func_get_filelist ()
2032 if ! $modcache; then
2033 func_lookup_file "modules/$1"
2034 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2036 func_cache_lookup_module "$1"
2037 # Output the field's value, including the final newline (if any).
2038 if $have_associative; then
2039 if eval 'test -n "${modcache_files[$1]+set}"'; then
2040 eval 'echo "${modcache_files[$1]}"'
2043 eval "field_set=\"\$${cachevar}_files_set\""
2044 if test -n "$field_set"; then
2045 eval "field_value=\"\$${cachevar}_files\""
2046 echo "${field_value}"
2051 echo m4/gnulib-common.m4
2052 case "$autoconf_minversion" in
2059 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2060 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2061 # elements starting with prefix and ending with suffix are considered.
2062 # Processing: removed_prefix and removed_suffix are removed from each element,
2063 # added_prefix and added_suffix are added to each element.
2064 # prefix, suffix should not contain shell-special characters.
2065 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2066 # added_prefix, added_suffix should not contain the characters \|&.
2067 func_filter_filelist ()
2069 if test "$2" != "$nl" \
2070 || { $fast_func_append \
2071 && { test -z "$6" || $fast_func_remove_prefix; } \
2072 && { test -z "$7" || $fast_func_remove_suffix; }; \
2076 # Do not quote possibly-empty parameters in case patterns,
2077 # AIX and HP-UX ksh won't match them if they are empty.
2080 if test -n "$6"; then
2081 func_remove_prefix fff "$6"
2083 if test -n "$7"; then
2084 func_remove_suffix fff "$7"
2087 if test -z "$ffflist"; then
2090 func_append ffflist "$2${fff}"
2096 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2097 ffflist=`for fff in $3; do
2099 $4*$5) echo "$fff" ;;
2101 done | sed -e "$sed_fff_filter"`
2103 eval "$1=\"\$ffflist\""
2106 # func_get_dependencies module
2108 # - local_gnulib_dir from --local-dir
2109 # - modcache true or false, from --cache-modules/--no-cache-modules
2110 func_get_dependencies ()
2112 # ${module}-tests implicitly depends on ${module}, if that module exists.
2116 func_remove_suffix fgd1 '-tests'
2117 if func_exists_module "$fgd1"; then
2122 # Then the explicit dependencies listed in the module description.
2123 { if ! $modcache; then
2124 func_lookup_file "modules/$1"
2125 sed -n -e "/^Depends-on$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_dependson[$1]+set}"'; then
2131 eval 'echo "${modcache_dependson[$1]}"'
2134 eval "field_set=\"\$${cachevar}_dependson_set\""
2135 if test -n "$field_set"; then
2136 eval "field_value=\"\$${cachevar}_dependson\""
2137 echo "${field_value}"
2145 # func_get_autoconf_early_snippet module
2147 # - local_gnulib_dir from --local-dir
2148 # - modcache true or false, from --cache-modules/--no-cache-modules
2149 func_get_autoconf_early_snippet ()
2151 if ! $modcache; then
2152 func_lookup_file "modules/$1"
2153 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2155 func_cache_lookup_module "$1"
2156 # Output the field's value, including the final newline (if any).
2157 if $have_associative; then
2158 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2159 eval 'echo "${modcache_configureac_early[$1]}"'
2162 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2163 if test -n "$field_set"; then
2164 eval "field_value=\"\$${cachevar}_configureac_early\""
2165 echo "${field_value}"
2171 # func_get_autoconf_snippet module
2173 # - local_gnulib_dir from --local-dir
2174 # - modcache true or false, from --cache-modules/--no-cache-modules
2175 func_get_autoconf_snippet ()
2177 if ! $modcache; then
2178 func_lookup_file "modules/$1"
2179 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2181 func_cache_lookup_module "$1"
2182 # Output the field's value, including the final newline (if any).
2183 if $have_associative; then
2184 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2185 eval 'echo "${modcache_configureac[$1]}"'
2188 eval "field_set=\"\$${cachevar}_configureac_set\""
2189 if test -n "$field_set"; then
2190 eval "field_value=\"\$${cachevar}_configureac\""
2191 echo "${field_value}"
2197 # func_get_automake_snippet_conditional module
2198 # returns the part of the Makefile.am snippet that can be put inside Automake
2201 # - local_gnulib_dir from --local-dir
2202 # - modcache true or false, from --cache-modules/--no-cache-modules
2203 func_get_automake_snippet_conditional ()
2205 if ! $modcache; then
2206 func_lookup_file "modules/$1"
2207 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2209 func_cache_lookup_module "$1"
2210 # Output the field's value, including the final newline (if any).
2211 if $have_associative; then
2212 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2213 eval 'echo "${modcache_makefile[$1]}"'
2216 eval "field_set=\"\$${cachevar}_makefile_set\""
2217 if test -n "$field_set"; then
2218 eval "field_value=\"\$${cachevar}_makefile\""
2219 echo "${field_value}"
2225 # func_get_automake_snippet_unconditional module
2226 # returns the part of the Makefile.am snippet that must stay outside of
2227 # Automake conditionals.
2229 # - local_gnulib_dir from --local-dir
2230 # - modcache true or false, from --cache-modules/--no-cache-modules
2231 func_get_automake_snippet_unconditional ()
2235 # *-tests module live in tests/, not lib/.
2236 # Synthesize an EXTRA_DIST augmentation.
2237 all_files=`func_get_filelist $1`
2238 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2239 extra_files="$tests_files"
2240 if test -n "$extra_files"; then
2241 echo "EXTRA_DIST +=" $extra_files
2246 # Synthesize an EXTRA_DIST augmentation.
2247 sed_combine_lines='/\\$/{
2254 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2255 already_mentioned_files=` \
2256 { if ! $modcache; then
2257 func_lookup_file "modules/$1"
2258 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2260 func_cache_lookup_module "$1"
2261 if $have_associative; then
2262 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2263 eval 'echo "${modcache_makefile[$1]}"'
2266 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2267 if test -n "$field_set"; then
2268 eval 'field_value="$'"${cachevar}"'_makefile"'
2269 echo "${field_value}"
2274 | sed -e "$sed_combine_lines" \
2275 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2276 all_files=`func_get_filelist $1`
2277 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2278 # Remove $already_mentioned_files from $lib_files.
2279 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2280 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2281 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2282 if test -n "$extra_files"; then
2283 echo "EXTRA_DIST +=" $extra_files
2286 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2287 # This is necessary so that automake can generate the right list of
2289 # A possible approach would be to use autom4te --trace of the redefined
2290 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2291 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2292 # inside autoconf's built-in macros are not missed).
2293 # But it's simpler and more robust to do it here, based on the file list.
2294 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2295 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2296 # automake will generate a useless dependency; this is harmless.
2298 relocatable-prog-wrapper) ;;
2301 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2302 if test -n "$extra_files"; then
2303 echo "EXTRA_lib_SOURCES +=" $extra_files
2308 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2309 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2310 if test -n "$buildaux_files"; then
2311 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2312 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2315 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2316 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2317 if test -n "$top_files"; then
2318 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2319 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2326 # func_get_automake_snippet module
2328 # - local_gnulib_dir from --local-dir
2329 # - modcache true or false, from --cache-modules/--no-cache-modules
2330 func_get_automake_snippet ()
2332 func_get_automake_snippet_conditional "$1"
2333 func_get_automake_snippet_unconditional "$1"
2336 # func_get_include_directive module
2338 # - local_gnulib_dir from --local-dir
2339 # - modcache true or false, from --cache-modules/--no-cache-modules
2340 func_get_include_directive ()
2343 if ! $modcache; then
2344 func_lookup_file "modules/$1"
2345 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2347 func_cache_lookup_module "$1"
2348 # Output the field's value, including the final newline (if any).
2349 if $have_associative; then
2350 if eval 'test -n "${modcache_include[$1]+set}"'; then
2351 eval 'echo "${modcache_include[$1]}"'
2354 eval "field_set=\"\$${cachevar}_include_set\""
2355 if test -n "$field_set"; then
2356 eval "field_value=\"\$${cachevar}_include\""
2357 echo "${field_value}"
2361 } | sed -e 's/^\(["<]\)/#include \1/'
2364 # func_get_link_directive module
2366 # - local_gnulib_dir from --local-dir
2367 # - modcache true or false, from --cache-modules/--no-cache-modules
2368 func_get_link_directive ()
2370 if ! $modcache; then
2371 func_lookup_file "modules/$1"
2372 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2374 func_cache_lookup_module "$1"
2375 # Output the field's value, including the final newline (if any).
2376 if $have_associative; then
2377 if eval 'test -n "${modcache_link[$1]+set}"'; then
2378 eval 'echo "${modcache_link[$1]}"'
2381 eval "field_set=\"\$${cachevar}_link_set\""
2382 if test -n "$field_set"; then
2383 eval "field_value=\"\$${cachevar}_link\""
2384 echo "${field_value}"
2390 # func_get_license_raw module
2392 # - local_gnulib_dir from --local-dir
2393 # - modcache true or false, from --cache-modules/--no-cache-modules
2394 func_get_license_raw ()
2396 if ! $modcache; then
2397 func_lookup_file "modules/$1"
2398 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2400 func_cache_lookup_module "$1"
2401 # Output the field's value, including the final newline (if any).
2402 if $have_associative; then
2403 if eval 'test -n "${modcache_license[$1]+set}"'; then
2404 eval 'echo "${modcache_license[$1]}"'
2407 eval "field_set=\"\$${cachevar}_license_set\""
2408 if test -n "$field_set"; then
2409 eval "field_value=\"\$${cachevar}_license\""
2410 echo "${field_value}"
2416 # func_get_license module
2418 # - local_gnulib_dir from --local-dir
2419 # - modcache true or false, from --cache-modules/--no-cache-modules
2422 # Warn if the License field is missing.
2426 license=`func_get_license_raw "$1"`
2427 if test -z "$license"; then
2428 func_warning "module $1 lacks a License"
2433 func_get_license_raw "$1"
2434 # The default is GPL.
2436 } | sed -e 's,^ *$,,' | sed -e 1q
2439 # func_get_maintainer module
2441 # - local_gnulib_dir from --local-dir
2442 # - modcache true or false, from --cache-modules/--no-cache-modules
2443 func_get_maintainer ()
2445 if ! $modcache; then
2446 func_lookup_file "modules/$1"
2447 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2449 func_cache_lookup_module "$1"
2450 # Output the field's value, including the final newline (if any).
2451 if $have_associative; then
2452 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2453 eval 'echo "${modcache_maintainer[$1]}"'
2456 eval "field_set=\"\$${cachevar}_maintainer_set\""
2457 if test -n "$field_set"; then
2458 eval "field_value=\"\$${cachevar}_maintainer\""
2459 echo "${field_value}"
2465 # func_get_tests_module module
2467 # - local_gnulib_dir from --local-dir
2468 func_get_tests_module ()
2470 # The naming convention for tests modules is hardwired: ${module}-tests.
2471 if test -f "$gnulib_dir/modules/$1"-tests \
2472 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2473 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2478 # func_acceptable module
2479 # tests whether a module is acceptable.
2481 # - avoidlist list of modules to avoid
2484 for avoid in $avoidlist; do
2485 if test "$avoid" = "$1"; then
2492 # sed expression to keep the first 32 characters of each line.
2493 sed_first_32_chars='s/^\(................................\).*/\1/'
2495 # func_module_shellfunc_name module
2496 # computes the shell function name that will contain the m4 macros for the module.
2498 # - macro_prefix prefix to use
2500 # - shellfunc shell function name
2501 func_module_shellfunc_name ()
2505 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2507 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2511 # func_module_shellvar_name module
2512 # computes the shell variable name the will be set to true once the m4 macros
2513 # for the module have been executed.
2515 # - shellvar shell variable name
2516 func_module_shellvar_name ()
2520 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2522 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2526 # func_module_conditional_name module
2527 # computes the automake conditional name for the module.
2529 # - conditional name of automake conditional
2530 func_module_conditional_name ()
2534 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2536 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2540 # func_uncond_add_module B
2541 # notes the presence of B as an unconditional module.
2543 # func_conddep_add_module A B cond
2544 # notes the presence of a conditional dependency from module A to module B,
2545 # subject to the condition that A is enabled and cond is true.
2547 # func_cond_module_p B
2548 # tests whether module B is conditional.
2550 # func_cond_module_condition A B
2551 # returns the condition when B should be enabled as a dependency of A, once the
2552 # m4 code for A has been executed.
2553 # Output: - condition
2555 if $have_associative; then
2556 declare -A conddep_isuncond
2557 declare -A conddep_dependers
2558 declare -A conddep_condition
2559 func_uncond_add_module ()
2561 eval 'conddep_isuncond[$1]=true'
2562 eval 'unset conddep_dependers[$1]'
2564 func_conddep_add_module ()
2566 eval 'isuncond="${conddep_isuncond[$2]}"'
2567 if test -z "$isuncond"; then
2568 # No unconditional dependency to B known at this point.
2569 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2570 eval 'conddep_condition[$1---$2]="$3"'
2573 func_cond_module_p ()
2575 eval 'previous_dependers="${conddep_dependers[$1]}"'
2576 test -n "$previous_dependers"
2578 func_cond_module_condition ()
2580 eval 'condition="${conddep_condition[$1---$2]}"'
2583 func_uncond_add_module ()
2587 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2591 eval 'conddep_isuncond_'"$suffix"'=true'
2592 eval 'unset conddep_dependers_'"$suffix"
2594 func_conddep_add_module ()
2598 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2602 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2603 if test -z "$isuncond"; then
2604 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2605 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2606 eval 'conddep_condition_'"$suffix"'="$3"'
2609 func_cond_module_p ()
2613 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2617 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2618 test -n "$previous_dependers"
2620 func_cond_module_condition ()
2622 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2623 eval 'condition="${conddep_condition_'"$suffix"'}"'
2627 sed_dependencies_without_conditions='s/ *\[.*//'
2629 # func_modules_transitive_closure
2631 # - local_gnulib_dir from --local-dir
2632 # - modcache true or false, from --cache-modules/--no-cache-modules
2633 # - modules list of specified modules
2634 # - inctests true if tests should be included, false otherwise
2635 # - incobsolete true if obsolete modules among dependencies should be
2636 # included, blank otherwise
2637 # - inc_cxx_tests true if C++ interoperability tests should be included,
2639 # - inc_longrunning_tests true if long-runnings tests should be included,
2641 # - inc_privileged_tests true if tests that require root privileges should be
2642 # included, blank otherwise
2643 # - inc_unportable_tests true if tests that fail on some platforms should be
2644 # included, blank otherwise
2645 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2646 # the unit tests of the specified modules should be
2647 # included, blank otherwise
2648 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2649 # the unit tests of the dependencies should be
2650 # included, blank otherwise
2651 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2653 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2655 # - excl_privileged_tests true if tests that require root privileges should be
2656 # excluded, blank otherwise
2657 # - excl_unportable_tests true if tests that fail on some platforms should be
2658 # excluded, blank otherwise
2659 # - avoidlist list of modules to avoid
2660 # - cond_dependencies true if conditional dependencies shall be supported,
2662 # - tmp pathname of a temporary directory
2664 # - modules list of modules, including dependencies
2665 # - conddep_dependers, conddep_condition information about conditionally
2667 func_modules_transitive_closure ()
2669 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2670 # In order to process every module only once (for speed), process an "input
2671 # list" of modules, producing an "output list" of modules. During each round,
2672 # more modules can be queued in the input list. Once a module on the input
2673 # list has been processed, it is added to the "handled list", so we can avoid
2674 # to process it again.
2676 inmodules="$modules"
2678 fmtc_inc_all_tests="$inc_all_direct_tests"
2679 if test "$cond_dependencies" = true; then
2680 for module in $inmodules; do
2682 if test -n "$module"; then
2683 if func_acceptable $module; then
2684 func_uncond_add_module $module
2689 while test -n "$inmodules"; do
2690 inmodules_this_round="$inmodules"
2691 inmodules= # Accumulator, queue for next round
2692 for module in $inmodules_this_round; do
2694 if test -n "$module"; then
2695 if func_acceptable $module; then
2696 func_append outmodules " $module"
2697 if test "$cond_dependencies" = true; then
2698 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2699 # A module whose Makefile.am snippet contains a reference to an
2700 # automake conditional. If we were to use it conditionally, we
2701 # would get an error
2702 # configure: error: conditional "..." was never defined.
2703 # because automake 1.11.1 does not handle nested conditionals
2704 # correctly. As a workaround, make the module unconditional.
2705 func_uncond_add_module $module
2707 if func_cond_module_p $module; then
2713 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2714 # Duplicate dependencies are harmless, but Jim wants a warning.
2715 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2716 if test -n "$duplicated_deps"; then
2717 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2720 testsmodule=`func_get_tests_module $module`
2721 if test -n "$testsmodule"; then
2722 deps="$deps $testsmodule"
2725 for dep in $deps; do
2726 # Determine whether to include the dependency or tests module.
2728 for word in `func_get_status $dep`; do
2731 test -n "$incobsolete" \
2735 test -z "$excl_cxx_tests" \
2737 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2741 test -z "$excl_longrunning_tests" \
2743 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2747 test -z "$excl_privileged_tests" \
2749 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2753 test -z "$excl_unportable_tests" \
2755 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2759 test -n "$fmtc_inc_all_tests" \
2764 if $inc && func_acceptable "$dep"; then
2765 func_append inmodules " $dep"
2766 if test "$cond_dependencies" = true; then
2767 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2768 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2771 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2772 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2774 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2775 if test "$condition" = true; then
2778 if test -n "$condition"; then
2779 func_conddep_add_module "$module" "$dep" "$condition"
2781 if $conditional; then
2782 func_conddep_add_module "$module" "$dep" true
2784 func_uncond_add_module "$dep"
2793 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2794 # Remove $handledmodules from $inmodules.
2795 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2796 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2797 fmtc_inc_all_tests="$inc_all_indirect_tests"
2799 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2800 rm -f "$tmp"/queued-modules
2803 # func_show_module_list
2805 # - specified_modules list of specified modules (one per line, sorted)
2806 # - modules complete list of modules (one per line, sorted)
2807 # - tmp pathname of a temporary directory
2808 func_show_module_list ()
2814 # Assume xterm compatible escape sequences.
2815 bold_on=`printf '\x1b[1m'`
2816 bold_off=`printf '\x1b[0m'`
2821 echo "Module list with included dependencies (indented):"
2822 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2823 echo "$modules" | sed -e '/^$/d' \
2824 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2825 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2828 # func_modules_transitive_closure_separately
2829 # Determine main module list and tests-related module list separately.
2830 # The main module list is the transitive closure of the specified modules,
2831 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2832 # is specified, it will consist only of LGPLed source.
2833 # The tests-related module list is the transitive closure of the specified
2834 # modules, including tests modules, minus the main module list excluding
2835 # modules of applicability 'all'. Its lib/* sources (brought in through
2836 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2837 # source, even if --lgpl is specified.
2839 # - local_gnulib_dir from --local-dir
2840 # - modcache true or false, from --cache-modules/--no-cache-modules
2841 # - specified_modules list of specified modules
2842 # - inctests true if tests should be included, false otherwise
2843 # - incobsolete true if obsolete modules among dependencies should be
2844 # included, blank otherwise
2845 # - inc_cxx_tests true if C++ interoperability tests should be included,
2847 # - inc_longrunning_tests true if long-runnings tests should be included,
2849 # - inc_privileged_tests true if tests that require root privileges should be
2850 # included, blank otherwise
2851 # - inc_unportable_tests true if tests that fail on some platforms should be
2852 # included, blank otherwise
2853 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2854 # the unit tests of the specified modules should be
2855 # included, blank otherwise
2856 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2857 # the unit tests of the dependencies should be
2858 # included, blank otherwise
2859 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2861 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2863 # - excl_privileged_tests true if tests that require root privileges should be
2864 # excluded, blank otherwise
2865 # - excl_unportable_tests true if tests that fail on some platforms should be
2866 # excluded, blank otherwise
2867 # - avoidlist list of modules to avoid
2868 # - cond_dependencies true if conditional dependencies shall be supported,
2870 # - tmp pathname of a temporary directory
2872 # - main_modules list of modules, including dependencies
2873 # - testsrelated_modules list of tests-related modules, including dependencies
2874 # - conddep_dependers, conddep_condition information about conditionally
2876 func_modules_transitive_closure_separately ()
2878 # Determine main module list.
2879 saved_inctests="$inctests"
2881 modules="$specified_modules"
2882 func_modules_transitive_closure
2883 main_modules="$modules"
2884 inctests="$saved_inctests"
2885 if test $verbose -ge 1; then
2886 echo "Main module list:"
2887 echo "$main_modules" | sed -e 's/^/ /'
2889 # Determine tests-related module list.
2890 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2891 testsrelated_modules=`for module in $main_modules; do
2892 if test \`func_get_applicability $module\` = main; then
2896 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2897 if test $verbose -ge 1; then
2898 echo "Tests-related module list:"
2899 echo "$testsrelated_modules" | sed -e 's/^/ /'
2903 # func_determine_use_libtests
2904 # Determines whether a $testsbase/libtests.a is needed.
2906 # - local_gnulib_dir from --local-dir
2907 # - modcache true or false, from --cache-modules/--no-cache-modules
2908 # - testsrelated_modules list of tests-related modules, including dependencies
2910 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2911 func_determine_use_libtests ()
2914 for module in $testsrelated_modules; do
2915 func_verify_nontests_module
2916 if test -n "$module"; then
2917 all_files=`func_get_filelist $module`
2918 # Test whether some file in $all_files lies in lib/.
2919 for f in $all_files; do
2931 # func_modules_add_dummy
2933 # - local_gnulib_dir from --local-dir
2934 # - modcache true or false, from --cache-modules/--no-cache-modules
2935 # - modules list of modules, including dependencies
2937 # - modules list of modules, including 'dummy' if needed
2938 func_modules_add_dummy ()
2940 # Determine whether any module provides a lib_SOURCES augmentation.
2942 sed_remove_backslash_newline=':a
2949 for module in $modules; do
2950 func_verify_nontests_module
2951 if test -n "$module"; then
2952 # Extract the value of "lib_SOURCES += ...".
2953 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2954 # Ignore .h files since they are not compiled.
2958 have_lib_SOURCES=yes
2965 # Add the dummy module, to make sure the library will be non-empty.
2966 if test -z "$have_lib_SOURCES"; then
2967 if func_acceptable "dummy"; then
2968 func_append modules " dummy"
2973 # func_modules_add_dummy_separately
2975 # - local_gnulib_dir from --local-dir
2976 # - modcache true or false, from --cache-modules/--no-cache-modules
2977 # - main_modules list of modules, including dependencies
2978 # - testsrelated_modules list of tests-related modules, including dependencies
2979 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2981 # - main_modules list of modules, including 'dummy' if needed
2982 # - testsrelated_modules list of tests-related modules, including 'dummy' if
2984 func_modules_add_dummy_separately ()
2986 # Add the dummy module to the main module list if needed.
2987 modules="$main_modules"
2988 func_modules_add_dummy
2989 main_modules="$modules"
2991 # Add the dummy module to the tests-related module list if needed.
2992 if $use_libtests; then
2993 modules="$testsrelated_modules"
2994 func_modules_add_dummy
2995 testsrelated_modules="$modules"
2999 # func_modules_notice
3001 # - local_gnulib_dir from --local-dir
3002 # - modcache true or false, from --cache-modules/--no-cache-modules
3003 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3004 # - modules list of modules, including dependencies
3005 func_modules_notice ()
3007 if test $verbose -ge -1; then
3008 for module in $modules; do
3010 if test -n "$module"; then
3011 msg=`func_get_notice $module`
3012 if test -n "$msg"; then
3013 echo "Notice from module $module:"
3014 echo "$msg" | sed -e 's/^/ /'
3021 # func_modules_to_filelist
3023 # - local_gnulib_dir from --local-dir
3024 # - modcache true or false, from --cache-modules/--no-cache-modules
3025 # - modules list of modules, including dependencies
3027 # - files list of files
3028 func_modules_to_filelist ()
3031 for module in $modules; do
3033 if test -n "$module"; then
3034 fs=`func_get_filelist $module`
3035 func_append files " $fs"
3038 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3041 # func_modules_to_filelist_separately
3042 # Determine the final file lists.
3043 # They must be computed separately, because files in lib/* go into
3044 # $sourcebase/ if they are in the main file list but into $testsbase/
3045 # if they are in the tests-related file list. Furthermore lib/dummy.c
3048 # - local_gnulib_dir from --local-dir
3049 # - modcache true or false, from --cache-modules/--no-cache-modules
3050 # - main_modules list of modules, including dependencies
3051 # - testsrelated_modules list of tests-related modules, including dependencies
3052 func_modules_to_filelist_separately ()
3054 # Determine final main file list.
3055 modules="$main_modules"
3056 func_modules_to_filelist
3058 # Determine final tests-related file list.
3059 modules="$testsrelated_modules"
3060 func_modules_to_filelist
3061 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3062 # Merge both file lists.
3063 sed_remove_empty_lines='/^$/d'
3064 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3065 if test $verbose -ge 0; then
3067 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3068 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3072 # func_compute_include_guard_prefix
3073 # Determine include_guard_prefix.
3075 # - macro_prefix prefix of gl_LIBOBJS macros to use
3077 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3078 # - sed_replace_include_guard_prefix
3079 # sed expression for resolving ${gl_include_guard_prefix}
3080 func_compute_include_guard_prefix ()
3082 if test "$macro_prefix" = gl; then
3083 include_guard_prefix='GL'
3085 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3087 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3090 # func_execute_command command [args...]
3091 # Executes a command.
3092 # Uses also the variables
3093 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3094 func_execute_command ()
3096 if test $verbose -ge 0; then
3100 # Commands like automake produce output to stderr even when they succeed.
3101 # Turn this output off if the command succeeds.
3102 "$@" > "$tmp"/cmdout 2>&1
3104 if test $cmdret = 0; then
3108 cat "$tmp"/cmdout 1>&2
3115 # func_dest_tmpfilename file
3116 # determines the name of a temporary file (file is relative to destdir).
3118 # - destdir target directory
3119 # - doit : if actions shall be executed, false if only to be printed
3120 # - tmp pathname of a temporary directory
3122 # - tmpfile absolute filename of the temporary file
3123 func_dest_tmpfilename ()
3126 # Put the new contents of $file in a file in the same directory (needed
3127 # to guarantee that an 'mv' to "$destdir/$file" works).
3128 tmpfile="$destdir/$1.tmp"
3130 # Put the new contents of $file in a file in a temporary directory
3131 # (because the directory of "$file" might not exist).
3132 tmpfile="$tmp"/`basename "$1"`.tmp
3137 # copies a file from gnulib into the destination directory. The destination
3138 # is known to not exist.
3140 # - destdir target directory
3141 # - local_gnulib_dir from --local-dir
3142 # - modcache true or false, from --cache-modules/--no-cache-modules
3143 # - f the original file name
3144 # - lookedup_file name of the merged (combined) file
3145 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3146 # - g the rewritten file name
3147 # - tmpfile absolute filename of the temporary file
3148 # - doit : if actions shall be executed, false if only to be printed
3149 # - symbolic true if files should be symlinked, copied otherwise
3150 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3155 echo "Copying file $g"
3156 if { test -n "$symbolic" \
3157 || { test -n "$lsymbolic" \
3158 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3159 && test -z "$lookedup_tmp" \
3160 && cmp -s "$lookedup_file" "$tmpfile"; then
3161 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3163 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3171 # copies a file from gnulib into the destination directory. The destination
3172 # is known to exist.
3174 # - destdir target directory
3175 # - local_gnulib_dir from --local-dir
3176 # - modcache true or false, from --cache-modules/--no-cache-modules
3177 # - f the original file name
3178 # - lookedup_file name of the merged (combined) file
3179 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3180 # - g the rewritten file name
3181 # - tmpfile absolute filename of the temporary file
3182 # - doit : if actions shall be executed, false if only to be printed
3183 # - symbolic true if files should be symlinked, copied otherwise
3184 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3186 # - already_present nonempty if the file should already exist, empty otherwise
3189 if cmp -s "$destdir/$g" "$tmpfile"; then
3190 : # The file has not changed.
3194 if test -n "$already_present"; then
3195 echo "Updating file $g (backup in ${g}~)"
3197 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3199 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3200 if { test -n "$symbolic" \
3201 || { test -n "$lsymbolic" \
3202 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3203 && test -z "$lookedup_tmp" \
3204 && cmp -s "$lookedup_file" "$tmpfile"; then
3205 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3207 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3210 if test -n "$already_present"; then
3211 echo "Update file $g (backup in ${g}~)"
3213 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3219 # func_emit_lib_Makefile_am
3220 # emits the contents of library makefile to standard output.
3222 # - local_gnulib_dir from --local-dir
3223 # - modcache true or false, from --cache-modules/--no-cache-modules
3224 # - modules list of modules, including dependencies
3225 # - libname library name
3226 # - pobase directory relative to destdir where to place *.po files
3227 # - auxdir directory relative to destdir where to place build aux files
3228 # - makefile_name from --makefile-name
3229 # - libtool true if libtool will be used, false or blank otherwise
3230 # - macro_prefix prefix of gl_LIBOBJS macros to use
3231 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3232 # - witness_c_macro from --witness-c-macro
3233 # - actioncmd (optional) command that will reproduce this invocation
3234 # - for_test true if creating a package for testing, false otherwise
3235 # - sed_replace_include_guard_prefix
3236 # sed expression for resolving ${gl_include_guard_prefix}
3237 # - destfile filename relative to destdir of makefile being generated
3239 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3240 # list of edits to be done to Makefile.am variables
3242 # - uses_subdirs nonempty if object files in subdirs exist
3243 func_emit_lib_Makefile_am ()
3245 # When creating an includable Makefile.am snippet, augment variables with
3246 # += instead of assigning them.
3247 if test -n "$makefile_name"; then
3252 if test "$libtool" = true; then
3255 sed_eliminate_LDFLAGS="$sed_noop"
3259 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3262 # When creating a package for testing: Attempt to provoke failures,
3263 # especially link errors, already during "make" rather than during
3264 # "make check", because "make check" is not possible in a cross-compiling
3265 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3266 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3268 sed_transform_check_PROGRAMS="$sed_noop"
3270 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3271 echo "## Process this file with automake to produce Makefile.in."
3272 func_emit_copyright_notice
3273 if test -n "$actioncmd"; then
3274 # The maximum line length (excluding the terminating newline) of any file
3275 # that is to be preprocessed by config.status is 3070. config.status uses
3276 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3277 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3278 len=`echo "$actioncmd" | wc -c`
3279 if test -n "$len" && test "$len" -le 3000; then
3280 echo "# Reproduce by: $actioncmd"
3286 for module in $modules; do
3287 func_verify_nontests_module
3288 if test -n "$module"; then
3290 func_get_automake_snippet_conditional "$module" |
3292 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3293 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3294 -e "$sed_eliminate_LDFLAGS" \
3295 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3296 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3297 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3298 -e "$sed_transform_check_PROGRAMS" \
3299 -e "$sed_replace_include_guard_prefix"
3300 if test "$module" = 'alloca'; then
3301 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3302 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3304 } > "$tmp"/amsnippet1
3306 func_get_automake_snippet_unconditional "$module" |
3307 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3308 } > "$tmp"/amsnippet2
3309 # Skip the contents if it's entirely empty.
3310 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3311 echo "## begin gnulib module $module"
3313 if test "$cond_dependencies" = true; then
3314 if func_cond_module_p "$module"; then
3315 func_module_conditional_name "$module"
3316 echo "if $conditional"
3319 cat "$tmp"/amsnippet1
3320 if test "$cond_dependencies" = true; then
3321 if func_cond_module_p "$module"; then
3325 cat "$tmp"/amsnippet2
3326 echo "## end gnulib module $module"
3329 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3330 # Test whether there are some source files in subdirectories.
3331 for f in `func_get_filelist "$module"`; do
3341 } > "$tmp"/allsnippets
3342 if test -z "$makefile_name"; then
3343 # If there are source files in subdirectories, prevent collision of the
3344 # object files (example: hash.c and libxml/hash.c).
3346 if test -n "$uses_subdirs"; then
3347 subdir_options=' subdir-objects'
3349 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
3352 if test -z "$makefile_name"; then
3354 echo "noinst_HEADERS ="
3355 echo "noinst_LIBRARIES ="
3356 echo "noinst_LTLIBRARIES ="
3357 # Automake versions < 1.11.4 create an empty pkgdatadir at
3358 # installation time if you specify pkgdata_DATA to empty.
3359 # See automake bugs #10997 and #11030:
3360 # * http://debbugs.gnu.org/10997
3361 # * http://debbugs.gnu.org/11030
3362 # So we need this workaround.
3363 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3364 echo "pkgdata_DATA ="
3367 echo "BUILT_SOURCES ="
3370 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3371 if test -z "$makefile_name"; then
3372 echo "MOSTLYCLEANDIRS ="
3374 echo "DISTCLEANFILES ="
3375 echo "MAINTAINERCLEANFILES ="
3377 # Execute edits that apply to the Makefile.am being generated.
3379 while test $edit != $makefile_am_edits; do
3380 edit=`expr $edit + 1`
3381 eval dir=\"\$makefile_am_edit${edit}_dir\"
3382 eval var=\"\$makefile_am_edit${edit}_var\"
3383 eval val=\"\$makefile_am_edit${edit}_val\"
3384 if test -n "$var"; then
3385 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3386 echo "${var} += ${val}"
3387 eval "makefile_am_edit${edit}_var="
3391 if test -n "$witness_c_macro"; then
3392 cppflags_part1=" -D$witness_c_macro=1"
3397 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3401 if test -z "$makefile_name"; then
3403 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3406 if test -n "$cppflags_part1$cppflags_part2"; then
3408 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3412 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3413 || { test -n "$makefile_name" \
3414 && test -f "$sourcebase/Makefile.am" \
3415 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3417 # One of the snippets or the user's Makefile.am already specifies an
3418 # installation location for the library. Don't confuse automake by saying
3419 # it should not be installed.
3422 # By default, the generated library should not be installed.
3423 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3426 echo "${libname}_${libext}_SOURCES ="
3427 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3428 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3429 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3430 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3431 echo "EXTRA_${libname}_${libext}_SOURCES ="
3432 if test "$libtool" = true; then
3433 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3434 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3435 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3436 # the link dependencies of all modules.
3437 for module in $modules; do
3438 func_verify_nontests_module
3439 if test -n "$module"; then
3440 func_get_link_directive "$module"
3443 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3444 | LC_ALL=C sort -u \
3445 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3448 if test -n "$pobase"; then
3449 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3452 cat "$tmp"/allsnippets \
3453 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3455 echo "mostlyclean-local: mostlyclean-generic"
3456 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3457 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3458 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3462 rm -f "$tmp"/allsnippets
3465 # func_emit_po_Makevars
3466 # emits the contents of po/ makefile parameterization to standard output.
3468 # - local_gnulib_dir from --local-dir
3469 # - modcache true or false, from --cache-modules/--no-cache-modules
3470 # - sourcebase directory relative to destdir where to place source code
3471 # - pobase directory relative to destdir where to place *.po files
3472 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3473 func_emit_po_Makevars ()
3475 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3476 func_emit_copyright_notice
3478 echo "# Usually the message domain is the same as the package name."
3479 echo "# But here it has a '-gnulib' suffix."
3480 echo "DOMAIN = ${po_domain}-gnulib"
3482 echo "# These two variables depend on the location of this directory."
3483 echo "subdir = ${pobase}"
3484 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3487 # These options get passed to xgettext.
3488 XGETTEXT_OPTIONS = \
3489 --keyword=_ --flag=_:1:pass-c-format \
3490 --keyword=N_ --flag=N_:1:pass-c-format \
3491 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3492 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3493 --flag=error:3:c-format --flag=error_at_line:5:c-format
3495 # This is the copyright holder that gets inserted into the header of the
3496 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3497 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3499 # This is the email address or URL to which the translators shall report
3500 # bugs in the untranslated strings:
3501 # - Strings which are not entire sentences, see the maintainer guidelines
3502 # in the GNU gettext documentation, section 'Preparing Strings'.
3503 # - Strings which use unclear terms or require additional context to be
3505 # - Strings which make invalid assumptions about notation of date, time or
3507 # - Pluralisation problems.
3508 # - Incorrect English spelling.
3509 # - Incorrect formatting.
3510 # It can be your email address, or a mailing list address where translators
3511 # can write to without being subscribed, or the URL of a web page through
3512 # which the translators can contact you.
3513 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3515 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3516 # message catalogs shall be used. It is usually empty.
3517 EXTRA_LOCALE_CATEGORIES =
3519 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3520 # context. Possible values are "yes" and "no". Set this to yes if the
3521 # package uses functions taking also a message context, like pgettext(), or
3522 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3527 # func_emit_po_POTFILES_in
3528 # emits the file list to be passed to xgettext to standard output.
3530 # - local_gnulib_dir from --local-dir
3531 # - modcache true or false, from --cache-modules/--no-cache-modules
3532 # - sourcebase directory relative to destdir where to place source code
3533 # - files list of new files
3534 func_emit_po_POTFILES_in ()
3536 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3537 func_emit_copyright_notice
3539 echo "# List of files which contain translatable strings."
3540 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3543 # func_emit_tests_Makefile_am witness_macro
3544 # emits the contents of tests makefile to standard output.
3546 # - local_gnulib_dir from --local-dir
3547 # - modcache true or false, from --cache-modules/--no-cache-modules
3548 # - modules list of modules, including dependencies
3549 # - libname library name
3550 # - auxdir directory relative to destdir where to place build aux files
3551 # - makefile_name from --makefile-name
3552 # - libtool true if libtool will be used, false or blank otherwise
3553 # - sourcebase relative directory containing lib source code
3554 # - m4base relative directory containing autoconf macros
3555 # - testsbase relative directory containing unit test code
3556 # - macro_prefix prefix of gl_LIBOBJS macros to use
3557 # - witness_c_macro from --witness-c-macro
3558 # - for_test true if creating a package for testing, false otherwise
3559 # - single_configure true if a single configure file should be generated,
3560 # false for a separate configure file for the tests
3561 # - use_libtests true if a libtests.a should be built, false otherwise
3562 # - sed_replace_include_guard_prefix
3563 # sed expression for resolving ${gl_include_guard_prefix}
3564 # - destfile filename relative to destdir of makefile being generated
3566 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3567 # list of edits to be done to Makefile.am variables
3569 # - uses_subdirs nonempty if object files in subdirs exist
3570 func_emit_tests_Makefile_am ()
3573 if test "$libtool" = true; then
3576 sed_eliminate_LDFLAGS="$sed_noop"
3580 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3583 # When creating a package for testing: Attempt to provoke failures,
3584 # especially link errors, already during "make" rather than during
3585 # "make check", because "make check" is not possible in a cross-compiling
3586 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3587 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3589 sed_transform_check_PROGRAMS="$sed_noop"
3591 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3592 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3593 echo "## Process this file with automake to produce Makefile.in."
3594 func_emit_copyright_notice
3598 for module in $modules; do
3599 if $for_test && ! $single_configure; then
3600 func_verify_tests_module
3604 if test -n "$module"; then
3606 func_get_automake_snippet "$module" |
3608 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3609 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3610 -e "$sed_eliminate_LDFLAGS" \
3611 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3612 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3613 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3614 -e "$sed_transform_check_PROGRAMS" \
3615 -e "$sed_replace_include_guard_prefix"
3616 if $use_libtests && test "$module" = 'alloca'; then
3617 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3618 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3620 } > "$tmp"/amsnippet
3621 # Skip the contents if it's entirely empty.
3622 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3623 # Mention long-running tests at the end.
3625 for word in `func_get_status "$module"`; do
3626 if test "$word" = 'longrunning-test'; then
3631 { echo "## begin gnulib module $module"
3633 cat "$tmp"/amsnippet
3634 echo "## end gnulib module $module"
3638 rm -f "$tmp"/amsnippet
3639 # Test whether there are some source files in subdirectories.
3640 for f in `func_get_filelist "$module"`; do
3642 lib/*/*.c | tests/*/*.c)
3650 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3651 # Generate dependencies here, since it eases the debugging of test failures.
3652 # If there are source files in subdirectories, prevent collision of the
3653 # object files (example: hash.c and libxml/hash.c).
3655 if test -n "$uses_subdirs"; then
3656 subdir_options=' subdir-objects'
3658 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3660 if $for_test && ! $single_configure; then
3661 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3664 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3665 # variable is needed to avoid an error from automake:
3666 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3669 echo "XFAIL_TESTS ="
3670 echo "TESTS_ENVIRONMENT ="
3671 echo "noinst_PROGRAMS ="
3672 if ! $for_test; then
3673 echo "check_PROGRAMS ="
3675 echo "noinst_HEADERS ="
3676 echo "noinst_LIBRARIES ="
3677 if $use_libtests; then
3679 echo "noinst_LIBRARIES += libtests.a"
3681 echo "check_LIBRARIES = libtests.a"
3684 # Automake versions < 1.11.4 create an empty pkgdatadir at
3685 # installation time if you specify pkgdata_DATA to empty.
3686 # See automake bugs #10997 and #11030:
3687 # * http://debbugs.gnu.org/10997
3688 # * http://debbugs.gnu.org/11030
3689 # So we need this workaround.
3690 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3691 echo "pkgdata_DATA ="
3694 echo "BUILT_SOURCES ="
3696 echo "MOSTLYCLEANFILES = core *.stackdump"
3697 echo "MOSTLYCLEANDIRS ="
3699 echo "DISTCLEANFILES ="
3700 echo "MAINTAINERCLEANFILES ="
3701 # Execute edits that apply to the Makefile.am being generated.
3703 while test $edit != $makefile_am_edits; do
3704 edit=`expr $edit + 1`
3705 eval dir=\"\$makefile_am_edit${edit}_dir\"
3706 eval var=\"\$makefile_am_edit${edit}_var\"
3707 eval val=\"\$makefile_am_edit${edit}_val\"
3708 if test -n "$var"; then
3709 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3710 echo "${var} += ${val}"
3711 eval "makefile_am_edit${edit}_var="
3716 echo "AM_CPPFLAGS = \\"
3718 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3720 if test -n "$witness_c_macro"; then
3721 echo " -D$witness_c_macro=1 \\"
3723 if test -n "${witness_macro}"; then
3724 echo " -D@${witness_macro}@=1 \\"
3726 echo " -I. -I\$(srcdir) \\"
3727 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3728 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3730 local_ldadd_before=''
3731 local_ldadd_after=''
3732 if $use_libtests; then
3733 # All test programs need to be linked with libtests.a.
3734 # It needs to be passed to the linker before ${libname}.${libext}, since
3735 # the tests-related modules depend on the main modules.
3736 # It also needs to be passed to the linker after ${libname}.${libext}
3737 # because the latter might contain incomplete modules (such as the 'error'
3738 # module whose dependency to 'progname' is voluntarily omitted).
3739 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3741 local_ldadd_before=' libtests.a'
3742 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3744 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3746 if $use_libtests; then
3747 echo "libtests_a_SOURCES ="
3748 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3749 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3750 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3751 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3752 echo "EXTRA_libtests_a_SOURCES ="
3753 # The circular dependency in LDADD requires this.
3754 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3757 # Many test scripts use ${EXEEXT} or ${srcdir}.
3758 # EXEEXT is defined by AC_PROG_CC through autoconf.
3759 # srcdir is defined by autoconf and automake.
3760 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3762 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3763 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3764 echo "# Clean up after Solaris cc."
3766 echo " rm -rf SunWS_cache"
3768 echo "mostlyclean-local: mostlyclean-generic"
3769 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3770 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3771 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3775 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3778 # func_emit_initmacro_start macro_prefix
3779 # emits the first few statements of the gl_INIT macro to standard output.
3780 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3781 func_emit_initmacro_start ()
3783 macro_prefix_arg="$1"
3784 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3785 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3786 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3787 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3789 # Furthermore it avoids an automake error like this when a Makefile.am
3790 # that uses pieces of gnulib also uses $(LIBOBJ):
3791 # automatically discovered file `error.c' should not be explicitly mentioned
3792 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3793 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3794 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3795 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3796 # automatically discovered file `error.c' should not be explicitly mentioned
3797 # We let automake know about the files to be distributed through the
3798 # EXTRA_lib_SOURCES variable.
3799 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3800 # Create data variables for checking the presence of files that are mentioned
3801 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3802 # because we want the check to happen when the configure file is created,
3803 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3804 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3805 # in which to expect them.
3806 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3807 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3811 # func_emit_initmacro_end macro_prefix
3812 # emits the last few statements of the gl_INIT macro to standard output.
3813 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3814 func_emit_initmacro_end ()
3816 macro_prefix_arg="$1"
3817 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3818 # The check is performed only when autoconf is run from the directory where
3819 # the configure.ac resides; if it is run from a different directory, the
3821 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3822 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3823 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3824 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3825 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3829 echo " m4_if(m4_sysval, [0], [],"
3830 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3832 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3833 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3834 echo " m4_popdef([AC_LIBSOURCES])"
3835 echo " m4_popdef([AC_REPLACE_FUNCS])"
3836 echo " m4_popdef([AC_LIBOBJ])"
3837 echo " AC_CONFIG_COMMANDS_PRE(["
3838 echo " ${macro_prefix_arg}_libobjs="
3839 echo " ${macro_prefix_arg}_ltlibobjs="
3840 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3841 echo " # Remove the extension."
3842 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3843 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3844 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3845 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3848 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3849 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3853 # func_emit_initmacro_done macro_prefix sourcebase
3854 # emits a few statements after the gl_INIT macro to standard output.
3855 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3856 # - sourcebase directory relative to destdir where to place source code
3857 func_emit_initmacro_done ()
3859 macro_prefix_arg="$1"
3862 echo "# Like AC_LIBOBJ, except that the module name goes"
3863 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3864 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3865 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3866 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3869 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3870 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3871 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3872 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3873 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3876 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3877 echo "# expected is derived from the gnulib-tool parameterization,"
3878 echo "# and alloca is special cased (for the alloca-opt module)."
3879 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3880 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3881 echo " m4_foreach([_gl_NAME], [\$1], ["
3882 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3883 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3884 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3890 # func_emit_autoconf_snippet indentation
3891 # emits the autoconf snippet of a module.
3893 # - indentation spaces to prepend on each line
3894 # - local_gnulib_dir from --local-dir
3895 # - modcache true or false, from --cache-modules/--no-cache-modules
3896 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3897 # - sed_replace_include_guard_prefix
3898 # sed expression for resolving ${gl_include_guard_prefix}
3899 # - module the module name
3900 # - toplevel true or false. 'false' means a subordinate use of
3902 # - disable_libtool true or false. It tells whether to disable libtool
3903 # handling even if it has been specified through the
3904 # command line options.
3905 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3907 func_emit_autoconf_snippet ()
3910 if { case $module in
3911 gnumakefile | maintainer-makefile)
3912 # These modules are meant to be used only in the top-level directory.
3918 func_get_autoconf_snippet "$module" \
3919 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3920 -e "$sed_replace_build_aux" \
3921 -e "$sed_replace_include_guard_prefix" \
3922 | { if $disable_libtool; then
3923 sed -e 's/\$gl_cond_libtool/false/g' \
3924 -e 's/gl_libdeps/gltests_libdeps/g' \
3925 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3930 | { if $disable_gettext; then
3931 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3936 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3937 echo 'changequote(,)dnl'
3938 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3939 echo 'changequote([, ])dnl'
3940 echo 'AC_SUBST([LTALLOCA])'
3945 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3946 # collects and emit the autoconf snippets of a set of modules.
3948 # - local_gnulib_dir from --local-dir
3949 # - modcache true or false, from --cache-modules/--no-cache-modules
3950 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3951 # - sed_replace_include_guard_prefix
3952 # sed expression for resolving ${gl_include_guard_prefix}
3953 # - modules the list of modules.
3954 # - verifier one of func_verify_module, func_verify_nontests_module,
3955 # func_verify_tests_module. It selects the subset of
3956 # $modules to consider.
3957 # - toplevel true or false. 'false' means a subordinate use of
3959 # - disable_libtool true or false. It tells whether to disable libtool
3960 # handling even if it has been specified through the
3961 # command line options.
3962 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3964 func_emit_autoconf_snippets ()
3968 disable_libtool="$4"
3969 disable_gettext="$5"
3970 if test "$cond_dependencies" = true; then
3971 for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
3972 # Emit the autoconf code for the unconditional modules.
3973 for module in $1; do
3975 if test -n "$module"; then
3976 if func_cond_module_p "$module"; then
3979 func_emit_autoconf_snippet " "
3983 # Initialize the shell variables indicating that the modules are enabled.
3984 for module in $1; do
3986 if test -n "$module"; then
3987 if func_cond_module_p "$module"; then
3988 func_module_shellvar_name "$module"
3989 echo " $shellvar=false"
3993 # Emit the autoconf code for the conditional modules, each in a separate
3994 # function. This makes it possible to support cycles among conditional
3996 for module in $1; do
3998 if test -n "$module"; then
3999 if func_cond_module_p "$module"; then
4000 func_module_shellfunc_name "$module"
4001 func_module_shellvar_name "$module"
4002 echo " $shellfunc ()"
4004 echo " if ! \$$shellvar; then"
4005 func_emit_autoconf_snippet " "
4006 echo " $shellvar=true"
4007 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4008 # Intersect $deps with the modules list $1.
4009 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4010 for dep in $deps; do
4011 if func_cond_module_p "$dep"; then
4012 func_module_shellfunc_name "$dep"
4013 func_cond_module_condition "$module" "$dep"
4014 if test "$condition" != true; then
4015 echo " if $condition; then"
4022 # The autoconf code for $dep has already been emitted above and
4023 # therefore is already executed when this function is run.
4032 # Emit the dependencies from the unconditional to the conditional modules.
4033 for module in $1; do
4035 if test -n "$module"; then
4036 if func_cond_module_p "$module"; then
4039 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4040 # Intersect $deps with the modules list $1.
4041 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4042 for dep in $deps; do
4043 if func_cond_module_p "$dep"; then
4044 func_module_shellfunc_name "$dep"
4045 func_cond_module_condition "$module" "$dep"
4046 if test "$condition" != true; then
4047 echo " if $condition; then"
4054 # The autoconf code for $dep has already been emitted above and
4055 # therefore is already executed when this code is run.
4062 # Define the Automake conditionals.
4063 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4064 for module in $1; do
4066 if test -n "$module"; then
4067 if func_cond_module_p "$module"; then
4068 func_module_conditional_name "$module"
4069 func_module_shellvar_name "$module"
4070 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4075 # Ignore the conditions, and enable all modules unconditionally.
4076 for module in $1; do
4078 if test -n "$module"; then
4079 func_emit_autoconf_snippet " "
4085 # func_import modules
4086 # Uses also the variables
4087 # - mode import or add-import or remove-import or update
4088 # - destdir target directory
4089 # - local_gnulib_dir from --local-dir
4090 # - modcache true or false, from --cache-modules/--no-cache-modules
4091 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4092 # - libname library name
4093 # - supplied_libname true if --lib was given, blank otherwise
4094 # - sourcebase directory relative to destdir where to place source code
4095 # - m4base directory relative to destdir where to place *.m4 macros
4096 # - pobase directory relative to destdir where to place *.po files
4097 # - docbase directory relative to destdir where to place doc files
4098 # - testsbase directory relative to destdir where to place unit test code
4099 # - auxdir directory relative to destdir where to place build aux files
4100 # - inctests true if --with-tests was given, false otherwise
4101 # - incobsolete true if --with-obsolete was given, blank otherwise
4102 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4103 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4105 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4107 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4109 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4110 # - avoidlist list of modules to avoid, from --avoid
4111 # - cond_dependencies true if --conditional-dependencies was given, false if
4112 # --no-conditional-dependencies was given, blank otherwise
4113 # - lgpl yes or a number if library's license shall be LGPL,
4115 # - makefile_name from --makefile-name
4116 # - libtool true if --libtool was given, false if --no-libtool was
4117 # given, blank otherwise
4118 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4119 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4120 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4121 # - witness_c_macro from --witness-c-macro
4122 # - vc_files true if --vc-files was given, false if --no-vc-files was
4123 # given, blank otherwise
4124 # - autoconf_minversion minimum supported autoconf version
4125 # - doit : if actions shall be executed, false if only to be printed
4126 # - symbolic true if files should be symlinked, copied otherwise
4127 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4129 # - do_copyrights true if copyright notices in files should be replaced,
4133 # Get the cached settings.
4134 # In 'import' mode, we read them only for the purpose of knowing the old
4135 # installed file list, and don't use them as defaults.
4136 cached_local_gnulib_dir=
4137 cached_specified_modules=
4139 cached_inc_cxx_tests=
4140 cached_inc_longrunning_tests=
4141 cached_inc_privileged_tests=
4142 cached_inc_unportable_tests=
4143 cached_inc_all_tests=
4153 cached_makefile_name=
4154 cached_cond_dependencies=
4156 cached_macro_prefix=
4158 cached_witness_c_macro=
4161 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4162 cached_libtool=false
4168 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
4178 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4180 /gl_WITH_OBSOLETE/ {
4181 s,^.*$,cached_incobsolete=true,p
4183 /gl_WITH_CXX_TESTS/ {
4184 s,^.*$,cached_inc_cxx_tests=true,p
4186 /gl_WITH_LONGRUNNING_TESTS/ {
4187 s,^.*$,cached_inc_longrunning_tests=true,p
4189 /gl_WITH_PRIVILEGED_TESTS/ {
4190 s,^.*$,cached_inc_privileged_tests=true,p
4192 /gl_WITH_UNPORTABLE_TESTS/ {
4193 s,^.*$,cached_inc_unportable_tests=true,p
4195 /gl_WITH_ALL_TESTS/ {
4196 s,^.*$,cached_inc_all_tests=true,p
4199 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4202 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4205 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4208 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4211 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4214 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4217 s,^.*$,cached_inctests=true,p
4220 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4223 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4226 s,^.*$,cached_lgpl=yes,p
4228 /gl_MAKEFILE_NAME(/ {
4229 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4231 /gl_CONDITIONAL_DEPENDENCIES/ {
4232 s,^.*$,cached_cond_dependencies=true,p
4235 s,^.*$,cached_libtool=true,p
4237 /gl_MACRO_PREFIX(/ {
4238 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4241 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4243 /gl_WITNESS_C_MACRO(/ {
4244 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4247 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4249 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4250 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4255 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4256 s,^.*$,cached_files=",p
4269 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4273 if test "$mode" = import; then
4274 # In 'import' mode, the new set of specified modules overrides the cached
4275 # set of modules. Ignore the cached settings.
4276 specified_modules="$1"
4278 # Merge the cached settings with the specified ones.
4279 # The m4base must be the same as expected from the pathname.
4280 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4281 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4283 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
4284 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4285 if test -z "$local_gnulib_dir"; then
4286 if test -n "$cached_local_gnulib_dir"; then
4289 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4291 case "$cached_local_gnulib_dir" in
4293 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4295 func_relconcat "$destdir" "$cached_local_gnulib_dir"
4296 local_gnulib_dir="$relconcat" ;;
4303 # Append the cached and the specified module names. So that
4304 # "gnulib-tool --add-import foo" means to add the module foo.
4305 specified_modules="$cached_specified_modules $1"
4308 # Take the cached module names, minus the specified module names.
4310 if $have_associative; then
4311 # Use an associative array, for O(N) worst-case run time.
4312 declare -A to_remove
4314 eval 'to_remove[$m]=yes'
4316 for module in $cached_specified_modules; do
4317 if eval 'test -z "${to_remove[$module]}"'; then
4318 func_append specified_modules "$module "
4322 # This loop has O(N²) worst-case run time.
4323 for module in $cached_specified_modules; do
4326 if test "$m" = "$module"; then
4331 if test -z "$to_remove"; then
4332 func_append specified_modules "$module "
4338 # Take the cached module names. There are no specified module names.
4339 specified_modules="$cached_specified_modules"
4342 # Included obsolete modules among the dependencies if specified either way.
4343 if test -z "$incobsolete"; then
4344 incobsolete="$cached_incobsolete"
4346 # Included special kinds of tests modules among the dependencies if specified
4348 if test -z "$inc_cxx_tests"; then
4349 inc_cxx_tests="$cached_inc_cxx_tests"
4351 if test -z "$inc_longrunning_tests"; then
4352 inc_longrunning_tests="$cached_inc_longrunning_tests"
4354 if test -z "$inc_privileged_tests"; then
4355 inc_privileged_tests="$cached_inc_privileged_tests"
4357 if test -z "$inc_unportable_tests"; then
4358 inc_unportable_tests="$cached_inc_unportable_tests"
4360 if test -z "$inc_all_tests"; then
4361 inc_all_tests="$cached_inc_all_tests"
4363 # Append the cached and the specified avoidlist. This is probably better
4364 # than dropping the cached one when --avoid is specified at least once.
4365 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4366 avoidlist=`echo $avoidlist`
4368 # The sourcebase defaults to the cached one.
4369 if test -z "$sourcebase"; then
4370 sourcebase="$cached_sourcebase"
4371 if test -z "$sourcebase"; then
4372 func_fatal_error "missing --source-base option"
4375 # The pobase defaults to the cached one.
4376 if test -z "$pobase"; then
4377 pobase="$cached_pobase"
4379 # The docbase defaults to the cached one.
4380 if test -z "$docbase"; then
4381 docbase="$cached_docbase"
4382 if test -z "$docbase"; then
4383 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."
4386 # The testsbase defaults to the cached one.
4387 if test -z "$testsbase"; then
4388 testsbase="$cached_testsbase"
4389 if test -z "$testsbase"; then
4390 func_fatal_error "missing --tests-base option"
4393 # Require the tests if specified either way.
4394 if ! $inctests; then
4395 inctests="$cached_inctests"
4396 if test -z "$inctests"; then
4400 # The libname defaults to the cached one.
4401 if test -z "$supplied_libname"; then
4402 libname="$cached_libname"
4403 if test -z "$libname"; then
4404 func_fatal_error "missing --lib option"
4407 # Require LGPL if specified either way.
4408 if test -z "$lgpl"; then
4411 # The makefile_name defaults to the cached one.
4412 if test -z "$makefile_name"; then
4413 makefile_name="$cached_makefile_name"
4415 # Use conditional dependencies if specified either way.
4416 if test -z "$cond_dependencies"; then
4417 cond_dependencies="$cached_cond_dependencies"
4419 # Use libtool if specified either way, or if guessed.
4420 if test -z "$libtool"; then
4421 if test -n "$cached_m4base"; then
4422 libtool="$cached_libtool"
4424 libtool="$guessed_libtool"
4427 # The macro_prefix defaults to the cached one.
4428 if test -z "$macro_prefix"; then
4429 macro_prefix="$cached_macro_prefix"
4430 if test -z "$macro_prefix"; then
4431 func_fatal_error "missing --macro-prefix option"
4434 # The po_domain defaults to the cached one.
4435 if test -z "$po_domain"; then
4436 po_domain="$cached_po_domain"
4438 # The witness_c_macro defaults to the cached one.
4439 if test -z "$witness_c_macro"; then
4440 witness_c_macro="$cached_witness_c_macro"
4442 # The vc_files defaults to the cached one.
4443 if test -z "$vc_files"; then
4444 vc_files="$cached_vc_files"
4446 # Ensure constraints.
4447 if test "$cond_dependencies" = true && $inctests; then
4448 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4452 # --without-*-tests options are not supported here.
4454 excl_longrunning_tests=
4455 excl_privileged_tests=
4456 excl_unportable_tests=
4458 # Canonicalize the list of specified modules.
4459 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4461 # Include all kinds of tests modules if --with-all-tests was specified.
4462 inc_all_direct_tests="$inc_all_tests"
4463 inc_all_indirect_tests="$inc_all_tests"
4465 # Determine final module list.
4466 modules="$specified_modules"
4467 func_modules_transitive_closure
4468 if test $verbose -ge 0; then
4469 func_show_module_list
4471 final_modules="$modules"
4473 # Determine main module list and tests-related module list separately.
4474 func_modules_transitive_closure_separately
4476 # Determine whether a $testsbase/libtests.a is needed.
4477 func_determine_use_libtests
4479 # Add the dummy module to the main module list or to the tests-related module
4481 func_modules_add_dummy_separately
4483 # If --lgpl, verify that the licenses of modules are compatible.
4484 if test -n "$lgpl"; then
4485 license_incompatibilities=
4486 for module in $main_modules; do
4487 license=`func_get_license $module`
4489 'GPLed build tool') ;;
4490 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4495 LGPL | LGPLv2+ | LGPLv3+) ;;
4496 *) func_append license_incompatibilities "$module $license$nl" ;;
4502 *) func_append license_incompatibilities "$module $license$nl" ;;
4505 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4510 if test -n "$license_incompatibilities"; then
4511 # Format the license incompatibilities as a table.
4512 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4513 s,^\(.................................................[^ ]*\) *, \1 ,'
4514 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4515 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4519 # Show banner notice of every module.
4520 modules="$main_modules"
4523 # Determine script to apply to imported library files.
4524 sed_transform_lib_file=
4525 for module in $main_modules; do
4526 if test $module = config-h; then
4527 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4528 sed_transform_lib_file=$sed_transform_lib_file'
4529 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4534 sed_transform_main_lib_file="$sed_transform_lib_file"
4535 if test -n "$do_copyrights"; then
4536 if test -n "$lgpl"; then
4540 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4541 s/GNU General/GNU Lesser General/g
4542 s/General Public License/Lesser General Public License/g
4543 s/Lesser Lesser General Public License/Lesser General Public License/g
4547 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4548 s/GNU General/GNU Lesser General/g
4549 s/General Public License/Lesser General Public License/g
4550 s/Lesser Lesser General Public License/Lesser General Public License/g
4552 s/version [23]\([ ,]\)/version 2.1\1/g
4555 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4559 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4560 s/GNU Lesser General/GNU General/g
4561 s/Lesser General Public License/General Public License/g
4563 s/GNU Library General/GNU General/g
4564 s/Library General Public License/General Public License/g
4566 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4571 # Determine script to apply to auxiliary files that go into $auxdir/.
4572 sed_transform_build_aux_file=
4573 if test -n "$do_copyrights"; then
4575 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4576 s/GNU Lesser General/GNU General/g
4577 s/Lesser General Public License/General Public License/g
4579 s/GNU Library General/GNU General/g
4580 s/Library General Public License/General Public License/g
4582 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4586 # Determine script to apply to library files that go into $testsbase/.
4587 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4588 if test -n "$do_copyrights"; then
4590 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4591 s/GNU Lesser General/GNU General/g
4592 s/Lesser General Public License/General Public License/g
4594 s/GNU Library General/GNU General/g
4595 s/Library General Public License/General Public License/g
4597 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4601 # Determine the final file lists.
4602 func_modules_to_filelist_separately
4605 || func_fatal_error "refusing to do nothing"
4607 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4608 new_files="$files m4/gnulib-tool.m4"
4609 old_files="$cached_files"
4610 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4611 func_append old_files " m4/gnulib-tool.m4"
4614 rewritten='%REWRITTEN%'
4615 sed_rewrite_old_files="\
4616 s,^build-aux/,$rewritten$auxdir/,
4617 s,^doc/,$rewritten$cached_docbase/,
4618 s,^lib/,$rewritten$cached_sourcebase/,
4619 s,^m4/,$rewritten$cached_m4base/,
4620 s,^tests/,$rewritten$cached_testsbase/,
4621 s,^tests=lib/,$rewritten$cached_testsbase/,
4624 sed_rewrite_new_files="\
4625 s,^build-aux/,$rewritten$auxdir/,
4626 s,^doc/,$rewritten$docbase/,
4627 s,^lib/,$rewritten$sourcebase/,
4628 s,^m4/,$rewritten$m4base/,
4629 s,^tests/,$rewritten$testsbase/,
4630 s,^tests=lib/,$rewritten$testsbase/,
4634 # Create directories.
4635 { echo "$sourcebase"
4637 if test -n "$pobase"; then
4640 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4641 if test -n "$docfiles"; then
4648 for f in $files; do echo $f; done \
4649 | sed -e "$sed_rewrite_new_files" \
4650 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4653 { # Rearrange file descriptors. Needed because "while ... done < ..."
4654 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4655 exec 5<&0 < "$tmp"/dirs
4657 if test ! -d "$destdir/$d"; then
4659 echo "Creating directory $destdir/$d"
4660 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4662 echo "Create directory $destdir/$d"
4669 # Copy files or make symbolic links. Remove obsolete files.
4673 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4674 # representing the files according to the last gnulib-tool invocation.
4675 for f in $old_files; do echo $f; done \
4676 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4679 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4680 # representing the files after this gnulib-tool invocation.
4681 for f in $new_files; do echo $f; done \
4682 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4685 # First the files that are in old-files, but not in new-files:
4686 sed_take_first_column='s,'"$delimiter"'.*,,'
4687 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4688 # Remove the file. Do nothing if the user already removed it.
4689 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4691 echo "Removing file $g (backup in ${g}~)"
4692 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4694 echo "Remove file $g (backup in ${g}~)"
4696 func_append removed_files "$g$nl"
4699 # func_add_or_update handles a file that ought to be present afterwards.
4701 # - f the original file name
4702 # - g the rewritten file name
4703 # - already_present nonempty if the file should already exist, empty
4705 func_add_or_update ()
4709 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4711 func_dest_tmpfilename "$g"
4712 func_lookup_file "$f"
4713 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4714 if test -n "$sed_transform_main_lib_file"; then
4717 sed -e "$sed_transform_main_lib_file" \
4718 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4722 if test -n "$sed_transform_build_aux_file"; then
4725 sed -e "$sed_transform_build_aux_file" \
4726 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4730 if test -n "$sed_transform_testsrelated_lib_file"; then
4733 sed -e "$sed_transform_testsrelated_lib_file" \
4734 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4738 if test -f "$destdir/$g"; then
4739 # The file already exists.
4743 # Don't protest if the file should be there but isn't: it happens
4744 # frequently that developers don't put autogenerated files under version control.
4746 func_append added_files "$g$nl"
4750 # Then the files that are in new-files, but not in old-files:
4751 sed_take_last_column='s,^.*'"$delimiter"',,'
4753 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4754 | sed -e "$sed_take_last_column" \
4755 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4756 { # Rearrange file descriptors. Needed because "while ... done < ..."
4757 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4758 exec 5<&0 < "$tmp"/added-files
4764 # Then the files that are in new-files and in old-files:
4765 already_present=true
4766 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4767 | sed -e "$sed_take_last_column" \
4768 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4769 { # Rearrange file descriptors. Needed because "while ... done < ..."
4770 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4771 exec 5<&0 < "$tmp"/kept-files
4778 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4779 actioncmd="gnulib-tool --import"
4780 func_append actioncmd " --dir=$destdir"
4781 if test -n "$local_gnulib_dir"; then
4782 func_append actioncmd " --local-dir=$local_gnulib_dir"
4784 func_append actioncmd " --lib=$libname"
4785 func_append actioncmd " --source-base=$sourcebase"
4786 func_append actioncmd " --m4-base=$m4base"
4787 if test -n "$pobase"; then
4788 func_append actioncmd " --po-base=$pobase"
4790 func_append actioncmd " --doc-base=$docbase"
4791 func_append actioncmd " --tests-base=$testsbase"
4792 func_append actioncmd " --aux-dir=$auxdir"
4794 func_append actioncmd " --with-tests"
4796 if test -n "$incobsolete"; then
4797 func_append actioncmd " --with-obsolete"
4799 if test -n "$inc_cxx_tests"; then
4800 func_append actioncmd " --with-c++-tests"
4802 if test -n "$inc_longrunning_tests"; then
4803 func_append actioncmd " --with-longrunning-tests"
4805 if test -n "$inc_privileged_tests"; then
4806 func_append actioncmd " --with-privileged-tests"
4808 if test -n "$inc_unportable_tests"; then
4809 func_append actioncmd " --with-unportable-tests"
4811 if test -n "$inc_all_tests"; then
4812 func_append actioncmd " --with-all-tests"
4814 for module in $avoidlist; do
4815 func_append actioncmd " --avoid=$module"
4817 if test -n "$lgpl"; then
4818 if test "$lgpl" = yes; then
4819 func_append actioncmd " --lgpl"
4821 func_append actioncmd " --lgpl=$lgpl"
4824 if test -n "$makefile_name"; then
4825 func_append actioncmd " --makefile-name=$makefile_name"
4827 if test "$cond_dependencies" = true; then
4828 func_append actioncmd " --conditional-dependencies"
4830 func_append actioncmd " --no-conditional-dependencies"
4832 if test "$libtool" = true; then
4833 func_append actioncmd " --libtool"
4835 func_append actioncmd " --no-libtool"
4837 func_append actioncmd " --macro-prefix=$macro_prefix"
4838 if test -n "$po_domain"; then
4839 func_append actioncmd " --po-domain=$po_domain"
4841 if test -n "$witness_c_macro"; then
4842 func_append actioncmd " --witness-c-macro=$witness_c_macro"
4844 if test -n "$vc_files"; then
4845 if test "$vc_files" = true; then
4846 func_append actioncmd " --vc-files"
4848 func_append actioncmd " --no-vc-files"
4851 func_append actioncmd " `echo $specified_modules`"
4853 # Determine include_guard_prefix.
4854 func_compute_include_guard_prefix
4856 # Default the makefile name to Makefile.am.
4857 if test -n "$makefile_name"; then
4858 makefile_am=$makefile_name
4860 makefile_am=Makefile.am
4863 # Create normal Makefile.ams.
4866 # Setup list of Makefile.am edits that are to be performed afterwards.
4867 # Some of these edits apply to files that we will generate; others are
4868 # under the responsibility of the developer.
4870 # func_note_Makefile_am_edit dir var value
4871 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4873 func_note_Makefile_am_edit ()
4875 makefile_am_edits=`expr $makefile_am_edits + 1`
4876 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4877 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4878 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4880 if test "$makefile_am" = Makefile.am; then
4881 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4882 sourcebase_base=`basename "$sourcebase"`
4883 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4885 if test -n "$pobase"; then
4886 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4887 pobase_base=`basename "$pobase"`
4888 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4891 if test "$makefile_am" = Makefile.am; then
4892 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4893 testsbase_base=`basename "$testsbase"`
4894 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4897 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4899 # Find the first parent directory of $m4base that contains or will contain
4901 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4903 sed_butlast='s,[^/][^/]*//*$,,'
4904 dir1="${m4base}/"; dir2=""
4905 while test -n "$dir1" \
4906 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4907 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4908 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4910 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4911 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4912 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4913 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4915 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4918 # Create library makefile.
4919 func_dest_tmpfilename $sourcebase/$makefile_am
4920 destfile="$sourcebase/$makefile_am"
4921 modules="$main_modules"
4922 func_emit_lib_Makefile_am > "$tmpfile"
4923 if test -f "$destdir"/$sourcebase/$makefile_am; then
4924 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
4928 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4929 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4930 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4932 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4938 echo "Creating $sourcebase/$makefile_am"
4939 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4941 echo "Create $sourcebase/$makefile_am"
4944 func_append added_files "$sourcebase/$makefile_am$nl"
4947 # Create po/ directory.
4948 if test -n "$pobase"; then
4949 # Create po makefile and auxiliary files.
4950 for file in Makefile.in.in remove-potcdate.sin; do
4951 func_dest_tmpfilename $pobase/$file
4952 func_lookup_file build-aux/po/$file
4953 cat "$lookedup_file" > "$tmpfile"
4954 if test -f "$destdir"/$pobase/$file; then
4955 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
4959 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4960 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4961 mv -f "$tmpfile" "$destdir"/$pobase/$file
4963 echo "Update $pobase/$file (backup in $pobase/$file~)"
4969 echo "Creating $pobase/$file"
4970 mv -f "$tmpfile" "$destdir"/$pobase/$file
4972 echo "Create $pobase/$file"
4975 func_append added_files "$pobase/$file$nl"
4978 # Create po makefile parameterization, part 1.
4979 func_dest_tmpfilename $pobase/Makevars
4980 func_emit_po_Makevars > "$tmpfile"
4981 if test -f "$destdir"/$pobase/Makevars; then
4982 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
4986 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4987 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4988 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4990 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4996 echo "Creating $pobase/Makevars"
4997 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4999 echo "Create $pobase/Makevars"
5002 func_append added_files "$pobase/Makevars$nl"
5004 # Create po makefile parameterization, part 2.
5005 func_dest_tmpfilename $pobase/POTFILES.in
5006 func_emit_po_POTFILES_in > "$tmpfile"
5007 if test -f "$destdir"/$pobase/POTFILES.in; then
5008 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5012 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5013 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5014 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5016 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5022 echo "Creating $pobase/POTFILES.in"
5023 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5025 echo "Create $pobase/POTFILES.in"
5028 func_append added_files "$pobase/POTFILES.in$nl"
5031 TP_URL="http://translationproject.org/latest/"
5032 TP_RSYNC_URI="translationproject.org::tp/latest/"
5034 echo "Fetching gnulib PO files from $TP_URL"
5035 (cd "$destdir"/$pobase \
5036 && { # Prefer rsync over wget if it is available, since it consumes
5037 # less network bandwidth, due to compression.
5038 if type rsync 2>/dev/null | grep / > /dev/null; then
5039 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
5041 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
5046 echo "Fetch gnulib PO files from $TP_URL"
5048 # Create po/LINGUAS.
5050 func_dest_tmpfilename $pobase/LINGUAS
5051 (cd "$destdir"/$pobase \
5052 && { echo '# Set of available languages.'
5053 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5056 if test -f "$destdir"/$pobase/LINGUAS; then
5057 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5060 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5061 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5062 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5065 echo "Creating $pobase/LINGUAS"
5066 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5067 func_append added_files "$pobase/LINGUAS$nl"
5070 if test -f "$destdir"/$pobase/LINGUAS; then
5071 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5073 echo "Create $pobase/LINGUAS"
5078 # Create m4/gnulib-cache.m4.
5079 func_dest_tmpfilename $m4base/gnulib-cache.m4
5081 func_emit_copyright_notice
5083 echo "# This file represents the specification of how gnulib-tool is used."
5084 echo "# It acts as a cache: It is written and read by gnulib-tool."
5085 echo "# In projects that use version control, this file is meant to be put under"
5086 echo "# version control, like the configure.ac and various Makefile.am files."
5089 echo "# Specification in the form of a command-line invocation:"
5092 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5093 # Store the local_gnulib_dir relative to destdir.
5094 case "$local_gnulib_dir" in
5096 relative_local_gnulib_dir="$local_gnulib_dir" ;;
5099 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
5101 # destdir, local_gnulib_dir are both relative.
5102 func_relativize "$destdir" "$local_gnulib_dir"
5103 relative_local_gnulib_dir="$reldir" ;;
5106 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
5108 echo "$specified_modules" | sed -e 's/^/ /g'
5110 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5111 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5112 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5113 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5114 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5115 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5116 echo "gl_AVOID([$avoidlist])"
5117 echo "gl_SOURCE_BASE([$sourcebase])"
5118 echo "gl_M4_BASE([$m4base])"
5119 echo "gl_PO_BASE([$pobase])"
5120 echo "gl_DOC_BASE([$docbase])"
5121 echo "gl_TESTS_BASE([$testsbase])"
5123 echo "gl_WITH_TESTS"
5125 echo "gl_LIB([$libname])"
5126 if test -n "$lgpl"; then
5127 if test "$lgpl" = yes; then
5130 echo "gl_LGPL([$lgpl])"
5133 echo "gl_MAKEFILE_NAME([$makefile_name])"
5134 if test "$cond_dependencies" = true; then
5135 echo "gl_CONDITIONAL_DEPENDENCIES"
5137 if test "$libtool" = true; then
5140 echo "gl_MACRO_PREFIX([$macro_prefix])"
5141 echo "gl_PO_DOMAIN([$po_domain])"
5142 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5143 if test -n "$vc_files"; then
5144 echo "gl_VC_FILES([$vc_files])"
5147 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5148 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5152 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5153 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5154 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5156 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5160 echo "# gnulib-cache.m4 ends here"
5167 echo "Creating $m4base/gnulib-cache.m4"
5168 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5170 echo "Create $m4base/gnulib-cache.m4"
5176 # Create m4/gnulib-comp.m4.
5177 func_dest_tmpfilename $m4base/gnulib-comp.m4
5179 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5180 func_emit_copyright_notice
5182 echo "# This file represents the compiled summary of the specification in"
5183 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5184 echo "# to be invoked from configure.ac."
5185 echo "# In projects that use version control, this file can be treated like"
5186 echo "# other built files."
5189 echo "# This macro should be invoked from $configure_ac, in the section"
5190 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5191 echo "# any checks for libraries, header files, types and library functions."
5192 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5194 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5195 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5196 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5197 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5198 echo " AC_REQUIRE([gl_PROG_AR_RANLIB])"
5199 if test -n "$uses_subdirs"; then
5200 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5202 for module in $final_modules; do
5204 if test -n "$module"; then
5205 echo "# Code from module $module:"
5206 func_get_autoconf_early_snippet "$module"
5209 | sed -e '/^$/d;' -e 's/^/ /'
5212 echo "# This macro should be invoked from $configure_ac, in the section"
5213 echo "# \"Check for header files, types and library functions\"."
5214 echo "AC_DEFUN([${macro_prefix}_INIT],"
5216 if test "$libtool" = true; then
5217 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5218 echo " gl_cond_libtool=true"
5220 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5221 echo " gl_cond_libtool=false"
5223 echo " gl_ltlibdeps="
5225 if test "$auxdir" != "build-aux"; then
5226 sed_replace_build_aux='
5228 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5229 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5233 sed_replace_build_aux="$sed_noop"
5235 echo " gl_m4_base='$m4base'"
5236 func_emit_initmacro_start $macro_prefix
5237 echo " gl_source_base='$sourcebase'"
5238 if test -n "$witness_c_macro"; then
5239 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5241 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5242 if test -n "$witness_c_macro"; then
5243 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5245 echo " # End of code from modules"
5246 func_emit_initmacro_end $macro_prefix
5247 echo " gltests_libdeps="
5248 echo " gltests_ltlibdeps="
5249 func_emit_initmacro_start ${macro_prefix}tests
5250 echo " gl_source_base='$testsbase'"
5251 # Define a tests witness macro that depends on the package.
5252 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5253 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5254 echo "changequote(,)dnl"
5255 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"
5256 echo "changequote([, ])dnl"
5257 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5258 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5259 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5260 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5261 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5262 func_emit_initmacro_end ${macro_prefix}tests
5263 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5264 # created using libtool, because libtool already handles the dependencies.
5265 if test "$libtool" != true; then
5266 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5267 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5268 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5269 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5270 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5272 if $use_libtests; then
5273 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5274 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5277 func_emit_initmacro_done $macro_prefix $sourcebase
5278 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5280 echo "# This macro records the list of files which have been installed by"
5281 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5282 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5283 echo "$files" | sed -e 's,^, ,'
5286 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5287 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5291 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5292 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5293 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5295 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5299 echo "# gnulib-comp.m4 ends here"
5306 echo "Creating $m4base/gnulib-comp.m4"
5307 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5309 echo "Create $m4base/gnulib-comp.m4"
5316 # Create tests makefile.
5317 func_dest_tmpfilename $testsbase/$makefile_am
5318 destfile="$testsbase/$makefile_am"
5319 modules="$testsrelated_modules"
5320 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5321 if test -f "$destdir"/$testsbase/$makefile_am; then
5322 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5326 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5327 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5328 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5330 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5336 echo "Creating $testsbase/$makefile_am"
5337 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5339 echo "Create $testsbase/$makefile_am"
5342 func_append added_files "$testsbase/$makefile_am$nl"
5346 if test "$vc_files" != false; then
5347 # Update the .cvsignore and .gitignore files.
5348 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5349 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5350 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5351 echo "$m4base/|A|gnulib-comp.m4"
5352 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5353 { # Rearrange file descriptors. Needed because "while ... done < ..."
5354 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5355 exec 5<&0 < "$tmp"/fileset-changes
5356 func_update_ignorelist ()
5359 if test "$ignore" = .gitignore; then
5360 # In a .gitignore file, "foo" applies to the current directory and all
5361 # subdirectories, whereas "/foo" applies to the current directory only.
5364 doubly_escaped_anchor='\\/'
5368 doubly_escaped_anchor=''
5370 if test -f "$destdir/$dir$ignore"; then
5371 if test -n "$dir_added" || test -n "$dir_removed"; then
5372 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5373 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5374 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5375 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5376 > "$tmp"/ignore-removed
5378 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5380 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5381 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5382 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5383 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5384 } > "$tmp"/sed-ignore-removed
5385 { cat "$destdir/$dir$ignore"~
5386 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5387 } | sed -f "$tmp"/sed-ignore-removed \
5388 > "$destdir/$dir$ignore"
5390 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5395 if test -n "$dir_added"; then
5397 echo "Creating $destdir/$dir$ignore"
5399 if test "$ignore" = .cvsignore; then
5401 # Automake generates Makefile rules that create .dirstamp files.
5404 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5405 } > "$destdir/$dir$ignore"
5407 echo "Create $destdir/$dir$ignore"
5417 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5418 func_update_ignorelist .cvsignore
5420 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5421 func_update_ignorelist .gitignore
5428 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5429 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5430 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5431 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5432 if test "$next_dir" != "$last_dir"; then
5433 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5434 last_dir="$next_dir"
5439 A) func_append last_dir_added "$file$nl";;
5440 R) func_append last_dir_removed "$file$nl";;
5443 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5450 echo "You may need to add #include directives for the following .h files."
5451 # Intersect $specified_modules and $main_modules
5452 # (since $specified_modules is not necessarily of subset of $main_modules
5453 # - some may have been skipped through --avoid, and since the elements of
5454 # $main_modules but not in $specified_modules can go away without explicit
5455 # notice - through changes in the module dependencies).
5456 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5457 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5458 # First the #include <...> directives without #ifs, sorted for convenience,
5459 # then the #include "..." directives without #ifs, sorted for convenience,
5460 # then the #include directives that are surrounded by #ifs. Not sorted.
5461 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5462 include_directive=`func_get_include_directive "$module"`
5463 case "$nl$include_directive" in
5465 echo "$include_directive" 1>&5
5468 echo "$include_directive" | grep -v 'include "' 1>&6
5469 echo "$include_directive" | grep 'include "' 1>&7
5472 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5474 LC_ALL=C sort -u "$tmp"/include-angles
5475 LC_ALL=C sort -u "$tmp"/include-quotes
5476 cat "$tmp"/include-if
5477 ) | sed -e '/^$/d' -e 's/^/ /'
5478 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5480 for module in $main_modules; do
5481 func_get_link_directive "$module"
5483 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5484 if test `wc -l < "$tmp"/link` != 0; then
5486 echo "You may need to use the following Makefile variables when linking."
5487 echo "Use them in <program>_LDADD when linking a program, or"
5488 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5494 echo "Don't forget to"
5495 if test "$makefile_am" = Makefile.am; then
5496 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5498 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5500 if test -n "$pobase"; then
5501 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5504 if test "$makefile_am" = Makefile.am; then
5505 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5507 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5511 while test $edit != $makefile_am_edits; do
5512 edit=`expr $edit + 1`
5513 eval dir=\"\$makefile_am_edit${edit}_dir\"
5514 eval var=\"\$makefile_am_edit${edit}_var\"
5515 eval val=\"\$makefile_am_edit${edit}_val\"
5516 if test -n "$var"; then
5517 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5520 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5521 position_early_after=AC_PROG_CC_STDC
5523 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5524 position_early_after=AC_PROG_CC_C99
5526 position_early_after=AC_PROG_CC
5529 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5530 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5533 # func_create_testdir testdir modules
5535 # - local_gnulib_dir from --local-dir
5536 # - modcache true or false, from --cache-modules/--no-cache-modules
5537 # - auxdir directory relative to destdir where to place build aux files
5538 # - inctests true if tests should be included, false otherwise
5539 # - incobsolete true if obsolete modules among dependencies should be
5540 # included, blank otherwise
5541 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5543 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5545 # - excl_privileged_tests true if tests that require root privileges should be
5546 # excluded, blank otherwise
5547 # - excl_unportable_tests true if tests that fail on some platforms should be
5548 # excluded, blank otherwise
5549 # - single_configure true if a single configure file should be generated,
5550 # false for a separate configure file for the tests
5551 # - avoidlist list of modules to avoid
5552 # - cond_dependencies true if --conditional-dependencies was given, false if
5553 # --no-conditional-dependencies was given, blank otherwise
5554 # - libtool true if --libtool was given, false if --no-libtool was
5555 # given, blank otherwise
5556 # - symbolic true if files should be symlinked, copied otherwise
5557 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5559 func_create_testdir ()
5563 if test -z "$modules"; then
5564 # All modules together.
5565 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5566 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5567 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5568 modules=`func_all_modules`
5569 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5571 specified_modules="$modules"
5573 # Canonicalize the list of specified modules.
5574 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5576 # Unlike in func_import, here we want to include all kinds of tests for the
5577 # directly specified modules, but not for dependencies.
5578 inc_all_direct_tests=true
5579 inc_all_indirect_tests="$inc_all_tests"
5581 # Check that the license of every module is consistent with the license of
5583 saved_inctests="$inctests"
5584 # When computing transitive closures, don't consider $module to depend on
5585 # $module-tests. Need this because tests are implicitly GPL and may depend
5586 # on GPL modules - therefore we don't want a warning in this case.
5588 for requested_module in $specified_modules; do
5589 requested_license=`func_get_license "$requested_module"`
5590 if test "$requested_license" != GPL; then
5591 # Here we use func_modules_transitive_closure, not just
5592 # func_get_dependencies, so that we also detect weird situations like
5593 # an LGPL module which depends on a GPLed build tool module which depends
5595 modules="$requested_module"
5596 func_modules_transitive_closure
5597 for module in $modules; do
5598 license=`func_get_license "$module"`
5600 'GPLed build tool') ;;
5601 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5603 case "$requested_license" in
5606 GPLv2+ | LGPLv2+) ;;
5607 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5613 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5619 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5628 inctests="$saved_inctests"
5630 # Subdirectory names.
5641 # Determine final module list.
5642 modules="$specified_modules"
5643 func_modules_transitive_closure
5644 if test $verbose -ge 0; then
5645 func_show_module_list
5647 final_modules="$modules"
5649 if $single_configure; then
5650 # Determine main module list and tests-related module list separately.
5651 func_modules_transitive_closure_separately
5654 if $single_configure; then
5655 # Determine whether a $testsbase/libtests.a is needed.
5656 func_determine_use_libtests
5659 # Add the dummy module if needed.
5660 if $single_configure; then
5661 func_modules_add_dummy_separately
5663 func_modules_add_dummy
5666 # Show banner notice of every module.
5667 if $single_configure; then
5668 modules="$main_modules"
5674 # Determine final file list.
5675 if $single_configure; then
5676 func_modules_to_filelist_separately
5678 func_modules_to_filelist
5679 if test $verbose -ge 0; then
5681 echo "$files" | sed -e 's/^/ /'
5684 # Add files for which the copy in gnulib is newer than the one that
5685 # "automake --add-missing --copy" would provide.
5686 files="$files build-aux/config.guess"
5687 files="$files build-aux/config.sub"
5688 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5690 rewritten='%REWRITTEN%'
5691 sed_rewrite_files="\
5692 s,^build-aux/,$rewritten$auxdir/,
5693 s,^doc/,$rewritten$docbase/,
5694 s,^lib/,$rewritten$sourcebase/,
5695 s,^m4/,$rewritten$m4base/,
5696 s,^tests/,$rewritten$testsbase/,
5697 s,^tests=lib/,$rewritten$testsbase/,
5701 # Create directories.
5702 for f in $files; do echo $f; done \
5703 | sed -e "$sed_rewrite_files" \
5704 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5705 | LC_ALL=C sort -u \
5707 { # Rearrange file descriptors. Needed because "while ... done < ..."
5708 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5709 exec 5<&0 < "$tmp"/dirs
5711 mkdir -p "$testdir/$d"
5716 # Copy files or make symbolic links.
5718 for f in $files; do echo $f; done \
5719 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5722 { # Rearrange file descriptors. Needed because "while ... done < ..."
5723 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5724 exec 5<&0 < "$tmp"/files
5727 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5729 func_lookup_file "$f"
5730 if test -n "$lookedup_tmp"; then
5731 cp -p "$lookedup_file" "$testdir/$g"
5733 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5734 if { test -n "$symbolic" \
5735 || { test -n "$lsymbolic" \
5736 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5737 func_ln "$lookedup_file" "$testdir/$g"
5739 cp -p "$lookedup_file" "$testdir/$g"
5746 # Determine include_guard_prefix.
5747 func_compute_include_guard_prefix
5749 # Create Makefile.ams that are for testing.
5752 # No special edits are needed.
5755 # Create $sourcebase/Makefile.am.
5756 mkdir -p "$testdir/$sourcebase"
5757 destfile="$sourcebase/Makefile.am"
5758 if $single_configure; then
5759 modules="$main_modules"
5761 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5762 any_uses_subdirs="$uses_subdirs"
5764 # Create $m4base/Makefile.am.
5765 mkdir -p "$testdir/$m4base"
5766 (echo "## Process this file with automake to produce Makefile.in."
5772 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5775 ) > "$testdir/$m4base/Makefile.am"
5777 subdirs="$sourcebase $m4base"
5778 subdirs_with_configure_ac=""
5780 if false && test -f "$testdir"/$m4base/gettext.m4; then
5781 # Avoid stupid error message from automake:
5782 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5783 mkdir -p "$testdir/po"
5784 (echo "## Process this file with automake to produce Makefile.in."
5785 ) > "$testdir/po/Makefile.am"
5786 func_append subdirs " po"
5790 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5791 if $single_configure; then
5792 # Create $testsbase/Makefile.am.
5793 destfile="$testsbase/Makefile.am"
5794 modules="$testsrelated_modules"
5795 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
5797 # Viewed from the $testsbase subdirectory, $auxdir is different.
5798 saved_auxdir="$auxdir"
5799 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5800 # Create $testsbase/Makefile.am.
5802 destfile="$testsbase/Makefile.am"
5803 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5804 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5805 # Create $testsbase/configure.ac.
5806 (echo "# Process this file with autoconf to produce a configure script."
5807 echo "AC_INIT([dummy], [0])"
5808 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5809 echo "AM_INIT_AUTOMAKE"
5811 echo "AC_CONFIG_HEADERS([config.h])"
5814 echo "AC_PROG_INSTALL"
5815 echo "AC_PROG_MAKE_SET"
5816 echo "gl_PROG_AR_RANLIB"
5818 if test -n "$uses_subdirs"; then
5819 echo "AM_PROG_CC_C_O"
5822 for module in $modules; do
5824 if test -n "$module"; then
5826 gnumakefile | maintainer-makefile)
5827 # These modules are meant to be used only in the top-level directory.
5830 func_get_autoconf_early_snippet "$module"
5835 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5836 if test "$libtool" = true; then
5837 echo "LT_INIT([win32-dll])"
5838 echo "LT_LANG([C++])"
5839 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5840 echo "gl_cond_libtool=true"
5842 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5843 echo "gl_cond_libtool=false"
5845 echo "gl_ltlibdeps="
5847 # Wrap the set of autoconf snippets into an autoconf macro that is then
5848 # invoked. This is needed because autoconf does not support AC_REQUIRE
5850 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5851 # but we want the AC_REQUIRE to have its normal meaning (provide one
5852 # expansion of the required macro before the current point, and only one
5854 echo "AC_DEFUN([gl_INIT], ["
5855 sed_replace_build_aux='
5857 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5858 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5861 echo "gl_m4_base='../$m4base'"
5862 func_emit_initmacro_start $macro_prefix
5863 # We don't have explicit ordering constraints between the various
5864 # autoconf snippets. It's cleanest to put those of the library before
5865 # those of the tests.
5866 echo "gl_source_base='../$sourcebase'"
5867 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5868 echo "gl_source_base='.'"
5869 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5870 func_emit_initmacro_end $macro_prefix
5871 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5872 # created using libtool, because libtool already handles the dependencies.
5873 if test "$libtool" != true; then
5874 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5875 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5876 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5877 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5878 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5881 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5885 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5886 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5887 echo "AH_TOP([#include \"../config.h\"])"
5889 echo "AC_CONFIG_FILES([Makefile])"
5891 ) > "$testdir/$testsbase/configure.ac"
5892 auxdir="$saved_auxdir"
5893 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5895 func_append subdirs " $testsbase"
5898 # Create Makefile.am.
5899 (echo "## Process this file with automake to produce Makefile.in."
5901 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5903 echo "SUBDIRS = $subdirs"
5905 echo "ACLOCAL_AMFLAGS = -I $m4base"
5906 ) > "$testdir/Makefile.am"
5908 # Create configure.ac.
5909 (echo "# Process this file with autoconf to produce a configure script."
5910 echo "AC_INIT([dummy], [0])"
5911 if test "$auxdir" != "."; then
5912 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5914 echo "AM_INIT_AUTOMAKE"
5916 echo "AC_CONFIG_HEADERS([config.h])"
5919 echo "AC_PROG_INSTALL"
5920 echo "AC_PROG_MAKE_SET"
5922 echo "# For autobuild."
5923 echo "AC_CANONICAL_BUILD"
5924 echo "AC_CANONICAL_HOST"
5926 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5927 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5928 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5929 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5931 echo "gl_PROG_AR_RANLIB"
5933 if test -n "$any_uses_subdirs"; then
5934 echo "AM_PROG_CC_C_O"
5937 for module in $final_modules; do
5938 if $single_configure; then
5941 func_verify_nontests_module
5943 if test -n "$module"; then
5944 func_get_autoconf_early_snippet "$module"
5947 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5948 if test "$libtool" = true; then
5949 echo "LT_INIT([win32-dll])"
5950 echo "LT_LANG([C++])"
5951 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5952 echo "gl_cond_libtool=true"
5954 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5955 echo "gl_cond_libtool=false"
5957 echo "gl_ltlibdeps="
5959 # Wrap the set of autoconf snippets into an autoconf macro that is then
5960 # invoked. This is needed because autoconf does not support AC_REQUIRE
5962 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5963 # but we want the AC_REQUIRE to have its normal meaning (provide one
5964 # expansion of the required macro before the current point, and only one
5966 echo "AC_DEFUN([gl_INIT], ["
5967 if test "$auxdir" != "build-aux"; then
5968 sed_replace_build_aux='
5970 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5971 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5975 sed_replace_build_aux="$sed_noop"
5977 echo "gl_m4_base='$m4base'"
5978 func_emit_initmacro_start $macro_prefix
5979 echo "gl_source_base='$sourcebase'"
5980 if $single_configure; then
5981 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
5983 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5985 func_emit_initmacro_end $macro_prefix
5986 if $single_configure; then
5987 echo " gltests_libdeps="
5988 echo " gltests_ltlibdeps="
5989 func_emit_initmacro_start ${macro_prefix}tests
5990 echo " gl_source_base='$testsbase'"
5991 # Define a tests witness macro.
5992 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
5993 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5994 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5995 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5996 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
5997 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5998 func_emit_initmacro_end ${macro_prefix}tests
6000 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6001 # created using libtool, because libtool already handles the dependencies.
6002 if test "$libtool" != true; then
6003 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6004 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6005 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6006 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6007 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6009 if $single_configure; then
6010 if $use_libtests; then
6011 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6012 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6016 func_emit_initmacro_done $macro_prefix $sourcebase
6017 if $single_configure; then
6018 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6023 if test -n "$subdirs_with_configure_ac"; then
6024 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6026 makefiles="Makefile"
6027 for d in $subdirs; do
6028 # For subdirs that have a configure.ac by their own, it's the subdir's
6029 # configure.ac which creates the subdir's Makefile.am, not this one.
6030 case " $subdirs_with_configure_ac " in
6032 *) func_append makefiles " $d/Makefile" ;;
6035 echo "AC_CONFIG_FILES([$makefiles])"
6037 ) > "$testdir/configure.ac"
6039 # Create autogenerated files.
6041 # Do not use "${AUTORECONF} --force --install", because it may invoke
6042 # autopoint, which brings in older versions of some of our .m4 files.
6043 if test -f $m4base/gettext.m4; then
6044 func_execute_command ${AUTOPOINT} --force || func_exit 1
6045 for f in $m4base/*.m4~; do
6047 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6051 if test "$libtool" = true; then
6052 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6054 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6055 if ! test -d build-aux; then
6056 func_execute_command mkdir build-aux || func_exit 1
6058 func_execute_command ${AUTOCONF} || func_exit 1
6059 func_execute_command ${AUTOHEADER} || func_exit 1
6060 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6062 if $inctests && ! $single_configure; then
6063 # Create autogenerated files.
6064 (cd "$testdir/$testsbase" || func_exit 1
6065 # Do not use "${AUTORECONF} --force --install", because it may invoke
6066 # autopoint, which brings in older versions of some of our .m4 files.
6067 if test -f ../$m4base/gettext.m4; then
6068 func_execute_command ${AUTOPOINT} --force || func_exit 1
6069 for f in ../$m4base/*.m4~; do
6071 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6075 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6076 if ! test -d ../build-aux; then
6077 func_execute_command mkdir ../build-aux
6079 func_execute_command ${AUTOCONF} || func_exit 1
6080 func_execute_command ${AUTOHEADER} || func_exit 1
6081 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6084 # Need to run configure and make once, to create built files that are to be
6085 # distributed (such as parse-datetime.c).
6086 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6087 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6088 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6089 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6090 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6091 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6092 # such $(FOO_H) because they don't refer to distributed files.
6093 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6094 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6095 | sed -e "$sed_remove_make_variables"`
6096 distributed_built_sources=`for file in $built_sources; do
6097 case "$cleaned_files" in
6102 tests_distributed_built_sources=
6104 # Likewise for built files in the $testsbase directory.
6105 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6106 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6107 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6108 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6109 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6110 | sed -e "$sed_remove_make_variables"`
6111 tests_distributed_built_sources=`for file in $tests_built_sources; do
6112 case "$tests_cleaned_files" in
6118 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6120 ./configure || func_exit 1
6121 if test -n "$distributed_built_sources"; then
6123 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6124 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6129 if test -n "$tests_distributed_built_sources"; then
6131 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6132 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6137 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6144 # func_create_megatestdir megatestdir allmodules
6146 # - local_gnulib_dir from --local-dir
6147 # - modcache true or false, from --cache-modules/--no-cache-modules
6148 # - auxdir directory relative to destdir where to place build aux files
6149 func_create_megatestdir ()
6153 if test -z "$allmodules"; then
6154 allmodules=`func_all_modules`
6158 # First, all modules one by one.
6159 for onemodule in $allmodules; do
6160 func_create_testdir "$megatestdir/$onemodule" $onemodule
6161 func_append megasubdirs "$onemodule "
6163 # Then, all modules all together.
6164 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6165 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6166 func_create_testdir "$megatestdir/ALL" "$allmodules"
6167 func_append megasubdirs "ALL"
6170 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
6171 vc_witness="$gnulib_dir/CVS/Entries"; \
6173 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6175 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6176 | sed -e 's,January,01,' -e 's,Jan,01,' \
6177 -e 's,February,02,' -e 's,Feb,02,' \
6178 -e 's,March,03,' -e 's,Mar,03,' \
6179 -e 's,April,04,' -e 's,Apr,04,' \
6181 -e 's,June,06,' -e 's,Jun,06,' \
6182 -e 's,July,07,' -e 's,Jul,07,' \
6183 -e 's,August,08,' -e 's,Aug,08,' \
6184 -e 's,September,09,' -e 's,Sep,09,' \
6185 -e 's,October,10,' -e 's,Oct,10,' \
6186 -e 's,November,11,' -e 's,Nov,11,' \
6187 -e 's,December,12,' -e 's,Dec,12,' \
6188 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6189 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6191 echo "CVSDATE=$cvsdate"
6192 echo ": \${MAKE=make}"
6193 echo "test -d logs || mkdir logs"
6194 echo "for module in $megasubdirs; do"
6195 echo " echo \"Working on module \$module...\""
6196 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6197 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6200 echo " : autobuild project... \$module"
6201 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6202 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6203 echo " : autobuild hostname... \`hostname\`"
6204 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6206 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6208 ) > "$megatestdir/do-autobuild"
6209 chmod a+x "$megatestdir/do-autobuild"
6211 # Create Makefile.am.
6212 (echo "## Process this file with automake to produce Makefile.in."
6214 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
6216 echo "SUBDIRS = $megasubdirs"
6218 echo "EXTRA_DIST = do-autobuild"
6219 ) > "$megatestdir/Makefile.am"
6221 # Create configure.ac.
6222 (echo "# Process this file with autoconf to produce a configure script."
6223 echo "AC_INIT([dummy], [0])"
6224 if test "$auxdir" != "."; then
6225 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6227 echo "AM_INIT_AUTOMAKE"
6229 echo "AC_PROG_MAKE_SET"
6231 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6232 echo "AC_CONFIG_FILES([Makefile])"
6234 ) > "$megatestdir/configure.ac"
6236 # Create autogenerated files.
6238 # Do not use "${AUTORECONF} --install", because autoreconf operates
6239 # recursively, but the subdirectories are already finished, therefore
6240 # calling autoreconf here would only waste lots of CPU time.
6241 func_execute_command ${ACLOCAL} || func_exit 1
6242 func_execute_command mkdir build-aux
6243 func_execute_command ${AUTOCONF} || func_exit 1
6244 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6250 func_fatal_error "no mode specified" ;;
6257 # sed expression that converts a literal to a basic regular expression.
6258 # Needs to handle . [ \ * ^ $.
6259 sed_literal_to_basic_regex='s/\\/\\\\/g
6265 if test -f "$gnulib_dir/$filename" \
6266 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
6267 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6268 filename_line_regex='^'"$filename_anywhere_regex"'$'
6271 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6272 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
6273 (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$,,')
6276 | func_sanitize_modulelist \
6279 for module in $module_candidates; do
6280 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6285 func_warning "file $filename does not exist"
6290 import | add-import | remove-import | update )
6293 if test -z "$destdir"; then
6296 test -d "$destdir" \
6297 || func_fatal_error "destination directory does not exist: $destdir"
6299 # Prefer configure.ac to configure.in.
6300 if test -f "$destdir"/configure.ac; then
6301 configure_ac="$destdir/configure.ac"
6303 if test -f "$destdir"/configure.in; then
6304 configure_ac="$destdir/configure.in"
6306 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6310 # Analyze configure.ac.
6312 guessed_libtool=false
6317 /AC_CONFIG_AUX_DIR/ {
6318 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6320 /A[CM]_PROG_LIBTOOL/ {
6321 s,^.*$,guessed_libtool=true,p
6323 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6325 if test -z "$auxdir"; then
6326 auxdir="$guessed_auxdir"
6329 # Determine where to apply func_import.
6330 if test "$mode" = import; then
6331 # Apply func_import to a particular gnulib directory.
6332 # The command line contains the complete specification; don't look at
6333 # the contents of gnulib-cache.m4.
6334 test -n "$supplied_libname" || supplied_libname=true
6335 test -n "$sourcebase" || sourcebase="lib"
6336 test -n "$m4base" || m4base="m4"
6337 test -n "$docbase" || docbase="doc"
6338 test -n "$testsbase" || testsbase="tests"
6339 test -n "$macro_prefix" || macro_prefix="gl"
6342 if test -n "$m4base"; then
6343 # Apply func_import to a particular gnulib directory.
6344 # Any number of additional modules can be given.
6345 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6346 # First use of gnulib in the given m4base.
6347 test -n "$supplied_libname" || supplied_libname=true
6348 test -n "$sourcebase" || sourcebase="lib"
6349 test -n "$docbase" || docbase="doc"
6350 test -n "$testsbase" || testsbase="tests"
6351 test -n "$macro_prefix" || macro_prefix="gl"
6355 # Apply func_import to all gnulib directories.
6356 # To get this list of directories, look at Makefile.am. (Not at
6357 # configure, because it may be omitted from version control. Also,
6358 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6362 if test -f "$destdir"/Makefile.am; then
6363 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6365 for arg in $aclocal_amflags; do
6366 if test -n "$m4dir_is_next"; then
6367 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6371 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6372 func_append m4dirs " $arg"
6373 m4dirs_count=`expr $m4dirs_count + 1`
6379 if test "X$arg" = "X-I"; then
6387 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6388 if test -f "$destdir"/aclocal.m4; then
6389 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6390 sedexpr2='s,^[^/]*$,.,'
6391 sedexpr3='s,/[^/]*$,,'
6392 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6393 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6394 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6397 if test $m4dirs_count = 0; then
6398 # First use of gnulib in a package.
6399 # Any number of additional modules can be given.
6400 test -n "$supplied_libname" || supplied_libname=true
6401 test -n "$sourcebase" || sourcebase="lib"
6403 test -n "$docbase" || docbase="doc"
6404 test -n "$testsbase" || testsbase="tests"
6405 test -n "$macro_prefix" || macro_prefix="gl"
6408 if test $m4dirs_count = 1; then
6409 # There's only one use of gnulib here. Assume the user means it.
6410 # Any number of additional modules can be given.
6411 for m4base in $m4dirs; do
6415 # Ambiguous - guess what the user meant.
6416 if test $# = 0; then
6417 # No further arguments. Guess the user wants to update all of them.
6418 for m4base in $m4dirs; do
6419 # Perform func_import in a subshell, so that variable values
6421 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6422 # inc_longrunning_tests, inc_privileged_tests,
6423 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6424 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6425 # makefile_name, libtool, macro_prefix, po_domain,
6426 # witness_c_macro, vc_files
6427 # don't propagate from one directory to another.
6428 (func_import) || func_exit 1
6432 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6441 if test -z "$destdir"; then
6442 func_fatal_error "please specify --dir option"
6445 test -d "$destdir" \
6446 || func_fatal_error "could not create destination directory"
6447 test -n "$auxdir" || auxdir="build-aux"
6448 func_create_testdir "$destdir" "$*"
6451 create-megatestdir )
6452 if test -z "$destdir"; then
6453 func_fatal_error "please specify --dir option"
6455 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6456 test -n "$auxdir" || auxdir="build-aux"
6457 func_create_megatestdir "$destdir" "$*"
6461 test -n "$destdir" || destdir=testdir$$
6462 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6463 test -n "$auxdir" || auxdir="build-aux"
6464 func_create_testdir "$destdir" "$*"
6468 ../configure || func_exit 1
6469 $MAKE || func_exit 1
6470 $MAKE check || func_exit 1
6471 $MAKE distclean || func_exit 1
6472 remaining=`find . -type f -print`
6473 if test -n "$remaining"; then
6474 echo "Remaining files:" $remaining 1>&2
6475 echo "gnulib-tool: *** Stop." 1>&2
6484 test -n "$destdir" || destdir=testdir$$
6485 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6486 test -n "$auxdir" || auxdir="build-aux"
6487 func_create_megatestdir "$destdir" "$*"
6495 remaining=`find . -type f -print`
6496 if test -n "$remaining"; then
6497 echo "Remaining files:" $remaining 1>&2
6498 echo "gnulib-tool: *** Stop." 1>&2
6506 extract-description )
6510 if test -n "$module"; then
6511 func_get_description "$module"
6520 if test -n "$module"; then
6521 func_get_comment "$module"
6530 if test -n "$module"; then
6531 func_get_status "$module"
6540 if test -n "$module"; then
6541 func_get_notice "$module"
6546 extract-applicability )
6550 if test -n "$module"; then
6551 func_get_applicability "$module"
6560 if test -n "$module"; then
6561 func_get_filelist "$module"
6566 extract-dependencies )
6567 if test -n "$avoidlist"; then
6568 func_fatal_error "cannot combine --avoid and --extract-dependencies"
6573 if test -n "$module"; then
6574 func_get_dependencies "$module"
6579 extract-autoconf-snippet )
6583 if test -n "$module"; then
6584 func_get_autoconf_snippet "$module"
6589 extract-automake-snippet )
6593 if test -n "$module"; then
6594 func_get_automake_snippet "$module"
6599 extract-include-directive )
6603 if test -n "$module"; then
6604 func_get_include_directive "$module"
6609 extract-link-directive )
6613 if test -n "$module"; then
6614 func_get_link_directive "$module"
6623 if test -n "$module"; then
6624 func_get_license "$module"
6629 extract-maintainer )
6633 if test -n "$module"; then
6634 func_get_maintainer "$module"
6639 extract-tests-module )
6643 if test -n "$module"; then
6644 func_get_tests_module "$module"
6650 # Verify the number of arguments.
6651 if test $# -lt 1 || test $# -gt 2; then
6652 func_fatal_error "invalid number of arguments for --$mode"
6655 # The first argument is the file to be copied.
6657 # Verify the file exists.
6658 func_lookup_file "$f"
6660 # The second argument is the destination; either a directory ot a file.
6661 # It defaults to the current directory.
6663 test -n "$dest" || dest='.'
6664 test -n "$sourcebase" || sourcebase="lib"
6665 test -n "$m4base" || m4base="m4"
6666 test -n "$docbase" || docbase="doc"
6667 test -n "$testsbase" || testsbase="tests"
6668 test -n "$auxdir" || auxdir="build-aux"
6669 rewritten='%REWRITTEN%'
6670 sed_rewrite_files="\
6671 s,^build-aux/,$rewritten$auxdir/,
6672 s,^doc/,$rewritten$docbase/,
6673 s,^lib/,$rewritten$sourcebase/,
6674 s,^m4/,$rewritten$m4base/,
6675 s,^tests/,$rewritten$testsbase/,
6678 if test -d "$dest"; then
6680 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6682 destdir=`dirname "$dest"`
6683 g=`basename "$dest"`
6686 # Create the directory for destfile.
6687 d=`dirname "$destdir/$g"`
6689 if test -n "$d" && test ! -d "$d"; then
6690 mkdir -p "$d" || func_fatal_error "failed"
6694 func_dest_tmpfilename "$g"
6695 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6696 already_present=true
6697 if test -f "$destdir/$g"; then
6698 # The file already exists.
6702 # Don't protest if the file should be there but isn't: it happens
6703 # frequently that developers don't put autogenerated files under version
6711 func_fatal_error "unknown operation mode --$mode" ;;
6715 # Undo the effect of the previous 'trap' command. Some shellology:
6716 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6717 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6718 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6719 # 128 + signal number and is set before the trap-registered command is run.
6721 trap 'func_exit $?' 1 2 3 13 15
6726 # indent-tabs-mode: nil
6727 # whitespace-check-buffer-indent: nil