3 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # (The GNU autoconf doc says that sed comments are not portable, but does
113 # not say which 'sed' versions are affected.)
114 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
131 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
132 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
133 gnulib-tool --test --dir=directory module1 ... moduleN
134 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
135 gnulib-tool --extract-description module
136 gnulib-tool --extract-comment module
137 gnulib-tool --extract-status module
138 gnulib-tool --extract-notice module
139 gnulib-tool --extract-applicability module
140 gnulib-tool --extract-filelist module
141 gnulib-tool --extract-dependencies module
142 gnulib-tool --extract-autoconf-snippet module
143 gnulib-tool --extract-automake-snippet module
144 gnulib-tool --extract-include-directive module
145 gnulib-tool --extract-link-directive module
146 gnulib-tool --extract-license module
147 gnulib-tool --extract-maintainer module
148 gnulib-tool --extract-tests-module module
149 gnulib-tool --copy-file file [destination]
152 --list print the available module names
153 --find find the modules which contain the specified file
154 --import import the given modules into the current package;
155 if no modules are specified, update the current
156 package from the current gnulib
157 --update update the current package, restore files omitted
159 --create-testdir create a scratch package with the given modules
160 --create-megatestdir create a mega scratch package with the given modules
161 one by one and all together
162 --test test the combination of the given modules
163 (recommended to use CC=\"gcc -Wall\" here)
164 --megatest test the given modules one by one and all together
165 (recommended to use CC=\"gcc -Wall\" here)
166 --extract-description extract the description
167 --extract-comment extract the comment
168 --extract-status extract the status (obsolete etc.)
169 --extract-notice extract the notice or banner
170 --extract-applicability extract the applicability
171 --extract-filelist extract the list of files
172 --extract-dependencies extract the dependencies
173 --extract-autoconf-snippet extract the snippet for configure.ac
174 --extract-automake-snippet extract the snippet for library makefile
175 --extract-include-directive extract the #include directive
176 --extract-link-directive extract the linker directive
177 --extract-license report the license terms of the source files
179 --extract-maintainer report the maintainer(s) inside gnulib
180 --extract-tests-module report the unit test module, if it exists
181 --copy-file copy a file that is not part of any module
184 --dir=DIRECTORY Specify the target directory.
185 For --import, this specifies where your
186 configure.ac can be found. Defaults to current
188 --local-dir=DIRECTORY Specify a local override directory where to look
189 up files before looking in gnulib's directory.
190 --cache-modules Enable module caching optimization.
191 --no-cache-modules Disable module caching optimization.
192 --verbose Increase verbosity. May be repeated.
193 --quiet Decrease verbosity. May be repeated.
195 Options for --import, --update:
196 --dry-run Only print what would have been done.
198 Options for --import, --create-[mega]testdir, --[mega]test:
199 --with-tests Include unit tests for the included modules.
200 --with-obsolete Include obsolete modules when they occur among the
201 dependencies. By default, dependencies to obsolete
203 --avoid=MODULE Avoid including the given MODULE. Useful if you
204 have code that provides equivalent functionality.
205 This option can be repeated.
206 --libtool Use libtool rules.
207 --no-libtool Don't use libtool rules.
209 Options for --import:
210 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
211 --source-base=DIRECTORY
212 Directory relative to --dir where source code is
213 placed (default \"lib\").
214 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
215 placed (default \"m4\").
216 --po-base=DIRECTORY Directory relative to --dir where *.po files are
217 placed (default \"po\").
218 --doc-base=DIRECTORY Directory relative to --dir where doc files are
219 placed (default \"doc\").
220 --tests-base=DIRECTORY
221 Directory relative to --dir where unit tests are
222 placed (default \"tests\").
223 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
224 tools are placed (default \"build-aux\").
225 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
226 Also modify license template from GPL to LGPL.
227 The version number of the LGPL can be specified;
228 the default is currently LGPLv3.
229 --makefile-name=NAME Name of makefile in automake syntax in the
230 source-base and tests-base directories
231 (default \"Makefile.am\").
232 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
233 'gl_INIT'. Default is 'gl'.
234 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
235 the package name. A suffix '-gnulib' is appended.
236 --with-c++-tests Include even unit tests for C++ interoperability.
237 --with-longrunning-tests
238 Include even unit tests that are long-runners.
239 --with-privileged-tests
240 Include even unit tests that require root
242 --with-unportable-tests
243 Include even unit tests that fail on some platforms.
244 --with-all-tests Include all kinds of problematic unit tests.
245 --vc-files Update version control related files.
246 --no-vc-files Don't update version control related files
247 (.gitignore and/or .cvsignore).
248 --no-changelog Don't update or create ChangeLog files.
250 Options for --import, --update, --create-[mega]testdir, --[mega]test:
251 -s, --symbolic, --symlink Make symbolic links instead of copying files.
252 --local-symlink Make symbolic links instead of copying files, only
253 for files from the local override directory.
255 Options for --import, --update:
256 -S, --more-symlinks Make symbolic links instead of copying files, and
257 don't replace copyright notices.
259 Report bugs to <bug-gnulib@gnu.org>."
263 # outputs to stdout the --version message.
267 if test -d "$gnulib_dir"/.git \
268 && (git --version) >/dev/null 2>/dev/null \
269 && (date --version) >/dev/null 2>/dev/null; then
270 # gnulib checked out from git.
271 sed_extract_first_date='/^Date/{
275 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
276 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
277 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
278 date=`echo "$date" | sed -e "$sed_year_before_time"`
279 # Use GNU date to compute the time in GMT.
280 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
281 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
283 if test -d "$gnulib_dir"/CVS \
284 && (cvs --version) >/dev/null 2>/dev/null; then
285 # gnulib checked out from CVS.
286 sed_extract_first_date='/^date: /{
287 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
290 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
292 # gnulib copy without versioning information.
293 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
297 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
299 gnulib-tool (GNU $package $date)$version
300 Copyright (C) $year Free Software Foundation, Inc.
301 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
302 This is free software: you are free to change and redistribute it.
303 There is NO WARRANTY, to the extent permitted by law.
305 Written by" "Bruno Haible" "and" "Simon Josefsson"
308 # func_emit_copyright_notice
309 # outputs to stdout a header for a generated file.
310 func_emit_copyright_notice ()
312 sed -n -e '/Copyright/ {
315 }' < "$self_abspathname"
317 echo "# This file is free software, distributed under the terms of the GNU"
318 echo "# General Public License. As a special exception to the GNU General"
319 echo "# Public License, this file may be distributed as part of a program"
320 echo "# that contains a configuration script generated by Autoconf, under"
321 echo "# the same distribution terms as the rest of that program."
323 echo "# Generated by gnulib-tool."
327 # exits with a given status.
328 # This function needs to be used, rather than 'exit', when a 'trap' handler is
329 # in effect that refers to $?.
336 # locates the directory where the gnulib repository lives
338 # - progname name of this program
340 # - self_abspathname absolute pathname of gnulib-tool
341 # - gnulib_dir absolute pathname of gnulib repository
345 /*) self_abspathname="$progname" ;;
346 */*) self_abspathname=`pwd`/"$progname" ;;
349 # Iterate through the elements of $PATH.
350 # We use IFS=: instead of
351 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
352 # because the latter does not work when some PATH element contains spaces.
353 # We use a canonicalized $pathx instead of $PATH, because empty PATH
354 # elements are by definition equivalent to '.', however field splitting
355 # according to IFS=: loses empty fields in many shells:
356 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
357 # beginning, at the end, and in the middle),
358 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
359 # at the beginning and at the end,
360 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
361 # Solaris lose empty fields at the end.
362 # The 'case' statement is an optimization, to avoid evaluating the
363 # explicit canonicalization command when $PATH contains no empty fields.
365 if test "${PATH_SEPARATOR+set}" != set; then
367 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
368 chmod +x "$tmp"/conf.sh
369 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
376 if test "$PATH_SEPARATOR" = ";"; then
377 # On Windows, programs are searched in "." before $PATH.
380 # On Unix, we have to convert empty PATH elements to ".".
384 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
389 IFS="$PATH_SEPARATOR"
393 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
394 self_abspathname="$d/$progname"
399 if test -z "$self_abspathname"; then
400 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
404 while test -h "$self_abspathname"; do
405 # Resolve symbolic link.
406 linkval=`func_readlink "$self_abspathname"`
407 test -n "$linkval" || break
409 /* ) self_abspathname="$linkval" ;;
410 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
413 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
417 # creates a temporary directory.
419 # - progname name of this program
421 # - tmp pathname of freshly created temporary directory
424 # Use the environment variable TMPDIR, falling back to /tmp. This allows
425 # users to specify a different temporary directory, for example, if their
426 # /tmp is filled up or too small.
429 # Use the mktemp program if available. If not available, hide the error
431 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
432 test -n "$tmp" && test -d "$tmp"
435 # Use a simple mkdir command. It is guaranteed to fail if the directory
436 # already exists. $RANDOM is bash specific and expands to empty in shells
437 # other than bash, ksh and zsh. Its use does not increase security;
438 # rather, it minimizes the probability of failure in a very cluttered /tmp
440 tmp=$TMPDIR/gl$$-$RANDOM
441 (umask 077 && mkdir "$tmp")
444 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
449 # func_append var value
450 # appends the given value to the shell variable var.
451 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
452 # Use bash's += operator. It reduces complexity of appending repeatedly to
453 # a single variable from O(n^2) to O(n).
458 fast_func_append=true
462 eval "$1=\"\$$1\$2\""
464 fast_func_append=false
467 # func_remove_prefix var prefix
468 # removes the given prefix from the value of the shell variable var.
469 # var should be the name of a shell variable.
470 # Its value should not contain a newline and not start or end with whitespace.
471 # prefix should not contain the characters "$`\{}[]^|.
472 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
473 func_remove_prefix ()
477 fast_func_remove_prefix=true
479 func_remove_prefix ()
481 eval "value=\"\$$1\""
485 sed_escape_dots='s/\([.]\)/\\\1/g'
486 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
489 value=`echo "$value" | sed -e "s|^${prefix}||"`
490 eval "$1=\"\$value\""
492 fast_func_remove_prefix=false
495 # func_remove_suffix var suffix
496 # removes the given suffix from the value of the shell variable var.
497 # var should be the name of a shell variable.
498 # Its value should not contain a newline and not start or end with whitespace.
499 # suffix should not contain the characters "$`\{}[]^|.
500 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
501 func_remove_suffix ()
505 fast_func_remove_suffix=true
507 func_remove_suffix ()
509 eval "value=\"\$$1\""
513 sed_escape_dots='s/\([.]\)/\\\1/g'
514 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
517 value=`echo "$value" | sed -e "s|${suffix}\$||"`
518 eval "$1=\"\$value\""
520 fast_func_remove_suffix=false
523 # func_fatal_error message
524 # outputs to stderr a fatal error message, and terminates the program.
526 # - progname name of this program
529 echo "$progname: *** $1" 1>&2
530 echo "$progname: *** Stop." 1>&2
534 # func_warning message
535 # Outputs to stderr a warning message,
538 echo "gnulib-tool: warning: $1" 1>&2
541 # func_readlink SYMLINK
542 # outputs the target of the given symlink.
543 if (type -p readlink) > /dev/null 2>&1; then
546 # Use the readlink program from GNU coreutils.
552 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
553 # would do the wrong thing if the link target contains " -> ".
554 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
558 # func_relativize DIR1 DIR2
559 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
561 # - DIR1 relative pathname, relative to the current directory
562 # - DIR2 relative pathname, relative to the current directory
564 # - reldir relative pathname of DIR2, relative to DIR1
570 sed_first='s,^\([^/]*\)/.*$,\1,'
571 sed_rest='s,^[^/]*/*,,'
572 sed_last='s,^.*/\([^/]*\)$,\1,'
573 sed_butlast='s,/*[^/]*$,,'
574 while test -n "$dir1"; do
575 first=`echo "$dir1" | sed -e "$sed_first"`
576 if test "$first" != "."; then
577 if test "$first" = ".."; then
578 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
579 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
581 first2=`echo "$dir2" | sed -e "$sed_first"`
582 if test "$first2" = "$first"; then
583 dir2=`echo "$dir2" | sed -e "$sed_rest"`
587 dir0="$dir0"/"$first"
590 dir1=`echo "$dir1" | sed -e "$sed_rest"`
595 # func_relconcat DIR1 DIR2
596 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
598 # - DIR1 relative pathname, relative to the current directory
599 # - DIR2 relative pathname, relative to DIR1
601 # - relconcat DIR1/DIR2, relative to the current directory
606 sed_first='s,^\([^/]*\)/.*$,\1,'
607 sed_rest='s,^[^/]*/*,,'
608 sed_last='s,^.*/\([^/]*\)$,\1,'
609 sed_butlast='s,/*[^/]*$,,'
611 first=`echo "$dir2" | sed -e "$sed_first"`
612 if test "$first" = "."; then
613 dir2=`echo "$dir2" | sed -e "$sed_rest"`
614 if test -z "$dir2"; then
619 last=`echo "$dir1" | sed -e "$sed_last"`
620 while test "$last" = "."; do
621 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
622 last=`echo "$dir1" | sed -e "$sed_last"`
624 if test -z "$dir1"; then
628 if test "$first" = ".."; then
629 if test "$last" = ".."; then
630 relconcat="$dir1/$dir2"
633 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
634 dir2=`echo "$dir2" | sed -e "$sed_rest"`
635 if test -z "$dir1"; then
639 if test -z "$dir2"; then
644 relconcat="$dir1/$dir2"
652 # Like ln -s, except that SRC is given relative to the current directory (or
653 # absolute), not given relative to the directory of DEST.
659 *) # SRC is relative.
662 ln -s "`pwd`/$1" "$2" ;;
663 *) # DEST is relative too.
664 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
665 test -n "$ln_destdir" || ln_destdir="."
666 func_relativize "$ln_destdir" "$1"
674 # func_ln_if_changed SRC DEST
675 # Like func_ln, but avoids munging timestamps if the link is correct.
676 func_ln_if_changed ()
678 if test $# -ne 2; then
679 echo "usage: func_ln_if_changed SRC DEST" >&2
681 ln_target=`func_readlink "$2"`
682 if test -h "$2" && test "$1" = "$ln_target"; then
690 # Ensure an 'echo' command that
691 # 1. does not interpret backslashes and
692 # 2. does not print an error message "broken pipe" when writing into a pipe
695 # Test cases for problem 1:
696 # echo '\n' | wc -l prints 1 when OK, 2 when KO
697 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
698 # Test cases for problem 2:
699 # echo hi | true frequently prints
700 # "bash: echo: write error: Broken pipe"
701 # to standard error in bash 3.2.
703 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
704 # BSD echo interprets '-n' as an option, which is also not desirable).
705 # Nowadays the problem occurs in 4 situations:
706 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
707 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
708 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
709 # - in zsh, when sh-emulation is not set,
710 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
711 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
712 # - in Solaris /bin/sh and OSF/1 /bin/sh.
713 # We try the following workarounds:
714 # - for all: respawn using $CONFIG_SHELL if that is set and works.
715 # - for bash >= 2.04: unset the shell option xpg_echo.
716 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
717 # - for bash < 2.0: define echo to a function that uses cat of a here document.
718 # - for zsh: turn sh-emulation on.
719 # - for ksh: alias echo to 'print -r'.
720 # - for ksh: alias echo to a function that uses cat of a here document.
721 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
722 # the ksh workaround.
723 # - otherwise: respawn using /bin/sh and rely on the workarounds.
724 # When respawning, we pass --no-reexec as first argument, so as to avoid
725 # turning this script into a fork bomb in unlucky situations.
727 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
728 # the 'printf' built-in. See
729 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
730 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
731 # The workaround is: define echo to a function that uses the printf built-in.
733 if echo '\t' | grep t > /dev/null; then
734 have_echo=yes # Lucky!
736 # Try the workarounds.
737 # Respawn using $CONFIG_SHELL if that is set and works.
738 if test -z "$have_echo" \
739 && test "X$1" != "X--no-reexec" \
740 && test -n "$CONFIG_SHELL" \
741 && test -f "$CONFIG_SHELL" \
742 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
743 exec $CONFIG_SHELL "$0" --no-reexec "$@"
746 # For bash >= 2.04: unset the shell option xpg_echo.
747 if test -z "$have_echo" \
748 && test -n "$BASH_VERSION" \
749 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
753 # For bash >= 2.0: define echo to a function that uses the printf built-in.
754 # For bash < 2.0: define echo to a function that uses cat of a here document.
755 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
756 # Also handle problem 2, specific to bash 3.2, here.
757 if { test -z "$have_echo" \
758 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
760 && test -n "$BASH_VERSION"; then \
761 if type printf 2>/dev/null | grep / > /dev/null; then
762 # 'printf' is not a shell built-in.
770 # 'printf' is a shell built-in.
776 if echo '\t' | grep t > /dev/null; then
780 # For zsh: turn sh-emulation on.
781 if test -z "$have_echo" \
782 && test -n "$ZSH_VERSION" \
783 && (emulate sh) >/dev/null 2>&1; then
786 # For ksh: alias echo to 'print -r'.
787 if test -z "$have_echo" \
788 && (type print) >/dev/null 2>&1; then
789 # A 'print' command exists.
790 if type print 2>/dev/null | grep / > /dev/null; then
793 # 'print' is a shell built-in.
794 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
795 # 'print' is the ksh shell built-in.
796 alias echo='print -r'
800 if test -z "$have_echo" \
801 && echo '\t' | grep t > /dev/null; then
804 # For ksh: alias echo to a function that uses cat of a here document.
805 # The ksh manual page says:
806 # "Aliasing is performed when scripts are read, not while they are executed.
807 # Therefore, for an alias to take effect, the alias definition command has
808 # to be executed before the command which references the alias is read."
809 # Because of this, we have to play strange tricks with have_echo, to ensure
810 # that the top-level statement containing the test starts after the 'alias'
812 if test -z "$have_echo"; then
819 alias echo=bsd_echo 2>/dev/null
821 if test -z "$have_echo" \
822 && echo '\t' | grep t > /dev/null; then
825 if test -z "$have_echo"; then
826 unalias echo 2>/dev/null
828 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
829 if test -z "$have_echo" \
830 && test "X$1" != "X--no-reexec" \
831 && test -f /bin/ksh; then
832 exec /bin/ksh "$0" --no-reexec "$@"
835 # Otherwise: respawn using /bin/sh.
836 if test -z "$have_echo" \
837 && test "X$1" != "X--no-reexec" \
838 && test -f /bin/sh; then
839 exec /bin/sh "$0" --no-reexec "$@"
842 if test -z "$have_echo"; then
843 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
845 if echo '\t' | grep t > /dev/null; then
848 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
850 if test "X$1" = "X--no-reexec"; then
854 # Command-line option processing.
855 # Removes the OPTIONS from the arguments. Sets the variables:
856 # - mode list or import or create-testdir or create-megatestdir
857 # - destdir from --dir
858 # - local_gnulib_dir from --local-dir
859 # - modcache true or false, from --cache-modules/--no-cache-modules
860 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
861 # - libname, supplied_libname from --lib
862 # - sourcebase from --source-base
863 # - m4base from --m4-base
864 # - pobase from --po-base
865 # - docbase from --doc-base
866 # - testsbase from --tests-base
867 # - auxdir from --aux-dir
868 # - inctests true if --with-tests was given, blank otherwise
869 # - incobsolete true if --with-obsolete was given, blank otherwise
870 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
871 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
873 # - inc_privileged_tests true if --with-privileged-tests was given, blank
875 # - inc_unportable_tests true if --with-unportable-tests was given, blank
877 # - inc_all_tests true if --with-all-tests was given, blank otherwise
878 # - avoidlist list of modules to avoid, from --avoid
879 # - lgpl yes or a number if --lgpl was given, blank otherwise
880 # - makefile_name from --makefile-name
881 # - libtool true if --libtool was given, false if --no-libtool was
882 # given, blank otherwise
883 # - macro_prefix from --macro-prefix
884 # - po_domain from --po-domain
885 # - vc_files true if --vc-files was given, false if --no-vc-files was
886 # given, blank otherwise
887 # - autoconf_minversion minimum supported autoconf version
888 # - do_changelog false if --no-changelog was given, : otherwise
889 # - doit : if actions shall be executed, false if only to be printed
890 # - symbolic true if --symlink or --more-symlinks was given, blank
892 # - lsymbolic true if --local-symlink was given, blank otherwise
893 # - do_copyrights blank if --more-symlinks was given, true otherwise
911 inc_longrunning_tests=
912 inc_privileged_tests=
913 inc_unportable_tests=
930 while test $# -gt 0; do
935 --find | --fin | --fi | --f )
938 --import | --impor | --impo | --imp | --im | --i )
941 --update | --updat | --upda | --upd | --up | --u )
944 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
947 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
948 mode=create-megatestdir
950 --test | --tes | --te | --t )
953 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
957 mode=`echo "X$1" | sed -e 's/^X--//'`
959 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
965 func_fatal_error "missing argument for --dir"
970 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
975 func_fatal_error "missing argument for --local-dir"
980 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
982 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
985 --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 )
988 --verbose | --verbos | --verbo | --verb )
989 verbose=`expr $verbose + 1`
991 --quiet | --quie | --qui | --qu | --q )
992 verbose=`expr $verbose - 1`
997 func_fatal_error "missing argument for --lib"
1000 supplied_libname=true
1003 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1004 supplied_libname=true
1008 if test $# = 0; then
1009 func_fatal_error "missing argument for --source-base"
1014 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1018 if test $# = 0; then
1019 func_fatal_error "missing argument for --m4-base"
1024 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1028 if test $# = 0; then
1029 func_fatal_error "missing argument for --po-base"
1034 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1038 if test $# = 0; then
1039 func_fatal_error "missing argument for --doc-base"
1044 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1048 if test $# = 0; then
1049 func_fatal_error "missing argument for --tests-base"
1054 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1058 if test $# = 0; then
1059 func_fatal_error "missing argument for --aux-dir"
1064 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1066 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1069 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1072 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1075 --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)
1076 inc_longrunning_tests=true
1078 --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)
1079 inc_privileged_tests=true
1081 --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)
1082 inc_unportable_tests=true
1084 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1089 if test $# = 0; then
1090 func_fatal_error "missing argument for --avoid"
1092 func_append avoidlist " $1"
1095 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1096 func_append avoidlist " $arg"
1102 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1105 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1111 if test $# = 0; then
1112 func_fatal_error "missing argument for --makefile-name"
1117 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1127 if test $# = 0; then
1128 func_fatal_error "missing argument for --macro-prefix"
1133 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1137 if test $# = 0; then
1138 func_fatal_error "missing argument for --po-domain"
1143 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1151 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1157 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1160 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1163 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1167 --help | --hel | --he | --h )
1170 --version | --versio | --versi | --vers )
1174 # Stop option processing
1178 echo "gnulib-tool: unknown option $1" 1>&2
1179 echo "Try 'gnulib-tool --help' for more information." 1>&2
1186 if test "$mode" = update; then
1187 if test $# != 0; then
1188 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1189 echo "Try 'gnulib-tool --help' for more information." 1>&2
1190 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1191 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1194 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1195 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1196 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1197 || test -n "$inctests" || test -n "$incobsolete" \
1198 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1199 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1200 || test -n "$inc_all_tests" \
1201 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1202 || test -n "$macro_prefix" || test -n "$po_domain" \
1203 || test -n "$vc_files"; then
1204 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1205 echo "Try 'gnulib-tool --help' for more information." 1>&2
1206 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1207 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1212 if test -n "$pobase" && test -z "$po_domain"; then
1213 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1214 echo "Try 'gnulib-tool --help' for more information." 1>&2
1217 if test -z "$pobase" && test -n "$po_domain"; then
1218 func_warning "--po-domain has no effect without a --po-base option"
1221 # Determine the minimum supported autoconf version from the project's
1223 DEFAULT_AUTOCONF_MINVERSION="2.59"
1224 autoconf_minversion=
1226 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1227 if test -f "$destdir"/configure.ac; then
1228 configure_ac="$destdir/configure.ac"
1230 if test -f "$destdir"/configure.in; then
1231 configure_ac="$destdir/configure.in"
1235 if test -f configure.ac; then
1236 configure_ac="configure.ac"
1238 if test -f configure.in; then
1239 configure_ac="configure.in"
1243 if test -n "$configure_ac"; then
1244 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1245 # because when some m4 files are omitted from a CVS repository,
1246 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1247 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1248 # autom4te: m4 failed with exit status: 1
1255 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1257 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1258 if test -n "$prereqs"; then
1259 autoconf_minversion=`
1260 for version in $prereqs; do echo $version; done |
1261 LC_ALL=C sort -nru | sed -e 1q
1265 if test -z "$autoconf_minversion"; then
1266 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1268 case "$autoconf_minversion" in
1269 1.* | 2.[0-4]* | 2.5[0-8]*)
1270 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1273 # Remove trailing slashes from the directory names. This is necessary for
1274 # m4base (to avoid an error in func_import) and optional for the others.
1275 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1276 case "$local_gnulib_dir" in
1277 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1279 case "$sourcebase" in
1280 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1283 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1286 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1289 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1291 case "$testsbase" in
1292 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1295 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1301 trap 'exit_status=$?
1302 if test "$signal" != 0; then
1303 echo "caught signal $signal" >&2
1306 exit $exit_status' 0
1307 for signal in 1 2 3 13 15; do
1308 trap '{ signal='$signal'; func_exit 1; }' $signal
1312 # func_lookup_file file
1313 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1316 # - local_gnulib_dir from --local-dir
1318 # - lookedup_file name of the merged (combined) file
1319 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1323 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1324 lookedup_file="$local_gnulib_dir/$lkfile"
1327 if test -f "$gnulib_dir/$lkfile"; then
1328 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1329 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1330 rm -f "$tmp/$lkbase"
1331 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1332 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1333 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1334 lookedup_file="$tmp/$lkbase"
1337 lookedup_file="$gnulib_dir/$lkfile"
1341 func_fatal_error "file $gnulib_dir/$lkfile not found"
1346 # func_sanitize_modulelist
1347 # receives a list of possible module names on standard input, one per line.
1348 # It removes those which are just file names unrelated to modules, and outputs
1349 # the resulting list to standard output, one per line.
1350 func_sanitize_modulelist ()
1352 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1353 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1354 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1355 -e '/^README$/d' -e '/\/README$/d' \
1356 -e '/^TEMPLATE$/d' \
1357 -e '/^TEMPLATE-EXTENDED$/d' \
1358 -e '/^TEMPLATE-TESTS$/d' \
1365 # - local_gnulib_dir from --local-dir
1368 # Filter out metainformation files like README, which are not modules.
1369 # Filter out unit test modules; they can be retrieved through
1370 # --extract-tests-module if desired.
1372 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1373 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1374 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1377 | func_sanitize_modulelist \
1378 | sed -e '/-tests$/d' \
1382 # func_verify_module
1383 # verifies a module name
1385 # - local_gnulib_dir from --local-dir
1386 # - module module name argument
1387 func_verify_module ()
1389 if { test -f "$gnulib_dir/modules/$module" \
1390 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1391 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1392 && test "CVS" != "$module" \
1393 && test "ChangeLog" != "$module" \
1394 && test "COPYING" != "$module" \
1395 && test "README" != "$module" \
1396 && test "TEMPLATE" != "$module" \
1397 && test "TEMPLATE-EXTENDED" != "$module" \
1398 && test "TEMPLATE-TESTS" != "$module"; then
1399 # OK, $module is a correct module name.
1400 # Verify that building the module description with 'patch' succeeds.
1401 func_lookup_file "modules/$module"
1403 func_warning "module $module doesn't exist"
1408 # func_verify_nontests_module
1409 # verifies a module name, excluding tests modules
1411 # - local_gnulib_dir from --local-dir
1412 # - module module name argument
1413 func_verify_nontests_module ()
1416 *-tests ) module= ;;
1417 * ) func_verify_module ;;
1421 # func_verify_tests_module
1422 # verifies a module name, considering only tests modules
1424 # - local_gnulib_dir from --local-dir
1425 # - module module name argument
1426 func_verify_tests_module ()
1429 *-tests ) func_verify_module ;;
1434 # Suffix of a sed expression that extracts a particular field from a
1435 # module description.
1436 # A field starts with a line that contains a keyword, such as 'Description',
1437 # followed by a colon and optional whitespace. All following lines, up to
1438 # the next field (or end of file if there is none) form the contents of the
1440 # An absent field is equivalent to a field with empty contents.
1441 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1442 sed_extract_prog=':[ ]*$/ {
1445 s/^Description:[ ]*$//
1449 s/^Applicability:[ ]*$//
1451 s/^Depends-on:[ ]*$//
1452 s/^configure\.ac-early:[ ]*$//
1453 s/^configure\.ac:[ ]*$//
1454 s/^Makefile\.am:[ ]*$//
1458 s/^Maintainer:[ ]*$//
1465 # Piece of a sed expression that converts a field header line to a shell
1467 # NOTE: Keep this in sync with sed_extract_prog above!
1468 sed_extract_field_header='
1469 s/^Description:[ ]*$/description/
1470 s/^Comment:[ ]*$/comment/
1471 s/^Status:[ ]*$/status/
1472 s/^Notice:[ ]*$/notice/
1473 s/^Applicability:[ ]*$/applicability/
1474 s/^Files:[ ]*$/files/
1475 s/^Depends-on:[ ]*$/dependson/
1476 s/^configure\.ac-early:[ ]*$/configureac_early/
1477 s/^configure\.ac:[ ]*$/configureac/
1478 s/^Makefile\.am:[ ]*$/makefile/
1479 s/^Include:[ ]*$/include/
1481 s/^License:[ ]*$/license/
1482 s/^Maintainer:[ ]*$/maintainer/'
1486 # Note: The 'eval' silences stderr output in dash.
1487 if declare -A x 2>/dev/null && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }; then
1488 # Zsh 4 and Bash 4 have associative arrays.
1489 have_associative=true
1491 # For other shells, use 'eval' with computed shell variable names.
1492 have_associative=false
1495 if $have_associative; then
1497 # Declare the associative arrays.
1498 declare -A modcache_cached
1499 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1500 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1501 eval "$declare_script"
1505 # func_cache_var module
1506 # computes the cache variable name corresponding to $module.
1507 # Note: This computation can map different module names to the same
1508 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1509 # to protect against this case.
1511 # - cachevar a shell variable name
1512 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1513 # Bash 2.0 and newer, ksh, and zsh support the syntax
1514 # ${param//pattern/replacement}
1515 # as a shorthand for
1516 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1517 # Note: The 'eval' above silences stderr output in dash.
1520 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1527 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1536 # func_init_sed_convert_to_cache_statements
1538 # - modcachevar_assignment
1540 # - sed_convert_to_cache_statements
1541 func_init_sed_convert_to_cache_statements ()
1543 # 'sed' script that turns a module description into shell script
1544 # assignments, suitable to be eval'ed. All active characters are escaped.
1547 # Some module's description
1552 # modcache_description[$1]=\
1553 # 'Some module'"'"'s description
1555 # modcache_files[$1]=\
1558 # c_MODULE_description_set=set; c_MODULE_description=\
1559 # 'Some module'"'"'s description
1561 # c_MODULE_files_set=set; c_MODULE_files=\
1563 # The script consists of two parts:
1564 # 1) Ignore the lines before the first field header.
1565 # 2) A loop, treating non-field-header lines by escaping single quotes
1566 # and adding a closing quote in the last line,
1567 sed_convert_to_cache_statements="
1569 # Here we have not yet seen a field header.
1571 # See if the current line contains a field header.
1574 ${sed_extract_field_header}
1577 # No field header. Ignore the line.
1579 # Read the next line. Upon EOF, just exit.
1584 # The current line contains a field header.
1586 # Turn it into the beginning of an assignment.
1587 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1589 # Move it to the hold space. Don't print it yet,
1590 # because we want no assignment if the field is empty.
1593 # Read the next line.
1594 # Upon EOF, the field was empty. Print no assignment. Just exit.
1597 # See if the current line contains a field header.
1600 ${sed_extract_field_header}
1601 # If it is, the previous field was empty. Print no assignment.
1604 # Not a field header.
1606 # Print the previous line, held in the hold space.
1611 # Transform single quotes.
1614 # Prepend a single quote.
1619 # Move it to the hold space.
1622 # Read the next line.
1629 # See if the current line contains a field header.
1632 ${sed_extract_field_header}
1635 # Print the previous line, held in the hold space.
1640 # Transform single quotes.
1647 # Print the previous line, held in the hold space, with a single quote
1648 # to end the assignment.
1658 # Print the previous line, held in the hold space, with a single quote
1659 # to end the assignment.
1666 if ! $sed_comments; then
1668 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1669 | sed -e 's/^ *//' -e 's/^#.*//'`
1673 if $have_associative; then
1674 # sed_convert_to_cache_statements does not depend on the module.
1675 modcachevar_assignment='modcache_\1[$1]='
1676 func_init_sed_convert_to_cache_statements
1679 # func_cache_lookup_module module
1681 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1682 # of its relevant data in a cache in the memory of the processing shell. If
1683 # already cached, it does not look it up again, thus saving file access time.
1685 # - module non-empty string
1686 # Output if $have_associative:
1687 # - modcache_cached[$module] set to yes
1688 # - modcache_description[$module] ==
1689 # - modcache_status[$module] \ set to the field's value, minus the
1690 # - ... / final newline,
1691 # - modcache_maintainer[$module] == or unset if the field's value is empty
1692 # Output if ! $have_associative:
1693 # - cachevar a shell variable name
1694 # - ${cachevar}_cached set to $module
1695 # - ${cachevar}_description ==
1696 # - ${cachevar}_status \ set to the field's value, minus the
1697 # - ... / final newline,
1698 # - ${cachevar}_maintainer == or unset if the field's value is empty
1699 # - ${cachevar}_description_set ==
1700 # - ${cachevar}_status_set \ set to non-empty if the field's value
1701 # - ... / is non-empty,
1702 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1703 func_cache_lookup_module ()
1705 if $have_associative; then
1706 cached=${modcache_cached[$1]}
1709 eval "cached=\"\$${cachevar}_cached\""
1711 if test -z "$cached"; then
1712 # Not found in cache. Look it up on the file system.
1713 func_lookup_file "modules/$1"
1714 if $have_associative; then
1715 modcache_cached[$1]=yes
1717 eval "${cachevar}_cached=\"\$1\""
1719 if ! $have_associative; then
1720 # sed_convert_to_cache_statements depends on the module.
1721 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1722 func_init_sed_convert_to_cache_statements
1724 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1725 eval "$cache_statements"
1727 if ! $have_associative; then
1728 if test "$1" != "$cached"; then
1729 func_fatal_error "cache variable collision between $1 and $cached"
1737 # func_get_description module
1739 # - local_gnulib_dir from --local-dir
1740 # - modcache true or false, from --cache-modules/--no-cache-modules
1741 func_get_description ()
1743 if ! $modcache; then
1744 func_lookup_file "modules/$1"
1745 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1747 func_cache_lookup_module "$1"
1748 # Output the field's value, including the final newline (if any).
1749 if $have_associative; then
1750 if test -n "${modcache_description[$1]+set}"; then
1751 echo "${modcache_description[$1]}"
1754 eval "field_set=\"\$${cachevar}_description_set\""
1755 if test -n "$field_set"; then
1756 eval "field_value=\"\$${cachevar}_description\""
1757 echo "${field_value}"
1763 # func_get_comment module
1765 # - local_gnulib_dir from --local-dir
1766 # - modcache true or false, from --cache-modules/--no-cache-modules
1769 if ! $modcache; then
1770 func_lookup_file "modules/$1"
1771 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1773 func_cache_lookup_module "$1"
1774 # Output the field's value, including the final newline (if any).
1775 if $have_associative; then
1776 if test -n "${modcache_comment[$1]+set}"; then
1777 echo "${modcache_comment[$1]}"
1780 eval "field_set=\"\$${cachevar}_comment_set\""
1781 if test -n "$field_set"; then
1782 eval "field_value=\"\$${cachevar}_comment\""
1783 echo "${field_value}"
1789 # func_get_status module
1791 # - local_gnulib_dir from --local-dir
1792 # - modcache true or false, from --cache-modules/--no-cache-modules
1795 if ! $modcache; then
1796 func_lookup_file "modules/$1"
1797 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1799 func_cache_lookup_module "$1"
1800 # Output the field's value, including the final newline (if any).
1801 if $have_associative; then
1802 if test -n "${modcache_status[$1]+set}"; then
1803 echo "${modcache_status[$1]}"
1806 eval "field_set=\"\$${cachevar}_status_set\""
1807 if test -n "$field_set"; then
1808 eval "field_value=\"\$${cachevar}_status\""
1809 echo "${field_value}"
1815 # func_get_notice module
1817 # - local_gnulib_dir from --local-dir
1818 # - modcache true or false, from --cache-modules/--no-cache-modules
1821 if ! $modcache; then
1822 func_lookup_file "modules/$1"
1823 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1825 func_cache_lookup_module "$1"
1826 # Output the field's value, including the final newline (if any).
1827 if $have_associative; then
1828 if test -n "${modcache_notice[$1]+set}"; then
1829 echo "${modcache_notice[$1]}"
1832 eval "field_set=\"\$${cachevar}_notice_set\""
1833 if test -n "$field_set"; then
1834 eval "field_value=\"\$${cachevar}_notice\""
1835 echo "${field_value}"
1841 # func_get_applicability module
1843 # - local_gnulib_dir from --local-dir
1844 # - modcache true or false, from --cache-modules/--no-cache-modules
1845 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1846 func_get_applicability ()
1848 if ! $modcache; then
1849 func_lookup_file "modules/$1"
1850 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1852 func_cache_lookup_module "$1"
1853 # Get the field's value, without the final newline.
1854 if $have_associative; then
1855 my_applicability="${modcache_applicability[$1]}"
1857 eval "my_applicability=\"\$${cachevar}_applicability\""
1860 if test -n "$my_applicability"; then
1861 echo $my_applicability
1863 # The default is 'main' or 'tests', depending on the module's name.
1865 *-tests) echo "tests";;
1871 # func_get_filelist module
1873 # - local_gnulib_dir from --local-dir
1874 # - modcache true or false, from --cache-modules/--no-cache-modules
1875 func_get_filelist ()
1877 if ! $modcache; then
1878 func_lookup_file "modules/$1"
1879 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1881 func_cache_lookup_module "$1"
1882 # Output the field's value, including the final newline (if any).
1883 if $have_associative; then
1884 if test -n "${modcache_files[$1]+set}"; then
1885 echo "${modcache_files[$1]}"
1888 eval "field_set=\"\$${cachevar}_files_set\""
1889 if test -n "$field_set"; then
1890 eval "field_value=\"\$${cachevar}_files\""
1891 echo "${field_value}"
1896 echo m4/gnulib-common.m4
1897 case "$autoconf_minversion" in
1904 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1905 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1906 # elements starting with prefix and ending with suffix are considered.
1907 # Processing: removed_prefix and removed_suffix are removed from each element,
1908 # added_prefix and added_suffix are added to each element.
1909 # prefix, suffix should not contain shell-special characters.
1910 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1911 # added_prefix, added_suffix should not contain the characters \|&.
1912 func_filter_filelist ()
1914 if test "$2" != "$nl" \
1915 || { $fast_func_append \
1916 && { test -z "$6" || $fast_func_remove_prefix; } \
1917 && { test -z "$7" || $fast_func_remove_suffix; }; \
1921 # Do not quote possibly-empty parameters in case patterns,
1922 # AIX and HP-UX ksh won't match them if they are empty.
1925 if test -n "$6"; then
1926 func_remove_prefix fff "$6"
1928 if test -n "$7"; then
1929 func_remove_suffix fff "$7"
1932 if test -z "$ffflist"; then
1935 func_append ffflist "$2${fff}"
1941 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1942 ffflist=`for fff in $3; do
1944 $4*$5) echo "$fff" ;;
1946 done | sed -e "$sed_fff_filter"`
1948 eval "$1=\"\$ffflist\""
1951 # func_get_dependencies module
1953 # - local_gnulib_dir from --local-dir
1954 # - modcache true or false, from --cache-modules/--no-cache-modules
1955 func_get_dependencies ()
1957 # ${module}-tests always implicitly depends on ${module}.
1961 func_remove_suffix fgd1 '-tests'
1965 # Then the explicit dependencies listed in the module description.
1966 if ! $modcache; then
1967 func_lookup_file "modules/$1"
1968 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1970 func_cache_lookup_module "$1"
1971 # Output the field's value, including the final newline (if any).
1972 if $have_associative; then
1973 if test -n "${modcache_dependson[$1]+set}"; then
1974 echo "${modcache_dependson[$1]}"
1977 eval "field_set=\"\$${cachevar}_dependson_set\""
1978 if test -n "$field_set"; then
1979 eval "field_value=\"\$${cachevar}_dependson\""
1980 echo "${field_value}"
1986 # func_get_autoconf_early_snippet module
1988 # - local_gnulib_dir from --local-dir
1989 # - modcache true or false, from --cache-modules/--no-cache-modules
1990 func_get_autoconf_early_snippet ()
1992 if ! $modcache; then
1993 func_lookup_file "modules/$1"
1994 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1996 func_cache_lookup_module "$1"
1997 # Output the field's value, including the final newline (if any).
1998 if $have_associative; then
1999 if test -n "${modcache_configureac_early[$1]+set}"; then
2000 echo "${modcache_configureac_early[$1]}"
2003 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2004 if test -n "$field_set"; then
2005 eval "field_value=\"\$${cachevar}_configureac_early\""
2006 echo "${field_value}"
2012 # func_get_autoconf_snippet module
2014 # - local_gnulib_dir from --local-dir
2015 # - modcache true or false, from --cache-modules/--no-cache-modules
2016 func_get_autoconf_snippet ()
2018 if ! $modcache; then
2019 func_lookup_file "modules/$1"
2020 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2022 func_cache_lookup_module "$1"
2023 # Output the field's value, including the final newline (if any).
2024 if $have_associative; then
2025 if test -n "${modcache_configureac[$1]+set}"; then
2026 echo "${modcache_configureac[$1]}"
2029 eval "field_set=\"\$${cachevar}_configureac_set\""
2030 if test -n "$field_set"; then
2031 eval "field_value=\"\$${cachevar}_configureac\""
2032 echo "${field_value}"
2038 # func_get_automake_snippet module
2040 # - local_gnulib_dir from --local-dir
2041 # - modcache true or false, from --cache-modules/--no-cache-modules
2042 func_get_automake_snippet ()
2044 if ! $modcache; then
2045 func_lookup_file "modules/$1"
2046 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2048 func_cache_lookup_module "$1"
2049 # Output the field's value, including the final newline (if any).
2050 if $have_associative; then
2051 if test -n "${modcache_makefile[$1]+set}"; then
2052 echo "${modcache_makefile[$1]}"
2055 eval "field_set=\"\$${cachevar}_makefile_set\""
2056 if test -n "$field_set"; then
2057 eval "field_value=\"\$${cachevar}_makefile\""
2058 echo "${field_value}"
2064 # *-tests module live in tests/, not lib/.
2065 # Synthesize an EXTRA_DIST augmentation.
2066 all_files=`func_get_filelist $1`
2067 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2068 extra_files="$tests_files"
2069 if test -n "$extra_files"; then
2070 echo "EXTRA_DIST +=" $extra_files
2075 # Synthesize an EXTRA_DIST augmentation.
2076 sed_combine_lines='/\\$/{
2083 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2084 already_mentioned_files=` \
2085 { if ! $modcache; then
2086 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2088 if $have_associative; then
2089 if test -n "${modcache_makefile[$1]+set}"; then
2090 echo "${modcache_makefile[$1]}"
2093 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2094 if test -n "$field_set"; then
2095 eval 'field_value="$'"${cachevar}"'_makefile"'
2096 echo "${field_value}"
2101 | sed -e "$sed_combine_lines" \
2102 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2103 all_files=`func_get_filelist $1`
2104 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2105 # Remove $already_mentioned_files from $lib_files.
2106 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2107 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2108 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2109 if test -n "$extra_files"; then
2110 echo "EXTRA_DIST +=" $extra_files
2113 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2114 # This is necessary so that automake can generate the right list of
2116 # A possible approach would be to use autom4te --trace of the redefined
2117 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2118 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2119 # inside autoconf's built-in macros are not missed).
2120 # But it's simpler and more robust to do it here, based on the file list.
2121 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2122 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2123 # automake will generate a useless dependency; this is harmless.
2125 relocatable-prog-wrapper) ;;
2127 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2128 if test -n "$extra_files"; then
2129 echo "EXTRA_lib_SOURCES +=" $extra_files
2134 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2135 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2136 if test -n "$buildaux_files"; then
2137 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2138 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2141 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2142 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2143 if test -n "$top_files"; then
2144 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2145 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2152 # func_get_include_directive module
2154 # - local_gnulib_dir from --local-dir
2155 # - modcache true or false, from --cache-modules/--no-cache-modules
2156 func_get_include_directive ()
2159 if ! $modcache; then
2160 func_lookup_file "modules/$1"
2161 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2163 func_cache_lookup_module "$1"
2164 # Output the field's value, including the final newline (if any).
2165 if $have_associative; then
2166 if test -n "${modcache_include[$1]+set}"; then
2167 echo "${modcache_include[$1]}"
2170 eval "field_set=\"\$${cachevar}_include_set\""
2171 if test -n "$field_set"; then
2172 eval "field_value=\"\$${cachevar}_include\""
2173 echo "${field_value}"
2177 } | sed -e 's/^\(["<]\)/#include \1/'
2180 # func_get_link_directive module
2182 # - local_gnulib_dir from --local-dir
2183 # - modcache true or false, from --cache-modules/--no-cache-modules
2184 func_get_link_directive ()
2186 if ! $modcache; then
2187 func_lookup_file "modules/$1"
2188 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2190 func_cache_lookup_module "$1"
2191 # Output the field's value, including the final newline (if any).
2192 if $have_associative; then
2193 if test -n "${modcache_link[$1]+set}"; then
2194 echo "${modcache_link[$1]}"
2197 eval "field_set=\"\$${cachevar}_link_set\""
2198 if test -n "$field_set"; then
2199 eval "field_value=\"\$${cachevar}_link\""
2200 echo "${field_value}"
2206 # func_get_license module
2208 # - local_gnulib_dir from --local-dir
2209 # - modcache true or false, from --cache-modules/--no-cache-modules
2213 if ! $modcache; then
2214 func_lookup_file "modules/$1"
2215 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2217 func_cache_lookup_module "$1"
2218 # Output the field's value, including the final newline (if any).
2219 if $have_associative; then
2220 if test -n "${modcache_license[$1]+set}"; then
2221 echo "${modcache_license[$1]}"
2224 eval "field_set=\"\$${cachevar}_license_set\""
2225 if test -n "$field_set"; then
2226 eval "field_value=\"\$${cachevar}_license\""
2227 echo "${field_value}"
2231 # The default is GPL.
2233 } | sed -e 's,^ *$,,' | sed -e 1q
2236 # func_get_maintainer module
2238 # - local_gnulib_dir from --local-dir
2239 # - modcache true or false, from --cache-modules/--no-cache-modules
2240 func_get_maintainer ()
2242 if ! $modcache; then
2243 func_lookup_file "modules/$1"
2244 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2246 func_cache_lookup_module "$1"
2247 # Output the field's value, including the final newline (if any).
2248 if $have_associative; then
2249 if test -n "${modcache_maintainer[$1]+set}"; then
2250 echo "${modcache_maintainer[$1]}"
2253 eval "field_set=\"\$${cachevar}_maintainer_set\""
2254 if test -n "$field_set"; then
2255 eval "field_value=\"\$${cachevar}_maintainer\""
2256 echo "${field_value}"
2262 # func_get_tests_module module
2264 # - local_gnulib_dir from --local-dir
2265 func_get_tests_module ()
2267 # The naming convention for tests modules is hardwired: ${module}-tests.
2268 if test -f "$gnulib_dir/modules/$1"-tests \
2269 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2270 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2275 # func_acceptable module
2276 # tests whether a module is acceptable.
2278 # - inc_cxx_tests true if C++ interoperability tests should be included,
2280 # - inc_longrunning_tests true if long-runnings tests should be included,
2282 # - inc_privileged_tests true if tests that require root privileges should be
2283 # included, blank otherwise
2284 # - inc_unportable_tests true if tests that fail on some platforms should be
2285 # included, blank otherwise
2286 # - inc_all_tests true if all kinds of problematic unit tests should be
2287 # included, blank otherwise
2288 # - avoidlist list of modules to avoid
2291 for avoid in $avoidlist; do
2292 if test "$avoid" = "$1"; then
2299 for word in `func_get_status "$1"`; do
2302 test -n "$inc_all_tests" || test -n "$inc_cxx_tests" \
2306 test -n "$inc_all_tests" || test -n "$inc_longrunning_tests" \
2310 test -n "$inc_all_tests" || test -n "$inc_privileged_tests" \
2314 test -n "$inc_all_tests" || test -n "$inc_unportable_tests" \
2318 test -n "$inc_all_tests" \
2331 # func_modules_transitive_closure
2333 # - local_gnulib_dir from --local-dir
2334 # - modcache true or false, from --cache-modules/--no-cache-modules
2335 # - modules list of specified modules
2336 # - inctests true if tests should be included, blank otherwise
2337 # - incobsolete true if obsolete modules among dependencies should be
2338 # included, blank otherwise
2339 # - inc_cxx_tests true if C++ interoperability tests should be included,
2341 # - inc_longrunning_tests true if long-runnings tests should be included,
2343 # - inc_privileged_tests true if tests that require root privileges should be
2344 # included, blank otherwise
2345 # - inc_unportable_tests true if tests that fail on some platforms should be
2346 # included, blank otherwise
2347 # - inc_all_tests true if all kinds of problematic unit tests should be
2348 # included, blank otherwise
2349 # - avoidlist list of modules to avoid
2350 # - tmp pathname of a temporary directory
2352 # - modules list of modules, including dependencies
2353 func_modules_transitive_closure ()
2355 # In order to process every module only once (for speed), process an "input
2356 # list" of modules, producing an "output list" of modules. During each round,
2357 # more modules can be queued in the input list. Once a module on the input
2358 # list has been processed, it is added to the "handled list", so we can avoid
2359 # to process it again.
2361 inmodules="$modules"
2363 while test -n "$inmodules"; do
2364 inmodules_this_round="$inmodules"
2365 inmodules= # Accumulator, queue for next round
2366 for module in $inmodules_this_round; do
2368 if test -n "$module"; then
2369 if func_acceptable $module; then
2370 func_append outmodules " $module"
2371 deps=`func_get_dependencies $module`
2372 # Duplicate dependencies are harmless, but Jim wants a warning.
2373 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2374 if test -n "$duplicated_deps"; then
2375 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2377 for dep in $deps; do
2378 if test -n "$incobsolete" \
2380 for word in `func_get_status $dep`; do
2389 func_append inmodules " $dep"
2392 if test -n "$inctests"; then
2393 testsmodule=`func_get_tests_module $module`
2394 if test -n "$testsmodule"; then
2395 func_append inmodules " $testsmodule"
2401 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2402 # Remove $handledmodules from $inmodules.
2403 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2404 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2406 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2407 rm -f "$tmp"/queued-modules
2410 # func_modules_add_dummy
2412 # - local_gnulib_dir from --local-dir
2413 # - modcache true or false, from --cache-modules/--no-cache-modules
2414 # - modules list of modules, including dependencies
2416 # - modules list of modules, including 'dummy' if needed
2417 func_modules_add_dummy ()
2419 # Determine whether any module provides a lib_SOURCES augmentation.
2421 sed_remove_backslash_newline=':a
2428 for module in $modules; do
2429 func_verify_nontests_module
2430 if test -n "$module"; then
2431 # Extract the value of "lib_SOURCES += ...".
2432 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2433 # Ignore .h files since they are not compiled.
2437 have_lib_SOURCES=yes
2444 # Add the dummy module, to make sure the library will be non-empty.
2445 if test -z "$have_lib_SOURCES"; then
2446 if func_acceptable "dummy"; then
2447 func_append modules " dummy"
2452 # func_modules_notice
2454 # - local_gnulib_dir from --local-dir
2455 # - modcache true or false, from --cache-modules/--no-cache-modules
2456 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2457 # - modules list of modules, including dependencies
2458 func_modules_notice ()
2460 if test $verbose -ge -1; then
2461 for module in $modules; do
2463 if test -n "$module"; then
2464 msg=`func_get_notice $module`
2465 if test -n "$msg"; then
2466 echo "Notice from module $module:"
2467 echo "$msg" | sed -e 's/^/ /'
2474 # func_modules_to_filelist
2476 # - local_gnulib_dir from --local-dir
2477 # - modcache true or false, from --cache-modules/--no-cache-modules
2478 # - modules list of modules, including dependencies
2480 # - files list of files
2481 func_modules_to_filelist ()
2484 for module in $modules; do
2486 if test -n "$module"; then
2487 fs=`func_get_filelist $module`
2488 func_append files " $fs"
2491 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2494 # func_execute_command command [args...]
2495 # Executes a command.
2496 # Uses also the variables
2497 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2498 func_execute_command ()
2500 if test $verbose -ge 0; then
2504 # Commands like automake produce output to stderr even when they succeed.
2505 # Turn this output off if the command succeeds.
2506 "$@" > "$tmp"/cmdout 2>&1
2508 if test $cmdret = 0; then
2512 cat "$tmp"/cmdout 1>&2
2519 # func_dest_tmpfilename file
2520 # determines the name of a temporary file (file is relative to destdir).
2522 # - destdir target directory
2523 # - doit : if actions shall be executed, false if only to be printed
2524 # - tmp pathname of a temporary directory
2526 # - tmpfile absolute filename of the temporary file
2527 func_dest_tmpfilename ()
2530 # Put the new contents of $file in a file in the same directory (needed
2531 # to guarantee that an 'mv' to "$destdir/$file" works).
2532 tmpfile="$destdir/$1.tmp"
2534 # Put the new contents of $file in a file in a temporary directory
2535 # (because the directory of "$file" might not exist).
2536 tmpfile="$tmp"/`basename "$1"`.tmp
2541 # copies a file from gnulib into the destination directory. The destination
2542 # is known to not exist.
2544 # - destdir target directory
2545 # - local_gnulib_dir from --local-dir
2546 # - modcache true or false, from --cache-modules/--no-cache-modules
2547 # - f the original file name
2548 # - lookedup_file name of the merged (combined) file
2549 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2550 # - g the rewritten file name
2551 # - tmpfile absolute filename of the temporary file
2552 # - doit : if actions shall be executed, false if only to be printed
2553 # - symbolic true if files should be symlinked, copied otherwise
2554 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2559 echo "Copying file $g"
2560 if { test -n "$symbolic" \
2561 || { test -n "$lsymbolic" \
2562 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2563 && test -z "$lookedup_tmp" \
2564 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2565 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2567 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2575 # copies a file from gnulib into the destination directory. The destination
2576 # is known to exist.
2578 # - destdir target directory
2579 # - local_gnulib_dir from --local-dir
2580 # - modcache true or false, from --cache-modules/--no-cache-modules
2581 # - f the original file name
2582 # - lookedup_file name of the merged (combined) file
2583 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2584 # - g the rewritten file name
2585 # - tmpfile absolute filename of the temporary file
2586 # - doit : if actions shall be executed, false if only to be printed
2587 # - symbolic true if files should be symlinked, copied otherwise
2588 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2590 # - already_present nonempty if the file should already exist, empty otherwise
2593 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2594 : # The file has not changed.
2598 if test -n "$already_present"; then
2599 echo "Updating file $g (backup in ${g}~)"
2601 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2603 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2604 if { test -n "$symbolic" \
2605 || { test -n "$lsymbolic" \
2606 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2607 && test -z "$lookedup_tmp" \
2608 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2609 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2611 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2614 if test -n "$already_present"; then
2615 echo "Update file $g (backup in ${g}~)"
2617 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2623 # func_emit_lib_Makefile_am
2624 # emits the contents of library makefile to standard output.
2626 # - local_gnulib_dir from --local-dir
2627 # - modcache true or false, from --cache-modules/--no-cache-modules
2628 # - modules list of modules, including dependencies
2629 # - libname library name
2630 # - pobase directory relative to destdir where to place *.po files
2631 # - auxdir directory relative to destdir where to place build aux files
2632 # - makefile_name from --makefile-name
2633 # - libtool true if libtool will be used, false or blank otherwise
2634 # - macro_prefix prefix of gl_LIBOBJS macros to use
2635 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2636 # - actioncmd (optional) command that will reproduce this invocation
2637 # - for_test true if creating a package for testing, false otherwise
2638 # - destfile filename relative to destdir of makefile being generated
2640 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2641 # list of edits to be done to Makefile.am variables
2643 # - uses_subdirs nonempty if object files in subdirs exist
2644 func_emit_lib_Makefile_am ()
2646 # When creating an includable Makefile.am snippet, augment variables with
2647 # += instead of assigning them.
2648 if test -n "$makefile_name"; then
2653 if test "$libtool" = true; then
2656 sed_eliminate_LDFLAGS="$sed_noop"
2660 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2663 # When creating a package for testing: Attempt to provoke failures,
2664 # especially link errors, already during "make" rather than during
2665 # "make check", because "make check" is not possible in a cross-compiling
2666 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2667 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2669 sed_transform_check_PROGRAMS="$sed_noop"
2671 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2672 echo "## Process this file with automake to produce Makefile.in."
2673 func_emit_copyright_notice
2674 if test -n "$actioncmd"; then
2675 # The maximum line length (excluding the terminating newline) of any file
2676 # that is to be preprocessed by config.status is 3070. config.status uses
2677 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2678 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2679 len=`echo "$actioncmd" | wc -c`
2680 if test -n "$len" && test "$len" -le 3000; then
2681 echo "# Reproduce by: $actioncmd"
2687 for module in $modules; do
2688 func_verify_nontests_module
2689 if test -n "$module"; then
2691 func_get_automake_snippet "$module" |
2693 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2694 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2695 -e "$sed_eliminate_LDFLAGS" \
2696 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2697 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2698 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2699 -e "$sed_transform_check_PROGRAMS"
2700 if test "$module" = 'alloca'; then
2701 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2702 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2704 } > "$tmp"/amsnippet
2705 # Skip the contents if it's entirely empty.
2706 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2707 echo "## begin gnulib module $module"
2709 cat "$tmp"/amsnippet
2710 echo "## end gnulib module $module"
2713 rm -f "$tmp"/amsnippet
2714 # Test whether there are some source files in subdirectories.
2715 for f in `func_get_filelist "$module"`; do
2725 } > "$tmp"/allsnippets
2726 if test -z "$makefile_name"; then
2727 # If there are source files in subdirectories, prevent collision of the
2728 # object files (example: hash.c and libxml/hash.c).
2730 if test -n "$uses_subdirs"; then
2731 subdir_options=' subdir-objects'
2733 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2736 if test -z "$makefile_name"; then
2738 echo "noinst_HEADERS ="
2739 echo "noinst_LIBRARIES ="
2740 echo "noinst_LTLIBRARIES ="
2741 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2742 # if you specify pkgdata_DATA to empty. This is a workaround.
2743 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2744 echo "pkgdata_DATA ="
2747 echo "BUILT_SOURCES ="
2750 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2751 if test -z "$makefile_name"; then
2752 echo "MOSTLYCLEANDIRS ="
2754 echo "DISTCLEANFILES ="
2755 echo "MAINTAINERCLEANFILES ="
2757 # Execute edits that apply to the Makefile.am being generated.
2759 while test $edit != $makefile_am_edits; do
2760 edit=`expr $edit + 1`
2761 eval dir=\"\$makefile_am_edit${edit}_dir\"
2762 eval var=\"\$makefile_am_edit${edit}_var\"
2763 eval val=\"\$makefile_am_edit${edit}_val\"
2764 if test -n "$var"; then
2765 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2766 echo "${var} += ${val}"
2767 eval "makefile_am_edit${edit}_var="
2771 if test -z "$makefile_name"; then
2773 echo "AM_CPPFLAGS ="
2777 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2778 || { test -n "$makefile_name" \
2779 && test -f "$sourcebase/Makefile.am" \
2780 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2782 # One of the snippets or the user's Makefile.am already specifies an
2783 # installation location for the library. Don't confuse automake by saying
2784 # it should not be installed.
2787 # By default, the generated library should not be installed.
2788 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2791 echo "${libname}_${libext}_SOURCES ="
2792 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2793 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2794 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2795 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2796 echo "EXTRA_${libname}_${libext}_SOURCES ="
2797 if test "$libtool" = true; then
2798 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2801 if test -n "$pobase"; then
2802 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2805 cat "$tmp"/allsnippets \
2806 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2808 echo "mostlyclean-local: mostlyclean-generic"
2809 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2810 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2811 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2815 rm -f "$tmp"/allsnippets
2818 # func_emit_po_Makevars
2819 # emits the contents of po/ makefile parameterization to standard output.
2821 # - local_gnulib_dir from --local-dir
2822 # - modcache true or false, from --cache-modules/--no-cache-modules
2823 # - sourcebase directory relative to destdir where to place source code
2824 # - pobase directory relative to destdir where to place *.po files
2825 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2826 func_emit_po_Makevars ()
2828 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2829 func_emit_copyright_notice
2831 echo "# Usually the message domain is the same as the package name."
2832 echo "# But here it has a '-gnulib' suffix."
2833 echo "DOMAIN = ${po_domain}-gnulib"
2835 echo "# These two variables depend on the location of this directory."
2836 echo "subdir = ${pobase}"
2837 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2840 # These options get passed to xgettext.
2841 XGETTEXT_OPTIONS = \
2842 --keyword=_ --flag=_:1:pass-c-format \
2843 --keyword=N_ --flag=N_:1:pass-c-format \
2844 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2845 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2846 --flag=error:3:c-format --flag=error_at_line:5:c-format
2848 # This is the copyright holder that gets inserted into the header of the
2849 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2850 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2852 # This is the email address or URL to which the translators shall report
2853 # bugs in the untranslated strings:
2854 # - Strings which are not entire sentences, see the maintainer guidelines
2855 # in the GNU gettext documentation, section 'Preparing Strings'.
2856 # - Strings which use unclear terms or require additional context to be
2858 # - Strings which make invalid assumptions about notation of date, time or
2860 # - Pluralisation problems.
2861 # - Incorrect English spelling.
2862 # - Incorrect formatting.
2863 # It can be your email address, or a mailing list address where translators
2864 # can write to without being subscribed, or the URL of a web page through
2865 # which the translators can contact you.
2866 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2868 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2869 # message catalogs shall be used. It is usually empty.
2870 EXTRA_LOCALE_CATEGORIES =
2872 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2873 # context. Possible values are "yes" and "no". Set this to yes if the
2874 # package uses functions taking also a message context, like pgettext(), or
2875 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2880 # func_emit_po_POTFILES_in
2881 # emits the file list to be passed to xgettext to standard output.
2883 # - local_gnulib_dir from --local-dir
2884 # - modcache true or false, from --cache-modules/--no-cache-modules
2885 # - sourcebase directory relative to destdir where to place source code
2886 # - files list of new files
2887 func_emit_po_POTFILES_in ()
2889 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2890 func_emit_copyright_notice
2892 echo "# List of files which contain translatable strings."
2893 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2896 # func_emit_tests_Makefile_am witness_macro
2897 # emits the contents of tests makefile to standard output.
2899 # - local_gnulib_dir from --local-dir
2900 # - modcache true or false, from --cache-modules/--no-cache-modules
2901 # - modules list of modules, including dependencies
2902 # - libname library name
2903 # - auxdir directory relative to destdir where to place build aux files
2904 # - makefile_name from --makefile-name
2905 # - libtool true if libtool will be used, false or blank otherwise
2906 # - sourcebase relative directory containing lib source code
2907 # - m4base relative directory containing autoconf macros
2908 # - testsbase relative directory containing unit test code
2909 # - macro_prefix prefix of gl_LIBOBJS macros to use
2910 # - for_test true if creating a package for testing, false otherwise
2911 # - use_libtests true if a libtests.a should be built, false otherwise
2912 # - destfile filename relative to destdir of makefile being generated
2914 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2915 # list of edits to be done to Makefile.am variables
2917 # - uses_subdirs nonempty if object files in subdirs exist
2918 func_emit_tests_Makefile_am ()
2921 if test "$libtool" = true; then
2923 sed_eliminate_LDFLAGS="$sed_noop"
2926 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2929 # When creating a package for testing: Attempt to provoke failures,
2930 # especially link errors, already during "make" rather than during
2931 # "make check", because "make check" is not possible in a cross-compiling
2932 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2933 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2935 sed_transform_check_PROGRAMS="$sed_noop"
2937 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2938 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2939 echo "## Process this file with automake to produce Makefile.in."
2940 func_emit_copyright_notice
2944 for module in $modules; do
2946 func_verify_tests_module
2950 if test -n "$module"; then
2952 func_get_automake_snippet "$module" |
2954 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2955 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2956 -e "$sed_eliminate_LDFLAGS" \
2957 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2958 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2959 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2960 -e "$sed_transform_check_PROGRAMS"
2961 if $use_libtests && test "$module" = 'alloca'; then
2962 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2963 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2965 } > "$tmp"/amsnippet
2966 # Skip the contents if it's entirely empty.
2967 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2968 echo "## begin gnulib module $module"
2970 cat "$tmp"/amsnippet
2971 echo "## end gnulib module $module"
2974 rm -f "$tmp"/amsnippet
2975 # Test whether there are some source files in subdirectories.
2976 for f in `func_get_filelist "$module"`; do
2978 lib/*/*.c | tests/*/*.c)
2986 } > "$tmp"/allsnippets
2987 # Generate dependencies here, since it eases the debugging of test failures.
2988 # If there are source files in subdirectories, prevent collision of the
2989 # object files (example: hash.c and libxml/hash.c).
2991 if test -n "$uses_subdirs"; then
2992 subdir_options=' subdir-objects'
2994 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2997 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3000 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3001 # variable is needed to avoid an error from automake:
3002 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3005 echo "XFAIL_TESTS ="
3006 echo "TESTS_ENVIRONMENT ="
3007 echo "noinst_PROGRAMS ="
3008 if ! $for_test; then
3009 echo "check_PROGRAMS ="
3011 echo "noinst_HEADERS ="
3012 echo "noinst_LIBRARIES ="
3013 if $use_libtests; then
3015 echo "noinst_LIBRARIES += libtests.a"
3017 echo "check_LIBRARIES = libtests.a"
3020 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3021 # if you specify pkgdata_DATA to empty. This is a workaround.
3022 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3023 echo "pkgdata_DATA ="
3026 echo "BUILT_SOURCES ="
3028 echo "MOSTLYCLEANFILES = core *.stackdump"
3029 echo "MOSTLYCLEANDIRS ="
3031 echo "DISTCLEANFILES ="
3032 echo "MAINTAINERCLEANFILES ="
3033 # Execute edits that apply to the Makefile.am being generated.
3035 while test $edit != $makefile_am_edits; do
3036 edit=`expr $edit + 1`
3037 eval dir=\"\$makefile_am_edit${edit}_dir\"
3038 eval var=\"\$makefile_am_edit${edit}_var\"
3039 eval val=\"\$makefile_am_edit${edit}_val\"
3040 if test -n "$var"; then
3041 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3042 echo "${var} += ${val}"
3043 eval "makefile_am_edit${edit}_var="
3048 echo "AM_CPPFLAGS = \\"
3049 if test -n "${witness_macro}"; then
3050 echo " -D@${witness_macro}@=1 \\"
3052 echo " -I. -I\$(srcdir) \\"
3053 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3054 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3056 local_ldadd_before=''
3057 local_ldadd_after=''
3058 if $use_libtests; then
3059 # All test programs need to be linked with libtests.a.
3060 # It needs to be passed to the linker before ${libname}.${libext}, since
3061 # the tests-related modules depend on the main modules.
3062 # It also needs to be passed to the linker after ${libname}.${libext}
3063 # because the latter might contain incomplete modules (such as the 'error'
3064 # module whose dependency to 'progname' is voluntarily omitted).
3065 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3067 local_ldadd_before=' libtests.a'
3068 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3070 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3072 if $use_libtests; then
3073 echo "libtests_a_SOURCES ="
3074 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3075 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3076 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3077 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3078 echo "EXTRA_libtests_a_SOURCES ="
3079 # The circular dependency in LDADD requires this.
3080 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3083 # Many test scripts use ${EXEEXT} or ${srcdir}.
3084 # EXEEXT is defined by AC_PROG_CC through autoconf.
3085 # srcdir is defined by autoconf and automake.
3086 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3088 cat "$tmp"/allsnippets \
3089 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3090 echo "# Clean up after Solaris cc."
3092 echo " rm -rf SunWS_cache"
3094 echo "mostlyclean-local: mostlyclean-generic"
3095 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3096 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3097 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3101 rm -f "$tmp"/allsnippets
3104 # func_emit_initmacro_start macro_prefix
3105 # emits the first few statements of the gl_INIT macro to standard output.
3106 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3107 func_emit_initmacro_start ()
3109 macro_prefix_arg="$1"
3110 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3111 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3112 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3113 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3115 # Furthermore it avoids an automake error like this when a Makefile.am
3116 # that uses pieces of gnulib also uses $(LIBOBJ):
3117 # automatically discovered file `error.c' should not be explicitly mentioned
3118 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3119 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3120 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3121 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3122 # automatically discovered file `error.c' should not be explicitly mentioned
3123 # We let automake know about the files to be distributed through the
3124 # EXTRA_lib_SOURCES variable.
3125 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3126 # Create data variables for checking the presence of files that are mentioned
3127 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3128 # because we want the check to happen when the configure file is created,
3129 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3130 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3131 # in which to expect them.
3132 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3133 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3137 # func_emit_initmacro_end macro_prefix
3138 # emits the last few statements of the gl_INIT macro to standard output.
3139 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3140 func_emit_initmacro_end ()
3142 macro_prefix_arg="$1"
3143 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3144 # The check is performed only when autoconf is run from the directory where
3145 # the configure.ac resides; if it is run from a different directory, the
3147 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3148 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3149 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3150 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3151 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3155 echo " m4_if(m4_sysval, [0], [],"
3156 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3158 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3159 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3160 echo " m4_popdef([AC_LIBSOURCES])"
3161 echo " m4_popdef([AC_REPLACE_FUNCS])"
3162 echo " m4_popdef([AC_LIBOBJ])"
3163 echo " AC_CONFIG_COMMANDS_PRE(["
3164 echo " ${macro_prefix_arg}_libobjs="
3165 echo " ${macro_prefix_arg}_ltlibobjs="
3166 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3167 echo " # Remove the extension."
3168 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3169 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3170 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3171 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3174 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3175 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3179 # func_emit_initmacro_done macro_prefix sourcebase
3180 # emits a few statements after the gl_INIT macro to standard output.
3181 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3182 # - sourcebase directory relative to destdir where to place source code
3183 func_emit_initmacro_done ()
3185 macro_prefix_arg="$1"
3188 echo "# Like AC_LIBOBJ, except that the module name goes"
3189 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3190 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3191 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3192 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3195 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3196 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3197 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3198 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3199 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3202 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3203 echo "# expected is derived from the gnulib-tool parameterization,"
3204 echo "# and alloca is special cased (for the alloca-opt module)."
3205 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3206 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3207 echo " m4_foreach([_gl_NAME], [\$1], ["
3208 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3209 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3210 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3216 # func_import modules
3217 # Uses also the variables
3218 # - destdir target directory
3219 # - local_gnulib_dir from --local-dir
3220 # - modcache true or false, from --cache-modules/--no-cache-modules
3221 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3222 # - libname library name
3223 # - sourcebase directory relative to destdir where to place source code
3224 # - m4base directory relative to destdir where to place *.m4 macros
3225 # - pobase directory relative to destdir where to place *.po files
3226 # - docbase directory relative to destdir where to place doc files
3227 # - testsbase directory relative to destdir where to place unit test code
3228 # - auxdir directory relative to destdir where to place build aux files
3229 # - inctests true if --with-tests was given, blank otherwise
3230 # - incobsolete true if --with-obsolete was given, blank otherwise
3231 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3232 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3234 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3236 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3238 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3239 # - avoidlist list of modules to avoid, from --avoid
3240 # - lgpl yes or a number if library's license shall be LGPL,
3242 # - makefile_name from --makefile-name
3243 # - libtool true if --libtool was given, false if --no-libtool was
3244 # given, blank otherwise
3245 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3246 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3247 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3248 # - vc_files true if --vc-files was given, false if --no-vc-files was
3249 # given, blank otherwise
3250 # - autoconf_minversion minimum supported autoconf version
3251 # - doit : if actions shall be executed, false if only to be printed
3252 # - symbolic true if files should be symlinked, copied otherwise
3253 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3255 # - do_copyrights true if copyright notices in files should be replaced,
3259 # Get the cached settings.
3260 cached_local_gnulib_dir=
3261 cached_specified_modules=
3263 cached_inc_cxx_tests=
3264 cached_inc_longrunning_tests=
3265 cached_inc_privileged_tests=
3266 cached_inc_unportable_tests=
3267 cached_inc_all_tests=
3277 cached_makefile_name=
3279 cached_macro_prefix=
3283 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3284 cached_libtool=false
3290 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3300 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3302 /gl_WITH_OBSOLETE/ {
3303 s,^.*$,cached_incobsolete=true,p
3305 /gl_WITH_CXX_TESTS/ {
3306 s,^.*$,cached_inc_cxx_tests=true,p
3308 /gl_WITH_LONGRUNNING_TESTS/ {
3309 s,^.*$,cached_inc_longrunning_tests=true,p
3311 /gl_WITH_PRIVILEGED_TESTS/ {
3312 s,^.*$,cached_inc_privileged_tests=true,p
3314 /gl_WITH_UNPORTABLE_TESTS/ {
3315 s,^.*$,cached_inc_unportable_tests=true,p
3317 /gl_WITH_ALL_TESTS/ {
3318 s,^.*$,cached_inc_all_tests=true,p
3321 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3324 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3327 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3330 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3333 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3336 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3339 s,^.*$,cached_inctests=true,p
3342 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3345 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3348 s,^.*$,cached_lgpl=yes,p
3350 /gl_MAKEFILE_NAME(/ {
3351 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3354 s,^.*$,cached_libtool=true,p
3356 /gl_MACRO_PREFIX(/ {
3357 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3360 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3363 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3365 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3366 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3371 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3372 s,^.*$,cached_files=",p
3385 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3389 # Merge the cached settings with the specified ones.
3390 # The m4base must be the same as expected from the pathname.
3391 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3392 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3394 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3395 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3396 if test -z "$local_gnulib_dir"; then
3397 if test -n "$cached_local_gnulib_dir"; then
3400 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3402 case "$cached_local_gnulib_dir" in
3404 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3406 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3407 local_gnulib_dir="$relconcat" ;;
3412 # Append the cached and the specified module names. So that
3413 # "gnulib-tool --import foo" means to add the module foo.
3414 specified_modules="$cached_specified_modules $1"
3415 # Included obsolete modules among the dependencies if specified either way.
3416 if test -z "$incobsolete"; then
3417 incobsolete="$cached_incobsolete"
3419 # Included special kinds of tests modules among the dependencies if specified
3421 if test -z "$inc_cxx_tests"; then
3422 inc_cxx_tests="$cached_inc_cxx_tests"
3424 if test -z "$inc_longrunning_tests"; then
3425 inc_longrunning_tests="$cached_inc_longrunning_tests"
3427 if test -z "$inc_privileged_tests"; then
3428 inc_privileged_tests="$cached_inc_privileged_tests"
3430 if test -z "$inc_unportable_tests"; then
3431 inc_unportable_tests="$cached_inc_unportable_tests"
3433 if test -z "$inc_all_tests"; then
3434 inc_all_tests="$cached_inc_all_tests"
3436 # Append the cached and the specified avoidlist. This is probably better
3437 # than dropping the cached one when --avoid is specified at least once.
3438 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3439 avoidlist=`echo $avoidlist`
3441 # The sourcebase defaults to the cached one.
3442 if test -z "$sourcebase"; then
3443 sourcebase="$cached_sourcebase"
3444 if test -z "$sourcebase"; then
3445 func_fatal_error "missing --source-base option"
3448 # The pobase defaults to the cached one.
3449 if test -z "$pobase"; then
3450 pobase="$cached_pobase"
3452 # The docbase defaults to the cached one.
3453 if test -z "$docbase"; then
3454 docbase="$cached_docbase"
3455 if test -z "$docbase"; then
3456 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."
3459 # The testsbase defaults to the cached one.
3460 if test -z "$testsbase"; then
3461 testsbase="$cached_testsbase"
3462 if test -z "$testsbase"; then
3463 func_fatal_error "missing --tests-base option"
3466 # Require the tests if specified either way.
3467 if test -z "$inctests"; then
3468 inctests="$cached_inctests"
3470 # The libname defaults to the cached one.
3471 if test -z "$supplied_libname"; then
3472 libname="$cached_libname"
3473 if test -z "$libname"; then
3474 func_fatal_error "missing --lib option"
3477 # Require LGPL if specified either way.
3478 if test -z "$lgpl"; then
3481 # The makefile_name defaults to the cached one.
3482 if test -z "$makefile_name"; then
3483 makefile_name="$cached_makefile_name"
3485 # Use libtool if specified either way, or if guessed.
3486 if test -z "$libtool"; then
3487 if test -n "$cached_m4base"; then
3488 libtool="$cached_libtool"
3490 libtool="$guessed_libtool"
3493 # The macro_prefix defaults to the cached one.
3494 if test -z "$macro_prefix"; then
3495 macro_prefix="$cached_macro_prefix"
3496 if test -z "$macro_prefix"; then
3497 func_fatal_error "missing --macro-prefix option"
3500 # The po_domain defaults to the cached one.
3501 if test -z "$po_domain"; then
3502 po_domain="$cached_po_domain"
3504 # The vc_files defaults to the cached one.
3505 if test -z "$vc_files"; then
3506 vc_files="$cached_vc_files"
3509 # Canonicalize the list of specified modules.
3510 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3512 # Determine final module list.
3513 modules="$specified_modules"
3514 func_modules_transitive_closure
3515 if test $verbose -ge 0; then
3516 echo "Module list with included dependencies:"
3517 echo "$modules" | sed -e 's/^/ /'
3519 final_modules="$modules"
3521 # Determine main module list and tests-related module list separately.
3522 # The main module list is the transitive closure of the specified modules,
3523 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3524 # is specified, it will consist only of LGPLed source.
3525 # The tests-related module list is the transitive closure of the specified
3526 # modules, including tests modules, minus the main module list excluding
3527 # modules of applicability 'all'. Its lib/* sources (brought in through
3528 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3529 # source, even if --lgpl is specified.
3530 # Determine main module list.
3531 saved_inctests="$inctests"
3533 modules="$specified_modules"
3534 func_modules_transitive_closure
3535 main_modules="$modules"
3536 inctests="$saved_inctests"
3537 if test $verbose -ge 1; then
3538 echo "Main module list:"
3539 echo "$main_modules" | sed -e 's/^/ /'
3541 # Determine tests-related module list.
3542 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3543 testsrelated_modules=`for module in $main_modules; do
3544 if test \`func_get_applicability $module\` = main; then
3548 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3549 if test $verbose -ge 1; then
3550 echo "Tests-related module list:"
3551 echo "$testsrelated_modules" | sed -e 's/^/ /'
3554 # Add the dummy module to the main module list if needed.
3555 modules="$main_modules"
3556 func_modules_add_dummy
3557 main_modules="$modules"
3559 # Determine whether a $testsbase/libtests.a is needed.
3561 for module in $testsrelated_modules; do
3562 func_verify_nontests_module
3563 if test -n "$module"; then
3564 all_files=`func_get_filelist $module`
3565 # Test whether some file in $all_files lies in lib/.
3566 for f in $all_files; do
3577 # Add the dummy module to the tests-related module list if needed.
3578 if $use_libtests; then
3579 modules="$testsrelated_modules"
3580 func_modules_add_dummy
3581 testsrelated_modules="$modules"
3584 # If --lgpl, verify that the licenses of modules are compatible.
3585 if test -n "$lgpl"; then
3586 license_incompatibilities=
3587 for module in $main_modules; do
3588 license=`func_get_license $module`
3590 'GPLed build tool') ;;
3591 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3596 LGPL | LGPLv2+ | LGPLv3+) ;;
3597 *) func_append license_incompatibilities "$module $license$nl" ;;
3603 *) func_append license_incompatibilities "$module $license$nl" ;;
3606 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3611 if test -n "$license_incompatibilities"; then
3612 # Format the license incompatibilities as a table.
3613 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3614 s,^\(.................................................[^ ]*\) *, \1 ,'
3615 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3616 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3620 # Show banner notice of every module.
3621 modules="$main_modules"
3624 # Determine script to apply to imported library files.
3625 sed_transform_lib_file=
3626 for module in $main_modules; do
3627 if test $module = config-h; then
3628 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3629 sed_transform_lib_file=$sed_transform_lib_file'
3630 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3635 sed_transform_main_lib_file="$sed_transform_lib_file"
3636 if test -n "$do_copyrights"; then
3637 if test -n "$lgpl"; then
3641 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3642 s/GNU General/GNU Lesser General/g
3646 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3647 s/GNU General/GNU Lesser General/g
3648 s/version [23]\([ ,]\)/version 2.1\1/g
3651 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3655 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3656 s/GNU Lesser General/GNU General/g
3657 s/GNU Library General/GNU General/g
3658 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3663 # Determine script to apply to auxiliary files that go into $auxdir/.
3664 sed_transform_build_aux_file=
3665 if test -n "$do_copyrights"; then
3667 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3668 s/GNU Lesser General/GNU General/g
3669 s/GNU Library General/GNU General/g
3670 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3674 # Determine script to apply to library files that go into $testsbase/.
3675 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3676 if test -n "$do_copyrights"; then
3678 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3679 s/GNU Lesser General/GNU General/g
3680 s/GNU Library General/GNU General/g
3681 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3685 # Determine the final file lists.
3686 # They must be computed separately, because files in lib/* go into
3687 # $sourcebase/ if they are in the main file list but into $testsbase/
3688 # if they are in the tests-related file list. Furthermore lib/dummy.c
3690 # Determine final main file list.
3691 modules="$main_modules"
3692 func_modules_to_filelist
3694 # Determine final tests-related file list.
3695 modules="$testsrelated_modules"
3696 func_modules_to_filelist
3697 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3698 # Merge both file lists.
3699 sed_remove_empty_lines='/^$/d'
3700 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3701 if test $verbose -ge 0; then
3703 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3704 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3708 || func_fatal_error "refusing to do nothing"
3710 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3711 new_files="$files m4/gnulib-tool.m4"
3712 old_files="$cached_files"
3713 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3714 func_append old_files " m4/gnulib-tool.m4"
3717 rewritten='%REWRITTEN%'
3718 sed_rewrite_old_files="\
3719 s,^build-aux/,$rewritten$auxdir/,
3720 s,^doc/,$rewritten$cached_docbase/,
3721 s,^lib/,$rewritten$cached_sourcebase/,
3722 s,^m4/,$rewritten$cached_m4base/,
3723 s,^tests/,$rewritten$cached_testsbase/,
3724 s,^tests=lib/,$rewritten$cached_testsbase/,
3727 sed_rewrite_new_files="\
3728 s,^build-aux/,$rewritten$auxdir/,
3729 s,^doc/,$rewritten$docbase/,
3730 s,^lib/,$rewritten$sourcebase/,
3731 s,^m4/,$rewritten$m4base/,
3732 s,^tests/,$rewritten$testsbase/,
3733 s,^tests=lib/,$rewritten$testsbase/,
3737 # Create directories.
3738 { echo "$sourcebase"
3740 if test -n "$pobase"; then
3743 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3744 if test -n "$docfiles"; then
3747 if test -n "$inctests"; then
3751 for f in $files; do echo $f; done \
3752 | sed -e "$sed_rewrite_new_files" \
3753 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3756 { # Rearrange file descriptors. Needed because "while ... done < ..."
3757 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3758 exec 5<&0 < "$tmp"/dirs
3760 if test ! -d "$destdir/$d"; then
3762 echo "Creating directory $destdir/$d"
3763 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3765 echo "Create directory $destdir/$d"
3772 # Copy files or make symbolic links. Remove obsolete files.
3776 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3777 # representing the files according to the last gnulib-tool invocation.
3778 for f in $old_files; do echo $f; done \
3779 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3782 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3783 # representing the files after this gnulib-tool invocation.
3784 for f in $new_files; do echo $f; done \
3785 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3788 # First the files that are in old-files, but not in new-files:
3789 sed_take_first_column='s,'"$delimiter"'.*,,'
3790 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3791 # Remove the file. Do nothing if the user already removed it.
3792 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3794 echo "Removing file $g (backup in ${g}~)"
3795 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3797 echo "Remove file $g (backup in ${g}~)"
3799 func_append removed_files "$g$nl"
3802 # func_add_or_update handles a file that ought to be present afterwards.
3804 # - f the original file name
3805 # - g the rewritten file name
3806 # - already_present nonempty if the file should already exist, empty
3808 func_add_or_update ()
3812 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3814 func_dest_tmpfilename "$g"
3815 func_lookup_file "$f"
3816 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3817 if test -n "$sed_transform_main_lib_file"; then
3820 sed -e "$sed_transform_main_lib_file" \
3821 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3825 if test -n "$sed_transform_build_aux_file"; then
3828 sed -e "$sed_transform_build_aux_file" \
3829 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3833 if test -n "$sed_transform_testsrelated_lib_file"; then
3836 sed -e "$sed_transform_testsrelated_lib_file" \
3837 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3841 if test -f "$destdir/$g"; then
3842 # The file already exists.
3846 # Don't protest if the file should be there but isn't: it happens
3847 # frequently that developers don't put autogenerated files into CVS.
3849 func_append added_files "$g$nl"
3853 # Then the files that are in new-files, but not in old-files:
3854 sed_take_last_column='s,^.*'"$delimiter"',,'
3856 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3857 | sed -e "$sed_take_last_column" \
3858 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3859 { # Rearrange file descriptors. Needed because "while ... done < ..."
3860 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3861 exec 5<&0 < "$tmp"/added-files
3867 # Then the files that are in new-files and in old-files:
3868 already_present=true
3869 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3870 | sed -e "$sed_take_last_column" \
3871 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3872 { # Rearrange file descriptors. Needed because "while ... done < ..."
3873 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3874 exec 5<&0 < "$tmp"/kept-files
3881 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3882 actioncmd="gnulib-tool --import"
3883 func_append actioncmd " --dir=$destdir"
3884 if test -n "$local_gnulib_dir"; then
3885 func_append actioncmd " --local-dir=$local_gnulib_dir"
3887 func_append actioncmd " --lib=$libname"
3888 func_append actioncmd " --source-base=$sourcebase"
3889 func_append actioncmd " --m4-base=$m4base"
3890 if test -n "$pobase"; then
3891 func_append actioncmd " --po-base=$pobase"
3893 func_append actioncmd " --doc-base=$docbase"
3894 func_append actioncmd " --tests-base=$testsbase"
3895 func_append actioncmd " --aux-dir=$auxdir"
3896 if test -n "$inctests"; then
3897 func_append actioncmd " --with-tests"
3899 if test -n "$incobsolete"; then
3900 func_append actioncmd " --with-obsolete"
3902 if test -n "$inc_cxx_tests"; then
3903 func_append actioncmd " --with-c++-tests"
3905 if test -n "$inc_longrunning_tests"; then
3906 func_append actioncmd " --with-longrunning-tests"
3908 if test -n "$inc_privileged_tests"; then
3909 func_append actioncmd " --with-privileged-tests"
3911 if test -n "$inc_unportable_tests"; then
3912 func_append actioncmd " --with-unportable-tests"
3914 if test -n "$inc_all_tests"; then
3915 func_append actioncmd " --with-all-tests"
3917 for module in $avoidlist; do
3918 func_append actioncmd " --avoid=$module"
3920 if test -n "$lgpl"; then
3921 if test "$lgpl" = yes; then
3922 func_append actioncmd " --lgpl"
3924 func_append actioncmd " --lgpl=$lgpl"
3927 if test -n "$makefile_name"; then
3928 func_append actioncmd " --makefile-name=$makefile_name"
3930 if test "$libtool" = true; then
3931 func_append actioncmd " --libtool"
3933 func_append actioncmd " --no-libtool"
3935 func_append actioncmd " --macro-prefix=$macro_prefix"
3936 if test -n "$po_domain"; then
3937 func_append actioncmd " --po-domain=$po_domain"
3939 if test -n "$vc_files"; then
3940 if test "$vc_files" = true; then
3941 func_append actioncmd " --vc-files"
3943 func_append actioncmd " --no-vc-files"
3946 func_append actioncmd " `echo $specified_modules`"
3948 # Default the makefile name to Makefile.am.
3949 if test -n "$makefile_name"; then
3950 makefile_am=$makefile_name
3952 makefile_am=Makefile.am
3955 # Create normal Makefile.ams.
3958 # Setup list of Makefile.am edits that are to be performed afterwards.
3959 # Some of these edits apply to files that we will generate; others are
3960 # under the responsibility of the developer.
3962 # func_note_Makefile_am_edit dir var value
3963 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3965 func_note_Makefile_am_edit ()
3967 makefile_am_edits=`expr $makefile_am_edits + 1`
3968 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3969 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3970 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3972 if test "$makefile_am" = Makefile.am; then
3973 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3974 sourcebase_base=`basename "$sourcebase"`
3975 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3977 if test -n "$pobase"; then
3978 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3979 pobase_base=`basename "$pobase"`
3980 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3982 if test -n "$inctests"; then
3983 if test "$makefile_am" = Makefile.am; then
3984 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3985 testsbase_base=`basename "$testsbase"`
3986 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3989 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3991 # Find the first parent directory of $m4base that contains or will contain
3993 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3995 sed_butlast='s,[^/][^/]*//*$,,'
3996 dir1="${m4base}/"; dir2=""
3997 while test -n "$dir1" \
3998 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3999 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4000 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4001 || { test -n "$inctests" \
4002 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4003 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4004 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4005 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4007 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4010 # Create library makefile.
4011 func_dest_tmpfilename $sourcebase/$makefile_am
4012 destfile="$sourcebase/$makefile_am"
4013 modules="$main_modules"
4014 func_emit_lib_Makefile_am > "$tmpfile"
4015 if test -f "$destdir"/$sourcebase/$makefile_am; then
4016 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4020 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4021 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4022 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4024 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4030 echo "Creating $sourcebase/$makefile_am"
4031 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4033 echo "Create $sourcebase/$makefile_am"
4036 func_append added_files "$sourcebase/$makefile_am$nl"
4039 # Create po/ directory.
4040 if test -n "$pobase"; then
4041 # Create po makefile and auxiliary files.
4042 for file in Makefile.in.in remove-potcdate.sin; do
4043 func_dest_tmpfilename $pobase/$file
4044 func_lookup_file build-aux/po/$file
4045 cat "$lookedup_file" > "$tmpfile"
4046 if test -f "$destdir"/$pobase/$file; then
4047 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4051 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4052 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4053 mv -f "$tmpfile" "$destdir"/$pobase/$file
4055 echo "Update $pobase/$file (backup in $pobase/$file~)"
4061 echo "Creating $pobase/$file"
4062 mv -f "$tmpfile" "$destdir"/$pobase/$file
4064 echo "Create $pobase/$file"
4067 func_append added_files "$pobase/$file$nl"
4070 # Create po makefile parameterization, part 1.
4071 func_dest_tmpfilename $pobase/Makevars
4072 func_emit_po_Makevars > "$tmpfile"
4073 if test -f "$destdir"/$pobase/Makevars; then
4074 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4078 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4079 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4080 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4082 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4088 echo "Creating $pobase/Makevars"
4089 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4091 echo "Create $pobase/Makevars"
4094 func_append added_files "$pobase/Makevars$nl"
4096 # Create po makefile parameterization, part 2.
4097 func_dest_tmpfilename $pobase/POTFILES.in
4098 func_emit_po_POTFILES_in > "$tmpfile"
4099 if test -f "$destdir"/$pobase/POTFILES.in; then
4100 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4104 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4105 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4106 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4108 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4114 echo "Creating $pobase/POTFILES.in"
4115 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4117 echo "Create $pobase/POTFILES.in"
4120 func_append added_files "$pobase/POTFILES.in$nl"
4123 TP_URL="http://translationproject.org/latest/"
4124 TP_RSYNC_URI="translationproject.org::tp/latest/"
4126 echo "Fetching gnulib PO files from $TP_URL"
4127 (cd "$destdir"/$pobase \
4128 && { # Prefer rsync over wget if it is available, since it consumes
4129 # less network bandwidth, due to compression.
4130 if type rsync 2>/dev/null | grep / > /dev/null; then
4131 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4133 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4138 echo "Fetch gnulib PO files from $TP_URL"
4140 # Create po/LINGUAS.
4142 func_dest_tmpfilename $pobase/LINGUAS
4143 (cd "$destdir"/$pobase \
4144 && { echo '# Set of available languages.'
4145 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4148 if test -f "$destdir"/$pobase/LINGUAS; then
4149 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4152 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4153 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4154 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4157 echo "Creating $pobase/LINGUAS"
4158 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4159 func_append added_files "$pobase/LINGUAS$nl"
4162 if test -f "$destdir"/$pobase/LINGUAS; then
4163 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4165 echo "Create $pobase/LINGUAS"
4170 # Create m4/gnulib-cache.m4.
4171 func_dest_tmpfilename $m4base/gnulib-cache.m4
4173 func_emit_copyright_notice
4175 echo "# This file represents the specification of how gnulib-tool is used."
4176 echo "# It acts as a cache: It is written and read by gnulib-tool."
4177 echo "# In projects using CVS, this file is meant to be stored in CVS,"
4178 echo "# like the configure.ac and various Makefile.am files."
4181 echo "# Specification in the form of a command-line invocation:"
4184 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4185 # Store the local_gnulib_dir relative to destdir.
4186 case "$local_gnulib_dir" in
4188 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4191 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4193 # destdir, local_gnulib_dir are both relative.
4194 func_relativize "$destdir" "$local_gnulib_dir"
4195 relative_local_gnulib_dir="$reldir" ;;
4198 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4200 echo "$specified_modules" | sed -e 's/^/ /g'
4202 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4203 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4204 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4205 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4206 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4207 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4208 echo "gl_AVOID([$avoidlist])"
4209 echo "gl_SOURCE_BASE([$sourcebase])"
4210 echo "gl_M4_BASE([$m4base])"
4211 echo "gl_PO_BASE([$pobase])"
4212 echo "gl_DOC_BASE([$docbase])"
4213 echo "gl_TESTS_BASE([$testsbase])"
4214 test -z "$inctests" || echo "gl_WITH_TESTS"
4215 echo "gl_LIB([$libname])"
4216 if test -n "$lgpl"; then
4217 if test "$lgpl" = yes; then
4220 echo "gl_LGPL([$lgpl])"
4223 echo "gl_MAKEFILE_NAME([$makefile_name])"
4224 if test "$libtool" = true; then
4227 echo "gl_MACRO_PREFIX([$macro_prefix])"
4228 echo "gl_PO_DOMAIN([$po_domain])"
4229 if test -n "$vc_files"; then
4230 echo "gl_VC_FILES([$vc_files])"
4233 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4234 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4238 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4239 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4240 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4242 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4246 echo "# gnulib-cache.m4 ends here"
4253 echo "Creating $m4base/gnulib-cache.m4"
4254 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4256 echo "Create $m4base/gnulib-cache.m4"
4262 # Create m4/gnulib-comp.m4.
4263 func_dest_tmpfilename $m4base/gnulib-comp.m4
4265 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4266 func_emit_copyright_notice
4268 echo "# This file represents the compiled summary of the specification in"
4269 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4270 echo "# to be invoked from configure.ac."
4271 echo "# In projects using CVS, this file can be treated like other built files."
4274 echo "# This macro should be invoked from $configure_ac, in the section"
4275 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4276 echo "# any checks for libraries, header files, types and library functions."
4277 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4279 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4280 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4281 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4282 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4283 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4284 if test -n "$uses_subdirs"; then
4285 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4287 for module in $final_modules; do
4289 if test -n "$module"; then
4290 echo "# Code from module $module:"
4291 func_get_autoconf_early_snippet "$module"
4294 | sed -e '/^$/d;' -e 's/^/ /'
4297 echo "# This macro should be invoked from $configure_ac, in the section"
4298 echo "# \"Check for header files, types and library functions\"."
4299 echo "AC_DEFUN([${macro_prefix}_INIT],"
4301 if test "$libtool" = true; then
4302 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4303 echo " gl_cond_libtool=true"
4305 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4306 echo " gl_cond_libtool=false"
4308 echo " gl_ltlibdeps="
4310 if test "$auxdir" != "build-aux"; then
4311 sed_replace_build_aux='
4313 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4314 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4318 sed_replace_build_aux="$sed_noop"
4320 func_emit_initmacro_start $macro_prefix
4321 echo " gl_source_base='$sourcebase'"
4322 for module in $main_modules; do
4324 if test -n "$module"; then
4325 echo " # Code from module $module:"
4326 func_get_autoconf_snippet "$module" \
4327 | sed -e '/^$/d;' -e 's/^/ /' \
4328 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4329 -e "$sed_replace_build_aux"
4330 if test "$module" = 'alloca' && test "$libtool" = true; then
4331 echo 'changequote(,)dnl'
4332 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4333 echo 'changequote([, ])dnl'
4334 echo 'AC_SUBST([LTALLOCA])'
4338 echo " # End of code from modules"
4339 func_emit_initmacro_end $macro_prefix
4340 echo " gltests_libdeps="
4341 echo " gltests_ltlibdeps="
4342 func_emit_initmacro_start ${macro_prefix}tests
4343 echo " gl_source_base='$testsbase'"
4344 # Define a tests witness macro that depends on the package.
4345 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4346 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4347 echo " ${macro_prefix}tests_WITNESS=IN_\`echo \"\${PACKAGE-\$PACKAGE_TARNAME}\" | LC_ALL=C tr 'a-z' 'A-Z' | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'\`_GNULIB_TESTS"
4348 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4349 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4350 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4351 for module in $testsrelated_modules; do
4353 if test -n "$module"; then
4354 func_get_autoconf_snippet "$module" \
4355 | sed -e '/^$/d;' -e 's/^/ /' \
4356 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4357 -e "$sed_replace_build_aux" \
4358 -e 's/\$gl_cond_libtool/false/g' \
4359 -e 's/gl_libdeps/gltests_libdeps/g' \
4360 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4363 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4364 func_emit_initmacro_end ${macro_prefix}tests
4365 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4366 # created using libtool, because libtool already handles the dependencies.
4367 if test "$libtool" != true; then
4368 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4369 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4370 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4371 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4372 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4374 if $use_libtests; then
4375 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4376 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4379 func_emit_initmacro_done $macro_prefix $sourcebase
4380 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4382 echo "# This macro records the list of files which have been installed by"
4383 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4384 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4385 echo "$files" | sed -e 's,^, ,'
4388 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4389 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4393 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4394 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4395 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4397 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4401 echo "# gnulib-comp.m4 ends here"
4408 echo "Creating $m4base/gnulib-comp.m4"
4409 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4411 echo "Create $m4base/gnulib-comp.m4"
4417 if test -n "$inctests"; then
4418 # Create tests makefile.
4419 func_dest_tmpfilename $testsbase/$makefile_am
4420 destfile="$testsbase/$makefile_am"
4421 modules="$testsrelated_modules"
4422 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4423 if test -f "$destdir"/$testsbase/$makefile_am; then
4424 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4428 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4429 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4430 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4432 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4438 echo "Creating $testsbase/$makefile_am"
4439 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4441 echo "Create $testsbase/$makefile_am"
4444 func_append added_files "$testsbase/$makefile_am$nl"
4448 if test "$vc_files" != false; then
4449 # Update the .cvsignore and .gitignore files.
4450 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4451 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4452 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4453 echo "$m4base/|A|gnulib-comp.m4"
4454 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4455 { # Rearrange file descriptors. Needed because "while ... done < ..."
4456 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4457 exec 5<&0 < "$tmp"/fileset-changes
4458 func_update_ignorelist ()
4461 if test "$ignore" = .gitignore; then
4462 # In a .gitignore file, "foo" applies to the current directory and all
4463 # subdirectories, whereas "/foo" applies to the current directory only.
4466 doubly_escaped_anchor='\\/'
4470 doubly_escaped_anchor=''
4472 if test -f "$destdir/$dir$ignore"; then
4473 if test -n "$dir_added" || test -n "$dir_removed"; then
4474 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4475 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4476 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4477 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4478 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4480 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4482 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4483 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4484 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4485 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4486 } > "$tmp"/sed-ignore-removed
4487 { cat "$destdir/$dir$ignore"~
4488 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4489 } | sed -f "$tmp"/sed-ignore-removed \
4490 > "$destdir/$dir$ignore"
4492 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4497 if test -n "$dir_added"; then
4499 echo "Creating $destdir/$dir$ignore"
4501 if test "$ignore" = .cvsignore; then
4503 # Automake generates Makefile rules that create .dirstamp files.
4506 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4507 } > "$destdir/$dir$ignore"
4509 echo "Create $destdir/$dir$ignore"
4519 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4520 func_update_ignorelist .cvsignore
4522 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4523 func_update_ignorelist .gitignore
4530 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4531 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4532 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4533 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4534 if test "$next_dir" != "$last_dir"; then
4535 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4536 last_dir="$next_dir"
4541 A) func_append last_dir_added "$file$nl";;
4542 R) func_append last_dir_removed "$file$nl";;
4545 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4552 echo "You may need to add #include directives for the following .h files."
4553 # Intersect $specified_modules and $main_modules
4554 # (since $specified_modules is not necessarily of subset of $main_modules
4555 # - some may have been skipped through --avoid, and since the elements of
4556 # $main_modules but not in $specified_modules can go away without explicit
4557 # notice - through changes in the module dependencies).
4558 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4559 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4560 # First the #include <...> directives without #ifs, sorted for convenience,
4561 # then the #include "..." directives without #ifs, sorted for convenience,
4562 # then the #include directives that are surrounded by #ifs. Not sorted.
4563 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4564 include_directive=`func_get_include_directive "$module"`
4565 case "$nl$include_directive" in
4567 echo "$include_directive" 1>&5
4570 echo "$include_directive" | grep -v 'include "' 1>&6
4571 echo "$include_directive" | grep 'include "' 1>&7
4574 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4576 LC_ALL=C sort -u "$tmp"/include-angles
4577 LC_ALL=C sort -u "$tmp"/include-quotes
4578 cat "$tmp"/include-if
4579 ) | sed -e '/^$/d' -e 's/^/ /'
4580 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4582 for module in $main_modules; do
4583 func_get_link_directive "$module"
4585 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4586 if test `wc -l < "$tmp"/link` != 0; then
4588 echo "You may need to use the following Makefile variables when linking."
4589 echo "Use them in <program>_LDADD when linking a program, or"
4590 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4596 echo "Don't forget to"
4597 if test "$makefile_am" = Makefile.am; then
4598 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4600 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4602 if test -n "$pobase"; then
4603 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4605 if test -n "$inctests"; then
4606 if test "$makefile_am" = Makefile.am; then
4607 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4609 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4613 while test $edit != $makefile_am_edits; do
4614 edit=`expr $edit + 1`
4615 eval dir=\"\$makefile_am_edit${edit}_dir\"
4616 eval var=\"\$makefile_am_edit${edit}_var\"
4617 eval val=\"\$makefile_am_edit${edit}_val\"
4618 if test -n "$var"; then
4619 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4622 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4623 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4626 # func_create_testdir testdir modules
4628 # - local_gnulib_dir from --local-dir
4629 # - modcache true or false, from --cache-modules/--no-cache-modules
4630 # - auxdir directory relative to destdir where to place build aux files
4631 # - inctests true if tests should be included, blank otherwise
4632 # - incobsolete true if obsolete modules among dependencies should be
4633 # included, blank otherwise
4634 # - avoidlist list of modules to avoid
4635 # - libtool true if --libtool was given, false if --no-libtool was
4636 # given, blank otherwise
4637 # - symbolic true if files should be symlinked, copied otherwise
4638 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4640 func_create_testdir ()
4644 if test -z "$modules"; then
4645 # All modules together.
4646 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4647 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4648 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4649 modules=`func_all_modules`
4650 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4652 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
4654 # Unlike in func_import, here we want to include all kinds of tests.
4657 # Check that the license of every module is consistent with the license of
4659 saved_modules="$modules"
4660 saved_inctests="$inctests"
4661 # When computing transitive closures, don't consider $module to depend on
4662 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4663 # on GPL modules - therefore we don't want a warning in this case.
4665 for requested_module in $saved_modules; do
4666 requested_license=`func_get_license "$requested_module"`
4667 if test "$requested_license" != GPL; then
4668 # Here we use func_modules_transitive_closure, not just
4669 # func_get_dependencies, so that we also detect weird situations like
4670 # an LGPL module which depends on a GPLed build tool module which depends
4672 modules="$requested_module"
4673 func_modules_transitive_closure
4674 for module in $modules; do
4675 license=`func_get_license "$module"`
4677 'GPLed build tool') ;;
4678 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4680 case "$requested_license" in
4683 GPLv2+ | LGPLv2+) ;;
4684 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4690 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4696 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4705 modules="$saved_modules"
4706 inctests="$saved_inctests"
4708 # Subdirectory names.
4718 # Determine final module list.
4719 func_modules_transitive_closure
4720 if test $verbose -ge 0; then
4721 echo "Module list with included dependencies:"
4722 echo "$modules" | sed -e 's/^/ /'
4725 # Add the dummy module if needed.
4726 func_modules_add_dummy
4728 # Show banner notice of every module.
4731 # Determine final file list.
4732 func_modules_to_filelist
4733 if test $verbose -ge 0; then
4735 echo "$files" | sed -e 's/^/ /'
4738 rewritten='%REWRITTEN%'
4739 sed_rewrite_files="\
4740 s,^build-aux/,$rewritten$auxdir/,
4741 s,^doc/,$rewritten$docbase/,
4742 s,^lib/,$rewritten$sourcebase/,
4743 s,^m4/,$rewritten$m4base/,
4744 s,^tests/,$rewritten$testsbase/,
4748 # Create directories.
4749 for f in $files; do echo $f; done \
4750 | sed -e "$sed_rewrite_files" \
4751 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4752 | LC_ALL=C sort -u \
4754 { # Rearrange file descriptors. Needed because "while ... done < ..."
4755 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4756 exec 5<&0 < "$tmp"/dirs
4758 mkdir -p "$testdir/$d"
4763 # Copy files or make symbolic links.
4765 for f in $files; do echo $f; done \
4766 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4769 { # Rearrange file descriptors. Needed because "while ... done < ..."
4770 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4771 exec 5<&0 < "$tmp"/files
4773 func_lookup_file "$f"
4774 if test -n "$lookedup_tmp"; then
4775 cp -p "$lookedup_file" "$testdir/$g"
4777 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4778 if { test -n "$symbolic" \
4779 || { test -n "$lsymbolic" \
4780 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4781 func_ln "$lookedup_file" "$testdir/$g"
4783 cp -p "$lookedup_file" "$testdir/$g"
4790 # Create Makefile.ams that are for testing.
4793 # No special edits are needed.
4796 # Create $sourcebase/Makefile.am.
4797 mkdir -p "$testdir/$sourcebase"
4798 destfile="$sourcebase/Makefile.am"
4799 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4800 any_uses_subdirs="$uses_subdirs"
4802 # Create $m4base/Makefile.am.
4803 mkdir -p "$testdir/$m4base"
4804 (echo "## Process this file with automake to produce Makefile.in."
4810 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4813 ) > "$testdir/$m4base/Makefile.am"
4815 subdirs="$sourcebase $m4base"
4816 subdirs_with_configure_ac=""
4818 if false && test -f "$testdir"/$m4base/gettext.m4; then
4819 # Avoid stupid error message from automake:
4820 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4821 mkdir -p "$testdir/po"
4822 (echo "## Process this file with automake to produce Makefile.in."
4823 ) > "$testdir/po/Makefile.am"
4824 func_append subdirs " po"
4827 if test -n "$inctests"; then
4828 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4829 # Viewed from the $testsbase subdirectory, $auxdir is different.
4830 saved_auxdir="$auxdir"
4831 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4832 # Create $testsbase/Makefile.am.
4834 destfile="$testsbase/Makefile.am"
4835 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
4836 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4837 # Create $testsbase/configure.ac.
4838 (echo "# Process this file with autoconf to produce a configure script."
4839 echo "AC_INIT([dummy], [0])"
4840 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4841 echo "AM_INIT_AUTOMAKE"
4843 echo "AC_CONFIG_HEADERS([config.h])"
4846 echo "AC_PROG_INSTALL"
4847 echo "AC_PROG_MAKE_SET"
4848 echo "AC_PROG_RANLIB"
4850 if test -n "$uses_subdirs"; then
4851 echo "AM_PROG_CC_C_O"
4854 for module in $modules; do
4856 if test -n "$module"; then
4858 gnumakefile | maintainer-makefile)
4859 # These modules are meant to be used only in the top-level directory.
4862 func_get_autoconf_early_snippet "$module"
4867 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4868 if test "$libtool" = true; then
4869 echo "LT_INIT([win32-dll])"
4870 echo "LT_LANG([C++])"
4871 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4872 echo "gl_cond_libtool=true"
4874 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4875 echo "gl_cond_libtool=false"
4877 echo "gl_ltlibdeps="
4879 # Wrap the set of autoconf snippets into an autoconf macro that is then
4880 # invoked. This is needed because autoconf does not support AC_REQUIRE
4882 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4883 # but we want the AC_REQUIRE to have its normal meaning (provide one
4884 # expansion of the required macro before the current point, and only one
4886 echo "AC_DEFUN([gl_INIT], ["
4887 sed_replace_build_aux='
4889 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4890 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4893 func_emit_initmacro_start $macro_prefix
4894 # We don't have explicit ordering constraints between the various
4895 # autoconf snippets. It's cleanest to put those of the library before
4896 # those of the tests.
4897 echo "gl_source_base='../$sourcebase'"
4898 for module in $modules; do
4899 func_verify_nontests_module
4900 if test -n "$module"; then
4902 gnumakefile | maintainer-makefile)
4903 # These modules are meant to be used only in the top-level directory.
4906 func_get_autoconf_snippet "$module" \
4907 | sed -e "$sed_replace_build_aux"
4912 echo "gl_source_base='.'"
4913 for module in $modules; do
4914 func_verify_tests_module
4915 if test -n "$module"; then
4916 func_get_autoconf_snippet "$module" \
4917 | sed -e "$sed_replace_build_aux"
4920 func_emit_initmacro_end $macro_prefix
4921 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4922 # created using libtool, because libtool already handles the dependencies.
4923 if test "$libtool" != true; then
4924 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4925 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4926 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4927 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4928 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4931 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4935 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4936 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4937 echo "AH_TOP([#include \"../config.h\"])"
4939 echo "AC_CONFIG_FILES([Makefile])"
4941 ) > "$testdir/$testsbase/configure.ac"
4942 auxdir="$saved_auxdir"
4943 func_append subdirs " $testsbase"
4944 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4947 # Create Makefile.am.
4948 (echo "## Process this file with automake to produce Makefile.in."
4950 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4952 echo "SUBDIRS = $subdirs"
4954 echo "ACLOCAL_AMFLAGS = -I $m4base"
4955 ) > "$testdir/Makefile.am"
4957 # Create configure.ac.
4958 (echo "# Process this file with autoconf to produce a configure script."
4959 echo "AC_INIT([dummy], [0])"
4960 if test "$auxdir" != "."; then
4961 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4963 echo "AM_INIT_AUTOMAKE"
4965 echo "AC_CONFIG_HEADERS([config.h])"
4968 echo "AC_PROG_INSTALL"
4969 echo "AC_PROG_MAKE_SET"
4971 echo "# For autobuild."
4972 echo "AC_CANONICAL_BUILD"
4973 echo "AC_CANONICAL_HOST"
4975 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4976 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4977 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4978 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4980 echo "AC_PROG_RANLIB"
4982 if test -n "$any_uses_subdirs"; then
4983 echo "AM_PROG_CC_C_O"
4986 for module in $modules; do
4987 func_verify_nontests_module
4988 if test -n "$module"; then
4989 func_get_autoconf_early_snippet "$module"
4992 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4993 if test "$libtool" = true; then
4994 echo "LT_INIT([win32-dll])"
4995 echo "LT_LANG([C++])"
4996 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4997 echo "gl_cond_libtool=true"
4999 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5000 echo "gl_cond_libtool=false"
5002 echo "gl_ltlibdeps="
5004 # Wrap the set of autoconf snippets into an autoconf macro that is then
5005 # invoked. This is needed because autoconf does not support AC_REQUIRE
5007 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5008 # but we want the AC_REQUIRE to have its normal meaning (provide one
5009 # expansion of the required macro before the current point, and only one
5011 echo "AC_DEFUN([gl_INIT], ["
5012 if test "$auxdir" != "build-aux"; then
5013 sed_replace_build_aux='
5015 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5016 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5020 sed_replace_build_aux="$sed_noop"
5022 func_emit_initmacro_start $macro_prefix
5023 echo "gl_source_base='$sourcebase'"
5024 for module in $modules; do
5025 func_verify_nontests_module
5026 if test -n "$module"; then
5027 func_get_autoconf_snippet "$module" \
5028 | sed -e "$sed_replace_build_aux"
5031 func_emit_initmacro_end $macro_prefix
5032 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5033 # created using libtool, because libtool already handles the dependencies.
5034 if test "$libtool" != true; then
5035 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5036 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5037 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5038 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5039 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5042 func_emit_initmacro_done $macro_prefix $sourcebase
5046 if test -n "$subdirs_with_configure_ac"; then
5047 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5049 makefiles="Makefile"
5050 for d in $subdirs; do
5051 # For subdirs that have a configure.ac by their own, it's the subdir's
5052 # configure.ac which creates the subdir's Makefile.am, not this one.
5053 case " $subdirs_with_configure_ac " in
5055 *) func_append makefiles " $d/Makefile" ;;
5058 echo "AC_CONFIG_FILES([$makefiles])"
5060 ) > "$testdir/configure.ac"
5062 # Create autogenerated files.
5064 # Do not use "${AUTORECONF} --force --install", because it may invoke
5065 # autopoint, which brings in older versions of some of our .m4 files.
5066 if test -f $m4base/gettext.m4; then
5067 func_execute_command ${AUTOPOINT} --force || func_exit 1
5068 for f in $m4base/*.m4~; do
5070 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5074 if test "$libtool" = true; then
5075 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5077 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5078 if ! test -d build-aux; then
5079 func_execute_command mkdir build-aux || func_exit 1
5081 func_execute_command ${AUTOCONF} || func_exit 1
5082 func_execute_command ${AUTOHEADER} || func_exit 1
5083 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5085 if test -n "$inctests"; then
5086 # Create autogenerated files.
5087 (cd "$testdir/$testsbase" || func_exit 1
5088 # Do not use "${AUTORECONF} --force --install", because it may invoke
5089 # autopoint, which brings in older versions of some of our .m4 files.
5090 if test -f ../$m4base/gettext.m4; then
5091 func_execute_command ${AUTOPOINT} --force || func_exit 1
5092 for f in ../$m4base/*.m4~; do
5094 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5098 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5099 if ! test -d ../build-aux; then
5100 func_execute_command mkdir ../build-aux
5102 func_execute_command ${AUTOCONF} || func_exit 1
5103 func_execute_command ${AUTOHEADER} || func_exit 1
5104 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5107 # Need to run configure and make once, to create built files that are to be
5108 # distributed (such as getdate.c).
5109 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5110 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5111 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5112 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5113 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5114 # such $(FOO_H) because they don't refer to distributed files.
5115 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5116 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5117 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5118 | sed -e "$sed_remove_make_variables"`
5119 distributed_built_sources=`for file in $built_sources; do
5120 case "$cleaned_files" in
5125 if test -n "$distributed_built_sources"; then
5127 ./configure || func_exit 1
5129 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5130 $MAKE built_sources || func_exit 1
5132 $MAKE distclean || func_exit 1
5137 # func_create_megatestdir megatestdir allmodules
5139 # - local_gnulib_dir from --local-dir
5140 # - modcache true or false, from --cache-modules/--no-cache-modules
5141 # - auxdir directory relative to destdir where to place build aux files
5142 func_create_megatestdir ()
5146 if test -z "$allmodules"; then
5147 allmodules=`func_all_modules`
5151 # First, all modules one by one.
5152 for onemodule in $allmodules; do
5153 func_create_testdir "$megatestdir/$onemodule" $onemodule
5154 func_append megasubdirs "$onemodule "
5156 # Then, all modules all together.
5157 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5158 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5159 func_create_testdir "$megatestdir/ALL" "$allmodules"
5160 func_append megasubdirs "ALL"
5163 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5164 vc_witness="$gnulib_dir/CVS/Entries"; \
5166 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5168 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5169 | sed -e 's,January,01,' -e 's,Jan,01,' \
5170 -e 's,February,02,' -e 's,Feb,02,' \
5171 -e 's,March,03,' -e 's,Mar,03,' \
5172 -e 's,April,04,' -e 's,Apr,04,' \
5174 -e 's,June,06,' -e 's,Jun,06,' \
5175 -e 's,July,07,' -e 's,Jul,07,' \
5176 -e 's,August,08,' -e 's,Aug,08,' \
5177 -e 's,September,09,' -e 's,Sep,09,' \
5178 -e 's,October,10,' -e 's,Oct,10,' \
5179 -e 's,November,11,' -e 's,Nov,11,' \
5180 -e 's,December,12,' -e 's,Dec,12,' \
5181 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5182 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5184 echo "CVSDATE=$cvsdate"
5185 echo ": \${MAKE=make}"
5186 echo "test -d logs || mkdir logs"
5187 echo "for module in $megasubdirs; do"
5188 echo " echo \"Working on module \$module...\""
5189 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5190 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5193 echo " : autobuild project... \$module"
5194 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5195 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5196 echo " : autobuild hostname... \`hostname\`"
5197 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5199 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5201 ) > "$megatestdir/do-autobuild"
5202 chmod a+x "$megatestdir/do-autobuild"
5204 # Create Makefile.am.
5205 (echo "## Process this file with automake to produce Makefile.in."
5207 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5209 echo "SUBDIRS = $megasubdirs"
5211 echo "EXTRA_DIST = do-autobuild"
5212 ) > "$megatestdir/Makefile.am"
5214 # Create configure.ac.
5215 (echo "# Process this file with autoconf to produce a configure script."
5216 echo "AC_INIT([dummy], [0])"
5217 if test "$auxdir" != "."; then
5218 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5220 echo "AM_INIT_AUTOMAKE"
5222 echo "AC_PROG_MAKE_SET"
5224 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5225 echo "AC_CONFIG_FILES([Makefile])"
5227 ) > "$megatestdir/configure.ac"
5229 # Create autogenerated files.
5231 # Do not use "${AUTORECONF} --install", because autoreconf operates
5232 # recursively, but the subdirectories are already finished, therefore
5233 # calling autoreconf here would only waste lots of CPU time.
5234 func_execute_command ${ACLOCAL} || func_exit 1
5235 func_execute_command mkdir build-aux
5236 func_execute_command ${AUTOCONF} || func_exit 1
5237 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5243 func_fatal_error "no mode specified" ;;
5250 # sed expression that converts a literal to a basic regular expression.
5251 # Needs to handle . [ \ * ^ $.
5252 sed_literal_to_basic_regex='s/\\/\\\\/g
5258 if test -f "$gnulib_dir/$filename" \
5259 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5260 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5261 filename_line_regex='^'"$filename_anywhere_regex"'$'
5264 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5265 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5266 (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$,,')
5269 | func_sanitize_modulelist \
5272 for module in $module_candidates; do
5273 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5278 func_warning "file $filename does not exist"
5286 if test -z "$destdir"; then
5289 test -d "$destdir" \
5290 || func_fatal_error "destination directory does not exist: $destdir"
5292 # Prefer configure.ac to configure.in.
5293 if test -f "$destdir"/configure.ac; then
5294 configure_ac="$destdir/configure.ac"
5296 if test -f "$destdir"/configure.in; then
5297 configure_ac="$destdir/configure.in"
5299 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5303 # Analyze configure.ac.
5305 guessed_libtool=false
5310 /AC_CONFIG_AUX_DIR/ {
5311 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5313 /A[CM]_PROG_LIBTOOL/ {
5314 s,^.*$,guessed_libtool=true,p
5316 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5318 if test -z "$auxdir"; then
5319 auxdir="$guessed_auxdir"
5322 # Determine where to apply func_import.
5323 if test -n "$m4base"; then
5324 # Apply func_import to a particular gnulib directory.
5325 # Any number of additional modules can be given.
5326 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5327 # First use of gnulib in the given m4base.
5328 test -n "$supplied_libname" || supplied_libname=true
5329 test -n "$sourcebase" || sourcebase="lib"
5330 test -n "$docbase" || docbase="doc"
5331 test -n "$testsbase" || testsbase="tests"
5332 test -n "$macro_prefix" || macro_prefix="gl"
5336 # Apply func_import to all gnulib directories.
5337 # To get this list of directories, look at Makefile.am. (Not at
5338 # configure, because it may be omitted from CVS. Also, don't run
5339 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5342 if test -f "$destdir"/Makefile.am; then
5343 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5345 for arg in $aclocal_amflags; do
5346 if test -n "$m4dir_is_next"; then
5347 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5351 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5352 func_append m4dirs " $arg"
5353 m4dirs_count=`expr $m4dirs_count + 1`
5359 if test "X$arg" = "X-I"; then
5367 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5368 if test -f "$destdir"/aclocal.m4; then
5369 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5370 sedexpr2='s,^[^/]*$,.,'
5371 sedexpr3='s,/[^/]*$,,'
5372 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5373 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5376 if test $m4dirs_count = 0; then
5377 # First use of gnulib in a package.
5378 # Any number of additional modules can be given.
5379 test -n "$supplied_libname" || supplied_libname=true
5380 test -n "$sourcebase" || sourcebase="lib"
5382 test -n "$docbase" || docbase="doc"
5383 test -n "$testsbase" || testsbase="tests"
5384 test -n "$macro_prefix" || macro_prefix="gl"
5387 if test $m4dirs_count = 1; then
5388 # There's only one use of gnulib here. Assume the user means it.
5389 # Any number of additional modules can be given.
5390 for m4base in $m4dirs; do
5394 # Ambiguous - guess what the user meant.
5395 if test $# = 0; then
5396 # No further arguments. Guess the user wants to update all of them.
5397 for m4base in $m4dirs; do
5398 # Perform func_import in a subshell, so that variable values
5400 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5401 # inc_longrunning_tests, inc_privileged_tests,
5402 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5403 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5404 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5405 # don't propagate from one directory to another.
5406 (func_import) || func_exit 1
5410 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5418 if test -z "$destdir"; then
5419 func_fatal_error "please specify --dir option"
5422 test -d "$destdir" \
5423 || func_fatal_error "could not create destination directory"
5424 test -n "$auxdir" || auxdir="build-aux"
5425 func_create_testdir "$destdir" "$*"
5428 create-megatestdir )
5429 if test -z "$destdir"; then
5430 func_fatal_error "please specify --dir option"
5432 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5433 test -n "$auxdir" || auxdir="build-aux"
5434 func_create_megatestdir "$destdir" "$*"
5438 test -n "$destdir" || destdir=testdir$$
5439 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5440 test -n "$auxdir" || auxdir="build-aux"
5441 func_create_testdir "$destdir" "$*"
5445 ../configure || func_exit 1
5446 $MAKE || func_exit 1
5447 $MAKE check || func_exit 1
5448 $MAKE distclean || func_exit 1
5449 remaining=`find . -type f -print`
5450 if test -n "$remaining"; then
5451 echo "Remaining files:" $remaining 1>&2
5452 echo "gnulib-tool: *** Stop." 1>&2
5461 test -n "$destdir" || destdir=testdir$$
5462 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5463 test -n "$auxdir" || auxdir="build-aux"
5464 func_create_megatestdir "$destdir" "$*"
5472 remaining=`find . -type f -print`
5473 if test -n "$remaining"; then
5474 echo "Remaining files:" $remaining 1>&2
5475 echo "gnulib-tool: *** Stop." 1>&2
5483 extract-description )
5487 if test -n "$module"; then
5488 func_get_description "$module"
5497 if test -n "$module"; then
5498 func_get_comment "$module"
5507 if test -n "$module"; then
5508 func_get_status "$module"
5517 if test -n "$module"; then
5518 func_get_notice "$module"
5523 extract-applicability )
5527 if test -n "$module"; then
5528 func_get_applicability "$module"
5537 if test -n "$module"; then
5538 func_get_filelist "$module"
5543 extract-dependencies )
5547 if test -n "$module"; then
5548 func_get_dependencies "$module"
5553 extract-autoconf-snippet )
5557 if test -n "$module"; then
5558 func_get_autoconf_snippet "$module"
5563 extract-automake-snippet )
5567 if test -n "$module"; then
5568 func_get_automake_snippet "$module"
5573 extract-include-directive )
5577 if test -n "$module"; then
5578 func_get_include_directive "$module"
5583 extract-link-directive )
5587 if test -n "$module"; then
5588 func_get_link_directive "$module"
5597 if test -n "$module"; then
5598 func_get_license "$module"
5603 extract-maintainer )
5607 if test -n "$module"; then
5608 func_get_maintainer "$module"
5613 extract-tests-module )
5617 if test -n "$module"; then
5618 func_get_tests_module "$module"
5624 # Verify the number of arguments.
5625 if test $# -lt 1 || test $# -gt 2; then
5626 func_fatal_error "invalid number of arguments for --$mode"
5629 # The first argument is the file to be copied.
5631 # Verify the file exists.
5632 func_lookup_file "$f"
5634 # The second argument is the destination; either a directory ot a file.
5635 # It defaults to the current directory.
5637 test -n "$dest" || dest='.'
5638 test -n "$sourcebase" || sourcebase="lib"
5639 test -n "$m4base" || m4base="m4"
5640 test -n "$docbase" || docbase="doc"
5641 test -n "$testsbase" || testsbase="tests"
5642 test -n "$auxdir" || auxdir="build-aux"
5643 rewritten='%REWRITTEN%'
5644 sed_rewrite_files="\
5645 s,^build-aux/,$rewritten$auxdir/,
5646 s,^doc/,$rewritten$docbase/,
5647 s,^lib/,$rewritten$sourcebase/,
5648 s,^m4/,$rewritten$m4base/,
5649 s,^tests/,$rewritten$testsbase/,
5652 if test -d "$dest"; then
5654 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5656 destdir=`dirname "$dest"`
5657 g=`basename "$dest"`
5660 # Create the directory for destfile.
5661 d=`dirname "$destdir/$g"`
5663 if test -n "$d" && test ! -d "$d"; then
5664 mkdir -p "$d" || func_fatal_error "failed"
5668 func_dest_tmpfilename "$g"
5669 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5670 already_present=true
5671 if test -f "$destdir/$g"; then
5672 # The file already exists.
5676 # Don't protest if the file should be there but isn't: it happens
5677 # frequently that developers don't put autogenerated files into CVS.
5684 func_fatal_error "unknown operation mode --$mode" ;;
5688 # Undo the effect of the previous 'trap' command. Some shellology:
5689 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5690 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5691 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5692 # 128 + signal number and is set before the trap-registered command is run.
5694 trap 'func_exit $?' 1 2 3 13 15
5699 # indent-tabs-mode: nil
5700 # whitespace-check-buffer-indent: nil