3 # Copyright (C) 2002-2011 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
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
192 --dir=DIRECTORY Specify the target directory.
193 For --import, this specifies where your
194 configure.ac can be found. Defaults to current
196 --local-dir=DIRECTORY Specify a local override directory where to look
197 up files before looking in gnulib's directory.
198 --cache-modules Enable module caching optimization.
199 --no-cache-modules Disable module caching optimization.
200 --verbose Increase verbosity. May be repeated.
201 --quiet Decrease verbosity. May be repeated.
203 Options for --import, --add/remove-import, --update:
205 --dry-run Only print what would have been done.
207 Options for --import, --add/remove-import,
208 --create-[mega]testdir, --[mega]test:
210 --with-tests Include unit tests for the included modules.
211 --with-obsolete Include obsolete modules when they occur among the
212 dependencies. By default, dependencies to obsolete
214 --with-c++-tests Include even unit tests for C++ interoperability.
215 --with-longrunning-tests
216 Include even unit tests that are long-runners.
217 --with-privileged-tests
218 Include even unit tests that require root
220 --with-unportable-tests
221 Include even unit tests that fail on some platforms.
222 --with-all-tests Include all kinds of problematic unit tests.
223 --avoid=MODULE Avoid including the given MODULE. Useful if you
224 have code that provides equivalent functionality.
225 This option can be repeated.
226 --libtool Use libtool rules.
227 --no-libtool Don't use libtool rules.
229 Options for --import, --add/remove-import:
231 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
232 --source-base=DIRECTORY
233 Directory relative to --dir where source code is
234 placed (default \"lib\").
235 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
236 placed (default \"m4\").
237 --po-base=DIRECTORY Directory relative to --dir where *.po files are
238 placed (default \"po\").
239 --doc-base=DIRECTORY Directory relative to --dir where doc files are
240 placed (default \"doc\").
241 --tests-base=DIRECTORY
242 Directory relative to --dir where unit tests are
243 placed (default \"tests\").
244 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
245 tools are placed (default comes from configure.ac).
246 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
247 Also modify license template from GPL to LGPL.
248 The version number of the LGPL can be specified;
249 the default is currently LGPLv3.
250 --makefile-name=NAME Name of makefile in automake syntax in the
251 source-base and tests-base directories
252 (default \"Makefile.am\").
253 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
254 'gl_INIT'. Default is 'gl'.
255 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
256 the package name. A suffix '-gnulib' is appended.
257 --vc-files Update version control related files.
258 --no-vc-files Don't update version control related files
259 (.gitignore and/or .cvsignore).
260 --no-changelog Don't update or create ChangeLog files.
262 Options for --create-[mega]testdir, --[mega]test:
264 --without-c++-tests Exclude unit tests for C++ interoperability.
265 --without-longrunning-tests
266 Exclude unit tests that are long-runners.
267 --without-privileged-tests
268 Exclude unit tests that require root privileges.
269 --without-unportable-tests
270 Exclude unit tests that fail on some platforms.
272 Options for --import, --add/remove-import, --update,
273 --create-[mega]testdir, --[mega]test:
275 -s, --symbolic, --symlink Make symbolic links instead of copying files.
276 --local-symlink Make symbolic links instead of copying files, only
277 for files from the local override directory.
279 Options for --import, --add/remove-import, --update:
281 -S, --more-symlinks Make symbolic links instead of copying files, and
282 don't replace copyright notices.
284 Report bugs to <bug-gnulib@gnu.org>."
288 # outputs to stdout the --version message.
292 if test -d "$gnulib_dir"/.git \
293 && (git --version) >/dev/null 2>/dev/null \
294 && (date --version) >/dev/null 2>/dev/null; then
295 # gnulib checked out from git.
296 sed_extract_first_date='/^Date/{
300 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
301 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
302 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
303 date=`echo "$date" | sed -e "$sed_year_before_time"`
304 # Use GNU date to compute the time in GMT.
305 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
306 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
308 if test -d "$gnulib_dir"/CVS \
309 && (cvs --version) >/dev/null 2>/dev/null; then
310 # gnulib checked out from CVS.
311 sed_extract_first_date='/^date: /{
312 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
315 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
317 # gnulib copy without versioning information.
318 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
322 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
324 gnulib-tool (GNU $package $date)$version
325 Copyright (C) $year Free Software Foundation, Inc.
326 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
327 This is free software: you are free to change and redistribute it.
328 There is NO WARRANTY, to the extent permitted by law.
330 Written by" "Bruno Haible" "and" "Simon Josefsson"
333 # func_emit_copyright_notice
334 # outputs to stdout a header for a generated file.
335 func_emit_copyright_notice ()
337 sed -n -e '/Copyright/ {
340 }' < "$self_abspathname"
342 echo "# This file is free software, distributed under the terms of the GNU"
343 echo "# General Public License. As a special exception to the GNU General"
344 echo "# Public License, this file may be distributed as part of a program"
345 echo "# that contains a configuration script generated by Autoconf, under"
346 echo "# the same distribution terms as the rest of that program."
348 echo "# Generated by gnulib-tool."
352 # exits with a given status.
353 # This function needs to be used, rather than 'exit', when a 'trap' handler is
354 # in effect that refers to $?.
361 # locates the directory where the gnulib repository lives
363 # - progname name of this program
365 # - self_abspathname absolute pathname of gnulib-tool
366 # - gnulib_dir absolute pathname of gnulib repository
370 /*) self_abspathname="$progname" ;;
371 */*) self_abspathname=`pwd`/"$progname" ;;
374 # Iterate through the elements of $PATH.
375 # We use IFS=: instead of
376 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
377 # because the latter does not work when some PATH element contains spaces.
378 # We use a canonicalized $pathx instead of $PATH, because empty PATH
379 # elements are by definition equivalent to '.', however field splitting
380 # according to IFS=: loses empty fields in many shells:
381 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
382 # beginning, at the end, and in the middle),
383 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
384 # at the beginning and at the end,
385 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
386 # Solaris lose empty fields at the end.
387 # The 'case' statement is an optimization, to avoid evaluating the
388 # explicit canonicalization command when $PATH contains no empty fields.
390 if test "${PATH_SEPARATOR+set}" != set; then
391 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
392 # contains only /bin. Note that ksh looks also at the FPATH variable,
393 # so we have to set that as well for the test.
395 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
396 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
397 || PATH_SEPARATOR=';'
400 if test "$PATH_SEPARATOR" = ";"; then
401 # On Windows, programs are searched in "." before $PATH.
404 # On Unix, we have to convert empty PATH elements to ".".
408 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
413 IFS="$PATH_SEPARATOR"
417 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
418 self_abspathname="$d/$progname"
423 if test -z "$self_abspathname"; then
424 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
428 while test -h "$self_abspathname"; do
429 # Resolve symbolic link.
430 linkval=`func_readlink "$self_abspathname"`
431 test -n "$linkval" || break
433 /* ) self_abspathname="$linkval" ;;
434 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
437 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
441 # creates a temporary directory.
443 # - progname name of this program
445 # - tmp pathname of freshly created temporary directory
448 # Use the environment variable TMPDIR, falling back to /tmp. This allows
449 # users to specify a different temporary directory, for example, if their
450 # /tmp is filled up or too small.
453 # Use the mktemp program if available. If not available, hide the error
455 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
456 test -n "$tmp" && test -d "$tmp"
459 # Use a simple mkdir command. It is guaranteed to fail if the directory
460 # already exists. $RANDOM is bash specific and expands to empty in shells
461 # other than bash, ksh and zsh. Its use does not increase security;
462 # rather, it minimizes the probability of failure in a very cluttered /tmp
464 tmp=$TMPDIR/gl$$-$RANDOM
465 (umask 077 && mkdir "$tmp")
468 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
473 # func_append var value
474 # appends the given value to the shell variable var.
475 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
476 # Use bash's += operator. It reduces complexity of appending repeatedly to
477 # a single variable from O(n^2) to O(n).
482 fast_func_append=true
486 eval "$1=\"\$$1\$2\""
488 fast_func_append=false
491 # func_remove_prefix var prefix
492 # removes the given prefix from the value of the shell variable var.
493 # var should be the name of a shell variable.
494 # Its value should not contain a newline and not start or end with whitespace.
495 # prefix should not contain the characters "$`\{}[]^|.
496 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
497 func_remove_prefix ()
501 fast_func_remove_prefix=true
503 func_remove_prefix ()
505 eval "value=\"\$$1\""
509 sed_escape_dots='s/\([.]\)/\\\1/g'
510 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
513 value=`echo "$value" | sed -e "s|^${prefix}||"`
514 eval "$1=\"\$value\""
516 fast_func_remove_prefix=false
519 # func_remove_suffix var suffix
520 # removes the given suffix from the value of the shell variable var.
521 # var should be the name of a shell variable.
522 # Its value should not contain a newline and not start or end with whitespace.
523 # suffix should not contain the characters "$`\{}[]^|.
524 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
525 func_remove_suffix ()
529 fast_func_remove_suffix=true
531 func_remove_suffix ()
533 eval "value=\"\$$1\""
537 sed_escape_dots='s/\([.]\)/\\\1/g'
538 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
541 value=`echo "$value" | sed -e "s|${suffix}\$||"`
542 eval "$1=\"\$value\""
544 fast_func_remove_suffix=false
547 # func_fatal_error message
548 # outputs to stderr a fatal error message, and terminates the program.
550 # - progname name of this program
553 echo "$progname: *** $1" 1>&2
554 echo "$progname: *** Stop." 1>&2
558 # func_warning message
559 # Outputs to stderr a warning message,
562 echo "gnulib-tool: warning: $1" 1>&2
565 # func_readlink SYMLINK
566 # outputs the target of the given symlink.
567 if (type -p readlink) > /dev/null 2>&1; then
570 # Use the readlink program from GNU coreutils.
576 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
577 # would do the wrong thing if the link target contains " -> ".
578 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
582 # func_relativize DIR1 DIR2
583 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
585 # - DIR1 relative pathname, relative to the current directory
586 # - DIR2 relative pathname, relative to the current directory
588 # - reldir relative pathname of DIR2, relative to DIR1
594 sed_first='s,^\([^/]*\)/.*$,\1,'
595 sed_rest='s,^[^/]*/*,,'
596 sed_last='s,^.*/\([^/]*\)$,\1,'
597 sed_butlast='s,/*[^/]*$,,'
598 while test -n "$dir1"; do
599 first=`echo "$dir1" | sed -e "$sed_first"`
600 if test "$first" != "."; then
601 if test "$first" = ".."; then
602 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
603 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
605 first2=`echo "$dir2" | sed -e "$sed_first"`
606 if test "$first2" = "$first"; then
607 dir2=`echo "$dir2" | sed -e "$sed_rest"`
611 dir0="$dir0"/"$first"
614 dir1=`echo "$dir1" | sed -e "$sed_rest"`
619 # func_relconcat DIR1 DIR2
620 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
622 # - DIR1 relative pathname, relative to the current directory
623 # - DIR2 relative pathname, relative to DIR1
625 # - relconcat DIR1/DIR2, relative to the current directory
630 sed_first='s,^\([^/]*\)/.*$,\1,'
631 sed_rest='s,^[^/]*/*,,'
632 sed_last='s,^.*/\([^/]*\)$,\1,'
633 sed_butlast='s,/*[^/]*$,,'
635 first=`echo "$dir2" | sed -e "$sed_first"`
636 if test "$first" = "."; then
637 dir2=`echo "$dir2" | sed -e "$sed_rest"`
638 if test -z "$dir2"; then
643 last=`echo "$dir1" | sed -e "$sed_last"`
644 while test "$last" = "."; do
645 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
646 last=`echo "$dir1" | sed -e "$sed_last"`
648 if test -z "$dir1"; then
652 if test "$first" = ".."; then
653 if test "$last" = ".."; then
654 relconcat="$dir1/$dir2"
657 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
658 dir2=`echo "$dir2" | sed -e "$sed_rest"`
659 if test -z "$dir1"; then
663 if test -z "$dir2"; then
668 relconcat="$dir1/$dir2"
676 # Like ln -s, except that SRC is given relative to the current directory (or
677 # absolute), not given relative to the directory of DEST.
683 *) # SRC is relative.
686 ln -s "`pwd`/$1" "$2" ;;
687 *) # DEST is relative too.
688 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
689 test -n "$ln_destdir" || ln_destdir="."
690 func_relativize "$ln_destdir" "$1"
698 # func_ln_if_changed SRC DEST
699 # Like func_ln, but avoids munging timestamps if the link is correct.
700 func_ln_if_changed ()
702 if test $# -ne 2; then
703 echo "usage: func_ln_if_changed SRC DEST" >&2
705 ln_target=`func_readlink "$2"`
706 if test -h "$2" && test "$1" = "$ln_target"; then
714 # Ensure an 'echo' command that
715 # 1. does not interpret backslashes and
716 # 2. does not print an error message "broken pipe" when writing into a pipe
719 # Test cases for problem 1:
720 # echo '\n' | wc -l prints 1 when OK, 2 when KO
721 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
722 # Test cases for problem 2:
723 # echo hi | true frequently prints
724 # "bash: echo: write error: Broken pipe"
725 # to standard error in bash 3.2.
727 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
728 # BSD echo interprets '-n' as an option, which is also not desirable).
729 # Nowadays the problem occurs in 4 situations:
730 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
731 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
732 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
733 # - in zsh, when sh-emulation is not set,
734 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
735 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
736 # - in Solaris /bin/sh and OSF/1 /bin/sh.
737 # We try the following workarounds:
738 # - for all: respawn using $CONFIG_SHELL if that is set and works.
739 # - for bash >= 2.04: unset the shell option xpg_echo.
740 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
741 # - for bash < 2.0: define echo to a function that uses cat of a here document.
742 # - for zsh: turn sh-emulation on.
743 # - for ksh: alias echo to 'print -r'.
744 # - for ksh: alias echo to a function that uses cat of a here document.
745 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
746 # the ksh workaround.
747 # - otherwise: respawn using /bin/sh and rely on the workarounds.
748 # When respawning, we pass --no-reexec as first argument, so as to avoid
749 # turning this script into a fork bomb in unlucky situations.
751 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
752 # the 'printf' built-in. See
753 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
754 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
755 # The workaround is: define echo to a function that uses the printf built-in.
757 if echo '\t' | grep t > /dev/null; then
758 have_echo=yes # Lucky!
760 # Try the workarounds.
761 # Respawn using $CONFIG_SHELL if that is set and works.
762 if test -z "$have_echo" \
763 && test "X$1" != "X--no-reexec" \
764 && test -n "$CONFIG_SHELL" \
765 && test -f "$CONFIG_SHELL" \
766 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
767 exec $CONFIG_SHELL "$0" --no-reexec "$@"
770 # For bash >= 2.04: unset the shell option xpg_echo.
771 if test -z "$have_echo" \
772 && test -n "$BASH_VERSION" \
773 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
777 # For bash >= 2.0: define echo to a function that uses the printf built-in.
778 # For bash < 2.0: define echo to a function that uses cat of a here document.
779 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
780 # Also handle problem 2, specific to bash 3.2, here.
781 if { test -z "$have_echo" \
782 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
784 && test -n "$BASH_VERSION"; then \
785 if type printf 2>/dev/null | grep / > /dev/null; then
786 # 'printf' is not a shell built-in.
794 # 'printf' is a shell built-in.
800 if echo '\t' | grep t > /dev/null; then
804 # For zsh: turn sh-emulation on.
805 if test -z "$have_echo" \
806 && test -n "$ZSH_VERSION" \
807 && (emulate sh) >/dev/null 2>&1; then
810 # For ksh: alias echo to 'print -r'.
811 if test -z "$have_echo" \
812 && (type print) >/dev/null 2>&1; then
813 # A 'print' command exists.
814 if type print 2>/dev/null | grep / > /dev/null; then
817 # 'print' is a shell built-in.
818 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
819 # 'print' is the ksh shell built-in.
820 alias echo='print -r'
824 if test -z "$have_echo" \
825 && echo '\t' | grep t > /dev/null; then
828 # For ksh: alias echo to a function that uses cat of a here document.
829 # The ksh manual page says:
830 # "Aliasing is performed when scripts are read, not while they are executed.
831 # Therefore, for an alias to take effect, the alias definition command has
832 # to be executed before the command which references the alias is read."
833 # Because of this, we have to play strange tricks with have_echo, to ensure
834 # that the top-level statement containing the test starts after the 'alias'
836 if test -z "$have_echo"; then
843 if (alias echo=bsd_echo) 2>/dev/null; then
844 alias echo=bsd_echo 2>/dev/null
847 if test -z "$have_echo" \
848 && echo '\t' | grep t > /dev/null; then
851 if test -z "$have_echo"; then
852 if (alias echo=bsd_echo) 2>/dev/null; then
853 unalias echo 2>/dev/null
856 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
857 if test -z "$have_echo" \
858 && test "X$1" != "X--no-reexec" \
859 && test -f /bin/ksh; then
860 exec /bin/ksh "$0" --no-reexec "$@"
863 # Otherwise: respawn using /bin/sh.
864 if test -z "$have_echo" \
865 && test "X$1" != "X--no-reexec" \
866 && test -f /bin/sh; then
867 exec /bin/sh "$0" --no-reexec "$@"
870 if test -z "$have_echo"; then
871 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
873 if echo '\t' | grep t > /dev/null; then
876 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
878 if test "X$1" = "X--no-reexec"; then
882 # Command-line option processing.
883 # Removes the OPTIONS from the arguments. Sets the variables:
884 # - mode list or import or add-import or remove-import or update
885 # or create-testdir or create-megatestdir
886 # - destdir from --dir
887 # - local_gnulib_dir from --local-dir
888 # - modcache true or false, from --cache-modules/--no-cache-modules
889 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
890 # - libname, supplied_libname from --lib
891 # - sourcebase from --source-base
892 # - m4base from --m4-base
893 # - pobase from --po-base
894 # - docbase from --doc-base
895 # - testsbase from --tests-base
896 # - auxdir from --aux-dir
897 # - inctests true if --with-tests was given, blank otherwise
898 # - incobsolete true if --with-obsolete was given, blank otherwise
899 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
900 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
902 # - inc_privileged_tests true if --with-privileged-tests was given, blank
904 # - inc_unportable_tests true if --with-unportable-tests was given, blank
906 # - inc_all_tests true if --with-all-tests was given, blank otherwise
907 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
908 # - excl_longrunning_tests true if --without-longrunning-tests was given,
910 # - excl_privileged_tests true if --without-privileged-tests was given, blank
912 # - excl_unportable_tests true if --without-unportable-tests was given, blank
914 # - avoidlist list of modules to avoid, from --avoid
915 # - lgpl yes or a number if --lgpl was given, blank otherwise
916 # - makefile_name from --makefile-name
917 # - libtool true if --libtool was given, false if --no-libtool was
918 # given, blank otherwise
919 # - macro_prefix from --macro-prefix
920 # - po_domain from --po-domain
921 # - vc_files true if --vc-files was given, false if --no-vc-files was
922 # given, blank otherwise
923 # - autoconf_minversion minimum supported autoconf version
924 # - do_changelog false if --no-changelog was given, : otherwise
925 # - doit : if actions shall be executed, false if only to be printed
926 # - symbolic true if --symlink or --more-symlinks was given, blank
928 # - lsymbolic true if --local-symlink was given, blank otherwise
929 # - do_copyrights blank if --more-symlinks was given, true otherwise
947 inc_longrunning_tests=
948 inc_privileged_tests=
949 inc_unportable_tests=
952 excl_longrunning_tests=
953 excl_privileged_tests=
954 excl_unportable_tests=
970 while test $# -gt 0; do
975 --find | --fin | --fi | --f )
978 --import | --impor | --impo | --imp | --im | --i )
981 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
984 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
987 --update | --updat | --upda | --upd | --up | --u )
990 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
993 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
994 mode=create-megatestdir
996 --test | --tes | --te | --t )
999 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1003 mode=`echo "X$1" | sed -e 's/^X--//'`
1005 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
1010 if test $# = 0; then
1011 func_fatal_error "missing argument for --dir"
1016 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1020 if test $# = 0; then
1021 func_fatal_error "missing argument for --local-dir"
1026 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1028 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1031 --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 )
1034 --verbose | --verbos | --verbo | --verb )
1035 verbose=`expr $verbose + 1`
1037 --quiet | --quie | --qui | --qu | --q )
1038 verbose=`expr $verbose - 1`
1042 if test $# = 0; then
1043 func_fatal_error "missing argument for --lib"
1046 supplied_libname=true
1049 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1050 supplied_libname=true
1054 if test $# = 0; then
1055 func_fatal_error "missing argument for --source-base"
1060 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1064 if test $# = 0; then
1065 func_fatal_error "missing argument for --m4-base"
1070 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1074 if test $# = 0; then
1075 func_fatal_error "missing argument for --po-base"
1080 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1084 if test $# = 0; then
1085 func_fatal_error "missing argument for --doc-base"
1090 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1094 if test $# = 0; then
1095 func_fatal_error "missing argument for --tests-base"
1100 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1104 if test $# = 0; then
1105 func_fatal_error "missing argument for --aux-dir"
1110 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1112 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1115 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1118 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1121 --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)
1122 inc_longrunning_tests=true
1124 --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)
1125 inc_privileged_tests=true
1127 --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)
1128 inc_unportable_tests=true
1130 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1133 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1136 --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)
1137 excl_longrunning_tests=true
1139 --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)
1140 excl_privileged_tests=true
1142 --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)
1143 excl_unportable_tests=true
1147 if test $# = 0; then
1148 func_fatal_error "missing argument for --avoid"
1150 func_append avoidlist " $1"
1153 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1154 func_append avoidlist " $arg"
1160 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1163 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1169 if test $# = 0; then
1170 func_fatal_error "missing argument for --makefile-name"
1175 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1185 if test $# = 0; then
1186 func_fatal_error "missing argument for --macro-prefix"
1191 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1195 if test $# = 0; then
1196 func_fatal_error "missing argument for --po-domain"
1201 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1209 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1215 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1218 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1221 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1225 --help | --hel | --he | --h )
1228 --version | --versio | --versi | --vers )
1232 # Stop option processing
1236 echo "gnulib-tool: unknown option $1" 1>&2
1237 echo "Try 'gnulib-tool --help' for more information." 1>&2
1244 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1245 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1246 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then
1247 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1248 echo "Try 'gnulib-tool --help' for more information." 1>&2
1252 # This code helps migrating from --import to --add-import or --update. It can
1253 # be removed on 2012-01-01.
1254 if test "$mode" = import && test $# = 0; then
1255 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1256 echo "The meaning of the option '--import' has changed." 1>&2
1257 echo "See the documentation at" 1>&2
1258 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1259 echo "For updating to a newer version of gnulib, use" 1>&2
1260 echo " gnulib-tool --add-import" 1>&2
1261 echo "For restoring files that were omitted from version control, use" 1>&2
1262 echo " gnulib-tool --update" 1>&2
1265 if test "$mode" = update; then
1266 if test $# != 0; then
1267 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1268 echo "Try 'gnulib-tool --help' for more information." 1>&2
1269 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1270 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1273 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1274 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1275 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1276 || test -n "$inctests" || test -n "$incobsolete" \
1277 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1278 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1279 || test -n "$inc_all_tests" \
1280 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1281 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1282 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1283 || test -n "$macro_prefix" || test -n "$po_domain" \
1284 || test -n "$vc_files"; then
1285 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1286 echo "Try 'gnulib-tool --help' for more information." 1>&2
1287 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1288 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1293 if test -n "$pobase" && test -z "$po_domain"; then
1294 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1295 echo "Try 'gnulib-tool --help' for more information." 1>&2
1298 if test -z "$pobase" && test -n "$po_domain"; then
1299 func_warning "--po-domain has no effect without a --po-base option"
1302 # Determine the minimum supported autoconf version from the project's
1304 DEFAULT_AUTOCONF_MINVERSION="2.59"
1305 autoconf_minversion=
1307 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1308 && test -n "$destdir"; then
1309 if test -f "$destdir"/configure.ac; then
1310 configure_ac="$destdir/configure.ac"
1312 if test -f "$destdir"/configure.in; then
1313 configure_ac="$destdir/configure.in"
1317 if test -f configure.ac; then
1318 configure_ac="configure.ac"
1320 if test -f configure.in; then
1321 configure_ac="configure.in"
1325 if test -n "$configure_ac"; then
1326 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1327 # because when some m4 files are omitted from a version control repository,
1328 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1329 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1330 # autom4te: m4 failed with exit status: 1
1337 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1339 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1340 if test -n "$prereqs"; then
1341 autoconf_minversion=`
1342 for version in $prereqs; do echo $version; done |
1343 LC_ALL=C sort -nru | sed -e 1q
1347 if test -z "$autoconf_minversion"; then
1348 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1350 case "$autoconf_minversion" in
1351 1.* | 2.[0-4]* | 2.5[0-8]*)
1352 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1355 # Remove trailing slashes from the directory names. This is necessary for
1356 # m4base (to avoid an error in func_import) and optional for the others.
1357 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1358 case "$local_gnulib_dir" in
1359 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1361 case "$sourcebase" in
1362 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1365 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1368 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1371 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1373 case "$testsbase" in
1374 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1377 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1383 trap 'exit_status=$?
1384 if test "$signal" != 0; then
1385 echo "caught signal $signal" >&2
1388 exit $exit_status' 0
1389 for signal in 1 2 3 13 15; do
1390 trap '{ signal='$signal'; func_exit 1; }' $signal
1394 # Note: The 'eval' silences stderr output in dash.
1395 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1396 # Zsh 4 and Bash 4 have associative arrays.
1397 have_associative=true
1399 # For other shells, use 'eval' with computed shell variable names.
1400 have_associative=false
1403 # func_lookup_file file
1404 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1407 # - local_gnulib_dir from --local-dir
1409 # - lookedup_file name of the merged (combined) file
1410 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1414 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1415 lookedup_file="$local_gnulib_dir/$lkfile"
1418 if test -f "$gnulib_dir/$lkfile"; then
1419 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1420 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1421 rm -f "$tmp/$lkbase"
1422 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1423 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1424 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1425 lookedup_file="$tmp/$lkbase"
1428 lookedup_file="$gnulib_dir/$lkfile"
1432 func_fatal_error "file $gnulib_dir/$lkfile not found"
1437 # func_sanitize_modulelist
1438 # receives a list of possible module names on standard input, one per line.
1439 # It removes those which are just file names unrelated to modules, and outputs
1440 # the resulting list to standard output, one per line.
1441 func_sanitize_modulelist ()
1443 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1444 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1445 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1446 -e '/^README$/d' -e '/\/README$/d' \
1447 -e '/^TEMPLATE$/d' \
1448 -e '/^TEMPLATE-EXTENDED$/d' \
1449 -e '/^TEMPLATE-TESTS$/d' \
1456 # - local_gnulib_dir from --local-dir
1459 # Filter out metainformation files like README, which are not modules.
1460 # Filter out unit test modules; they can be retrieved through
1461 # --extract-tests-module if desired.
1463 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1464 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1465 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1468 | func_sanitize_modulelist \
1469 | sed -e '/-tests$/d' \
1473 # func_exists_module module
1474 # tests whether a module, given by name, exists
1476 # - local_gnulib_dir from --local-dir
1477 func_exists_module ()
1479 { test -f "$gnulib_dir/modules/$1" \
1480 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1481 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1482 && test "CVS" != "$1" \
1483 && test "ChangeLog" != "$1" \
1484 && test "COPYING" != "$1" \
1485 && test "README" != "$1" \
1486 && test "TEMPLATE" != "$1" \
1487 && test "TEMPLATE-EXTENDED" != "$1" \
1488 && test "TEMPLATE-TESTS" != "$1"
1491 # func_verify_module
1492 # verifies a module name
1494 # - local_gnulib_dir from --local-dir
1495 # - module module name argument
1496 func_verify_module ()
1498 if func_exists_module "$module"; then
1499 # OK, $module is a correct module name.
1500 # Verify that building the module description with 'patch' succeeds.
1501 func_lookup_file "modules/$module"
1503 func_warning "module $module doesn't exist"
1508 # func_verify_nontests_module
1509 # verifies a module name, excluding tests modules
1511 # - local_gnulib_dir from --local-dir
1512 # - module module name argument
1513 func_verify_nontests_module ()
1516 *-tests ) module= ;;
1517 * ) func_verify_module ;;
1521 # func_verify_tests_module
1522 # verifies a module name, considering only tests modules
1524 # - local_gnulib_dir from --local-dir
1525 # - module module name argument
1526 func_verify_tests_module ()
1529 *-tests ) func_verify_module ;;
1534 # Suffix of a sed expression that extracts a particular field from a
1535 # module description.
1536 # A field starts with a line that contains a keyword, such as 'Description',
1537 # followed by a colon and optional whitespace. All following lines, up to
1538 # the next field (or end of file if there is none) form the contents of the
1540 # An absent field is equivalent to a field with empty contents.
1541 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1542 sed_extract_prog=':[ ]*$/ {
1545 s/^Description:[ ]*$//
1549 s/^Applicability:[ ]*$//
1551 s/^Depends-on:[ ]*$//
1552 s/^configure\.ac-early:[ ]*$//
1553 s/^configure\.ac:[ ]*$//
1554 s/^Makefile\.am:[ ]*$//
1558 s/^Maintainer:[ ]*$//
1565 # Piece of a sed expression that converts a field header line to a shell
1567 # NOTE: Keep this in sync with sed_extract_prog above!
1568 sed_extract_field_header='
1569 s/^Description:[ ]*$/description/
1570 s/^Comment:[ ]*$/comment/
1571 s/^Status:[ ]*$/status/
1572 s/^Notice:[ ]*$/notice/
1573 s/^Applicability:[ ]*$/applicability/
1574 s/^Files:[ ]*$/files/
1575 s/^Depends-on:[ ]*$/dependson/
1576 s/^configure\.ac-early:[ ]*$/configureac_early/
1577 s/^configure\.ac:[ ]*$/configureac/
1578 s/^Makefile\.am:[ ]*$/makefile/
1579 s/^Include:[ ]*$/include/
1581 s/^License:[ ]*$/license/
1582 s/^Maintainer:[ ]*$/maintainer/'
1586 if $have_associative; then
1588 # Declare the associative arrays.
1589 declare -A modcache_cached
1590 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1591 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1592 eval "$declare_script"
1596 # func_cache_var module
1597 # computes the cache variable name corresponding to $module.
1598 # Note: This computation can map different module names to the same
1599 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1600 # to protect against this case.
1602 # - cachevar a shell variable name
1603 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1604 # Bash 2.0 and newer, ksh, and zsh support the syntax
1605 # ${param//pattern/replacement}
1606 # as a shorthand for
1607 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1608 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1609 eval 'func_cache_var ()
1611 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1618 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1627 # func_init_sed_convert_to_cache_statements
1629 # - modcachevar_assignment
1631 # - sed_convert_to_cache_statements
1632 func_init_sed_convert_to_cache_statements ()
1634 # 'sed' script that turns a module description into shell script
1635 # assignments, suitable to be eval'ed. All active characters are escaped.
1638 # Some module's description
1643 # modcache_description[$1]=\
1644 # 'Some module'"'"'s description
1646 # modcache_files[$1]=\
1649 # c_MODULE_description_set=set; c_MODULE_description=\
1650 # 'Some module'"'"'s description
1652 # c_MODULE_files_set=set; c_MODULE_files=\
1654 # The script consists of two parts:
1655 # 1) Ignore the lines before the first field header.
1656 # 2) A loop, treating non-field-header lines by escaping single quotes
1657 # and adding a closing quote in the last line,
1658 sed_convert_to_cache_statements="
1660 # Here we have not yet seen a field header.
1662 # See if the current line contains a field header.
1665 ${sed_extract_field_header}
1668 # No field header. Ignore the line.
1670 # Read the next line. Upon EOF, just exit.
1675 # The current line contains a field header.
1677 # Turn it into the beginning of an assignment.
1678 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1680 # Move it to the hold space. Don't print it yet,
1681 # because we want no assignment if the field is empty.
1684 # Read the next line.
1685 # Upon EOF, the field was empty. Print no assignment. Just exit.
1688 # See if the current line contains a field header.
1691 ${sed_extract_field_header}
1692 # If it is, the previous field was empty. Print no assignment.
1695 # Not a field header.
1697 # Print the previous line, held in the hold space.
1702 # Transform single quotes.
1705 # Prepend a single quote.
1710 # Move it to the hold space.
1713 # Read the next line.
1720 # See if the current line contains a field header.
1723 ${sed_extract_field_header}
1726 # Print the previous line, held in the hold space.
1731 # Transform single quotes.
1738 # Print the previous line, held in the hold space, with a single quote
1739 # to end the assignment.
1749 # Print the previous line, held in the hold space, with a single quote
1750 # to end the assignment.
1757 if ! $sed_comments; then
1759 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1760 | sed -e 's/^ *//' -e 's/^#.*//'`
1764 if $have_associative; then
1765 # sed_convert_to_cache_statements does not depend on the module.
1766 modcachevar_assignment='modcache_\1[$1]='
1767 func_init_sed_convert_to_cache_statements
1770 # func_cache_lookup_module module
1772 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1773 # of its relevant data in a cache in the memory of the processing shell. If
1774 # already cached, it does not look it up again, thus saving file access time.
1776 # - module non-empty string
1777 # Output if $have_associative:
1778 # - modcache_cached[$module] set to yes
1779 # - modcache_description[$module] ==
1780 # - modcache_status[$module] \ set to the field's value, minus the
1781 # - ... / final newline,
1782 # - modcache_maintainer[$module] == or unset if the field's value is empty
1783 # Output if ! $have_associative:
1784 # - cachevar a shell variable name
1785 # - ${cachevar}_cached set to $module
1786 # - ${cachevar}_description ==
1787 # - ${cachevar}_status \ set to the field's value, minus the
1788 # - ... / final newline,
1789 # - ${cachevar}_maintainer == or unset if the field's value is empty
1790 # - ${cachevar}_description_set ==
1791 # - ${cachevar}_status_set \ set to non-empty if the field's value
1792 # - ... / is non-empty,
1793 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1794 func_cache_lookup_module ()
1796 if $have_associative; then
1797 eval 'cached=${modcache_cached[$1]}'
1800 eval "cached=\"\$${cachevar}_cached\""
1802 if test -z "$cached"; then
1803 # Not found in cache. Look it up on the file system.
1804 func_lookup_file "modules/$1"
1805 if $have_associative; then
1806 eval 'modcache_cached[$1]=yes'
1808 eval "${cachevar}_cached=\"\$1\""
1810 if ! $have_associative; then
1811 # sed_convert_to_cache_statements depends on the module.
1812 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1813 func_init_sed_convert_to_cache_statements
1815 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1816 eval "$cache_statements"
1818 if ! $have_associative; then
1819 if test "$1" != "$cached"; then
1820 func_fatal_error "cache variable collision between $1 and $cached"
1828 # func_get_description module
1830 # - local_gnulib_dir from --local-dir
1831 # - modcache true or false, from --cache-modules/--no-cache-modules
1832 func_get_description ()
1834 if ! $modcache; then
1835 func_lookup_file "modules/$1"
1836 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1838 func_cache_lookup_module "$1"
1839 # Output the field's value, including the final newline (if any).
1840 if $have_associative; then
1841 if eval 'test -n "${modcache_description[$1]+set}"'; then
1842 eval 'echo "${modcache_description[$1]}"'
1845 eval "field_set=\"\$${cachevar}_description_set\""
1846 if test -n "$field_set"; then
1847 eval "field_value=\"\$${cachevar}_description\""
1848 echo "${field_value}"
1854 # func_get_comment module
1856 # - local_gnulib_dir from --local-dir
1857 # - modcache true or false, from --cache-modules/--no-cache-modules
1860 if ! $modcache; then
1861 func_lookup_file "modules/$1"
1862 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1864 func_cache_lookup_module "$1"
1865 # Output the field's value, including the final newline (if any).
1866 if $have_associative; then
1867 if eval 'test -n "${modcache_comment[$1]+set}"'; then
1868 eval 'echo "${modcache_comment[$1]}"'
1871 eval "field_set=\"\$${cachevar}_comment_set\""
1872 if test -n "$field_set"; then
1873 eval "field_value=\"\$${cachevar}_comment\""
1874 echo "${field_value}"
1880 # func_get_status module
1882 # - local_gnulib_dir from --local-dir
1883 # - modcache true or false, from --cache-modules/--no-cache-modules
1886 if ! $modcache; then
1887 func_lookup_file "modules/$1"
1888 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1890 func_cache_lookup_module "$1"
1891 # Output the field's value, including the final newline (if any).
1892 if $have_associative; then
1893 if eval 'test -n "${modcache_status[$1]+set}"'; then
1894 eval 'echo "${modcache_status[$1]}"'
1897 eval "field_set=\"\$${cachevar}_status_set\""
1898 if test -n "$field_set"; then
1899 eval "field_value=\"\$${cachevar}_status\""
1900 echo "${field_value}"
1906 # func_get_notice module
1908 # - local_gnulib_dir from --local-dir
1909 # - modcache true or false, from --cache-modules/--no-cache-modules
1912 if ! $modcache; then
1913 func_lookup_file "modules/$1"
1914 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1916 func_cache_lookup_module "$1"
1917 # Output the field's value, including the final newline (if any).
1918 if $have_associative; then
1919 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1920 eval 'echo "${modcache_notice[$1]}"'
1923 eval "field_set=\"\$${cachevar}_notice_set\""
1924 if test -n "$field_set"; then
1925 eval "field_value=\"\$${cachevar}_notice\""
1926 echo "${field_value}"
1932 # func_get_applicability module
1934 # - local_gnulib_dir from --local-dir
1935 # - modcache true or false, from --cache-modules/--no-cache-modules
1936 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1937 func_get_applicability ()
1939 if ! $modcache; then
1940 func_lookup_file "modules/$1"
1941 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1943 func_cache_lookup_module "$1"
1944 # Get the field's value, without the final newline.
1945 if $have_associative; then
1946 eval 'my_applicability="${modcache_applicability[$1]}"'
1948 eval "my_applicability=\"\$${cachevar}_applicability\""
1951 if test -n "$my_applicability"; then
1952 echo $my_applicability
1954 # The default is 'main' or 'tests', depending on the module's name.
1956 *-tests) echo "tests";;
1962 # func_get_filelist module
1964 # - local_gnulib_dir from --local-dir
1965 # - modcache true or false, from --cache-modules/--no-cache-modules
1966 func_get_filelist ()
1968 if ! $modcache; then
1969 func_lookup_file "modules/$1"
1970 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1972 func_cache_lookup_module "$1"
1973 # Output the field's value, including the final newline (if any).
1974 if $have_associative; then
1975 if eval 'test -n "${modcache_files[$1]+set}"'; then
1976 eval 'echo "${modcache_files[$1]}"'
1979 eval "field_set=\"\$${cachevar}_files_set\""
1980 if test -n "$field_set"; then
1981 eval "field_value=\"\$${cachevar}_files\""
1982 echo "${field_value}"
1987 echo m4/gnulib-common.m4
1988 case "$autoconf_minversion" in
1995 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1996 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1997 # elements starting with prefix and ending with suffix are considered.
1998 # Processing: removed_prefix and removed_suffix are removed from each element,
1999 # added_prefix and added_suffix are added to each element.
2000 # prefix, suffix should not contain shell-special characters.
2001 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2002 # added_prefix, added_suffix should not contain the characters \|&.
2003 func_filter_filelist ()
2005 if test "$2" != "$nl" \
2006 || { $fast_func_append \
2007 && { test -z "$6" || $fast_func_remove_prefix; } \
2008 && { test -z "$7" || $fast_func_remove_suffix; }; \
2012 # Do not quote possibly-empty parameters in case patterns,
2013 # AIX and HP-UX ksh won't match them if they are empty.
2016 if test -n "$6"; then
2017 func_remove_prefix fff "$6"
2019 if test -n "$7"; then
2020 func_remove_suffix fff "$7"
2023 if test -z "$ffflist"; then
2026 func_append ffflist "$2${fff}"
2032 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2033 ffflist=`for fff in $3; do
2035 $4*$5) echo "$fff" ;;
2037 done | sed -e "$sed_fff_filter"`
2039 eval "$1=\"\$ffflist\""
2042 # func_get_dependencies module
2044 # - local_gnulib_dir from --local-dir
2045 # - modcache true or false, from --cache-modules/--no-cache-modules
2046 func_get_dependencies ()
2048 # ${module}-tests implicitly depends on ${module}, if that module exists.
2052 func_remove_suffix fgd1 '-tests'
2053 if func_exists_module "$fgd1"; then
2058 # Then the explicit dependencies listed in the module description.
2059 if ! $modcache; then
2060 func_lookup_file "modules/$1"
2061 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2063 func_cache_lookup_module "$1"
2064 # Output the field's value, including the final newline (if any).
2065 if $have_associative; then
2066 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2067 eval 'echo "${modcache_dependson[$1]}"'
2070 eval "field_set=\"\$${cachevar}_dependson_set\""
2071 if test -n "$field_set"; then
2072 eval "field_value=\"\$${cachevar}_dependson\""
2073 echo "${field_value}"
2079 # func_get_autoconf_early_snippet module
2081 # - local_gnulib_dir from --local-dir
2082 # - modcache true or false, from --cache-modules/--no-cache-modules
2083 func_get_autoconf_early_snippet ()
2085 if ! $modcache; then
2086 func_lookup_file "modules/$1"
2087 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2089 func_cache_lookup_module "$1"
2090 # Output the field's value, including the final newline (if any).
2091 if $have_associative; then
2092 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2093 eval 'echo "${modcache_configureac_early[$1]}"'
2096 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2097 if test -n "$field_set"; then
2098 eval "field_value=\"\$${cachevar}_configureac_early\""
2099 echo "${field_value}"
2105 # func_get_autoconf_snippet module
2107 # - local_gnulib_dir from --local-dir
2108 # - modcache true or false, from --cache-modules/--no-cache-modules
2109 func_get_autoconf_snippet ()
2111 if ! $modcache; then
2112 func_lookup_file "modules/$1"
2113 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2115 func_cache_lookup_module "$1"
2116 # Output the field's value, including the final newline (if any).
2117 if $have_associative; then
2118 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2119 eval 'echo "${modcache_configureac[$1]}"'
2122 eval "field_set=\"\$${cachevar}_configureac_set\""
2123 if test -n "$field_set"; then
2124 eval "field_value=\"\$${cachevar}_configureac\""
2125 echo "${field_value}"
2131 # func_get_automake_snippet module
2133 # - local_gnulib_dir from --local-dir
2134 # - modcache true or false, from --cache-modules/--no-cache-modules
2135 func_get_automake_snippet ()
2137 if ! $modcache; then
2138 func_lookup_file "modules/$1"
2139 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2141 func_cache_lookup_module "$1"
2142 # Output the field's value, including the final newline (if any).
2143 if $have_associative; then
2144 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2145 eval 'echo "${modcache_makefile[$1]}"'
2148 eval "field_set=\"\$${cachevar}_makefile_set\""
2149 if test -n "$field_set"; then
2150 eval "field_value=\"\$${cachevar}_makefile\""
2151 echo "${field_value}"
2157 # *-tests module live in tests/, not lib/.
2158 # Synthesize an EXTRA_DIST augmentation.
2159 all_files=`func_get_filelist $1`
2160 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2161 extra_files="$tests_files"
2162 if test -n "$extra_files"; then
2163 echo "EXTRA_DIST +=" $extra_files
2168 # Synthesize an EXTRA_DIST augmentation.
2169 sed_combine_lines='/\\$/{
2176 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2177 already_mentioned_files=` \
2178 { if ! $modcache; then
2179 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2181 if $have_associative; then
2182 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2183 eval 'echo "${modcache_makefile[$1]}"'
2186 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2187 if test -n "$field_set"; then
2188 eval 'field_value="$'"${cachevar}"'_makefile"'
2189 echo "${field_value}"
2194 | sed -e "$sed_combine_lines" \
2195 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2196 all_files=`func_get_filelist $1`
2197 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2198 # Remove $already_mentioned_files from $lib_files.
2199 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2200 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2201 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2202 if test -n "$extra_files"; then
2203 echo "EXTRA_DIST +=" $extra_files
2206 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2207 # This is necessary so that automake can generate the right list of
2209 # A possible approach would be to use autom4te --trace of the redefined
2210 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2211 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2212 # inside autoconf's built-in macros are not missed).
2213 # But it's simpler and more robust to do it here, based on the file list.
2214 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2215 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2216 # automake will generate a useless dependency; this is harmless.
2218 relocatable-prog-wrapper) ;;
2221 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2222 if test -n "$extra_files"; then
2223 echo "EXTRA_lib_SOURCES +=" $extra_files
2228 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2229 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2230 if test -n "$buildaux_files"; then
2231 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2232 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2235 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2236 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2237 if test -n "$top_files"; then
2238 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2239 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2246 # func_get_include_directive module
2248 # - local_gnulib_dir from --local-dir
2249 # - modcache true or false, from --cache-modules/--no-cache-modules
2250 func_get_include_directive ()
2253 if ! $modcache; then
2254 func_lookup_file "modules/$1"
2255 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2257 func_cache_lookup_module "$1"
2258 # Output the field's value, including the final newline (if any).
2259 if $have_associative; then
2260 if eval 'test -n "${modcache_include[$1]+set}"'; then
2261 eval 'echo "${modcache_include[$1]}"'
2264 eval "field_set=\"\$${cachevar}_include_set\""
2265 if test -n "$field_set"; then
2266 eval "field_value=\"\$${cachevar}_include\""
2267 echo "${field_value}"
2271 } | sed -e 's/^\(["<]\)/#include \1/'
2274 # func_get_link_directive module
2276 # - local_gnulib_dir from --local-dir
2277 # - modcache true or false, from --cache-modules/--no-cache-modules
2278 func_get_link_directive ()
2280 if ! $modcache; then
2281 func_lookup_file "modules/$1"
2282 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2284 func_cache_lookup_module "$1"
2285 # Output the field's value, including the final newline (if any).
2286 if $have_associative; then
2287 if eval 'test -n "${modcache_link[$1]+set}"'; then
2288 eval 'echo "${modcache_link[$1]}"'
2291 eval "field_set=\"\$${cachevar}_link_set\""
2292 if test -n "$field_set"; then
2293 eval "field_value=\"\$${cachevar}_link\""
2294 echo "${field_value}"
2300 # func_get_license module
2302 # - local_gnulib_dir from --local-dir
2303 # - modcache true or false, from --cache-modules/--no-cache-modules
2307 if ! $modcache; then
2308 func_lookup_file "modules/$1"
2309 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2311 func_cache_lookup_module "$1"
2312 # Output the field's value, including the final newline (if any).
2313 if $have_associative; then
2314 if eval 'test -n "${modcache_license[$1]+set}"'; then
2315 eval 'echo "${modcache_license[$1]}"'
2318 eval "field_set=\"\$${cachevar}_license_set\""
2319 if test -n "$field_set"; then
2320 eval "field_value=\"\$${cachevar}_license\""
2321 echo "${field_value}"
2325 # The default is GPL.
2327 } | sed -e 's,^ *$,,' | sed -e 1q
2330 # func_get_maintainer module
2332 # - local_gnulib_dir from --local-dir
2333 # - modcache true or false, from --cache-modules/--no-cache-modules
2334 func_get_maintainer ()
2336 if ! $modcache; then
2337 func_lookup_file "modules/$1"
2338 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2340 func_cache_lookup_module "$1"
2341 # Output the field's value, including the final newline (if any).
2342 if $have_associative; then
2343 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2344 eval 'echo "${modcache_maintainer[$1]}"'
2347 eval "field_set=\"\$${cachevar}_maintainer_set\""
2348 if test -n "$field_set"; then
2349 eval "field_value=\"\$${cachevar}_maintainer\""
2350 echo "${field_value}"
2356 # func_get_tests_module module
2358 # - local_gnulib_dir from --local-dir
2359 func_get_tests_module ()
2361 # The naming convention for tests modules is hardwired: ${module}-tests.
2362 if test -f "$gnulib_dir/modules/$1"-tests \
2363 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2364 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2369 # func_acceptable module
2370 # tests whether a module is acceptable.
2372 # - avoidlist list of modules to avoid
2375 for avoid in $avoidlist; do
2376 if test "$avoid" = "$1"; then
2383 # func_modules_transitive_closure
2385 # - local_gnulib_dir from --local-dir
2386 # - modcache true or false, from --cache-modules/--no-cache-modules
2387 # - modules list of specified modules
2388 # - inctests true if tests should be included, blank otherwise
2389 # - incobsolete true if obsolete modules among dependencies should be
2390 # included, blank otherwise
2391 # - inc_cxx_tests true if C++ interoperability tests should be included,
2393 # - inc_longrunning_tests true if long-runnings tests should be included,
2395 # - inc_privileged_tests true if tests that require root privileges should be
2396 # included, blank otherwise
2397 # - inc_unportable_tests true if tests that fail on some platforms should be
2398 # included, blank otherwise
2399 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2400 # the unit tests of the specified modules should be
2401 # included, blank otherwise
2402 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2403 # the unit tests of the dependencies should be
2404 # included, blank otherwise
2405 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2407 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2409 # - excl_privileged_tests true if tests that require root privileges should be
2410 # excluded, blank otherwise
2411 # - excl_unportable_tests true if tests that fail on some platforms should be
2412 # excluded, blank otherwise
2413 # - avoidlist list of modules to avoid
2414 # - tmp pathname of a temporary directory
2416 # - modules list of modules, including dependencies
2417 func_modules_transitive_closure ()
2419 # In order to process every module only once (for speed), process an "input
2420 # list" of modules, producing an "output list" of modules. During each round,
2421 # more modules can be queued in the input list. Once a module on the input
2422 # list has been processed, it is added to the "handled list", so we can avoid
2423 # to process it again.
2425 inmodules="$modules"
2427 fmtc_inc_all_tests="$inc_all_direct_tests"
2428 while test -n "$inmodules"; do
2429 inmodules_this_round="$inmodules"
2430 inmodules= # Accumulator, queue for next round
2431 for module in $inmodules_this_round; do
2433 if test -n "$module"; then
2434 if func_acceptable $module; then
2435 func_append outmodules " $module"
2436 deps=`func_get_dependencies $module`
2437 # Duplicate dependencies are harmless, but Jim wants a warning.
2438 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2439 if test -n "$duplicated_deps"; then
2440 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2442 if test -n "$inctests"; then
2443 testsmodule=`func_get_tests_module $module`
2444 if test -n "$testsmodule"; then
2445 deps="$deps $testsmodule"
2448 for dep in $deps; do
2449 # Determine whether to include the dependency or tests module.
2451 for word in `func_get_status $dep`; do
2454 test -n "$incobsolete" \
2458 test -z "$excl_cxx_tests" \
2460 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2464 test -z "$excl_longrunning_tests" \
2466 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2470 test -z "$excl_privileged_tests" \
2472 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2476 test -z "$excl_unportable_tests" \
2478 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2482 test -n "$fmtc_inc_all_tests" \
2488 func_append inmodules " $dep"
2494 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2495 # Remove $handledmodules from $inmodules.
2496 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2497 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2498 fmtc_inc_all_tests="$inc_all_indirect_tests"
2500 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2501 rm -f "$tmp"/queued-modules
2504 # func_show_module_list
2506 # - specified_modules list of specified modules (one per line, sorted)
2507 # - modules complete list of modules (one per line, sorted)
2508 # - tmp pathname of a temporary directory
2509 func_show_module_list ()
2515 # Assume xterm compatible escape sequences.
2516 bold_on=`printf '\x1b[1m'`
2517 bold_off=`printf '\x1b[0m'`
2522 echo "Module list with included dependencies (indented):"
2523 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2524 echo "$modules" | sed -e '/^$/d' \
2525 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2526 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2529 # func_modules_add_dummy
2531 # - local_gnulib_dir from --local-dir
2532 # - modcache true or false, from --cache-modules/--no-cache-modules
2533 # - modules list of modules, including dependencies
2535 # - modules list of modules, including 'dummy' if needed
2536 func_modules_add_dummy ()
2538 # Determine whether any module provides a lib_SOURCES augmentation.
2540 sed_remove_backslash_newline=':a
2547 for module in $modules; do
2548 func_verify_nontests_module
2549 if test -n "$module"; then
2550 # Extract the value of "lib_SOURCES += ...".
2551 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2552 # Ignore .h files since they are not compiled.
2556 have_lib_SOURCES=yes
2563 # Add the dummy module, to make sure the library will be non-empty.
2564 if test -z "$have_lib_SOURCES"; then
2565 if func_acceptable "dummy"; then
2566 func_append modules " dummy"
2571 # func_modules_notice
2573 # - local_gnulib_dir from --local-dir
2574 # - modcache true or false, from --cache-modules/--no-cache-modules
2575 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2576 # - modules list of modules, including dependencies
2577 func_modules_notice ()
2579 if test $verbose -ge -1; then
2580 for module in $modules; do
2582 if test -n "$module"; then
2583 msg=`func_get_notice $module`
2584 if test -n "$msg"; then
2585 echo "Notice from module $module:"
2586 echo "$msg" | sed -e 's/^/ /'
2593 # func_modules_to_filelist
2595 # - local_gnulib_dir from --local-dir
2596 # - modcache true or false, from --cache-modules/--no-cache-modules
2597 # - modules list of modules, including dependencies
2599 # - files list of files
2600 func_modules_to_filelist ()
2603 for module in $modules; do
2605 if test -n "$module"; then
2606 fs=`func_get_filelist $module`
2607 func_append files " $fs"
2610 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2613 # func_execute_command command [args...]
2614 # Executes a command.
2615 # Uses also the variables
2616 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2617 func_execute_command ()
2619 if test $verbose -ge 0; then
2623 # Commands like automake produce output to stderr even when they succeed.
2624 # Turn this output off if the command succeeds.
2625 "$@" > "$tmp"/cmdout 2>&1
2627 if test $cmdret = 0; then
2631 cat "$tmp"/cmdout 1>&2
2638 # func_dest_tmpfilename file
2639 # determines the name of a temporary file (file is relative to destdir).
2641 # - destdir target directory
2642 # - doit : if actions shall be executed, false if only to be printed
2643 # - tmp pathname of a temporary directory
2645 # - tmpfile absolute filename of the temporary file
2646 func_dest_tmpfilename ()
2649 # Put the new contents of $file in a file in the same directory (needed
2650 # to guarantee that an 'mv' to "$destdir/$file" works).
2651 tmpfile="$destdir/$1.tmp"
2653 # Put the new contents of $file in a file in a temporary directory
2654 # (because the directory of "$file" might not exist).
2655 tmpfile="$tmp"/`basename "$1"`.tmp
2660 # copies a file from gnulib into the destination directory. The destination
2661 # is known to not exist.
2663 # - destdir target directory
2664 # - local_gnulib_dir from --local-dir
2665 # - modcache true or false, from --cache-modules/--no-cache-modules
2666 # - f the original file name
2667 # - lookedup_file name of the merged (combined) file
2668 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2669 # - g the rewritten file name
2670 # - tmpfile absolute filename of the temporary file
2671 # - doit : if actions shall be executed, false if only to be printed
2672 # - symbolic true if files should be symlinked, copied otherwise
2673 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2678 echo "Copying file $g"
2679 if { test -n "$symbolic" \
2680 || { test -n "$lsymbolic" \
2681 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2682 && test -z "$lookedup_tmp" \
2683 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2684 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2686 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2694 # copies a file from gnulib into the destination directory. The destination
2695 # is known to exist.
2697 # - destdir target directory
2698 # - local_gnulib_dir from --local-dir
2699 # - modcache true or false, from --cache-modules/--no-cache-modules
2700 # - f the original file name
2701 # - lookedup_file name of the merged (combined) file
2702 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2703 # - g the rewritten file name
2704 # - tmpfile absolute filename of the temporary file
2705 # - doit : if actions shall be executed, false if only to be printed
2706 # - symbolic true if files should be symlinked, copied otherwise
2707 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2709 # - already_present nonempty if the file should already exist, empty otherwise
2712 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2713 : # The file has not changed.
2717 if test -n "$already_present"; then
2718 echo "Updating file $g (backup in ${g}~)"
2720 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2722 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2723 if { test -n "$symbolic" \
2724 || { test -n "$lsymbolic" \
2725 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2726 && test -z "$lookedup_tmp" \
2727 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2728 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2730 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2733 if test -n "$already_present"; then
2734 echo "Update file $g (backup in ${g}~)"
2736 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2742 # func_emit_lib_Makefile_am
2743 # emits the contents of library makefile to standard output.
2745 # - local_gnulib_dir from --local-dir
2746 # - modcache true or false, from --cache-modules/--no-cache-modules
2747 # - modules list of modules, including dependencies
2748 # - libname library name
2749 # - pobase directory relative to destdir where to place *.po files
2750 # - auxdir directory relative to destdir where to place build aux files
2751 # - makefile_name from --makefile-name
2752 # - libtool true if libtool will be used, false or blank otherwise
2753 # - macro_prefix prefix of gl_LIBOBJS macros to use
2754 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2755 # - actioncmd (optional) command that will reproduce this invocation
2756 # - for_test true if creating a package for testing, false otherwise
2757 # - destfile filename relative to destdir of makefile being generated
2759 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2760 # list of edits to be done to Makefile.am variables
2762 # - uses_subdirs nonempty if object files in subdirs exist
2763 func_emit_lib_Makefile_am ()
2765 # When creating an includable Makefile.am snippet, augment variables with
2766 # += instead of assigning them.
2767 if test -n "$makefile_name"; then
2772 if test "$libtool" = true; then
2775 sed_eliminate_LDFLAGS="$sed_noop"
2779 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2782 # When creating a package for testing: Attempt to provoke failures,
2783 # especially link errors, already during "make" rather than during
2784 # "make check", because "make check" is not possible in a cross-compiling
2785 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2786 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2788 sed_transform_check_PROGRAMS="$sed_noop"
2790 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2791 echo "## Process this file with automake to produce Makefile.in."
2792 func_emit_copyright_notice
2793 if test -n "$actioncmd"; then
2794 # The maximum line length (excluding the terminating newline) of any file
2795 # that is to be preprocessed by config.status is 3070. config.status uses
2796 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2797 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2798 len=`echo "$actioncmd" | wc -c`
2799 if test -n "$len" && test "$len" -le 3000; then
2800 echo "# Reproduce by: $actioncmd"
2806 for module in $modules; do
2807 func_verify_nontests_module
2808 if test -n "$module"; then
2810 func_get_automake_snippet "$module" |
2812 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2813 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2814 -e "$sed_eliminate_LDFLAGS" \
2815 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2816 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2817 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2818 -e "$sed_transform_check_PROGRAMS"
2819 if test "$module" = 'alloca'; then
2820 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2821 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2823 } > "$tmp"/amsnippet
2824 # Skip the contents if it's entirely empty.
2825 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2826 echo "## begin gnulib module $module"
2828 cat "$tmp"/amsnippet
2829 echo "## end gnulib module $module"
2832 rm -f "$tmp"/amsnippet
2833 # Test whether there are some source files in subdirectories.
2834 for f in `func_get_filelist "$module"`; do
2844 } > "$tmp"/allsnippets
2845 if test -z "$makefile_name"; then
2846 # If there are source files in subdirectories, prevent collision of the
2847 # object files (example: hash.c and libxml/hash.c).
2849 if test -n "$uses_subdirs"; then
2850 subdir_options=' subdir-objects'
2852 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2855 if test -z "$makefile_name"; then
2857 echo "noinst_HEADERS ="
2858 echo "noinst_LIBRARIES ="
2859 echo "noinst_LTLIBRARIES ="
2860 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2861 # if you specify pkgdata_DATA to empty. This is a workaround.
2862 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2863 echo "pkgdata_DATA ="
2866 echo "BUILT_SOURCES ="
2869 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2870 if test -z "$makefile_name"; then
2871 echo "MOSTLYCLEANDIRS ="
2873 echo "DISTCLEANFILES ="
2874 echo "MAINTAINERCLEANFILES ="
2876 # Execute edits that apply to the Makefile.am being generated.
2878 while test $edit != $makefile_am_edits; do
2879 edit=`expr $edit + 1`
2880 eval dir=\"\$makefile_am_edit${edit}_dir\"
2881 eval var=\"\$makefile_am_edit${edit}_var\"
2882 eval val=\"\$makefile_am_edit${edit}_val\"
2883 if test -n "$var"; then
2884 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2885 echo "${var} += ${val}"
2886 eval "makefile_am_edit${edit}_var="
2890 if test -z "$makefile_name"; then
2893 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
2895 echo "AM_CPPFLAGS ="
2900 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2901 || { test -n "$makefile_name" \
2902 && test -f "$sourcebase/Makefile.am" \
2903 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2905 # One of the snippets or the user's Makefile.am already specifies an
2906 # installation location for the library. Don't confuse automake by saying
2907 # it should not be installed.
2910 # By default, the generated library should not be installed.
2911 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2914 echo "${libname}_${libext}_SOURCES ="
2915 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2916 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2917 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2918 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2919 echo "EXTRA_${libname}_${libext}_SOURCES ="
2920 if test "$libtool" = true; then
2921 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2922 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
2923 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
2924 # the link dependencies of all modules.
2925 for module in $modules; do
2926 func_verify_nontests_module
2927 if test -n "$module"; then
2928 func_get_link_directive "$module"
2931 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
2932 | LC_ALL=C sort -u \
2933 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
2936 if test -n "$pobase"; then
2937 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2940 cat "$tmp"/allsnippets \
2941 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2943 echo "mostlyclean-local: mostlyclean-generic"
2944 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2945 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2946 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2950 rm -f "$tmp"/allsnippets
2953 # func_emit_po_Makevars
2954 # emits the contents of po/ makefile parameterization to standard output.
2956 # - local_gnulib_dir from --local-dir
2957 # - modcache true or false, from --cache-modules/--no-cache-modules
2958 # - sourcebase directory relative to destdir where to place source code
2959 # - pobase directory relative to destdir where to place *.po files
2960 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2961 func_emit_po_Makevars ()
2963 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2964 func_emit_copyright_notice
2966 echo "# Usually the message domain is the same as the package name."
2967 echo "# But here it has a '-gnulib' suffix."
2968 echo "DOMAIN = ${po_domain}-gnulib"
2970 echo "# These two variables depend on the location of this directory."
2971 echo "subdir = ${pobase}"
2972 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2975 # These options get passed to xgettext.
2976 XGETTEXT_OPTIONS = \
2977 --keyword=_ --flag=_:1:pass-c-format \
2978 --keyword=N_ --flag=N_:1:pass-c-format \
2979 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2980 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2981 --flag=error:3:c-format --flag=error_at_line:5:c-format
2983 # This is the copyright holder that gets inserted into the header of the
2984 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2985 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2987 # This is the email address or URL to which the translators shall report
2988 # bugs in the untranslated strings:
2989 # - Strings which are not entire sentences, see the maintainer guidelines
2990 # in the GNU gettext documentation, section 'Preparing Strings'.
2991 # - Strings which use unclear terms or require additional context to be
2993 # - Strings which make invalid assumptions about notation of date, time or
2995 # - Pluralisation problems.
2996 # - Incorrect English spelling.
2997 # - Incorrect formatting.
2998 # It can be your email address, or a mailing list address where translators
2999 # can write to without being subscribed, or the URL of a web page through
3000 # which the translators can contact you.
3001 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3003 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3004 # message catalogs shall be used. It is usually empty.
3005 EXTRA_LOCALE_CATEGORIES =
3007 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3008 # context. Possible values are "yes" and "no". Set this to yes if the
3009 # package uses functions taking also a message context, like pgettext(), or
3010 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3015 # func_emit_po_POTFILES_in
3016 # emits the file list to be passed to xgettext to standard output.
3018 # - local_gnulib_dir from --local-dir
3019 # - modcache true or false, from --cache-modules/--no-cache-modules
3020 # - sourcebase directory relative to destdir where to place source code
3021 # - files list of new files
3022 func_emit_po_POTFILES_in ()
3024 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3025 func_emit_copyright_notice
3027 echo "# List of files which contain translatable strings."
3028 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3031 # func_emit_tests_Makefile_am witness_macro
3032 # emits the contents of tests makefile to standard output.
3034 # - local_gnulib_dir from --local-dir
3035 # - modcache true or false, from --cache-modules/--no-cache-modules
3036 # - modules list of modules, including dependencies
3037 # - libname library name
3038 # - auxdir directory relative to destdir where to place build aux files
3039 # - makefile_name from --makefile-name
3040 # - libtool true if libtool will be used, false or blank otherwise
3041 # - sourcebase relative directory containing lib source code
3042 # - m4base relative directory containing autoconf macros
3043 # - testsbase relative directory containing unit test code
3044 # - macro_prefix prefix of gl_LIBOBJS macros to use
3045 # - for_test true if creating a package for testing, false otherwise
3046 # - use_libtests true if a libtests.a should be built, false otherwise
3047 # - destfile filename relative to destdir of makefile being generated
3049 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3050 # list of edits to be done to Makefile.am variables
3052 # - uses_subdirs nonempty if object files in subdirs exist
3053 func_emit_tests_Makefile_am ()
3056 if test "$libtool" = true; then
3058 sed_eliminate_LDFLAGS="$sed_noop"
3061 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3064 # When creating a package for testing: Attempt to provoke failures,
3065 # especially link errors, already during "make" rather than during
3066 # "make check", because "make check" is not possible in a cross-compiling
3067 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3068 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3070 sed_transform_check_PROGRAMS="$sed_noop"
3072 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3073 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3074 echo "## Process this file with automake to produce Makefile.in."
3075 func_emit_copyright_notice
3079 for module in $modules; do
3081 func_verify_tests_module
3085 if test -n "$module"; then
3087 func_get_automake_snippet "$module" |
3089 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3090 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3091 -e "$sed_eliminate_LDFLAGS" \
3092 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3093 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3094 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3095 -e "$sed_transform_check_PROGRAMS"
3096 if $use_libtests && test "$module" = 'alloca'; then
3097 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3098 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3100 } > "$tmp"/amsnippet
3101 # Skip the contents if it's entirely empty.
3102 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3103 # Mention long-running tests at the end.
3105 for word in `func_get_status "$module"`; do
3106 if test "$word" = 'longrunning-test'; then
3111 { echo "## begin gnulib module $module"
3113 cat "$tmp"/amsnippet
3114 echo "## end gnulib module $module"
3118 rm -f "$tmp"/amsnippet
3119 # Test whether there are some source files in subdirectories.
3120 for f in `func_get_filelist "$module"`; do
3122 lib/*/*.c | tests/*/*.c)
3130 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3131 # Generate dependencies here, since it eases the debugging of test failures.
3132 # If there are source files in subdirectories, prevent collision of the
3133 # object files (example: hash.c and libxml/hash.c).
3135 if test -n "$uses_subdirs"; then
3136 subdir_options=' subdir-objects'
3138 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3141 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3144 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3145 # variable is needed to avoid an error from automake:
3146 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3149 echo "XFAIL_TESTS ="
3150 echo "TESTS_ENVIRONMENT ="
3151 echo "noinst_PROGRAMS ="
3152 if ! $for_test; then
3153 echo "check_PROGRAMS ="
3155 echo "noinst_HEADERS ="
3156 echo "noinst_LIBRARIES ="
3157 if $use_libtests; then
3159 echo "noinst_LIBRARIES += libtests.a"
3161 echo "check_LIBRARIES = libtests.a"
3164 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3165 # if you specify pkgdata_DATA to empty. This is a workaround.
3166 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3167 echo "pkgdata_DATA ="
3170 echo "BUILT_SOURCES ="
3172 echo "MOSTLYCLEANFILES = core *.stackdump"
3173 echo "MOSTLYCLEANDIRS ="
3175 echo "DISTCLEANFILES ="
3176 echo "MAINTAINERCLEANFILES ="
3177 # Execute edits that apply to the Makefile.am being generated.
3179 while test $edit != $makefile_am_edits; do
3180 edit=`expr $edit + 1`
3181 eval dir=\"\$makefile_am_edit${edit}_dir\"
3182 eval var=\"\$makefile_am_edit${edit}_var\"
3183 eval val=\"\$makefile_am_edit${edit}_val\"
3184 if test -n "$var"; then
3185 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3186 echo "${var} += ${val}"
3187 eval "makefile_am_edit${edit}_var="
3192 echo "AM_CPPFLAGS = \\"
3194 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3196 if test -n "${witness_macro}"; then
3197 echo " -D@${witness_macro}@=1 \\"
3199 echo " -I. -I\$(srcdir) \\"
3200 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3201 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3203 local_ldadd_before=''
3204 local_ldadd_after=''
3205 if $use_libtests; then
3206 # All test programs need to be linked with libtests.a.
3207 # It needs to be passed to the linker before ${libname}.${libext}, since
3208 # the tests-related modules depend on the main modules.
3209 # It also needs to be passed to the linker after ${libname}.${libext}
3210 # because the latter might contain incomplete modules (such as the 'error'
3211 # module whose dependency to 'progname' is voluntarily omitted).
3212 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3214 local_ldadd_before=' libtests.a'
3215 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3217 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3219 if $use_libtests; then
3220 echo "libtests_a_SOURCES ="
3221 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3222 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3223 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3224 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3225 echo "EXTRA_libtests_a_SOURCES ="
3226 # The circular dependency in LDADD requires this.
3227 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3230 # Many test scripts use ${EXEEXT} or ${srcdir}.
3231 # EXEEXT is defined by AC_PROG_CC through autoconf.
3232 # srcdir is defined by autoconf and automake.
3233 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3235 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3236 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3237 echo "# Clean up after Solaris cc."
3239 echo " rm -rf SunWS_cache"
3241 echo "mostlyclean-local: mostlyclean-generic"
3242 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3243 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3244 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3248 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3251 # func_emit_initmacro_start macro_prefix
3252 # emits the first few statements of the gl_INIT macro to standard output.
3253 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3254 func_emit_initmacro_start ()
3256 macro_prefix_arg="$1"
3257 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3258 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3259 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3260 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3262 # Furthermore it avoids an automake error like this when a Makefile.am
3263 # that uses pieces of gnulib also uses $(LIBOBJ):
3264 # automatically discovered file `error.c' should not be explicitly mentioned
3265 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3266 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3267 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3268 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3269 # automatically discovered file `error.c' should not be explicitly mentioned
3270 # We let automake know about the files to be distributed through the
3271 # EXTRA_lib_SOURCES variable.
3272 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3273 # Create data variables for checking the presence of files that are mentioned
3274 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3275 # because we want the check to happen when the configure file is created,
3276 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3277 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3278 # in which to expect them.
3279 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3280 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3284 # func_emit_initmacro_end macro_prefix
3285 # emits the last few statements of the gl_INIT macro to standard output.
3286 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3287 func_emit_initmacro_end ()
3289 macro_prefix_arg="$1"
3290 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3291 # The check is performed only when autoconf is run from the directory where
3292 # the configure.ac resides; if it is run from a different directory, the
3294 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3295 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3296 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3297 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3298 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3302 echo " m4_if(m4_sysval, [0], [],"
3303 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3305 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3306 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3307 echo " m4_popdef([AC_LIBSOURCES])"
3308 echo " m4_popdef([AC_REPLACE_FUNCS])"
3309 echo " m4_popdef([AC_LIBOBJ])"
3310 echo " AC_CONFIG_COMMANDS_PRE(["
3311 echo " ${macro_prefix_arg}_libobjs="
3312 echo " ${macro_prefix_arg}_ltlibobjs="
3313 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3314 echo " # Remove the extension."
3315 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3316 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3317 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3318 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3321 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3322 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3326 # func_emit_initmacro_done macro_prefix sourcebase
3327 # emits a few statements after the gl_INIT macro to standard output.
3328 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3329 # - sourcebase directory relative to destdir where to place source code
3330 func_emit_initmacro_done ()
3332 macro_prefix_arg="$1"
3335 echo "# Like AC_LIBOBJ, except that the module name goes"
3336 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3337 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3338 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3339 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3342 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3343 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3344 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3345 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3346 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3349 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3350 echo "# expected is derived from the gnulib-tool parameterization,"
3351 echo "# and alloca is special cased (for the alloca-opt module)."
3352 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3353 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3354 echo " m4_foreach([_gl_NAME], [\$1], ["
3355 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3356 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3357 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3363 # func_emit_autoconf_snippet indentation
3364 # emits the autoconf snippet of a module.
3366 # - local_gnulib_dir from --local-dir
3367 # - modcache true or false, from --cache-modules/--no-cache-modules
3368 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3369 # - module the module name
3370 # - toplevel true or false. 'false' means a subordinate use of
3372 # - disable_libtool true or false. It tells whether to disable libtool
3373 # handling even if it has been specified through the
3374 # command line options.
3375 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3377 # - indentation spaces to prepend on each line
3378 func_emit_autoconf_snippet ()
3380 if { case $module in
3381 gnumakefile | maintainer-makefile)
3382 # These modules are meant to be used only in the top-level directory.
3388 func_get_autoconf_snippet "$module" \
3389 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3390 -e "$sed_replace_build_aux" \
3391 | { if $disable_libtool; then
3392 sed -e 's/\$gl_cond_libtool/false/g' \
3393 -e 's/gl_libdeps/gltests_libdeps/g' \
3394 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3399 | { if $disable_gettext; then
3400 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3405 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3406 echo 'changequote(,)dnl'
3407 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3408 echo 'changequote([, ])dnl'
3409 echo 'AC_SUBST([LTALLOCA])'
3414 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3415 # collects and emit the autoconf snippets of a set of modules.
3417 # - local_gnulib_dir from --local-dir
3418 # - modcache true or false, from --cache-modules/--no-cache-modules
3419 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3420 # - modules the list of modules.
3421 # - verifier one of func_verify_module, func_verify_nontests_module,
3422 # func_verify_tests_module. It selects the subset of
3423 # $modules to consider.
3424 # - toplevel true or false. 'false' means a subordinate use of
3426 # - disable_libtool true or false. It tells whether to disable libtool
3427 # handling even if it has been specified through the
3428 # command line options.
3429 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3431 func_emit_autoconf_snippets ()
3435 disable_libtool="$4"
3436 disable_gettext="$5"
3437 for module in $1; do
3438 eval $verifier # one of func_verify_module, func_verify_nontests_module, func_verify_tests_module.
3439 if test -n "$module"; then
3440 func_emit_autoconf_snippet " "
3445 # func_import modules
3446 # Uses also the variables
3447 # - mode import or add-import or remove-import or update
3448 # - destdir target directory
3449 # - local_gnulib_dir from --local-dir
3450 # - modcache true or false, from --cache-modules/--no-cache-modules
3451 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3452 # - libname library name
3453 # - supplied_libname true if --lib was given, blank otherwise
3454 # - sourcebase directory relative to destdir where to place source code
3455 # - m4base directory relative to destdir where to place *.m4 macros
3456 # - pobase directory relative to destdir where to place *.po files
3457 # - docbase directory relative to destdir where to place doc files
3458 # - testsbase directory relative to destdir where to place unit test code
3459 # - auxdir directory relative to destdir where to place build aux files
3460 # - inctests true if --with-tests was given, blank otherwise
3461 # - incobsolete true if --with-obsolete was given, blank otherwise
3462 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3463 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3465 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3467 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3469 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3470 # - avoidlist list of modules to avoid, from --avoid
3471 # - lgpl yes or a number if library's license shall be LGPL,
3473 # - makefile_name from --makefile-name
3474 # - libtool true if --libtool was given, false if --no-libtool was
3475 # given, blank otherwise
3476 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3477 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3478 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3479 # - vc_files true if --vc-files was given, false if --no-vc-files was
3480 # given, blank otherwise
3481 # - autoconf_minversion minimum supported autoconf version
3482 # - doit : if actions shall be executed, false if only to be printed
3483 # - symbolic true if files should be symlinked, copied otherwise
3484 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3486 # - do_copyrights true if copyright notices in files should be replaced,
3490 # Get the cached settings.
3491 # In 'import' mode, we read them only for the purpose of knowing the old
3492 # installed file list, and don't use them as defaults.
3493 cached_local_gnulib_dir=
3494 cached_specified_modules=
3496 cached_inc_cxx_tests=
3497 cached_inc_longrunning_tests=
3498 cached_inc_privileged_tests=
3499 cached_inc_unportable_tests=
3500 cached_inc_all_tests=
3510 cached_makefile_name=
3512 cached_macro_prefix=
3516 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3517 cached_libtool=false
3523 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3533 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3535 /gl_WITH_OBSOLETE/ {
3536 s,^.*$,cached_incobsolete=true,p
3538 /gl_WITH_CXX_TESTS/ {
3539 s,^.*$,cached_inc_cxx_tests=true,p
3541 /gl_WITH_LONGRUNNING_TESTS/ {
3542 s,^.*$,cached_inc_longrunning_tests=true,p
3544 /gl_WITH_PRIVILEGED_TESTS/ {
3545 s,^.*$,cached_inc_privileged_tests=true,p
3547 /gl_WITH_UNPORTABLE_TESTS/ {
3548 s,^.*$,cached_inc_unportable_tests=true,p
3550 /gl_WITH_ALL_TESTS/ {
3551 s,^.*$,cached_inc_all_tests=true,p
3554 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3557 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3560 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3563 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3566 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3569 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3572 s,^.*$,cached_inctests=true,p
3575 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3578 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3581 s,^.*$,cached_lgpl=yes,p
3583 /gl_MAKEFILE_NAME(/ {
3584 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3587 s,^.*$,cached_libtool=true,p
3589 /gl_MACRO_PREFIX(/ {
3590 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3593 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3596 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3598 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3599 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3604 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3605 s,^.*$,cached_files=",p
3618 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3622 if test "$mode" = import; then
3623 # In 'import' mode, the new set of specified modules overrides the cached
3624 # set of modules. Ignore the cached settings.
3625 specified_modules="$1"
3627 # Merge the cached settings with the specified ones.
3628 # The m4base must be the same as expected from the pathname.
3629 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3630 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3632 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3633 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3634 if test -z "$local_gnulib_dir"; then
3635 if test -n "$cached_local_gnulib_dir"; then
3638 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3640 case "$cached_local_gnulib_dir" in
3642 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3644 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3645 local_gnulib_dir="$relconcat" ;;
3652 # Append the cached and the specified module names. So that
3653 # "gnulib-tool --add-import foo" means to add the module foo.
3654 specified_modules="$cached_specified_modules $1"
3657 # Take the cached module names, minus the specified module names.
3659 if $have_associative; then
3660 # Use an associative array, for O(N) worst-case run time.
3661 declare -A to_remove
3663 eval 'to_remove[$m]=yes'
3665 for module in $cached_specified_modules; do
3666 if eval 'test -z "${to_remove[$module]}"'; then
3667 func_append specified_modules "$module "
3671 # This loop has O(N²) worst-case run time.
3672 for module in $cached_specified_modules; do
3675 if test "$m" = "$module"; then
3680 if test -z "$to_remove"; then
3681 func_append specified_modules "$module "
3687 # Take the cached module names. There are no specified module names.
3688 specified_modules="$cached_specified_modules"
3691 # Included obsolete modules among the dependencies if specified either way.
3692 if test -z "$incobsolete"; then
3693 incobsolete="$cached_incobsolete"
3695 # Included special kinds of tests modules among the dependencies if specified
3697 if test -z "$inc_cxx_tests"; then
3698 inc_cxx_tests="$cached_inc_cxx_tests"
3700 if test -z "$inc_longrunning_tests"; then
3701 inc_longrunning_tests="$cached_inc_longrunning_tests"
3703 if test -z "$inc_privileged_tests"; then
3704 inc_privileged_tests="$cached_inc_privileged_tests"
3706 if test -z "$inc_unportable_tests"; then
3707 inc_unportable_tests="$cached_inc_unportable_tests"
3709 if test -z "$inc_all_tests"; then
3710 inc_all_tests="$cached_inc_all_tests"
3712 # Append the cached and the specified avoidlist. This is probably better
3713 # than dropping the cached one when --avoid is specified at least once.
3714 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3715 avoidlist=`echo $avoidlist`
3717 # The sourcebase defaults to the cached one.
3718 if test -z "$sourcebase"; then
3719 sourcebase="$cached_sourcebase"
3720 if test -z "$sourcebase"; then
3721 func_fatal_error "missing --source-base option"
3724 # The pobase defaults to the cached one.
3725 if test -z "$pobase"; then
3726 pobase="$cached_pobase"
3728 # The docbase defaults to the cached one.
3729 if test -z "$docbase"; then
3730 docbase="$cached_docbase"
3731 if test -z "$docbase"; then
3732 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."
3735 # The testsbase defaults to the cached one.
3736 if test -z "$testsbase"; then
3737 testsbase="$cached_testsbase"
3738 if test -z "$testsbase"; then
3739 func_fatal_error "missing --tests-base option"
3742 # Require the tests if specified either way.
3743 if test -z "$inctests"; then
3744 inctests="$cached_inctests"
3746 # The libname defaults to the cached one.
3747 if test -z "$supplied_libname"; then
3748 libname="$cached_libname"
3749 if test -z "$libname"; then
3750 func_fatal_error "missing --lib option"
3753 # Require LGPL if specified either way.
3754 if test -z "$lgpl"; then
3757 # The makefile_name defaults to the cached one.
3758 if test -z "$makefile_name"; then
3759 makefile_name="$cached_makefile_name"
3761 # Use libtool if specified either way, or if guessed.
3762 if test -z "$libtool"; then
3763 if test -n "$cached_m4base"; then
3764 libtool="$cached_libtool"
3766 libtool="$guessed_libtool"
3769 # The macro_prefix defaults to the cached one.
3770 if test -z "$macro_prefix"; then
3771 macro_prefix="$cached_macro_prefix"
3772 if test -z "$macro_prefix"; then
3773 func_fatal_error "missing --macro-prefix option"
3776 # The po_domain defaults to the cached one.
3777 if test -z "$po_domain"; then
3778 po_domain="$cached_po_domain"
3780 # The vc_files defaults to the cached one.
3781 if test -z "$vc_files"; then
3782 vc_files="$cached_vc_files"
3785 # --without-*-tests options are not supported here.
3787 excl_longrunning_tests=
3788 excl_privileged_tests=
3789 excl_unportable_tests=
3791 # Canonicalize the list of specified modules.
3792 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3794 # Include all kinds of tests modules if --with-all-tests was specified.
3795 inc_all_direct_tests="$inc_all_tests"
3796 inc_all_indirect_tests="$inc_all_tests"
3798 # Determine final module list.
3799 modules="$specified_modules"
3800 func_modules_transitive_closure
3801 if test $verbose -ge 0; then
3802 func_show_module_list
3804 final_modules="$modules"
3806 # Determine main module list and tests-related module list separately.
3807 # The main module list is the transitive closure of the specified modules,
3808 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3809 # is specified, it will consist only of LGPLed source.
3810 # The tests-related module list is the transitive closure of the specified
3811 # modules, including tests modules, minus the main module list excluding
3812 # modules of applicability 'all'. Its lib/* sources (brought in through
3813 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3814 # source, even if --lgpl is specified.
3815 # Determine main module list.
3816 saved_inctests="$inctests"
3818 modules="$specified_modules"
3819 func_modules_transitive_closure
3820 main_modules="$modules"
3821 inctests="$saved_inctests"
3822 if test $verbose -ge 1; then
3823 echo "Main module list:"
3824 echo "$main_modules" | sed -e 's/^/ /'
3826 # Determine tests-related module list.
3827 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3828 testsrelated_modules=`for module in $main_modules; do
3829 if test \`func_get_applicability $module\` = main; then
3833 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3834 if test $verbose -ge 1; then
3835 echo "Tests-related module list:"
3836 echo "$testsrelated_modules" | sed -e 's/^/ /'
3839 # Add the dummy module to the main module list if needed.
3840 modules="$main_modules"
3841 func_modules_add_dummy
3842 main_modules="$modules"
3844 # Determine whether a $testsbase/libtests.a is needed.
3846 for module in $testsrelated_modules; do
3847 func_verify_nontests_module
3848 if test -n "$module"; then
3849 all_files=`func_get_filelist $module`
3850 # Test whether some file in $all_files lies in lib/.
3851 for f in $all_files; do
3862 # Add the dummy module to the tests-related module list if needed.
3863 if $use_libtests; then
3864 modules="$testsrelated_modules"
3865 func_modules_add_dummy
3866 testsrelated_modules="$modules"
3869 # If --lgpl, verify that the licenses of modules are compatible.
3870 if test -n "$lgpl"; then
3871 license_incompatibilities=
3872 for module in $main_modules; do
3873 license=`func_get_license $module`
3875 'GPLed build tool') ;;
3876 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3881 LGPL | LGPLv2+ | LGPLv3+) ;;
3882 *) func_append license_incompatibilities "$module $license$nl" ;;
3888 *) func_append license_incompatibilities "$module $license$nl" ;;
3891 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3896 if test -n "$license_incompatibilities"; then
3897 # Format the license incompatibilities as a table.
3898 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3899 s,^\(.................................................[^ ]*\) *, \1 ,'
3900 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3901 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3905 # Show banner notice of every module.
3906 modules="$main_modules"
3909 # Determine script to apply to imported library files.
3910 sed_transform_lib_file=
3911 for module in $main_modules; do
3912 if test $module = config-h; then
3913 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3914 sed_transform_lib_file=$sed_transform_lib_file'
3915 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3920 sed_transform_main_lib_file="$sed_transform_lib_file"
3921 if test -n "$do_copyrights"; then
3922 if test -n "$lgpl"; then
3926 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3927 s/GNU General/GNU Lesser General/g
3928 s/General Public License/Lesser General Public License/g
3929 s/Lesser Lesser General Public License/Lesser General Public License/g
3933 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3934 s/GNU General/GNU Lesser General/g
3935 s/General Public License/Lesser General Public License/g
3936 s/Lesser Lesser General Public License/Lesser General Public License/g
3938 s/version [23]\([ ,]\)/version 2.1\1/g
3941 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3945 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3946 s/GNU Lesser General/GNU General/g
3947 s/Lesser General Public License/General Public License/g
3949 s/GNU Library General/GNU General/g
3950 s/Library General Public License/General Public License/g
3952 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3957 # Determine script to apply to auxiliary files that go into $auxdir/.
3958 sed_transform_build_aux_file=
3959 if test -n "$do_copyrights"; then
3961 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3962 s/GNU Lesser General/GNU General/g
3963 s/Lesser General Public License/General Public License/g
3965 s/GNU Library General/GNU General/g
3966 s/Library General Public License/General Public License/g
3968 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3972 # Determine script to apply to library files that go into $testsbase/.
3973 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3974 if test -n "$do_copyrights"; then
3976 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3977 s/GNU Lesser General/GNU General/g
3978 s/Lesser General Public License/General Public License/g
3980 s/GNU Library General/GNU General/g
3981 s/Library General Public License/General Public License/g
3983 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3987 # Determine the final file lists.
3988 # They must be computed separately, because files in lib/* go into
3989 # $sourcebase/ if they are in the main file list but into $testsbase/
3990 # if they are in the tests-related file list. Furthermore lib/dummy.c
3992 # Determine final main file list.
3993 modules="$main_modules"
3994 func_modules_to_filelist
3996 # Determine final tests-related file list.
3997 modules="$testsrelated_modules"
3998 func_modules_to_filelist
3999 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
4000 # Merge both file lists.
4001 sed_remove_empty_lines='/^$/d'
4002 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
4003 if test $verbose -ge 0; then
4005 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
4006 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
4010 || func_fatal_error "refusing to do nothing"
4012 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4013 new_files="$files m4/gnulib-tool.m4"
4014 old_files="$cached_files"
4015 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4016 func_append old_files " m4/gnulib-tool.m4"
4019 rewritten='%REWRITTEN%'
4020 sed_rewrite_old_files="\
4021 s,^build-aux/,$rewritten$auxdir/,
4022 s,^doc/,$rewritten$cached_docbase/,
4023 s,^lib/,$rewritten$cached_sourcebase/,
4024 s,^m4/,$rewritten$cached_m4base/,
4025 s,^tests/,$rewritten$cached_testsbase/,
4026 s,^tests=lib/,$rewritten$cached_testsbase/,
4029 sed_rewrite_new_files="\
4030 s,^build-aux/,$rewritten$auxdir/,
4031 s,^doc/,$rewritten$docbase/,
4032 s,^lib/,$rewritten$sourcebase/,
4033 s,^m4/,$rewritten$m4base/,
4034 s,^tests/,$rewritten$testsbase/,
4035 s,^tests=lib/,$rewritten$testsbase/,
4039 # Create directories.
4040 { echo "$sourcebase"
4042 if test -n "$pobase"; then
4045 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4046 if test -n "$docfiles"; then
4049 if test -n "$inctests"; then
4053 for f in $files; do echo $f; done \
4054 | sed -e "$sed_rewrite_new_files" \
4055 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4058 { # Rearrange file descriptors. Needed because "while ... done < ..."
4059 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4060 exec 5<&0 < "$tmp"/dirs
4062 if test ! -d "$destdir/$d"; then
4064 echo "Creating directory $destdir/$d"
4065 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4067 echo "Create directory $destdir/$d"
4074 # Copy files or make symbolic links. Remove obsolete files.
4078 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4079 # representing the files according to the last gnulib-tool invocation.
4080 for f in $old_files; do echo $f; done \
4081 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4084 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4085 # representing the files after this gnulib-tool invocation.
4086 for f in $new_files; do echo $f; done \
4087 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4090 # First the files that are in old-files, but not in new-files:
4091 sed_take_first_column='s,'"$delimiter"'.*,,'
4092 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4093 # Remove the file. Do nothing if the user already removed it.
4094 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4096 echo "Removing file $g (backup in ${g}~)"
4097 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4099 echo "Remove file $g (backup in ${g}~)"
4101 func_append removed_files "$g$nl"
4104 # func_add_or_update handles a file that ought to be present afterwards.
4106 # - f the original file name
4107 # - g the rewritten file name
4108 # - already_present nonempty if the file should already exist, empty
4110 func_add_or_update ()
4114 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4116 func_dest_tmpfilename "$g"
4117 func_lookup_file "$f"
4118 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4119 if test -n "$sed_transform_main_lib_file"; then
4122 sed -e "$sed_transform_main_lib_file" \
4123 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4127 if test -n "$sed_transform_build_aux_file"; then
4130 sed -e "$sed_transform_build_aux_file" \
4131 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4135 if test -n "$sed_transform_testsrelated_lib_file"; then
4138 sed -e "$sed_transform_testsrelated_lib_file" \
4139 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4143 if test -f "$destdir/$g"; then
4144 # The file already exists.
4148 # Don't protest if the file should be there but isn't: it happens
4149 # frequently that developers don't put autogenerated files under version control.
4151 func_append added_files "$g$nl"
4155 # Then the files that are in new-files, but not in old-files:
4156 sed_take_last_column='s,^.*'"$delimiter"',,'
4158 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4159 | sed -e "$sed_take_last_column" \
4160 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4161 { # Rearrange file descriptors. Needed because "while ... done < ..."
4162 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4163 exec 5<&0 < "$tmp"/added-files
4169 # Then the files that are in new-files and in old-files:
4170 already_present=true
4171 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4172 | sed -e "$sed_take_last_column" \
4173 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4174 { # Rearrange file descriptors. Needed because "while ... done < ..."
4175 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4176 exec 5<&0 < "$tmp"/kept-files
4183 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4184 actioncmd="gnulib-tool --import"
4185 func_append actioncmd " --dir=$destdir"
4186 if test -n "$local_gnulib_dir"; then
4187 func_append actioncmd " --local-dir=$local_gnulib_dir"
4189 func_append actioncmd " --lib=$libname"
4190 func_append actioncmd " --source-base=$sourcebase"
4191 func_append actioncmd " --m4-base=$m4base"
4192 if test -n "$pobase"; then
4193 func_append actioncmd " --po-base=$pobase"
4195 func_append actioncmd " --doc-base=$docbase"
4196 func_append actioncmd " --tests-base=$testsbase"
4197 func_append actioncmd " --aux-dir=$auxdir"
4198 if test -n "$inctests"; then
4199 func_append actioncmd " --with-tests"
4201 if test -n "$incobsolete"; then
4202 func_append actioncmd " --with-obsolete"
4204 if test -n "$inc_cxx_tests"; then
4205 func_append actioncmd " --with-c++-tests"
4207 if test -n "$inc_longrunning_tests"; then
4208 func_append actioncmd " --with-longrunning-tests"
4210 if test -n "$inc_privileged_tests"; then
4211 func_append actioncmd " --with-privileged-tests"
4213 if test -n "$inc_unportable_tests"; then
4214 func_append actioncmd " --with-unportable-tests"
4216 if test -n "$inc_all_tests"; then
4217 func_append actioncmd " --with-all-tests"
4219 for module in $avoidlist; do
4220 func_append actioncmd " --avoid=$module"
4222 if test -n "$lgpl"; then
4223 if test "$lgpl" = yes; then
4224 func_append actioncmd " --lgpl"
4226 func_append actioncmd " --lgpl=$lgpl"
4229 if test -n "$makefile_name"; then
4230 func_append actioncmd " --makefile-name=$makefile_name"
4232 if test "$libtool" = true; then
4233 func_append actioncmd " --libtool"
4235 func_append actioncmd " --no-libtool"
4237 func_append actioncmd " --macro-prefix=$macro_prefix"
4238 if test -n "$po_domain"; then
4239 func_append actioncmd " --po-domain=$po_domain"
4241 if test -n "$vc_files"; then
4242 if test "$vc_files" = true; then
4243 func_append actioncmd " --vc-files"
4245 func_append actioncmd " --no-vc-files"
4248 func_append actioncmd " `echo $specified_modules`"
4250 # Default the makefile name to Makefile.am.
4251 if test -n "$makefile_name"; then
4252 makefile_am=$makefile_name
4254 makefile_am=Makefile.am
4257 # Create normal Makefile.ams.
4260 # Setup list of Makefile.am edits that are to be performed afterwards.
4261 # Some of these edits apply to files that we will generate; others are
4262 # under the responsibility of the developer.
4264 # func_note_Makefile_am_edit dir var value
4265 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4267 func_note_Makefile_am_edit ()
4269 makefile_am_edits=`expr $makefile_am_edits + 1`
4270 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4271 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4272 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4274 if test "$makefile_am" = Makefile.am; then
4275 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4276 sourcebase_base=`basename "$sourcebase"`
4277 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4279 if test -n "$pobase"; then
4280 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4281 pobase_base=`basename "$pobase"`
4282 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4284 if test -n "$inctests"; then
4285 if test "$makefile_am" = Makefile.am; then
4286 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4287 testsbase_base=`basename "$testsbase"`
4288 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4291 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4293 # Find the first parent directory of $m4base that contains or will contain
4295 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4297 sed_butlast='s,[^/][^/]*//*$,,'
4298 dir1="${m4base}/"; dir2=""
4299 while test -n "$dir1" \
4300 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4301 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4302 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4303 || { test -n "$inctests" \
4304 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4305 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4306 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4307 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4309 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4312 # Create library makefile.
4313 func_dest_tmpfilename $sourcebase/$makefile_am
4314 destfile="$sourcebase/$makefile_am"
4315 modules="$main_modules"
4316 func_emit_lib_Makefile_am > "$tmpfile"
4317 if test -f "$destdir"/$sourcebase/$makefile_am; then
4318 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4322 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4323 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4324 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4326 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4332 echo "Creating $sourcebase/$makefile_am"
4333 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4335 echo "Create $sourcebase/$makefile_am"
4338 func_append added_files "$sourcebase/$makefile_am$nl"
4341 # Create po/ directory.
4342 if test -n "$pobase"; then
4343 # Create po makefile and auxiliary files.
4344 for file in Makefile.in.in remove-potcdate.sin; do
4345 func_dest_tmpfilename $pobase/$file
4346 func_lookup_file build-aux/po/$file
4347 cat "$lookedup_file" > "$tmpfile"
4348 if test -f "$destdir"/$pobase/$file; then
4349 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4353 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4354 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4355 mv -f "$tmpfile" "$destdir"/$pobase/$file
4357 echo "Update $pobase/$file (backup in $pobase/$file~)"
4363 echo "Creating $pobase/$file"
4364 mv -f "$tmpfile" "$destdir"/$pobase/$file
4366 echo "Create $pobase/$file"
4369 func_append added_files "$pobase/$file$nl"
4372 # Create po makefile parameterization, part 1.
4373 func_dest_tmpfilename $pobase/Makevars
4374 func_emit_po_Makevars > "$tmpfile"
4375 if test -f "$destdir"/$pobase/Makevars; then
4376 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4380 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4381 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4382 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4384 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4390 echo "Creating $pobase/Makevars"
4391 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4393 echo "Create $pobase/Makevars"
4396 func_append added_files "$pobase/Makevars$nl"
4398 # Create po makefile parameterization, part 2.
4399 func_dest_tmpfilename $pobase/POTFILES.in
4400 func_emit_po_POTFILES_in > "$tmpfile"
4401 if test -f "$destdir"/$pobase/POTFILES.in; then
4402 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4406 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4407 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4408 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4410 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4416 echo "Creating $pobase/POTFILES.in"
4417 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4419 echo "Create $pobase/POTFILES.in"
4422 func_append added_files "$pobase/POTFILES.in$nl"
4425 TP_URL="http://translationproject.org/latest/"
4426 TP_RSYNC_URI="translationproject.org::tp/latest/"
4428 echo "Fetching gnulib PO files from $TP_URL"
4429 (cd "$destdir"/$pobase \
4430 && { # Prefer rsync over wget if it is available, since it consumes
4431 # less network bandwidth, due to compression.
4432 if type rsync 2>/dev/null | grep / > /dev/null; then
4433 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4435 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4440 echo "Fetch gnulib PO files from $TP_URL"
4442 # Create po/LINGUAS.
4444 func_dest_tmpfilename $pobase/LINGUAS
4445 (cd "$destdir"/$pobase \
4446 && { echo '# Set of available languages.'
4447 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4450 if test -f "$destdir"/$pobase/LINGUAS; then
4451 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4454 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4455 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4456 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4459 echo "Creating $pobase/LINGUAS"
4460 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4461 func_append added_files "$pobase/LINGUAS$nl"
4464 if test -f "$destdir"/$pobase/LINGUAS; then
4465 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4467 echo "Create $pobase/LINGUAS"
4472 # Create m4/gnulib-cache.m4.
4473 func_dest_tmpfilename $m4base/gnulib-cache.m4
4475 func_emit_copyright_notice
4477 echo "# This file represents the specification of how gnulib-tool is used."
4478 echo "# It acts as a cache: It is written and read by gnulib-tool."
4479 echo "# In projects that use version control, this file is meant to be put under"
4480 echo "# version control, like the configure.ac and various Makefile.am files."
4483 echo "# Specification in the form of a command-line invocation:"
4486 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4487 # Store the local_gnulib_dir relative to destdir.
4488 case "$local_gnulib_dir" in
4490 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4493 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4495 # destdir, local_gnulib_dir are both relative.
4496 func_relativize "$destdir" "$local_gnulib_dir"
4497 relative_local_gnulib_dir="$reldir" ;;
4500 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4502 echo "$specified_modules" | sed -e 's/^/ /g'
4504 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4505 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4506 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4507 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4508 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4509 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4510 echo "gl_AVOID([$avoidlist])"
4511 echo "gl_SOURCE_BASE([$sourcebase])"
4512 echo "gl_M4_BASE([$m4base])"
4513 echo "gl_PO_BASE([$pobase])"
4514 echo "gl_DOC_BASE([$docbase])"
4515 echo "gl_TESTS_BASE([$testsbase])"
4516 test -z "$inctests" || echo "gl_WITH_TESTS"
4517 echo "gl_LIB([$libname])"
4518 if test -n "$lgpl"; then
4519 if test "$lgpl" = yes; then
4522 echo "gl_LGPL([$lgpl])"
4525 echo "gl_MAKEFILE_NAME([$makefile_name])"
4526 if test "$libtool" = true; then
4529 echo "gl_MACRO_PREFIX([$macro_prefix])"
4530 echo "gl_PO_DOMAIN([$po_domain])"
4531 if test -n "$vc_files"; then
4532 echo "gl_VC_FILES([$vc_files])"
4535 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4536 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4540 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4541 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4542 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4544 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4548 echo "# gnulib-cache.m4 ends here"
4555 echo "Creating $m4base/gnulib-cache.m4"
4556 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4558 echo "Create $m4base/gnulib-cache.m4"
4564 # Create m4/gnulib-comp.m4.
4565 func_dest_tmpfilename $m4base/gnulib-comp.m4
4567 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4568 func_emit_copyright_notice
4570 echo "# This file represents the compiled summary of the specification in"
4571 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4572 echo "# to be invoked from configure.ac."
4573 echo "# In projects that use version control, this file can be treated like"
4574 echo "# other built files."
4577 echo "# This macro should be invoked from $configure_ac, in the section"
4578 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4579 echo "# any checks for libraries, header files, types and library functions."
4580 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4582 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4583 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4584 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4585 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4586 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4587 if test -n "$uses_subdirs"; then
4588 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4590 for module in $final_modules; do
4592 if test -n "$module"; then
4593 echo "# Code from module $module:"
4594 func_get_autoconf_early_snippet "$module"
4597 | sed -e '/^$/d;' -e 's/^/ /'
4600 echo "# This macro should be invoked from $configure_ac, in the section"
4601 echo "# \"Check for header files, types and library functions\"."
4602 echo "AC_DEFUN([${macro_prefix}_INIT],"
4604 if test "$libtool" = true; then
4605 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4606 echo " gl_cond_libtool=true"
4608 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4609 echo " gl_cond_libtool=false"
4611 echo " gl_ltlibdeps="
4613 if test "$auxdir" != "build-aux"; then
4614 sed_replace_build_aux='
4616 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4617 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4621 sed_replace_build_aux="$sed_noop"
4623 echo " gl_m4_base='$m4base'"
4624 func_emit_initmacro_start $macro_prefix
4625 echo " gl_source_base='$sourcebase'"
4626 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
4627 echo " # End of code from modules"
4628 func_emit_initmacro_end $macro_prefix
4629 echo " gltests_libdeps="
4630 echo " gltests_ltlibdeps="
4631 func_emit_initmacro_start ${macro_prefix}tests
4632 echo " gl_source_base='$testsbase'"
4633 # Define a tests witness macro that depends on the package.
4634 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4635 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4636 echo "changequote(,)dnl"
4637 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"
4638 echo "changequote([, ])dnl"
4639 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4640 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4641 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4642 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
4643 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4644 func_emit_initmacro_end ${macro_prefix}tests
4645 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4646 # created using libtool, because libtool already handles the dependencies.
4647 if test "$libtool" != true; then
4648 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
4649 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4650 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4651 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4652 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4654 if $use_libtests; then
4655 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4656 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4659 func_emit_initmacro_done $macro_prefix $sourcebase
4660 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4662 echo "# This macro records the list of files which have been installed by"
4663 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4664 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4665 echo "$files" | sed -e 's,^, ,'
4668 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4669 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4673 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4674 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4675 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4677 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4681 echo "# gnulib-comp.m4 ends here"
4688 echo "Creating $m4base/gnulib-comp.m4"
4689 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4691 echo "Create $m4base/gnulib-comp.m4"
4697 if test -n "$inctests"; then
4698 # Create tests makefile.
4699 func_dest_tmpfilename $testsbase/$makefile_am
4700 destfile="$testsbase/$makefile_am"
4701 modules="$testsrelated_modules"
4702 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4703 if test -f "$destdir"/$testsbase/$makefile_am; then
4704 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4708 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4709 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4710 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4712 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4718 echo "Creating $testsbase/$makefile_am"
4719 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4721 echo "Create $testsbase/$makefile_am"
4724 func_append added_files "$testsbase/$makefile_am$nl"
4728 if test "$vc_files" != false; then
4729 # Update the .cvsignore and .gitignore files.
4730 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4731 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4732 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4733 echo "$m4base/|A|gnulib-comp.m4"
4734 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4735 { # Rearrange file descriptors. Needed because "while ... done < ..."
4736 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4737 exec 5<&0 < "$tmp"/fileset-changes
4738 func_update_ignorelist ()
4741 if test "$ignore" = .gitignore; then
4742 # In a .gitignore file, "foo" applies to the current directory and all
4743 # subdirectories, whereas "/foo" applies to the current directory only.
4746 doubly_escaped_anchor='\\/'
4750 doubly_escaped_anchor=''
4752 if test -f "$destdir/$dir$ignore"; then
4753 if test -n "$dir_added" || test -n "$dir_removed"; then
4754 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4755 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4756 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4757 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4758 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4760 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4762 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4763 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4764 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4765 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4766 } > "$tmp"/sed-ignore-removed
4767 { cat "$destdir/$dir$ignore"~
4768 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4769 } | sed -f "$tmp"/sed-ignore-removed \
4770 > "$destdir/$dir$ignore"
4772 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4777 if test -n "$dir_added"; then
4779 echo "Creating $destdir/$dir$ignore"
4781 if test "$ignore" = .cvsignore; then
4783 # Automake generates Makefile rules that create .dirstamp files.
4786 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4787 } > "$destdir/$dir$ignore"
4789 echo "Create $destdir/$dir$ignore"
4799 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4800 func_update_ignorelist .cvsignore
4802 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4803 func_update_ignorelist .gitignore
4810 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4811 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4812 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4813 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4814 if test "$next_dir" != "$last_dir"; then
4815 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4816 last_dir="$next_dir"
4821 A) func_append last_dir_added "$file$nl";;
4822 R) func_append last_dir_removed "$file$nl";;
4825 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4832 echo "You may need to add #include directives for the following .h files."
4833 # Intersect $specified_modules and $main_modules
4834 # (since $specified_modules is not necessarily of subset of $main_modules
4835 # - some may have been skipped through --avoid, and since the elements of
4836 # $main_modules but not in $specified_modules can go away without explicit
4837 # notice - through changes in the module dependencies).
4838 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4839 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4840 # First the #include <...> directives without #ifs, sorted for convenience,
4841 # then the #include "..." directives without #ifs, sorted for convenience,
4842 # then the #include directives that are surrounded by #ifs. Not sorted.
4843 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4844 include_directive=`func_get_include_directive "$module"`
4845 case "$nl$include_directive" in
4847 echo "$include_directive" 1>&5
4850 echo "$include_directive" | grep -v 'include "' 1>&6
4851 echo "$include_directive" | grep 'include "' 1>&7
4854 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4856 LC_ALL=C sort -u "$tmp"/include-angles
4857 LC_ALL=C sort -u "$tmp"/include-quotes
4858 cat "$tmp"/include-if
4859 ) | sed -e '/^$/d' -e 's/^/ /'
4860 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4862 for module in $main_modules; do
4863 func_get_link_directive "$module"
4865 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4866 if test `wc -l < "$tmp"/link` != 0; then
4868 echo "You may need to use the following Makefile variables when linking."
4869 echo "Use them in <program>_LDADD when linking a program, or"
4870 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4876 echo "Don't forget to"
4877 if test "$makefile_am" = Makefile.am; then
4878 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4880 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4882 if test -n "$pobase"; then
4883 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4885 if test -n "$inctests"; then
4886 if test "$makefile_am" = Makefile.am; then
4887 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4889 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4893 while test $edit != $makefile_am_edits; do
4894 edit=`expr $edit + 1`
4895 eval dir=\"\$makefile_am_edit${edit}_dir\"
4896 eval var=\"\$makefile_am_edit${edit}_var\"
4897 eval val=\"\$makefile_am_edit${edit}_val\"
4898 if test -n "$var"; then
4899 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4902 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4903 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4906 # func_create_testdir testdir modules
4908 # - local_gnulib_dir from --local-dir
4909 # - modcache true or false, from --cache-modules/--no-cache-modules
4910 # - auxdir directory relative to destdir where to place build aux files
4911 # - inctests true if tests should be included, blank otherwise
4912 # - incobsolete true if obsolete modules among dependencies should be
4913 # included, blank otherwise
4914 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
4916 # - excl_longrunning_tests true if long-runnings tests should be excluded,
4918 # - excl_privileged_tests true if tests that require root privileges should be
4919 # excluded, blank otherwise
4920 # - excl_unportable_tests true if tests that fail on some platforms should be
4921 # excluded, blank otherwise
4922 # - avoidlist list of modules to avoid
4923 # - libtool true if --libtool was given, false if --no-libtool was
4924 # given, blank otherwise
4925 # - symbolic true if files should be symlinked, copied otherwise
4926 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4928 func_create_testdir ()
4932 if test -z "$modules"; then
4933 # All modules together.
4934 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4935 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4936 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4937 modules=`func_all_modules`
4938 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4940 specified_modules="$modules"
4942 # Canonicalize the list of specified modules.
4943 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4945 # Unlike in func_import, here we want to include all kinds of tests for the
4946 # directly specified modules, but not for dependencies.
4947 inc_all_direct_tests=true
4948 inc_all_indirect_tests="$inc_all_tests"
4950 # Check that the license of every module is consistent with the license of
4952 saved_inctests="$inctests"
4953 # When computing transitive closures, don't consider $module to depend on
4954 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4955 # on GPL modules - therefore we don't want a warning in this case.
4957 for requested_module in $specified_modules; do
4958 requested_license=`func_get_license "$requested_module"`
4959 if test "$requested_license" != GPL; then
4960 # Here we use func_modules_transitive_closure, not just
4961 # func_get_dependencies, so that we also detect weird situations like
4962 # an LGPL module which depends on a GPLed build tool module which depends
4964 modules="$requested_module"
4965 func_modules_transitive_closure
4966 for module in $modules; do
4967 license=`func_get_license "$module"`
4969 'GPLed build tool') ;;
4970 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4972 case "$requested_license" in
4975 GPLv2+ | LGPLv2+) ;;
4976 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4982 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4988 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4997 inctests="$saved_inctests"
4999 # Subdirectory names.
5009 # Determine final module list.
5010 modules="$specified_modules"
5011 func_modules_transitive_closure
5012 if test $verbose -ge 0; then
5013 func_show_module_list
5016 # Add the dummy module if needed.
5017 func_modules_add_dummy
5019 # Show banner notice of every module.
5022 # Determine final file list.
5023 func_modules_to_filelist
5024 if test $verbose -ge 0; then
5026 echo "$files" | sed -e 's/^/ /'
5028 # Add files for which the copy in gnulib is newer than the one that
5029 # "automake --add-missing --copy" would provide.
5030 files="$files build-aux/config.guess"
5031 files="$files build-aux/config.sub"
5032 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5034 rewritten='%REWRITTEN%'
5035 sed_rewrite_files="\
5036 s,^build-aux/,$rewritten$auxdir/,
5037 s,^doc/,$rewritten$docbase/,
5038 s,^lib/,$rewritten$sourcebase/,
5039 s,^m4/,$rewritten$m4base/,
5040 s,^tests/,$rewritten$testsbase/,
5044 # Create directories.
5045 for f in $files; do echo $f; done \
5046 | sed -e "$sed_rewrite_files" \
5047 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5048 | LC_ALL=C sort -u \
5050 { # Rearrange file descriptors. Needed because "while ... done < ..."
5051 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5052 exec 5<&0 < "$tmp"/dirs
5054 mkdir -p "$testdir/$d"
5059 # Copy files or make symbolic links.
5061 for f in $files; do echo $f; done \
5062 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5065 { # Rearrange file descriptors. Needed because "while ... done < ..."
5066 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5067 exec 5<&0 < "$tmp"/files
5069 func_lookup_file "$f"
5070 if test -n "$lookedup_tmp"; then
5071 cp -p "$lookedup_file" "$testdir/$g"
5073 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5074 if { test -n "$symbolic" \
5075 || { test -n "$lsymbolic" \
5076 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5077 func_ln "$lookedup_file" "$testdir/$g"
5079 cp -p "$lookedup_file" "$testdir/$g"
5086 # Create Makefile.ams that are for testing.
5089 # No special edits are needed.
5092 # Create $sourcebase/Makefile.am.
5093 mkdir -p "$testdir/$sourcebase"
5094 destfile="$sourcebase/Makefile.am"
5095 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5096 any_uses_subdirs="$uses_subdirs"
5098 # Create $m4base/Makefile.am.
5099 mkdir -p "$testdir/$m4base"
5100 (echo "## Process this file with automake to produce Makefile.in."
5106 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5109 ) > "$testdir/$m4base/Makefile.am"
5111 subdirs="$sourcebase $m4base"
5112 subdirs_with_configure_ac=""
5114 if false && test -f "$testdir"/$m4base/gettext.m4; then
5115 # Avoid stupid error message from automake:
5116 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5117 mkdir -p "$testdir/po"
5118 (echo "## Process this file with automake to produce Makefile.in."
5119 ) > "$testdir/po/Makefile.am"
5120 func_append subdirs " po"
5123 if test -n "$inctests"; then
5124 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5125 # Viewed from the $testsbase subdirectory, $auxdir is different.
5126 saved_auxdir="$auxdir"
5127 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5128 # Create $testsbase/Makefile.am.
5130 destfile="$testsbase/Makefile.am"
5131 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5132 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5133 # Create $testsbase/configure.ac.
5134 (echo "# Process this file with autoconf to produce a configure script."
5135 echo "AC_INIT([dummy], [0])"
5136 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5137 echo "AM_INIT_AUTOMAKE"
5139 echo "AC_CONFIG_HEADERS([config.h])"
5142 echo "AC_PROG_INSTALL"
5143 echo "AC_PROG_MAKE_SET"
5144 echo "AC_PROG_RANLIB"
5146 if test -n "$uses_subdirs"; then
5147 echo "AM_PROG_CC_C_O"
5150 for module in $modules; do
5152 if test -n "$module"; then
5154 gnumakefile | maintainer-makefile)
5155 # These modules are meant to be used only in the top-level directory.
5158 func_get_autoconf_early_snippet "$module"
5163 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5164 if test "$libtool" = true; then
5165 echo "LT_INIT([win32-dll])"
5166 echo "LT_LANG([C++])"
5167 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5168 echo "gl_cond_libtool=true"
5170 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5171 echo "gl_cond_libtool=false"
5173 echo "gl_ltlibdeps="
5175 # Wrap the set of autoconf snippets into an autoconf macro that is then
5176 # invoked. This is needed because autoconf does not support AC_REQUIRE
5178 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5179 # but we want the AC_REQUIRE to have its normal meaning (provide one
5180 # expansion of the required macro before the current point, and only one
5182 echo "AC_DEFUN([gl_INIT], ["
5183 sed_replace_build_aux='
5185 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5186 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5189 echo "gl_m4_base='../$m4base'"
5190 func_emit_initmacro_start $macro_prefix
5191 # We don't have explicit ordering constraints between the various
5192 # autoconf snippets. It's cleanest to put those of the library before
5193 # those of the tests.
5194 echo "gl_source_base='../$sourcebase'"
5195 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5196 echo "gl_source_base='.'"
5197 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5198 func_emit_initmacro_end $macro_prefix
5199 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5200 # created using libtool, because libtool already handles the dependencies.
5201 if test "$libtool" != true; then
5202 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5203 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5204 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5205 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5206 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5209 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5213 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5214 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5215 echo "AH_TOP([#include \"../config.h\"])"
5217 echo "AC_CONFIG_FILES([Makefile])"
5219 ) > "$testdir/$testsbase/configure.ac"
5220 auxdir="$saved_auxdir"
5221 func_append subdirs " $testsbase"
5222 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5225 # Create Makefile.am.
5226 (echo "## Process this file with automake to produce Makefile.in."
5228 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5230 echo "SUBDIRS = $subdirs"
5232 echo "ACLOCAL_AMFLAGS = -I $m4base"
5233 ) > "$testdir/Makefile.am"
5235 # Create configure.ac.
5236 (echo "# Process this file with autoconf to produce a configure script."
5237 echo "AC_INIT([dummy], [0])"
5238 if test "$auxdir" != "."; then
5239 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5241 echo "AM_INIT_AUTOMAKE"
5243 echo "AC_CONFIG_HEADERS([config.h])"
5246 echo "AC_PROG_INSTALL"
5247 echo "AC_PROG_MAKE_SET"
5249 echo "# For autobuild."
5250 echo "AC_CANONICAL_BUILD"
5251 echo "AC_CANONICAL_HOST"
5253 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5254 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5255 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5256 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5258 echo "AC_PROG_RANLIB"
5260 if test -n "$any_uses_subdirs"; then
5261 echo "AM_PROG_CC_C_O"
5264 for module in $modules; do
5265 func_verify_nontests_module
5266 if test -n "$module"; then
5267 func_get_autoconf_early_snippet "$module"
5270 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5271 if test "$libtool" = true; then
5272 echo "LT_INIT([win32-dll])"
5273 echo "LT_LANG([C++])"
5274 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5275 echo "gl_cond_libtool=true"
5277 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5278 echo "gl_cond_libtool=false"
5280 echo "gl_ltlibdeps="
5282 # Wrap the set of autoconf snippets into an autoconf macro that is then
5283 # invoked. This is needed because autoconf does not support AC_REQUIRE
5285 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5286 # but we want the AC_REQUIRE to have its normal meaning (provide one
5287 # expansion of the required macro before the current point, and only one
5289 echo "AC_DEFUN([gl_INIT], ["
5290 if test "$auxdir" != "build-aux"; then
5291 sed_replace_build_aux='
5293 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5294 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5298 sed_replace_build_aux="$sed_noop"
5300 echo "gl_m4_base='$m4base'"
5301 func_emit_initmacro_start $macro_prefix
5302 echo "gl_source_base='$sourcebase'"
5303 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5304 func_emit_initmacro_end $macro_prefix
5305 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5306 # created using libtool, because libtool already handles the dependencies.
5307 if test "$libtool" != true; then
5308 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5309 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5310 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5311 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5312 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5315 func_emit_initmacro_done $macro_prefix $sourcebase
5319 if test -n "$subdirs_with_configure_ac"; then
5320 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5322 makefiles="Makefile"
5323 for d in $subdirs; do
5324 # For subdirs that have a configure.ac by their own, it's the subdir's
5325 # configure.ac which creates the subdir's Makefile.am, not this one.
5326 case " $subdirs_with_configure_ac " in
5328 *) func_append makefiles " $d/Makefile" ;;
5331 echo "AC_CONFIG_FILES([$makefiles])"
5333 ) > "$testdir/configure.ac"
5335 # Create autogenerated files.
5337 # Do not use "${AUTORECONF} --force --install", because it may invoke
5338 # autopoint, which brings in older versions of some of our .m4 files.
5339 if test -f $m4base/gettext.m4; then
5340 func_execute_command ${AUTOPOINT} --force || func_exit 1
5341 for f in $m4base/*.m4~; do
5343 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5347 if test "$libtool" = true; then
5348 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5350 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5351 if ! test -d build-aux; then
5352 func_execute_command mkdir build-aux || func_exit 1
5354 func_execute_command ${AUTOCONF} || func_exit 1
5355 func_execute_command ${AUTOHEADER} || func_exit 1
5356 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5358 if test -n "$inctests"; then
5359 # Create autogenerated files.
5360 (cd "$testdir/$testsbase" || func_exit 1
5361 # Do not use "${AUTORECONF} --force --install", because it may invoke
5362 # autopoint, which brings in older versions of some of our .m4 files.
5363 if test -f ../$m4base/gettext.m4; then
5364 func_execute_command ${AUTOPOINT} --force || func_exit 1
5365 for f in ../$m4base/*.m4~; do
5367 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5371 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5372 if ! test -d ../build-aux; then
5373 func_execute_command mkdir ../build-aux
5375 func_execute_command ${AUTOCONF} || func_exit 1
5376 func_execute_command ${AUTOHEADER} || func_exit 1
5377 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5380 # Need to run configure and make once, to create built files that are to be
5381 # distributed (such as parse-datetime.c).
5382 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5383 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5384 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5385 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5386 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5387 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5388 # such $(FOO_H) because they don't refer to distributed files.
5389 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5390 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5391 | sed -e "$sed_remove_make_variables"`
5392 distributed_built_sources=`for file in $built_sources; do
5393 case "$cleaned_files" in
5398 tests_distributed_built_sources=
5399 if test -n "$inctests"; then
5400 # Likewise for built files in the $testsbase directory.
5401 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5402 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5403 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5404 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5405 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5406 | sed -e "$sed_remove_make_variables"`
5407 tests_distributed_built_sources=`for file in $tests_built_sources; do
5408 case "$tests_cleaned_files" in
5414 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5416 ./configure || func_exit 1
5417 if test -n "$distributed_built_sources"; then
5419 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5420 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5425 if test -n "$tests_distributed_built_sources"; then
5427 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5428 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5433 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5440 # func_create_megatestdir megatestdir allmodules
5442 # - local_gnulib_dir from --local-dir
5443 # - modcache true or false, from --cache-modules/--no-cache-modules
5444 # - auxdir directory relative to destdir where to place build aux files
5445 func_create_megatestdir ()
5449 if test -z "$allmodules"; then
5450 allmodules=`func_all_modules`
5454 # First, all modules one by one.
5455 for onemodule in $allmodules; do
5456 func_create_testdir "$megatestdir/$onemodule" $onemodule
5457 func_append megasubdirs "$onemodule "
5459 # Then, all modules all together.
5460 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5461 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5462 func_create_testdir "$megatestdir/ALL" "$allmodules"
5463 func_append megasubdirs "ALL"
5466 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5467 vc_witness="$gnulib_dir/CVS/Entries"; \
5469 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5471 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5472 | sed -e 's,January,01,' -e 's,Jan,01,' \
5473 -e 's,February,02,' -e 's,Feb,02,' \
5474 -e 's,March,03,' -e 's,Mar,03,' \
5475 -e 's,April,04,' -e 's,Apr,04,' \
5477 -e 's,June,06,' -e 's,Jun,06,' \
5478 -e 's,July,07,' -e 's,Jul,07,' \
5479 -e 's,August,08,' -e 's,Aug,08,' \
5480 -e 's,September,09,' -e 's,Sep,09,' \
5481 -e 's,October,10,' -e 's,Oct,10,' \
5482 -e 's,November,11,' -e 's,Nov,11,' \
5483 -e 's,December,12,' -e 's,Dec,12,' \
5484 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5485 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5487 echo "CVSDATE=$cvsdate"
5488 echo ": \${MAKE=make}"
5489 echo "test -d logs || mkdir logs"
5490 echo "for module in $megasubdirs; do"
5491 echo " echo \"Working on module \$module...\""
5492 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5493 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5496 echo " : autobuild project... \$module"
5497 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5498 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5499 echo " : autobuild hostname... \`hostname\`"
5500 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5502 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5504 ) > "$megatestdir/do-autobuild"
5505 chmod a+x "$megatestdir/do-autobuild"
5507 # Create Makefile.am.
5508 (echo "## Process this file with automake to produce Makefile.in."
5510 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5512 echo "SUBDIRS = $megasubdirs"
5514 echo "EXTRA_DIST = do-autobuild"
5515 ) > "$megatestdir/Makefile.am"
5517 # Create configure.ac.
5518 (echo "# Process this file with autoconf to produce a configure script."
5519 echo "AC_INIT([dummy], [0])"
5520 if test "$auxdir" != "."; then
5521 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5523 echo "AM_INIT_AUTOMAKE"
5525 echo "AC_PROG_MAKE_SET"
5527 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5528 echo "AC_CONFIG_FILES([Makefile])"
5530 ) > "$megatestdir/configure.ac"
5532 # Create autogenerated files.
5534 # Do not use "${AUTORECONF} --install", because autoreconf operates
5535 # recursively, but the subdirectories are already finished, therefore
5536 # calling autoreconf here would only waste lots of CPU time.
5537 func_execute_command ${ACLOCAL} || func_exit 1
5538 func_execute_command mkdir build-aux
5539 func_execute_command ${AUTOCONF} || func_exit 1
5540 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5546 func_fatal_error "no mode specified" ;;
5553 # sed expression that converts a literal to a basic regular expression.
5554 # Needs to handle . [ \ * ^ $.
5555 sed_literal_to_basic_regex='s/\\/\\\\/g
5561 if test -f "$gnulib_dir/$filename" \
5562 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5563 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5564 filename_line_regex='^'"$filename_anywhere_regex"'$'
5567 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5568 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5569 (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$,,')
5572 | func_sanitize_modulelist \
5575 for module in $module_candidates; do
5576 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5581 func_warning "file $filename does not exist"
5586 import | add-import | remove-import | update )
5589 if test -z "$destdir"; then
5592 test -d "$destdir" \
5593 || func_fatal_error "destination directory does not exist: $destdir"
5595 # Prefer configure.ac to configure.in.
5596 if test -f "$destdir"/configure.ac; then
5597 configure_ac="$destdir/configure.ac"
5599 if test -f "$destdir"/configure.in; then
5600 configure_ac="$destdir/configure.in"
5602 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5606 # Analyze configure.ac.
5608 guessed_libtool=false
5613 /AC_CONFIG_AUX_DIR/ {
5614 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5616 /A[CM]_PROG_LIBTOOL/ {
5617 s,^.*$,guessed_libtool=true,p
5619 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5621 if test -z "$auxdir"; then
5622 auxdir="$guessed_auxdir"
5625 # Determine where to apply func_import.
5626 if test "$mode" = import; then
5627 # Apply func_import to a particular gnulib directory.
5628 # The command line contains the complete specification; don't look at
5629 # the contents of gnulib-cache.m4.
5630 test -n "$supplied_libname" || supplied_libname=true
5631 test -n "$sourcebase" || sourcebase="lib"
5632 test -n "$m4base" || m4base="m4"
5633 test -n "$docbase" || docbase="doc"
5634 test -n "$testsbase" || testsbase="tests"
5635 test -n "$macro_prefix" || macro_prefix="gl"
5638 if test -n "$m4base"; then
5639 # Apply func_import to a particular gnulib directory.
5640 # Any number of additional modules can be given.
5641 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5642 # First use of gnulib in the given m4base.
5643 test -n "$supplied_libname" || supplied_libname=true
5644 test -n "$sourcebase" || sourcebase="lib"
5645 test -n "$docbase" || docbase="doc"
5646 test -n "$testsbase" || testsbase="tests"
5647 test -n "$macro_prefix" || macro_prefix="gl"
5651 # Apply func_import to all gnulib directories.
5652 # To get this list of directories, look at Makefile.am. (Not at
5653 # configure, because it may be omitted from version control. Also,
5654 # don't run "find $destdir -name gnulib-cache.m4", as it might be
5658 if test -f "$destdir"/Makefile.am; then
5659 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5661 for arg in $aclocal_amflags; do
5662 if test -n "$m4dir_is_next"; then
5663 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5667 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5668 func_append m4dirs " $arg"
5669 m4dirs_count=`expr $m4dirs_count + 1`
5675 if test "X$arg" = "X-I"; then
5683 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5684 if test -f "$destdir"/aclocal.m4; then
5685 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5686 sedexpr2='s,^[^/]*$,.,'
5687 sedexpr3='s,/[^/]*$,,'
5688 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5689 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
5690 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
5693 if test $m4dirs_count = 0; then
5694 # First use of gnulib in a package.
5695 # Any number of additional modules can be given.
5696 test -n "$supplied_libname" || supplied_libname=true
5697 test -n "$sourcebase" || sourcebase="lib"
5699 test -n "$docbase" || docbase="doc"
5700 test -n "$testsbase" || testsbase="tests"
5701 test -n "$macro_prefix" || macro_prefix="gl"
5704 if test $m4dirs_count = 1; then
5705 # There's only one use of gnulib here. Assume the user means it.
5706 # Any number of additional modules can be given.
5707 for m4base in $m4dirs; do
5711 # Ambiguous - guess what the user meant.
5712 if test $# = 0; then
5713 # No further arguments. Guess the user wants to update all of them.
5714 for m4base in $m4dirs; do
5715 # Perform func_import in a subshell, so that variable values
5717 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5718 # inc_longrunning_tests, inc_privileged_tests,
5719 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5720 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5721 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5722 # don't propagate from one directory to another.
5723 (func_import) || func_exit 1
5727 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5736 if test -z "$destdir"; then
5737 func_fatal_error "please specify --dir option"
5740 test -d "$destdir" \
5741 || func_fatal_error "could not create destination directory"
5742 test -n "$auxdir" || auxdir="build-aux"
5743 func_create_testdir "$destdir" "$*"
5746 create-megatestdir )
5747 if test -z "$destdir"; then
5748 func_fatal_error "please specify --dir option"
5750 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5751 test -n "$auxdir" || auxdir="build-aux"
5752 func_create_megatestdir "$destdir" "$*"
5756 test -n "$destdir" || destdir=testdir$$
5757 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5758 test -n "$auxdir" || auxdir="build-aux"
5759 func_create_testdir "$destdir" "$*"
5763 ../configure || func_exit 1
5764 $MAKE || func_exit 1
5765 $MAKE check || func_exit 1
5766 $MAKE distclean || func_exit 1
5767 remaining=`find . -type f -print`
5768 if test -n "$remaining"; then
5769 echo "Remaining files:" $remaining 1>&2
5770 echo "gnulib-tool: *** Stop." 1>&2
5779 test -n "$destdir" || destdir=testdir$$
5780 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5781 test -n "$auxdir" || auxdir="build-aux"
5782 func_create_megatestdir "$destdir" "$*"
5790 remaining=`find . -type f -print`
5791 if test -n "$remaining"; then
5792 echo "Remaining files:" $remaining 1>&2
5793 echo "gnulib-tool: *** Stop." 1>&2
5801 extract-description )
5805 if test -n "$module"; then
5806 func_get_description "$module"
5815 if test -n "$module"; then
5816 func_get_comment "$module"
5825 if test -n "$module"; then
5826 func_get_status "$module"
5835 if test -n "$module"; then
5836 func_get_notice "$module"
5841 extract-applicability )
5845 if test -n "$module"; then
5846 func_get_applicability "$module"
5855 if test -n "$module"; then
5856 func_get_filelist "$module"
5861 extract-dependencies )
5865 if test -n "$module"; then
5866 func_get_dependencies "$module"
5871 extract-autoconf-snippet )
5875 if test -n "$module"; then
5876 func_get_autoconf_snippet "$module"
5881 extract-automake-snippet )
5885 if test -n "$module"; then
5886 func_get_automake_snippet "$module"
5891 extract-include-directive )
5895 if test -n "$module"; then
5896 func_get_include_directive "$module"
5901 extract-link-directive )
5905 if test -n "$module"; then
5906 func_get_link_directive "$module"
5915 if test -n "$module"; then
5916 func_get_license "$module"
5921 extract-maintainer )
5925 if test -n "$module"; then
5926 func_get_maintainer "$module"
5931 extract-tests-module )
5935 if test -n "$module"; then
5936 func_get_tests_module "$module"
5942 # Verify the number of arguments.
5943 if test $# -lt 1 || test $# -gt 2; then
5944 func_fatal_error "invalid number of arguments for --$mode"
5947 # The first argument is the file to be copied.
5949 # Verify the file exists.
5950 func_lookup_file "$f"
5952 # The second argument is the destination; either a directory ot a file.
5953 # It defaults to the current directory.
5955 test -n "$dest" || dest='.'
5956 test -n "$sourcebase" || sourcebase="lib"
5957 test -n "$m4base" || m4base="m4"
5958 test -n "$docbase" || docbase="doc"
5959 test -n "$testsbase" || testsbase="tests"
5960 test -n "$auxdir" || auxdir="build-aux"
5961 rewritten='%REWRITTEN%'
5962 sed_rewrite_files="\
5963 s,^build-aux/,$rewritten$auxdir/,
5964 s,^doc/,$rewritten$docbase/,
5965 s,^lib/,$rewritten$sourcebase/,
5966 s,^m4/,$rewritten$m4base/,
5967 s,^tests/,$rewritten$testsbase/,
5970 if test -d "$dest"; then
5972 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5974 destdir=`dirname "$dest"`
5975 g=`basename "$dest"`
5978 # Create the directory for destfile.
5979 d=`dirname "$destdir/$g"`
5981 if test -n "$d" && test ! -d "$d"; then
5982 mkdir -p "$d" || func_fatal_error "failed"
5986 func_dest_tmpfilename "$g"
5987 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5988 already_present=true
5989 if test -f "$destdir/$g"; then
5990 # The file already exists.
5994 # Don't protest if the file should be there but isn't: it happens
5995 # frequently that developers don't put autogenerated files under version
6003 func_fatal_error "unknown operation mode --$mode" ;;
6007 # Undo the effect of the previous 'trap' command. Some shellology:
6008 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6009 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6010 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6011 # 128 + signal number and is set before the trap-registered command is run.
6013 trap 'func_exit $?' 1 2 3 13 15
6018 # indent-tabs-mode: nil
6019 # whitespace-check-buffer-indent: nil