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_exists_module module
1383 # tests whether a module, given by name, exists
1385 # - local_gnulib_dir from --local-dir
1386 func_exists_module ()
1388 { test -f "$gnulib_dir/modules/$1" \
1389 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1390 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1391 && test "CVS" != "$1" \
1392 && test "ChangeLog" != "$1" \
1393 && test "COPYING" != "$1" \
1394 && test "README" != "$1" \
1395 && test "TEMPLATE" != "$1" \
1396 && test "TEMPLATE-EXTENDED" != "$1" \
1397 && test "TEMPLATE-TESTS" != "$1"
1400 # func_verify_module
1401 # verifies a module name
1403 # - local_gnulib_dir from --local-dir
1404 # - module module name argument
1405 func_verify_module ()
1407 if func_exists_module "$module"; then
1408 # OK, $module is a correct module name.
1409 # Verify that building the module description with 'patch' succeeds.
1410 func_lookup_file "modules/$module"
1412 func_warning "module $module doesn't exist"
1417 # func_verify_nontests_module
1418 # verifies a module name, excluding tests modules
1420 # - local_gnulib_dir from --local-dir
1421 # - module module name argument
1422 func_verify_nontests_module ()
1425 *-tests ) module= ;;
1426 * ) func_verify_module ;;
1430 # func_verify_tests_module
1431 # verifies a module name, considering only tests modules
1433 # - local_gnulib_dir from --local-dir
1434 # - module module name argument
1435 func_verify_tests_module ()
1438 *-tests ) func_verify_module ;;
1443 # Suffix of a sed expression that extracts a particular field from a
1444 # module description.
1445 # A field starts with a line that contains a keyword, such as 'Description',
1446 # followed by a colon and optional whitespace. All following lines, up to
1447 # the next field (or end of file if there is none) form the contents of the
1449 # An absent field is equivalent to a field with empty contents.
1450 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1451 sed_extract_prog=':[ ]*$/ {
1454 s/^Description:[ ]*$//
1458 s/^Applicability:[ ]*$//
1460 s/^Depends-on:[ ]*$//
1461 s/^configure\.ac-early:[ ]*$//
1462 s/^configure\.ac:[ ]*$//
1463 s/^Makefile\.am:[ ]*$//
1467 s/^Maintainer:[ ]*$//
1474 # Piece of a sed expression that converts a field header line to a shell
1476 # NOTE: Keep this in sync with sed_extract_prog above!
1477 sed_extract_field_header='
1478 s/^Description:[ ]*$/description/
1479 s/^Comment:[ ]*$/comment/
1480 s/^Status:[ ]*$/status/
1481 s/^Notice:[ ]*$/notice/
1482 s/^Applicability:[ ]*$/applicability/
1483 s/^Files:[ ]*$/files/
1484 s/^Depends-on:[ ]*$/dependson/
1485 s/^configure\.ac-early:[ ]*$/configureac_early/
1486 s/^configure\.ac:[ ]*$/configureac/
1487 s/^Makefile\.am:[ ]*$/makefile/
1488 s/^Include:[ ]*$/include/
1490 s/^License:[ ]*$/license/
1491 s/^Maintainer:[ ]*$/maintainer/'
1495 # Note: The 'eval' silences stderr output in dash.
1496 if declare -A x 2>/dev/null && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }; then
1497 # Zsh 4 and Bash 4 have associative arrays.
1498 have_associative=true
1500 # For other shells, use 'eval' with computed shell variable names.
1501 have_associative=false
1504 if $have_associative; then
1506 # Declare the associative arrays.
1507 declare -A modcache_cached
1508 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1509 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1510 eval "$declare_script"
1514 # func_cache_var module
1515 # computes the cache variable name corresponding to $module.
1516 # Note: This computation can map different module names to the same
1517 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1518 # to protect against this case.
1520 # - cachevar a shell variable name
1521 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1522 # Bash 2.0 and newer, ksh, and zsh support the syntax
1523 # ${param//pattern/replacement}
1524 # as a shorthand for
1525 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1526 # Note: The 'eval' above silences stderr output in dash.
1529 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1536 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1545 # func_init_sed_convert_to_cache_statements
1547 # - modcachevar_assignment
1549 # - sed_convert_to_cache_statements
1550 func_init_sed_convert_to_cache_statements ()
1552 # 'sed' script that turns a module description into shell script
1553 # assignments, suitable to be eval'ed. All active characters are escaped.
1556 # Some module's description
1561 # modcache_description[$1]=\
1562 # 'Some module'"'"'s description
1564 # modcache_files[$1]=\
1567 # c_MODULE_description_set=set; c_MODULE_description=\
1568 # 'Some module'"'"'s description
1570 # c_MODULE_files_set=set; c_MODULE_files=\
1572 # The script consists of two parts:
1573 # 1) Ignore the lines before the first field header.
1574 # 2) A loop, treating non-field-header lines by escaping single quotes
1575 # and adding a closing quote in the last line,
1576 sed_convert_to_cache_statements="
1578 # Here we have not yet seen a field header.
1580 # See if the current line contains a field header.
1583 ${sed_extract_field_header}
1586 # No field header. Ignore the line.
1588 # Read the next line. Upon EOF, just exit.
1593 # The current line contains a field header.
1595 # Turn it into the beginning of an assignment.
1596 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1598 # Move it to the hold space. Don't print it yet,
1599 # because we want no assignment if the field is empty.
1602 # Read the next line.
1603 # Upon EOF, the field was empty. Print no assignment. Just exit.
1606 # See if the current line contains a field header.
1609 ${sed_extract_field_header}
1610 # If it is, the previous field was empty. Print no assignment.
1613 # Not a field header.
1615 # Print the previous line, held in the hold space.
1620 # Transform single quotes.
1623 # Prepend a single quote.
1628 # Move it to the hold space.
1631 # Read the next line.
1638 # See if the current line contains a field header.
1641 ${sed_extract_field_header}
1644 # Print the previous line, held in the hold space.
1649 # Transform single quotes.
1656 # Print the previous line, held in the hold space, with a single quote
1657 # to end the assignment.
1667 # Print the previous line, held in the hold space, with a single quote
1668 # to end the assignment.
1675 if ! $sed_comments; then
1677 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1678 | sed -e 's/^ *//' -e 's/^#.*//'`
1682 if $have_associative; then
1683 # sed_convert_to_cache_statements does not depend on the module.
1684 modcachevar_assignment='modcache_\1[$1]='
1685 func_init_sed_convert_to_cache_statements
1688 # func_cache_lookup_module module
1690 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1691 # of its relevant data in a cache in the memory of the processing shell. If
1692 # already cached, it does not look it up again, thus saving file access time.
1694 # - module non-empty string
1695 # Output if $have_associative:
1696 # - modcache_cached[$module] set to yes
1697 # - modcache_description[$module] ==
1698 # - modcache_status[$module] \ set to the field's value, minus the
1699 # - ... / final newline,
1700 # - modcache_maintainer[$module] == or unset if the field's value is empty
1701 # Output if ! $have_associative:
1702 # - cachevar a shell variable name
1703 # - ${cachevar}_cached set to $module
1704 # - ${cachevar}_description ==
1705 # - ${cachevar}_status \ set to the field's value, minus the
1706 # - ... / final newline,
1707 # - ${cachevar}_maintainer == or unset if the field's value is empty
1708 # - ${cachevar}_description_set ==
1709 # - ${cachevar}_status_set \ set to non-empty if the field's value
1710 # - ... / is non-empty,
1711 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1712 func_cache_lookup_module ()
1714 if $have_associative; then
1715 cached=${modcache_cached[$1]}
1718 eval "cached=\"\$${cachevar}_cached\""
1720 if test -z "$cached"; then
1721 # Not found in cache. Look it up on the file system.
1722 func_lookup_file "modules/$1"
1723 if $have_associative; then
1724 modcache_cached[$1]=yes
1726 eval "${cachevar}_cached=\"\$1\""
1728 if ! $have_associative; then
1729 # sed_convert_to_cache_statements depends on the module.
1730 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1731 func_init_sed_convert_to_cache_statements
1733 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1734 eval "$cache_statements"
1736 if ! $have_associative; then
1737 if test "$1" != "$cached"; then
1738 func_fatal_error "cache variable collision between $1 and $cached"
1746 # func_get_description module
1748 # - local_gnulib_dir from --local-dir
1749 # - modcache true or false, from --cache-modules/--no-cache-modules
1750 func_get_description ()
1752 if ! $modcache; then
1753 func_lookup_file "modules/$1"
1754 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1756 func_cache_lookup_module "$1"
1757 # Output the field's value, including the final newline (if any).
1758 if $have_associative; then
1759 if test -n "${modcache_description[$1]+set}"; then
1760 echo "${modcache_description[$1]}"
1763 eval "field_set=\"\$${cachevar}_description_set\""
1764 if test -n "$field_set"; then
1765 eval "field_value=\"\$${cachevar}_description\""
1766 echo "${field_value}"
1772 # func_get_comment module
1774 # - local_gnulib_dir from --local-dir
1775 # - modcache true or false, from --cache-modules/--no-cache-modules
1778 if ! $modcache; then
1779 func_lookup_file "modules/$1"
1780 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1782 func_cache_lookup_module "$1"
1783 # Output the field's value, including the final newline (if any).
1784 if $have_associative; then
1785 if test -n "${modcache_comment[$1]+set}"; then
1786 echo "${modcache_comment[$1]}"
1789 eval "field_set=\"\$${cachevar}_comment_set\""
1790 if test -n "$field_set"; then
1791 eval "field_value=\"\$${cachevar}_comment\""
1792 echo "${field_value}"
1798 # func_get_status module
1800 # - local_gnulib_dir from --local-dir
1801 # - modcache true or false, from --cache-modules/--no-cache-modules
1804 if ! $modcache; then
1805 func_lookup_file "modules/$1"
1806 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1808 func_cache_lookup_module "$1"
1809 # Output the field's value, including the final newline (if any).
1810 if $have_associative; then
1811 if test -n "${modcache_status[$1]+set}"; then
1812 echo "${modcache_status[$1]}"
1815 eval "field_set=\"\$${cachevar}_status_set\""
1816 if test -n "$field_set"; then
1817 eval "field_value=\"\$${cachevar}_status\""
1818 echo "${field_value}"
1824 # func_get_notice module
1826 # - local_gnulib_dir from --local-dir
1827 # - modcache true or false, from --cache-modules/--no-cache-modules
1830 if ! $modcache; then
1831 func_lookup_file "modules/$1"
1832 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1834 func_cache_lookup_module "$1"
1835 # Output the field's value, including the final newline (if any).
1836 if $have_associative; then
1837 if test -n "${modcache_notice[$1]+set}"; then
1838 echo "${modcache_notice[$1]}"
1841 eval "field_set=\"\$${cachevar}_notice_set\""
1842 if test -n "$field_set"; then
1843 eval "field_value=\"\$${cachevar}_notice\""
1844 echo "${field_value}"
1850 # func_get_applicability module
1852 # - local_gnulib_dir from --local-dir
1853 # - modcache true or false, from --cache-modules/--no-cache-modules
1854 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1855 func_get_applicability ()
1857 if ! $modcache; then
1858 func_lookup_file "modules/$1"
1859 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1861 func_cache_lookup_module "$1"
1862 # Get the field's value, without the final newline.
1863 if $have_associative; then
1864 my_applicability="${modcache_applicability[$1]}"
1866 eval "my_applicability=\"\$${cachevar}_applicability\""
1869 if test -n "$my_applicability"; then
1870 echo $my_applicability
1872 # The default is 'main' or 'tests', depending on the module's name.
1874 *-tests) echo "tests";;
1880 # func_get_filelist module
1882 # - local_gnulib_dir from --local-dir
1883 # - modcache true or false, from --cache-modules/--no-cache-modules
1884 func_get_filelist ()
1886 if ! $modcache; then
1887 func_lookup_file "modules/$1"
1888 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1890 func_cache_lookup_module "$1"
1891 # Output the field's value, including the final newline (if any).
1892 if $have_associative; then
1893 if test -n "${modcache_files[$1]+set}"; then
1894 echo "${modcache_files[$1]}"
1897 eval "field_set=\"\$${cachevar}_files_set\""
1898 if test -n "$field_set"; then
1899 eval "field_value=\"\$${cachevar}_files\""
1900 echo "${field_value}"
1905 echo m4/gnulib-common.m4
1906 case "$autoconf_minversion" in
1913 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1914 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1915 # elements starting with prefix and ending with suffix are considered.
1916 # Processing: removed_prefix and removed_suffix are removed from each element,
1917 # added_prefix and added_suffix are added to each element.
1918 # prefix, suffix should not contain shell-special characters.
1919 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1920 # added_prefix, added_suffix should not contain the characters \|&.
1921 func_filter_filelist ()
1923 if test "$2" != "$nl" \
1924 || { $fast_func_append \
1925 && { test -z "$6" || $fast_func_remove_prefix; } \
1926 && { test -z "$7" || $fast_func_remove_suffix; }; \
1930 # Do not quote possibly-empty parameters in case patterns,
1931 # AIX and HP-UX ksh won't match them if they are empty.
1934 if test -n "$6"; then
1935 func_remove_prefix fff "$6"
1937 if test -n "$7"; then
1938 func_remove_suffix fff "$7"
1941 if test -z "$ffflist"; then
1944 func_append ffflist "$2${fff}"
1950 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1951 ffflist=`for fff in $3; do
1953 $4*$5) echo "$fff" ;;
1955 done | sed -e "$sed_fff_filter"`
1957 eval "$1=\"\$ffflist\""
1960 # func_get_dependencies module
1962 # - local_gnulib_dir from --local-dir
1963 # - modcache true or false, from --cache-modules/--no-cache-modules
1964 func_get_dependencies ()
1966 # ${module}-tests implicitly depends on ${module}, if that module exists.
1970 func_remove_suffix fgd1 '-tests'
1971 if func_exists_module "$fgd1"; then
1976 # Then the explicit dependencies listed in the module description.
1977 if ! $modcache; then
1978 func_lookup_file "modules/$1"
1979 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1981 func_cache_lookup_module "$1"
1982 # Output the field's value, including the final newline (if any).
1983 if $have_associative; then
1984 if test -n "${modcache_dependson[$1]+set}"; then
1985 echo "${modcache_dependson[$1]}"
1988 eval "field_set=\"\$${cachevar}_dependson_set\""
1989 if test -n "$field_set"; then
1990 eval "field_value=\"\$${cachevar}_dependson\""
1991 echo "${field_value}"
1997 # func_get_autoconf_early_snippet module
1999 # - local_gnulib_dir from --local-dir
2000 # - modcache true or false, from --cache-modules/--no-cache-modules
2001 func_get_autoconf_early_snippet ()
2003 if ! $modcache; then
2004 func_lookup_file "modules/$1"
2005 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2007 func_cache_lookup_module "$1"
2008 # Output the field's value, including the final newline (if any).
2009 if $have_associative; then
2010 if test -n "${modcache_configureac_early[$1]+set}"; then
2011 echo "${modcache_configureac_early[$1]}"
2014 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2015 if test -n "$field_set"; then
2016 eval "field_value=\"\$${cachevar}_configureac_early\""
2017 echo "${field_value}"
2023 # func_get_autoconf_snippet module
2025 # - local_gnulib_dir from --local-dir
2026 # - modcache true or false, from --cache-modules/--no-cache-modules
2027 func_get_autoconf_snippet ()
2029 if ! $modcache; then
2030 func_lookup_file "modules/$1"
2031 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2033 func_cache_lookup_module "$1"
2034 # Output the field's value, including the final newline (if any).
2035 if $have_associative; then
2036 if test -n "${modcache_configureac[$1]+set}"; then
2037 echo "${modcache_configureac[$1]}"
2040 eval "field_set=\"\$${cachevar}_configureac_set\""
2041 if test -n "$field_set"; then
2042 eval "field_value=\"\$${cachevar}_configureac\""
2043 echo "${field_value}"
2049 # func_get_automake_snippet module
2051 # - local_gnulib_dir from --local-dir
2052 # - modcache true or false, from --cache-modules/--no-cache-modules
2053 func_get_automake_snippet ()
2055 if ! $modcache; then
2056 func_lookup_file "modules/$1"
2057 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2059 func_cache_lookup_module "$1"
2060 # Output the field's value, including the final newline (if any).
2061 if $have_associative; then
2062 if test -n "${modcache_makefile[$1]+set}"; then
2063 echo "${modcache_makefile[$1]}"
2066 eval "field_set=\"\$${cachevar}_makefile_set\""
2067 if test -n "$field_set"; then
2068 eval "field_value=\"\$${cachevar}_makefile\""
2069 echo "${field_value}"
2075 # *-tests module live in tests/, not lib/.
2076 # Synthesize an EXTRA_DIST augmentation.
2077 all_files=`func_get_filelist $1`
2078 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2079 extra_files="$tests_files"
2080 if test -n "$extra_files"; then
2081 echo "EXTRA_DIST +=" $extra_files
2086 # Synthesize an EXTRA_DIST augmentation.
2087 sed_combine_lines='/\\$/{
2094 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2095 already_mentioned_files=` \
2096 { if ! $modcache; then
2097 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2099 if $have_associative; then
2100 if test -n "${modcache_makefile[$1]+set}"; then
2101 echo "${modcache_makefile[$1]}"
2104 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2105 if test -n "$field_set"; then
2106 eval 'field_value="$'"${cachevar}"'_makefile"'
2107 echo "${field_value}"
2112 | sed -e "$sed_combine_lines" \
2113 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2114 all_files=`func_get_filelist $1`
2115 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2116 # Remove $already_mentioned_files from $lib_files.
2117 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2118 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2119 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2120 if test -n "$extra_files"; then
2121 echo "EXTRA_DIST +=" $extra_files
2124 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2125 # This is necessary so that automake can generate the right list of
2127 # A possible approach would be to use autom4te --trace of the redefined
2128 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2129 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2130 # inside autoconf's built-in macros are not missed).
2131 # But it's simpler and more robust to do it here, based on the file list.
2132 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2133 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2134 # automake will generate a useless dependency; this is harmless.
2136 relocatable-prog-wrapper) ;;
2138 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2139 if test -n "$extra_files"; then
2140 echo "EXTRA_lib_SOURCES +=" $extra_files
2145 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2146 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2147 if test -n "$buildaux_files"; then
2148 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2149 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2152 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2153 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2154 if test -n "$top_files"; then
2155 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2156 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2163 # func_get_include_directive module
2165 # - local_gnulib_dir from --local-dir
2166 # - modcache true or false, from --cache-modules/--no-cache-modules
2167 func_get_include_directive ()
2170 if ! $modcache; then
2171 func_lookup_file "modules/$1"
2172 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2174 func_cache_lookup_module "$1"
2175 # Output the field's value, including the final newline (if any).
2176 if $have_associative; then
2177 if test -n "${modcache_include[$1]+set}"; then
2178 echo "${modcache_include[$1]}"
2181 eval "field_set=\"\$${cachevar}_include_set\""
2182 if test -n "$field_set"; then
2183 eval "field_value=\"\$${cachevar}_include\""
2184 echo "${field_value}"
2188 } | sed -e 's/^\(["<]\)/#include \1/'
2191 # func_get_link_directive module
2193 # - local_gnulib_dir from --local-dir
2194 # - modcache true or false, from --cache-modules/--no-cache-modules
2195 func_get_link_directive ()
2197 if ! $modcache; then
2198 func_lookup_file "modules/$1"
2199 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2201 func_cache_lookup_module "$1"
2202 # Output the field's value, including the final newline (if any).
2203 if $have_associative; then
2204 if test -n "${modcache_link[$1]+set}"; then
2205 echo "${modcache_link[$1]}"
2208 eval "field_set=\"\$${cachevar}_link_set\""
2209 if test -n "$field_set"; then
2210 eval "field_value=\"\$${cachevar}_link\""
2211 echo "${field_value}"
2217 # func_get_license module
2219 # - local_gnulib_dir from --local-dir
2220 # - modcache true or false, from --cache-modules/--no-cache-modules
2224 if ! $modcache; then
2225 func_lookup_file "modules/$1"
2226 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2228 func_cache_lookup_module "$1"
2229 # Output the field's value, including the final newline (if any).
2230 if $have_associative; then
2231 if test -n "${modcache_license[$1]+set}"; then
2232 echo "${modcache_license[$1]}"
2235 eval "field_set=\"\$${cachevar}_license_set\""
2236 if test -n "$field_set"; then
2237 eval "field_value=\"\$${cachevar}_license\""
2238 echo "${field_value}"
2242 # The default is GPL.
2244 } | sed -e 's,^ *$,,' | sed -e 1q
2247 # func_get_maintainer module
2249 # - local_gnulib_dir from --local-dir
2250 # - modcache true or false, from --cache-modules/--no-cache-modules
2251 func_get_maintainer ()
2253 if ! $modcache; then
2254 func_lookup_file "modules/$1"
2255 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2257 func_cache_lookup_module "$1"
2258 # Output the field's value, including the final newline (if any).
2259 if $have_associative; then
2260 if test -n "${modcache_maintainer[$1]+set}"; then
2261 echo "${modcache_maintainer[$1]}"
2264 eval "field_set=\"\$${cachevar}_maintainer_set\""
2265 if test -n "$field_set"; then
2266 eval "field_value=\"\$${cachevar}_maintainer\""
2267 echo "${field_value}"
2273 # func_get_tests_module module
2275 # - local_gnulib_dir from --local-dir
2276 func_get_tests_module ()
2278 # The naming convention for tests modules is hardwired: ${module}-tests.
2279 if test -f "$gnulib_dir/modules/$1"-tests \
2280 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2281 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2286 # func_acceptable module
2287 # tests whether a module is acceptable.
2289 # - inc_cxx_tests true if C++ interoperability tests should be included,
2291 # - inc_longrunning_tests true if long-runnings tests should be included,
2293 # - inc_privileged_tests true if tests that require root privileges should be
2294 # included, blank otherwise
2295 # - inc_unportable_tests true if tests that fail on some platforms should be
2296 # included, blank otherwise
2297 # - inc_all_tests true if all kinds of problematic unit tests should be
2298 # included, blank otherwise
2299 # - avoidlist list of modules to avoid
2302 for avoid in $avoidlist; do
2303 if test "$avoid" = "$1"; then
2310 for word in `func_get_status "$1"`; do
2313 test -n "$inc_all_tests" || test -n "$inc_cxx_tests" \
2317 test -n "$inc_all_tests" || test -n "$inc_longrunning_tests" \
2321 test -n "$inc_all_tests" || test -n "$inc_privileged_tests" \
2325 test -n "$inc_all_tests" || test -n "$inc_unportable_tests" \
2329 test -n "$inc_all_tests" \
2342 # func_modules_transitive_closure
2344 # - local_gnulib_dir from --local-dir
2345 # - modcache true or false, from --cache-modules/--no-cache-modules
2346 # - modules list of specified modules
2347 # - inctests true if tests should be included, blank otherwise
2348 # - incobsolete true if obsolete modules among dependencies should be
2349 # included, blank otherwise
2350 # - inc_cxx_tests true if C++ interoperability tests should be included,
2352 # - inc_longrunning_tests true if long-runnings tests should be included,
2354 # - inc_privileged_tests true if tests that require root privileges should be
2355 # included, blank otherwise
2356 # - inc_unportable_tests true if tests that fail on some platforms should be
2357 # included, blank otherwise
2358 # - inc_all_tests true if all kinds of problematic unit tests should be
2359 # included, blank otherwise
2360 # - avoidlist list of modules to avoid
2361 # - tmp pathname of a temporary directory
2363 # - modules list of modules, including dependencies
2364 func_modules_transitive_closure ()
2366 # In order to process every module only once (for speed), process an "input
2367 # list" of modules, producing an "output list" of modules. During each round,
2368 # more modules can be queued in the input list. Once a module on the input
2369 # list has been processed, it is added to the "handled list", so we can avoid
2370 # to process it again.
2372 inmodules="$modules"
2374 while test -n "$inmodules"; do
2375 inmodules_this_round="$inmodules"
2376 inmodules= # Accumulator, queue for next round
2377 for module in $inmodules_this_round; do
2379 if test -n "$module"; then
2380 if func_acceptable $module; then
2381 func_append outmodules " $module"
2382 deps=`func_get_dependencies $module`
2383 # Duplicate dependencies are harmless, but Jim wants a warning.
2384 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2385 if test -n "$duplicated_deps"; then
2386 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2388 for dep in $deps; do
2389 if test -n "$incobsolete" \
2391 for word in `func_get_status $dep`; do
2400 func_append inmodules " $dep"
2403 if test -n "$inctests"; then
2404 testsmodule=`func_get_tests_module $module`
2405 if test -n "$testsmodule"; then
2406 func_append inmodules " $testsmodule"
2412 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2413 # Remove $handledmodules from $inmodules.
2414 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2415 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2417 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2418 rm -f "$tmp"/queued-modules
2421 # func_modules_add_dummy
2423 # - local_gnulib_dir from --local-dir
2424 # - modcache true or false, from --cache-modules/--no-cache-modules
2425 # - modules list of modules, including dependencies
2427 # - modules list of modules, including 'dummy' if needed
2428 func_modules_add_dummy ()
2430 # Determine whether any module provides a lib_SOURCES augmentation.
2432 sed_remove_backslash_newline=':a
2439 for module in $modules; do
2440 func_verify_nontests_module
2441 if test -n "$module"; then
2442 # Extract the value of "lib_SOURCES += ...".
2443 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2444 # Ignore .h files since they are not compiled.
2448 have_lib_SOURCES=yes
2455 # Add the dummy module, to make sure the library will be non-empty.
2456 if test -z "$have_lib_SOURCES"; then
2457 if func_acceptable "dummy"; then
2458 func_append modules " dummy"
2463 # func_modules_notice
2465 # - local_gnulib_dir from --local-dir
2466 # - modcache true or false, from --cache-modules/--no-cache-modules
2467 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2468 # - modules list of modules, including dependencies
2469 func_modules_notice ()
2471 if test $verbose -ge -1; then
2472 for module in $modules; do
2474 if test -n "$module"; then
2475 msg=`func_get_notice $module`
2476 if test -n "$msg"; then
2477 echo "Notice from module $module:"
2478 echo "$msg" | sed -e 's/^/ /'
2485 # func_modules_to_filelist
2487 # - local_gnulib_dir from --local-dir
2488 # - modcache true or false, from --cache-modules/--no-cache-modules
2489 # - modules list of modules, including dependencies
2491 # - files list of files
2492 func_modules_to_filelist ()
2495 for module in $modules; do
2497 if test -n "$module"; then
2498 fs=`func_get_filelist $module`
2499 func_append files " $fs"
2502 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2505 # func_execute_command command [args...]
2506 # Executes a command.
2507 # Uses also the variables
2508 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2509 func_execute_command ()
2511 if test $verbose -ge 0; then
2515 # Commands like automake produce output to stderr even when they succeed.
2516 # Turn this output off if the command succeeds.
2517 "$@" > "$tmp"/cmdout 2>&1
2519 if test $cmdret = 0; then
2523 cat "$tmp"/cmdout 1>&2
2530 # func_dest_tmpfilename file
2531 # determines the name of a temporary file (file is relative to destdir).
2533 # - destdir target directory
2534 # - doit : if actions shall be executed, false if only to be printed
2535 # - tmp pathname of a temporary directory
2537 # - tmpfile absolute filename of the temporary file
2538 func_dest_tmpfilename ()
2541 # Put the new contents of $file in a file in the same directory (needed
2542 # to guarantee that an 'mv' to "$destdir/$file" works).
2543 tmpfile="$destdir/$1.tmp"
2545 # Put the new contents of $file in a file in a temporary directory
2546 # (because the directory of "$file" might not exist).
2547 tmpfile="$tmp"/`basename "$1"`.tmp
2552 # copies a file from gnulib into the destination directory. The destination
2553 # is known to not exist.
2555 # - destdir target directory
2556 # - local_gnulib_dir from --local-dir
2557 # - modcache true or false, from --cache-modules/--no-cache-modules
2558 # - f the original file name
2559 # - lookedup_file name of the merged (combined) file
2560 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2561 # - g the rewritten file name
2562 # - tmpfile absolute filename of the temporary file
2563 # - doit : if actions shall be executed, false if only to be printed
2564 # - symbolic true if files should be symlinked, copied otherwise
2565 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2570 echo "Copying file $g"
2571 if { test -n "$symbolic" \
2572 || { test -n "$lsymbolic" \
2573 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2574 && test -z "$lookedup_tmp" \
2575 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2576 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2578 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2586 # copies a file from gnulib into the destination directory. The destination
2587 # is known to exist.
2589 # - destdir target directory
2590 # - local_gnulib_dir from --local-dir
2591 # - modcache true or false, from --cache-modules/--no-cache-modules
2592 # - f the original file name
2593 # - lookedup_file name of the merged (combined) file
2594 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2595 # - g the rewritten file name
2596 # - tmpfile absolute filename of the temporary file
2597 # - doit : if actions shall be executed, false if only to be printed
2598 # - symbolic true if files should be symlinked, copied otherwise
2599 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2601 # - already_present nonempty if the file should already exist, empty otherwise
2604 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2605 : # The file has not changed.
2609 if test -n "$already_present"; then
2610 echo "Updating file $g (backup in ${g}~)"
2612 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2614 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2615 if { test -n "$symbolic" \
2616 || { test -n "$lsymbolic" \
2617 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2618 && test -z "$lookedup_tmp" \
2619 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2620 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2622 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2625 if test -n "$already_present"; then
2626 echo "Update file $g (backup in ${g}~)"
2628 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2634 # func_emit_lib_Makefile_am
2635 # emits the contents of library makefile to standard output.
2637 # - local_gnulib_dir from --local-dir
2638 # - modcache true or false, from --cache-modules/--no-cache-modules
2639 # - modules list of modules, including dependencies
2640 # - libname library name
2641 # - pobase directory relative to destdir where to place *.po files
2642 # - auxdir directory relative to destdir where to place build aux files
2643 # - makefile_name from --makefile-name
2644 # - libtool true if libtool will be used, false or blank otherwise
2645 # - macro_prefix prefix of gl_LIBOBJS macros to use
2646 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2647 # - actioncmd (optional) command that will reproduce this invocation
2648 # - for_test true if creating a package for testing, false otherwise
2649 # - destfile filename relative to destdir of makefile being generated
2651 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2652 # list of edits to be done to Makefile.am variables
2654 # - uses_subdirs nonempty if object files in subdirs exist
2655 func_emit_lib_Makefile_am ()
2657 # When creating an includable Makefile.am snippet, augment variables with
2658 # += instead of assigning them.
2659 if test -n "$makefile_name"; then
2664 if test "$libtool" = true; then
2667 sed_eliminate_LDFLAGS="$sed_noop"
2671 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2674 # When creating a package for testing: Attempt to provoke failures,
2675 # especially link errors, already during "make" rather than during
2676 # "make check", because "make check" is not possible in a cross-compiling
2677 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2678 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2680 sed_transform_check_PROGRAMS="$sed_noop"
2682 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2683 echo "## Process this file with automake to produce Makefile.in."
2684 func_emit_copyright_notice
2685 if test -n "$actioncmd"; then
2686 # The maximum line length (excluding the terminating newline) of any file
2687 # that is to be preprocessed by config.status is 3070. config.status uses
2688 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2689 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2690 len=`echo "$actioncmd" | wc -c`
2691 if test -n "$len" && test "$len" -le 3000; then
2692 echo "# Reproduce by: $actioncmd"
2698 for module in $modules; do
2699 func_verify_nontests_module
2700 if test -n "$module"; then
2702 func_get_automake_snippet "$module" |
2704 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2705 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2706 -e "$sed_eliminate_LDFLAGS" \
2707 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2708 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2709 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2710 -e "$sed_transform_check_PROGRAMS"
2711 if test "$module" = 'alloca'; then
2712 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2713 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2715 } > "$tmp"/amsnippet
2716 # Skip the contents if it's entirely empty.
2717 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2718 echo "## begin gnulib module $module"
2720 cat "$tmp"/amsnippet
2721 echo "## end gnulib module $module"
2724 rm -f "$tmp"/amsnippet
2725 # Test whether there are some source files in subdirectories.
2726 for f in `func_get_filelist "$module"`; do
2736 } > "$tmp"/allsnippets
2737 if test -z "$makefile_name"; then
2738 # If there are source files in subdirectories, prevent collision of the
2739 # object files (example: hash.c and libxml/hash.c).
2741 if test -n "$uses_subdirs"; then
2742 subdir_options=' subdir-objects'
2744 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2747 if test -z "$makefile_name"; then
2749 echo "noinst_HEADERS ="
2750 echo "noinst_LIBRARIES ="
2751 echo "noinst_LTLIBRARIES ="
2752 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2753 # if you specify pkgdata_DATA to empty. This is a workaround.
2754 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2755 echo "pkgdata_DATA ="
2758 echo "BUILT_SOURCES ="
2761 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2762 if test -z "$makefile_name"; then
2763 echo "MOSTLYCLEANDIRS ="
2765 echo "DISTCLEANFILES ="
2766 echo "MAINTAINERCLEANFILES ="
2768 # Execute edits that apply to the Makefile.am being generated.
2770 while test $edit != $makefile_am_edits; do
2771 edit=`expr $edit + 1`
2772 eval dir=\"\$makefile_am_edit${edit}_dir\"
2773 eval var=\"\$makefile_am_edit${edit}_var\"
2774 eval val=\"\$makefile_am_edit${edit}_val\"
2775 if test -n "$var"; then
2776 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2777 echo "${var} += ${val}"
2778 eval "makefile_am_edit${edit}_var="
2782 if test -z "$makefile_name"; then
2784 echo "AM_CPPFLAGS ="
2788 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2789 || { test -n "$makefile_name" \
2790 && test -f "$sourcebase/Makefile.am" \
2791 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2793 # One of the snippets or the user's Makefile.am already specifies an
2794 # installation location for the library. Don't confuse automake by saying
2795 # it should not be installed.
2798 # By default, the generated library should not be installed.
2799 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2802 echo "${libname}_${libext}_SOURCES ="
2803 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2804 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2805 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2806 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2807 echo "EXTRA_${libname}_${libext}_SOURCES ="
2808 if test "$libtool" = true; then
2809 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2812 if test -n "$pobase"; then
2813 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2816 cat "$tmp"/allsnippets \
2817 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2819 echo "mostlyclean-local: mostlyclean-generic"
2820 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2821 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2822 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2826 rm -f "$tmp"/allsnippets
2829 # func_emit_po_Makevars
2830 # emits the contents of po/ makefile parameterization to standard output.
2832 # - local_gnulib_dir from --local-dir
2833 # - modcache true or false, from --cache-modules/--no-cache-modules
2834 # - sourcebase directory relative to destdir where to place source code
2835 # - pobase directory relative to destdir where to place *.po files
2836 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2837 func_emit_po_Makevars ()
2839 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2840 func_emit_copyright_notice
2842 echo "# Usually the message domain is the same as the package name."
2843 echo "# But here it has a '-gnulib' suffix."
2844 echo "DOMAIN = ${po_domain}-gnulib"
2846 echo "# These two variables depend on the location of this directory."
2847 echo "subdir = ${pobase}"
2848 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2851 # These options get passed to xgettext.
2852 XGETTEXT_OPTIONS = \
2853 --keyword=_ --flag=_:1:pass-c-format \
2854 --keyword=N_ --flag=N_:1:pass-c-format \
2855 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2856 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2857 --flag=error:3:c-format --flag=error_at_line:5:c-format
2859 # This is the copyright holder that gets inserted into the header of the
2860 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2861 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2863 # This is the email address or URL to which the translators shall report
2864 # bugs in the untranslated strings:
2865 # - Strings which are not entire sentences, see the maintainer guidelines
2866 # in the GNU gettext documentation, section 'Preparing Strings'.
2867 # - Strings which use unclear terms or require additional context to be
2869 # - Strings which make invalid assumptions about notation of date, time or
2871 # - Pluralisation problems.
2872 # - Incorrect English spelling.
2873 # - Incorrect formatting.
2874 # It can be your email address, or a mailing list address where translators
2875 # can write to without being subscribed, or the URL of a web page through
2876 # which the translators can contact you.
2877 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2879 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2880 # message catalogs shall be used. It is usually empty.
2881 EXTRA_LOCALE_CATEGORIES =
2883 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2884 # context. Possible values are "yes" and "no". Set this to yes if the
2885 # package uses functions taking also a message context, like pgettext(), or
2886 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2891 # func_emit_po_POTFILES_in
2892 # emits the file list to be passed to xgettext to standard output.
2894 # - local_gnulib_dir from --local-dir
2895 # - modcache true or false, from --cache-modules/--no-cache-modules
2896 # - sourcebase directory relative to destdir where to place source code
2897 # - files list of new files
2898 func_emit_po_POTFILES_in ()
2900 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2901 func_emit_copyright_notice
2903 echo "# List of files which contain translatable strings."
2904 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2907 # func_emit_tests_Makefile_am witness_macro
2908 # emits the contents of tests makefile to standard output.
2910 # - local_gnulib_dir from --local-dir
2911 # - modcache true or false, from --cache-modules/--no-cache-modules
2912 # - modules list of modules, including dependencies
2913 # - libname library name
2914 # - auxdir directory relative to destdir where to place build aux files
2915 # - makefile_name from --makefile-name
2916 # - libtool true if libtool will be used, false or blank otherwise
2917 # - sourcebase relative directory containing lib source code
2918 # - m4base relative directory containing autoconf macros
2919 # - testsbase relative directory containing unit test code
2920 # - macro_prefix prefix of gl_LIBOBJS macros to use
2921 # - for_test true if creating a package for testing, false otherwise
2922 # - use_libtests true if a libtests.a should be built, false otherwise
2923 # - destfile filename relative to destdir of makefile being generated
2925 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2926 # list of edits to be done to Makefile.am variables
2928 # - uses_subdirs nonempty if object files in subdirs exist
2929 func_emit_tests_Makefile_am ()
2932 if test "$libtool" = true; then
2934 sed_eliminate_LDFLAGS="$sed_noop"
2937 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2940 # When creating a package for testing: Attempt to provoke failures,
2941 # especially link errors, already during "make" rather than during
2942 # "make check", because "make check" is not possible in a cross-compiling
2943 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2944 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2946 sed_transform_check_PROGRAMS="$sed_noop"
2948 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2949 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2950 echo "## Process this file with automake to produce Makefile.in."
2951 func_emit_copyright_notice
2955 for module in $modules; do
2957 func_verify_tests_module
2961 if test -n "$module"; then
2963 func_get_automake_snippet "$module" |
2965 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2966 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2967 -e "$sed_eliminate_LDFLAGS" \
2968 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2969 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2970 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2971 -e "$sed_transform_check_PROGRAMS"
2972 if $use_libtests && test "$module" = 'alloca'; then
2973 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2974 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2976 } > "$tmp"/amsnippet
2977 # Skip the contents if it's entirely empty.
2978 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2979 # Mention long-running tests at the end.
2981 for word in `func_get_status "$module"`; do
2982 if test "$word" = 'longrunning-test'; then
2987 { echo "## begin gnulib module $module"
2989 cat "$tmp"/amsnippet
2990 echo "## end gnulib module $module"
2994 rm -f "$tmp"/amsnippet
2995 # Test whether there are some source files in subdirectories.
2996 for f in `func_get_filelist "$module"`; do
2998 lib/*/*.c | tests/*/*.c)
3006 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3007 # Generate dependencies here, since it eases the debugging of test failures.
3008 # If there are source files in subdirectories, prevent collision of the
3009 # object files (example: hash.c and libxml/hash.c).
3011 if test -n "$uses_subdirs"; then
3012 subdir_options=' subdir-objects'
3014 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3017 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3020 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3021 # variable is needed to avoid an error from automake:
3022 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3025 echo "XFAIL_TESTS ="
3026 echo "TESTS_ENVIRONMENT ="
3027 echo "noinst_PROGRAMS ="
3028 if ! $for_test; then
3029 echo "check_PROGRAMS ="
3031 echo "noinst_HEADERS ="
3032 echo "noinst_LIBRARIES ="
3033 if $use_libtests; then
3035 echo "noinst_LIBRARIES += libtests.a"
3037 echo "check_LIBRARIES = libtests.a"
3040 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3041 # if you specify pkgdata_DATA to empty. This is a workaround.
3042 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3043 echo "pkgdata_DATA ="
3046 echo "BUILT_SOURCES ="
3048 echo "MOSTLYCLEANFILES = core *.stackdump"
3049 echo "MOSTLYCLEANDIRS ="
3051 echo "DISTCLEANFILES ="
3052 echo "MAINTAINERCLEANFILES ="
3053 # Execute edits that apply to the Makefile.am being generated.
3055 while test $edit != $makefile_am_edits; do
3056 edit=`expr $edit + 1`
3057 eval dir=\"\$makefile_am_edit${edit}_dir\"
3058 eval var=\"\$makefile_am_edit${edit}_var\"
3059 eval val=\"\$makefile_am_edit${edit}_val\"
3060 if test -n "$var"; then
3061 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3062 echo "${var} += ${val}"
3063 eval "makefile_am_edit${edit}_var="
3068 echo "AM_CPPFLAGS = \\"
3069 if test -n "${witness_macro}"; then
3070 echo " -D@${witness_macro}@=1 \\"
3072 echo " -I. -I\$(srcdir) \\"
3073 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3074 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3076 local_ldadd_before=''
3077 local_ldadd_after=''
3078 if $use_libtests; then
3079 # All test programs need to be linked with libtests.a.
3080 # It needs to be passed to the linker before ${libname}.${libext}, since
3081 # the tests-related modules depend on the main modules.
3082 # It also needs to be passed to the linker after ${libname}.${libext}
3083 # because the latter might contain incomplete modules (such as the 'error'
3084 # module whose dependency to 'progname' is voluntarily omitted).
3085 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3087 local_ldadd_before=' libtests.a'
3088 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3090 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3092 if $use_libtests; then
3093 echo "libtests_a_SOURCES ="
3094 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3095 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3096 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3097 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3098 echo "EXTRA_libtests_a_SOURCES ="
3099 # The circular dependency in LDADD requires this.
3100 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3103 # Many test scripts use ${EXEEXT} or ${srcdir}.
3104 # EXEEXT is defined by AC_PROG_CC through autoconf.
3105 # srcdir is defined by autoconf and automake.
3106 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3108 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3109 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3110 echo "# Clean up after Solaris cc."
3112 echo " rm -rf SunWS_cache"
3114 echo "mostlyclean-local: mostlyclean-generic"
3115 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3116 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3117 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3121 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3124 # func_emit_initmacro_start macro_prefix
3125 # emits the first few statements of the gl_INIT macro to standard output.
3126 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3127 func_emit_initmacro_start ()
3129 macro_prefix_arg="$1"
3130 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3131 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3132 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3133 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3135 # Furthermore it avoids an automake error like this when a Makefile.am
3136 # that uses pieces of gnulib also uses $(LIBOBJ):
3137 # automatically discovered file `error.c' should not be explicitly mentioned
3138 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3139 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3140 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3141 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3142 # automatically discovered file `error.c' should not be explicitly mentioned
3143 # We let automake know about the files to be distributed through the
3144 # EXTRA_lib_SOURCES variable.
3145 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3146 # Create data variables for checking the presence of files that are mentioned
3147 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3148 # because we want the check to happen when the configure file is created,
3149 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3150 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3151 # in which to expect them.
3152 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3153 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3157 # func_emit_initmacro_end macro_prefix
3158 # emits the last few statements of the gl_INIT macro to standard output.
3159 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3160 func_emit_initmacro_end ()
3162 macro_prefix_arg="$1"
3163 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3164 # The check is performed only when autoconf is run from the directory where
3165 # the configure.ac resides; if it is run from a different directory, the
3167 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3168 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3169 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3170 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3171 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3175 echo " m4_if(m4_sysval, [0], [],"
3176 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3178 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3179 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3180 echo " m4_popdef([AC_LIBSOURCES])"
3181 echo " m4_popdef([AC_REPLACE_FUNCS])"
3182 echo " m4_popdef([AC_LIBOBJ])"
3183 echo " AC_CONFIG_COMMANDS_PRE(["
3184 echo " ${macro_prefix_arg}_libobjs="
3185 echo " ${macro_prefix_arg}_ltlibobjs="
3186 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3187 echo " # Remove the extension."
3188 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3189 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3190 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3191 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3194 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3195 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3199 # func_emit_initmacro_done macro_prefix sourcebase
3200 # emits a few statements after the gl_INIT macro to standard output.
3201 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3202 # - sourcebase directory relative to destdir where to place source code
3203 func_emit_initmacro_done ()
3205 macro_prefix_arg="$1"
3208 echo "# Like AC_LIBOBJ, except that the module name goes"
3209 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3210 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3211 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3212 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3215 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3216 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3217 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3218 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3219 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3222 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3223 echo "# expected is derived from the gnulib-tool parameterization,"
3224 echo "# and alloca is special cased (for the alloca-opt module)."
3225 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3226 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3227 echo " m4_foreach([_gl_NAME], [\$1], ["
3228 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3229 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3230 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3236 # func_import modules
3237 # Uses also the variables
3238 # - destdir target directory
3239 # - local_gnulib_dir from --local-dir
3240 # - modcache true or false, from --cache-modules/--no-cache-modules
3241 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3242 # - libname library name
3243 # - sourcebase directory relative to destdir where to place source code
3244 # - m4base directory relative to destdir where to place *.m4 macros
3245 # - pobase directory relative to destdir where to place *.po files
3246 # - docbase directory relative to destdir where to place doc files
3247 # - testsbase directory relative to destdir where to place unit test code
3248 # - auxdir directory relative to destdir where to place build aux files
3249 # - inctests true if --with-tests was given, blank otherwise
3250 # - incobsolete true if --with-obsolete was given, blank otherwise
3251 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3252 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3254 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3256 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3258 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3259 # - avoidlist list of modules to avoid, from --avoid
3260 # - lgpl yes or a number if library's license shall be LGPL,
3262 # - makefile_name from --makefile-name
3263 # - libtool true if --libtool was given, false if --no-libtool was
3264 # given, blank otherwise
3265 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3266 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3267 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3268 # - vc_files true if --vc-files was given, false if --no-vc-files was
3269 # given, blank otherwise
3270 # - autoconf_minversion minimum supported autoconf version
3271 # - doit : if actions shall be executed, false if only to be printed
3272 # - symbolic true if files should be symlinked, copied otherwise
3273 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3275 # - do_copyrights true if copyright notices in files should be replaced,
3279 # Get the cached settings.
3280 cached_local_gnulib_dir=
3281 cached_specified_modules=
3283 cached_inc_cxx_tests=
3284 cached_inc_longrunning_tests=
3285 cached_inc_privileged_tests=
3286 cached_inc_unportable_tests=
3287 cached_inc_all_tests=
3297 cached_makefile_name=
3299 cached_macro_prefix=
3303 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3304 cached_libtool=false
3310 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3320 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3322 /gl_WITH_OBSOLETE/ {
3323 s,^.*$,cached_incobsolete=true,p
3325 /gl_WITH_CXX_TESTS/ {
3326 s,^.*$,cached_inc_cxx_tests=true,p
3328 /gl_WITH_LONGRUNNING_TESTS/ {
3329 s,^.*$,cached_inc_longrunning_tests=true,p
3331 /gl_WITH_PRIVILEGED_TESTS/ {
3332 s,^.*$,cached_inc_privileged_tests=true,p
3334 /gl_WITH_UNPORTABLE_TESTS/ {
3335 s,^.*$,cached_inc_unportable_tests=true,p
3337 /gl_WITH_ALL_TESTS/ {
3338 s,^.*$,cached_inc_all_tests=true,p
3341 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3344 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3347 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3350 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3353 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3356 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3359 s,^.*$,cached_inctests=true,p
3362 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3365 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3368 s,^.*$,cached_lgpl=yes,p
3370 /gl_MAKEFILE_NAME(/ {
3371 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3374 s,^.*$,cached_libtool=true,p
3376 /gl_MACRO_PREFIX(/ {
3377 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3380 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3383 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3385 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3386 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3391 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3392 s,^.*$,cached_files=",p
3405 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3409 # Merge the cached settings with the specified ones.
3410 # The m4base must be the same as expected from the pathname.
3411 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3412 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3414 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3415 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3416 if test -z "$local_gnulib_dir"; then
3417 if test -n "$cached_local_gnulib_dir"; then
3420 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3422 case "$cached_local_gnulib_dir" in
3424 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3426 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3427 local_gnulib_dir="$relconcat" ;;
3432 # Append the cached and the specified module names. So that
3433 # "gnulib-tool --import foo" means to add the module foo.
3434 specified_modules="$cached_specified_modules $1"
3435 # Included obsolete modules among the dependencies if specified either way.
3436 if test -z "$incobsolete"; then
3437 incobsolete="$cached_incobsolete"
3439 # Included special kinds of tests modules among the dependencies if specified
3441 if test -z "$inc_cxx_tests"; then
3442 inc_cxx_tests="$cached_inc_cxx_tests"
3444 if test -z "$inc_longrunning_tests"; then
3445 inc_longrunning_tests="$cached_inc_longrunning_tests"
3447 if test -z "$inc_privileged_tests"; then
3448 inc_privileged_tests="$cached_inc_privileged_tests"
3450 if test -z "$inc_unportable_tests"; then
3451 inc_unportable_tests="$cached_inc_unportable_tests"
3453 if test -z "$inc_all_tests"; then
3454 inc_all_tests="$cached_inc_all_tests"
3456 # Append the cached and the specified avoidlist. This is probably better
3457 # than dropping the cached one when --avoid is specified at least once.
3458 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3459 avoidlist=`echo $avoidlist`
3461 # The sourcebase defaults to the cached one.
3462 if test -z "$sourcebase"; then
3463 sourcebase="$cached_sourcebase"
3464 if test -z "$sourcebase"; then
3465 func_fatal_error "missing --source-base option"
3468 # The pobase defaults to the cached one.
3469 if test -z "$pobase"; then
3470 pobase="$cached_pobase"
3472 # The docbase defaults to the cached one.
3473 if test -z "$docbase"; then
3474 docbase="$cached_docbase"
3475 if test -z "$docbase"; then
3476 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."
3479 # The testsbase defaults to the cached one.
3480 if test -z "$testsbase"; then
3481 testsbase="$cached_testsbase"
3482 if test -z "$testsbase"; then
3483 func_fatal_error "missing --tests-base option"
3486 # Require the tests if specified either way.
3487 if test -z "$inctests"; then
3488 inctests="$cached_inctests"
3490 # The libname defaults to the cached one.
3491 if test -z "$supplied_libname"; then
3492 libname="$cached_libname"
3493 if test -z "$libname"; then
3494 func_fatal_error "missing --lib option"
3497 # Require LGPL if specified either way.
3498 if test -z "$lgpl"; then
3501 # The makefile_name defaults to the cached one.
3502 if test -z "$makefile_name"; then
3503 makefile_name="$cached_makefile_name"
3505 # Use libtool if specified either way, or if guessed.
3506 if test -z "$libtool"; then
3507 if test -n "$cached_m4base"; then
3508 libtool="$cached_libtool"
3510 libtool="$guessed_libtool"
3513 # The macro_prefix defaults to the cached one.
3514 if test -z "$macro_prefix"; then
3515 macro_prefix="$cached_macro_prefix"
3516 if test -z "$macro_prefix"; then
3517 func_fatal_error "missing --macro-prefix option"
3520 # The po_domain defaults to the cached one.
3521 if test -z "$po_domain"; then
3522 po_domain="$cached_po_domain"
3524 # The vc_files defaults to the cached one.
3525 if test -z "$vc_files"; then
3526 vc_files="$cached_vc_files"
3529 # Canonicalize the list of specified modules.
3530 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3532 # Determine final module list.
3533 modules="$specified_modules"
3534 func_modules_transitive_closure
3535 if test $verbose -ge 0; then
3536 echo "Module list with included dependencies:"
3537 echo "$modules" | sed -e 's/^/ /'
3539 final_modules="$modules"
3541 # Determine main module list and tests-related module list separately.
3542 # The main module list is the transitive closure of the specified modules,
3543 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3544 # is specified, it will consist only of LGPLed source.
3545 # The tests-related module list is the transitive closure of the specified
3546 # modules, including tests modules, minus the main module list excluding
3547 # modules of applicability 'all'. Its lib/* sources (brought in through
3548 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3549 # source, even if --lgpl is specified.
3550 # Determine main module list.
3551 saved_inctests="$inctests"
3553 modules="$specified_modules"
3554 func_modules_transitive_closure
3555 main_modules="$modules"
3556 inctests="$saved_inctests"
3557 if test $verbose -ge 1; then
3558 echo "Main module list:"
3559 echo "$main_modules" | sed -e 's/^/ /'
3561 # Determine tests-related module list.
3562 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3563 testsrelated_modules=`for module in $main_modules; do
3564 if test \`func_get_applicability $module\` = main; then
3568 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3569 if test $verbose -ge 1; then
3570 echo "Tests-related module list:"
3571 echo "$testsrelated_modules" | sed -e 's/^/ /'
3574 # Add the dummy module to the main module list if needed.
3575 modules="$main_modules"
3576 func_modules_add_dummy
3577 main_modules="$modules"
3579 # Determine whether a $testsbase/libtests.a is needed.
3581 for module in $testsrelated_modules; do
3582 func_verify_nontests_module
3583 if test -n "$module"; then
3584 all_files=`func_get_filelist $module`
3585 # Test whether some file in $all_files lies in lib/.
3586 for f in $all_files; do
3597 # Add the dummy module to the tests-related module list if needed.
3598 if $use_libtests; then
3599 modules="$testsrelated_modules"
3600 func_modules_add_dummy
3601 testsrelated_modules="$modules"
3604 # If --lgpl, verify that the licenses of modules are compatible.
3605 if test -n "$lgpl"; then
3606 license_incompatibilities=
3607 for module in $main_modules; do
3608 license=`func_get_license $module`
3610 'GPLed build tool') ;;
3611 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3616 LGPL | LGPLv2+ | LGPLv3+) ;;
3617 *) func_append license_incompatibilities "$module $license$nl" ;;
3623 *) func_append license_incompatibilities "$module $license$nl" ;;
3626 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3631 if test -n "$license_incompatibilities"; then
3632 # Format the license incompatibilities as a table.
3633 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3634 s,^\(.................................................[^ ]*\) *, \1 ,'
3635 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3636 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3640 # Show banner notice of every module.
3641 modules="$main_modules"
3644 # Determine script to apply to imported library files.
3645 sed_transform_lib_file=
3646 for module in $main_modules; do
3647 if test $module = config-h; then
3648 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3649 sed_transform_lib_file=$sed_transform_lib_file'
3650 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3655 sed_transform_main_lib_file="$sed_transform_lib_file"
3656 if test -n "$do_copyrights"; then
3657 if test -n "$lgpl"; then
3661 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3662 s/GNU General/GNU Lesser General/g
3666 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3667 s/GNU General/GNU Lesser General/g
3668 s/version [23]\([ ,]\)/version 2.1\1/g
3671 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3675 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3676 s/GNU Lesser General/GNU General/g
3677 s/GNU Library General/GNU General/g
3678 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3683 # Determine script to apply to auxiliary files that go into $auxdir/.
3684 sed_transform_build_aux_file=
3685 if test -n "$do_copyrights"; then
3687 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3688 s/GNU Lesser General/GNU General/g
3689 s/GNU Library General/GNU General/g
3690 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3694 # Determine script to apply to library files that go into $testsbase/.
3695 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3696 if test -n "$do_copyrights"; then
3698 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3699 s/GNU Lesser General/GNU General/g
3700 s/GNU Library General/GNU General/g
3701 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3705 # Determine the final file lists.
3706 # They must be computed separately, because files in lib/* go into
3707 # $sourcebase/ if they are in the main file list but into $testsbase/
3708 # if they are in the tests-related file list. Furthermore lib/dummy.c
3710 # Determine final main file list.
3711 modules="$main_modules"
3712 func_modules_to_filelist
3714 # Determine final tests-related file list.
3715 modules="$testsrelated_modules"
3716 func_modules_to_filelist
3717 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3718 # Merge both file lists.
3719 sed_remove_empty_lines='/^$/d'
3720 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3721 if test $verbose -ge 0; then
3723 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3724 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3728 || func_fatal_error "refusing to do nothing"
3730 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3731 new_files="$files m4/gnulib-tool.m4"
3732 old_files="$cached_files"
3733 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3734 func_append old_files " m4/gnulib-tool.m4"
3737 rewritten='%REWRITTEN%'
3738 sed_rewrite_old_files="\
3739 s,^build-aux/,$rewritten$auxdir/,
3740 s,^doc/,$rewritten$cached_docbase/,
3741 s,^lib/,$rewritten$cached_sourcebase/,
3742 s,^m4/,$rewritten$cached_m4base/,
3743 s,^tests/,$rewritten$cached_testsbase/,
3744 s,^tests=lib/,$rewritten$cached_testsbase/,
3747 sed_rewrite_new_files="\
3748 s,^build-aux/,$rewritten$auxdir/,
3749 s,^doc/,$rewritten$docbase/,
3750 s,^lib/,$rewritten$sourcebase/,
3751 s,^m4/,$rewritten$m4base/,
3752 s,^tests/,$rewritten$testsbase/,
3753 s,^tests=lib/,$rewritten$testsbase/,
3757 # Create directories.
3758 { echo "$sourcebase"
3760 if test -n "$pobase"; then
3763 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3764 if test -n "$docfiles"; then
3767 if test -n "$inctests"; then
3771 for f in $files; do echo $f; done \
3772 | sed -e "$sed_rewrite_new_files" \
3773 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3776 { # Rearrange file descriptors. Needed because "while ... done < ..."
3777 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3778 exec 5<&0 < "$tmp"/dirs
3780 if test ! -d "$destdir/$d"; then
3782 echo "Creating directory $destdir/$d"
3783 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3785 echo "Create directory $destdir/$d"
3792 # Copy files or make symbolic links. Remove obsolete files.
3796 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3797 # representing the files according to the last gnulib-tool invocation.
3798 for f in $old_files; do echo $f; done \
3799 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3802 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3803 # representing the files after this gnulib-tool invocation.
3804 for f in $new_files; do echo $f; done \
3805 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3808 # First the files that are in old-files, but not in new-files:
3809 sed_take_first_column='s,'"$delimiter"'.*,,'
3810 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3811 # Remove the file. Do nothing if the user already removed it.
3812 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3814 echo "Removing file $g (backup in ${g}~)"
3815 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3817 echo "Remove file $g (backup in ${g}~)"
3819 func_append removed_files "$g$nl"
3822 # func_add_or_update handles a file that ought to be present afterwards.
3824 # - f the original file name
3825 # - g the rewritten file name
3826 # - already_present nonempty if the file should already exist, empty
3828 func_add_or_update ()
3832 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3834 func_dest_tmpfilename "$g"
3835 func_lookup_file "$f"
3836 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3837 if test -n "$sed_transform_main_lib_file"; then
3840 sed -e "$sed_transform_main_lib_file" \
3841 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3845 if test -n "$sed_transform_build_aux_file"; then
3848 sed -e "$sed_transform_build_aux_file" \
3849 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3853 if test -n "$sed_transform_testsrelated_lib_file"; then
3856 sed -e "$sed_transform_testsrelated_lib_file" \
3857 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3861 if test -f "$destdir/$g"; then
3862 # The file already exists.
3866 # Don't protest if the file should be there but isn't: it happens
3867 # frequently that developers don't put autogenerated files into CVS.
3869 func_append added_files "$g$nl"
3873 # Then the files that are in new-files, but not in old-files:
3874 sed_take_last_column='s,^.*'"$delimiter"',,'
3876 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3877 | sed -e "$sed_take_last_column" \
3878 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3879 { # Rearrange file descriptors. Needed because "while ... done < ..."
3880 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3881 exec 5<&0 < "$tmp"/added-files
3887 # Then the files that are in new-files and in old-files:
3888 already_present=true
3889 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3890 | sed -e "$sed_take_last_column" \
3891 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3892 { # Rearrange file descriptors. Needed because "while ... done < ..."
3893 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3894 exec 5<&0 < "$tmp"/kept-files
3901 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3902 actioncmd="gnulib-tool --import"
3903 func_append actioncmd " --dir=$destdir"
3904 if test -n "$local_gnulib_dir"; then
3905 func_append actioncmd " --local-dir=$local_gnulib_dir"
3907 func_append actioncmd " --lib=$libname"
3908 func_append actioncmd " --source-base=$sourcebase"
3909 func_append actioncmd " --m4-base=$m4base"
3910 if test -n "$pobase"; then
3911 func_append actioncmd " --po-base=$pobase"
3913 func_append actioncmd " --doc-base=$docbase"
3914 func_append actioncmd " --tests-base=$testsbase"
3915 func_append actioncmd " --aux-dir=$auxdir"
3916 if test -n "$inctests"; then
3917 func_append actioncmd " --with-tests"
3919 if test -n "$incobsolete"; then
3920 func_append actioncmd " --with-obsolete"
3922 if test -n "$inc_cxx_tests"; then
3923 func_append actioncmd " --with-c++-tests"
3925 if test -n "$inc_longrunning_tests"; then
3926 func_append actioncmd " --with-longrunning-tests"
3928 if test -n "$inc_privileged_tests"; then
3929 func_append actioncmd " --with-privileged-tests"
3931 if test -n "$inc_unportable_tests"; then
3932 func_append actioncmd " --with-unportable-tests"
3934 if test -n "$inc_all_tests"; then
3935 func_append actioncmd " --with-all-tests"
3937 for module in $avoidlist; do
3938 func_append actioncmd " --avoid=$module"
3940 if test -n "$lgpl"; then
3941 if test "$lgpl" = yes; then
3942 func_append actioncmd " --lgpl"
3944 func_append actioncmd " --lgpl=$lgpl"
3947 if test -n "$makefile_name"; then
3948 func_append actioncmd " --makefile-name=$makefile_name"
3950 if test "$libtool" = true; then
3951 func_append actioncmd " --libtool"
3953 func_append actioncmd " --no-libtool"
3955 func_append actioncmd " --macro-prefix=$macro_prefix"
3956 if test -n "$po_domain"; then
3957 func_append actioncmd " --po-domain=$po_domain"
3959 if test -n "$vc_files"; then
3960 if test "$vc_files" = true; then
3961 func_append actioncmd " --vc-files"
3963 func_append actioncmd " --no-vc-files"
3966 func_append actioncmd " `echo $specified_modules`"
3968 # Default the makefile name to Makefile.am.
3969 if test -n "$makefile_name"; then
3970 makefile_am=$makefile_name
3972 makefile_am=Makefile.am
3975 # Create normal Makefile.ams.
3978 # Setup list of Makefile.am edits that are to be performed afterwards.
3979 # Some of these edits apply to files that we will generate; others are
3980 # under the responsibility of the developer.
3982 # func_note_Makefile_am_edit dir var value
3983 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3985 func_note_Makefile_am_edit ()
3987 makefile_am_edits=`expr $makefile_am_edits + 1`
3988 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3989 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3990 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3992 if test "$makefile_am" = Makefile.am; then
3993 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3994 sourcebase_base=`basename "$sourcebase"`
3995 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3997 if test -n "$pobase"; then
3998 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3999 pobase_base=`basename "$pobase"`
4000 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4002 if test -n "$inctests"; then
4003 if test "$makefile_am" = Makefile.am; then
4004 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4005 testsbase_base=`basename "$testsbase"`
4006 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4009 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4011 # Find the first parent directory of $m4base that contains or will contain
4013 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4015 sed_butlast='s,[^/][^/]*//*$,,'
4016 dir1="${m4base}/"; dir2=""
4017 while test -n "$dir1" \
4018 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4019 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4020 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4021 || { test -n "$inctests" \
4022 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4023 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4024 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4025 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4027 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4030 # Create library makefile.
4031 func_dest_tmpfilename $sourcebase/$makefile_am
4032 destfile="$sourcebase/$makefile_am"
4033 modules="$main_modules"
4034 func_emit_lib_Makefile_am > "$tmpfile"
4035 if test -f "$destdir"/$sourcebase/$makefile_am; then
4036 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4040 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4041 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4042 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4044 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4050 echo "Creating $sourcebase/$makefile_am"
4051 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4053 echo "Create $sourcebase/$makefile_am"
4056 func_append added_files "$sourcebase/$makefile_am$nl"
4059 # Create po/ directory.
4060 if test -n "$pobase"; then
4061 # Create po makefile and auxiliary files.
4062 for file in Makefile.in.in remove-potcdate.sin; do
4063 func_dest_tmpfilename $pobase/$file
4064 func_lookup_file build-aux/po/$file
4065 cat "$lookedup_file" > "$tmpfile"
4066 if test -f "$destdir"/$pobase/$file; then
4067 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4071 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4072 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4073 mv -f "$tmpfile" "$destdir"/$pobase/$file
4075 echo "Update $pobase/$file (backup in $pobase/$file~)"
4081 echo "Creating $pobase/$file"
4082 mv -f "$tmpfile" "$destdir"/$pobase/$file
4084 echo "Create $pobase/$file"
4087 func_append added_files "$pobase/$file$nl"
4090 # Create po makefile parameterization, part 1.
4091 func_dest_tmpfilename $pobase/Makevars
4092 func_emit_po_Makevars > "$tmpfile"
4093 if test -f "$destdir"/$pobase/Makevars; then
4094 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4098 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4099 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4100 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4102 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4108 echo "Creating $pobase/Makevars"
4109 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4111 echo "Create $pobase/Makevars"
4114 func_append added_files "$pobase/Makevars$nl"
4116 # Create po makefile parameterization, part 2.
4117 func_dest_tmpfilename $pobase/POTFILES.in
4118 func_emit_po_POTFILES_in > "$tmpfile"
4119 if test -f "$destdir"/$pobase/POTFILES.in; then
4120 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4124 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4125 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4126 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4128 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4134 echo "Creating $pobase/POTFILES.in"
4135 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4137 echo "Create $pobase/POTFILES.in"
4140 func_append added_files "$pobase/POTFILES.in$nl"
4143 TP_URL="http://translationproject.org/latest/"
4144 TP_RSYNC_URI="translationproject.org::tp/latest/"
4146 echo "Fetching gnulib PO files from $TP_URL"
4147 (cd "$destdir"/$pobase \
4148 && { # Prefer rsync over wget if it is available, since it consumes
4149 # less network bandwidth, due to compression.
4150 if type rsync 2>/dev/null | grep / > /dev/null; then
4151 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4153 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4158 echo "Fetch gnulib PO files from $TP_URL"
4160 # Create po/LINGUAS.
4162 func_dest_tmpfilename $pobase/LINGUAS
4163 (cd "$destdir"/$pobase \
4164 && { echo '# Set of available languages.'
4165 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4168 if test -f "$destdir"/$pobase/LINGUAS; then
4169 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4172 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4173 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4174 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4177 echo "Creating $pobase/LINGUAS"
4178 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4179 func_append added_files "$pobase/LINGUAS$nl"
4182 if test -f "$destdir"/$pobase/LINGUAS; then
4183 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4185 echo "Create $pobase/LINGUAS"
4190 # Create m4/gnulib-cache.m4.
4191 func_dest_tmpfilename $m4base/gnulib-cache.m4
4193 func_emit_copyright_notice
4195 echo "# This file represents the specification of how gnulib-tool is used."
4196 echo "# It acts as a cache: It is written and read by gnulib-tool."
4197 echo "# In projects using CVS, this file is meant to be stored in CVS,"
4198 echo "# like the configure.ac and various Makefile.am files."
4201 echo "# Specification in the form of a command-line invocation:"
4204 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4205 # Store the local_gnulib_dir relative to destdir.
4206 case "$local_gnulib_dir" in
4208 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4211 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4213 # destdir, local_gnulib_dir are both relative.
4214 func_relativize "$destdir" "$local_gnulib_dir"
4215 relative_local_gnulib_dir="$reldir" ;;
4218 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4220 echo "$specified_modules" | sed -e 's/^/ /g'
4222 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4223 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4224 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4225 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4226 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4227 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4228 echo "gl_AVOID([$avoidlist])"
4229 echo "gl_SOURCE_BASE([$sourcebase])"
4230 echo "gl_M4_BASE([$m4base])"
4231 echo "gl_PO_BASE([$pobase])"
4232 echo "gl_DOC_BASE([$docbase])"
4233 echo "gl_TESTS_BASE([$testsbase])"
4234 test -z "$inctests" || echo "gl_WITH_TESTS"
4235 echo "gl_LIB([$libname])"
4236 if test -n "$lgpl"; then
4237 if test "$lgpl" = yes; then
4240 echo "gl_LGPL([$lgpl])"
4243 echo "gl_MAKEFILE_NAME([$makefile_name])"
4244 if test "$libtool" = true; then
4247 echo "gl_MACRO_PREFIX([$macro_prefix])"
4248 echo "gl_PO_DOMAIN([$po_domain])"
4249 if test -n "$vc_files"; then
4250 echo "gl_VC_FILES([$vc_files])"
4253 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4254 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4258 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4259 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4260 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4262 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4266 echo "# gnulib-cache.m4 ends here"
4273 echo "Creating $m4base/gnulib-cache.m4"
4274 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4276 echo "Create $m4base/gnulib-cache.m4"
4282 # Create m4/gnulib-comp.m4.
4283 func_dest_tmpfilename $m4base/gnulib-comp.m4
4285 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4286 func_emit_copyright_notice
4288 echo "# This file represents the compiled summary of the specification in"
4289 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4290 echo "# to be invoked from configure.ac."
4291 echo "# In projects using CVS, this file can be treated like other built files."
4294 echo "# This macro should be invoked from $configure_ac, in the section"
4295 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4296 echo "# any checks for libraries, header files, types and library functions."
4297 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4299 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4300 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4301 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4302 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4303 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4304 if test -n "$uses_subdirs"; then
4305 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4307 for module in $final_modules; do
4309 if test -n "$module"; then
4310 echo "# Code from module $module:"
4311 func_get_autoconf_early_snippet "$module"
4314 | sed -e '/^$/d;' -e 's/^/ /'
4317 echo "# This macro should be invoked from $configure_ac, in the section"
4318 echo "# \"Check for header files, types and library functions\"."
4319 echo "AC_DEFUN([${macro_prefix}_INIT],"
4321 if test "$libtool" = true; then
4322 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4323 echo " gl_cond_libtool=true"
4325 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4326 echo " gl_cond_libtool=false"
4328 echo " gl_ltlibdeps="
4330 if test "$auxdir" != "build-aux"; then
4331 sed_replace_build_aux='
4333 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4334 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4338 sed_replace_build_aux="$sed_noop"
4340 echo " gl_m4_base='$m4base'"
4341 func_emit_initmacro_start $macro_prefix
4342 echo " gl_source_base='$sourcebase'"
4343 for module in $main_modules; do
4345 if test -n "$module"; then
4346 echo " # Code from module $module:"
4347 func_get_autoconf_snippet "$module" \
4348 | sed -e '/^$/d;' -e 's/^/ /' \
4349 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4350 -e "$sed_replace_build_aux"
4351 if test "$module" = 'alloca' && test "$libtool" = true; then
4352 echo 'changequote(,)dnl'
4353 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4354 echo 'changequote([, ])dnl'
4355 echo 'AC_SUBST([LTALLOCA])'
4359 echo " # End of code from modules"
4360 func_emit_initmacro_end $macro_prefix
4361 echo " gltests_libdeps="
4362 echo " gltests_ltlibdeps="
4363 func_emit_initmacro_start ${macro_prefix}tests
4364 echo " gl_source_base='$testsbase'"
4365 # Define a tests witness macro that depends on the package.
4366 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4367 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4368 echo "changequote(,)dnl"
4369 echo " ${macro_prefix}tests_WITNESS=IN_\`echo \"\${PACKAGE-\$PACKAGE_TARNAME}\" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'\`_GNULIB_TESTS"
4370 echo "changequote([, ])dnl"
4371 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4372 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4373 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4374 for module in $testsrelated_modules; do
4376 if test -n "$module"; then
4377 func_get_autoconf_snippet "$module" \
4378 | sed -e '/^$/d;' -e 's/^/ /' \
4379 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4380 -e "$sed_replace_build_aux" \
4381 -e 's/\$gl_cond_libtool/false/g' \
4382 -e 's/gl_libdeps/gltests_libdeps/g' \
4383 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4386 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4387 func_emit_initmacro_end ${macro_prefix}tests
4388 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4389 # created using libtool, because libtool already handles the dependencies.
4390 if test "$libtool" != true; then
4391 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4392 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4393 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4394 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4395 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4397 if $use_libtests; then
4398 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4399 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4402 func_emit_initmacro_done $macro_prefix $sourcebase
4403 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4405 echo "# This macro records the list of files which have been installed by"
4406 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4407 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4408 echo "$files" | sed -e 's,^, ,'
4411 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4412 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4416 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4417 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4418 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4420 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4424 echo "# gnulib-comp.m4 ends here"
4431 echo "Creating $m4base/gnulib-comp.m4"
4432 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4434 echo "Create $m4base/gnulib-comp.m4"
4440 if test -n "$inctests"; then
4441 # Create tests makefile.
4442 func_dest_tmpfilename $testsbase/$makefile_am
4443 destfile="$testsbase/$makefile_am"
4444 modules="$testsrelated_modules"
4445 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4446 if test -f "$destdir"/$testsbase/$makefile_am; then
4447 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4451 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4452 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4453 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4455 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4461 echo "Creating $testsbase/$makefile_am"
4462 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4464 echo "Create $testsbase/$makefile_am"
4467 func_append added_files "$testsbase/$makefile_am$nl"
4471 if test "$vc_files" != false; then
4472 # Update the .cvsignore and .gitignore files.
4473 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4474 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4475 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4476 echo "$m4base/|A|gnulib-comp.m4"
4477 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4478 { # Rearrange file descriptors. Needed because "while ... done < ..."
4479 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4480 exec 5<&0 < "$tmp"/fileset-changes
4481 func_update_ignorelist ()
4484 if test "$ignore" = .gitignore; then
4485 # In a .gitignore file, "foo" applies to the current directory and all
4486 # subdirectories, whereas "/foo" applies to the current directory only.
4489 doubly_escaped_anchor='\\/'
4493 doubly_escaped_anchor=''
4495 if test -f "$destdir/$dir$ignore"; then
4496 if test -n "$dir_added" || test -n "$dir_removed"; then
4497 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4498 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4499 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4500 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4501 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4503 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4505 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4506 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4507 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4508 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4509 } > "$tmp"/sed-ignore-removed
4510 { cat "$destdir/$dir$ignore"~
4511 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4512 } | sed -f "$tmp"/sed-ignore-removed \
4513 > "$destdir/$dir$ignore"
4515 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4520 if test -n "$dir_added"; then
4522 echo "Creating $destdir/$dir$ignore"
4524 if test "$ignore" = .cvsignore; then
4526 # Automake generates Makefile rules that create .dirstamp files.
4529 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4530 } > "$destdir/$dir$ignore"
4532 echo "Create $destdir/$dir$ignore"
4542 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4543 func_update_ignorelist .cvsignore
4545 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4546 func_update_ignorelist .gitignore
4553 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4554 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4555 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4556 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4557 if test "$next_dir" != "$last_dir"; then
4558 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4559 last_dir="$next_dir"
4564 A) func_append last_dir_added "$file$nl";;
4565 R) func_append last_dir_removed "$file$nl";;
4568 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4575 echo "You may need to add #include directives for the following .h files."
4576 # Intersect $specified_modules and $main_modules
4577 # (since $specified_modules is not necessarily of subset of $main_modules
4578 # - some may have been skipped through --avoid, and since the elements of
4579 # $main_modules but not in $specified_modules can go away without explicit
4580 # notice - through changes in the module dependencies).
4581 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4582 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4583 # First the #include <...> directives without #ifs, sorted for convenience,
4584 # then the #include "..." directives without #ifs, sorted for convenience,
4585 # then the #include directives that are surrounded by #ifs. Not sorted.
4586 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4587 include_directive=`func_get_include_directive "$module"`
4588 case "$nl$include_directive" in
4590 echo "$include_directive" 1>&5
4593 echo "$include_directive" | grep -v 'include "' 1>&6
4594 echo "$include_directive" | grep 'include "' 1>&7
4597 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4599 LC_ALL=C sort -u "$tmp"/include-angles
4600 LC_ALL=C sort -u "$tmp"/include-quotes
4601 cat "$tmp"/include-if
4602 ) | sed -e '/^$/d' -e 's/^/ /'
4603 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4605 for module in $main_modules; do
4606 func_get_link_directive "$module"
4608 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4609 if test `wc -l < "$tmp"/link` != 0; then
4611 echo "You may need to use the following Makefile variables when linking."
4612 echo "Use them in <program>_LDADD when linking a program, or"
4613 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4619 echo "Don't forget to"
4620 if test "$makefile_am" = Makefile.am; then
4621 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4623 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4625 if test -n "$pobase"; then
4626 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4628 if test -n "$inctests"; then
4629 if test "$makefile_am" = Makefile.am; then
4630 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4632 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4636 while test $edit != $makefile_am_edits; do
4637 edit=`expr $edit + 1`
4638 eval dir=\"\$makefile_am_edit${edit}_dir\"
4639 eval var=\"\$makefile_am_edit${edit}_var\"
4640 eval val=\"\$makefile_am_edit${edit}_val\"
4641 if test -n "$var"; then
4642 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4645 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4646 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4649 # func_create_testdir testdir modules
4651 # - local_gnulib_dir from --local-dir
4652 # - modcache true or false, from --cache-modules/--no-cache-modules
4653 # - auxdir directory relative to destdir where to place build aux files
4654 # - inctests true if tests should be included, blank otherwise
4655 # - incobsolete true if obsolete modules among dependencies should be
4656 # included, blank otherwise
4657 # - avoidlist list of modules to avoid
4658 # - libtool true if --libtool was given, false if --no-libtool was
4659 # given, blank otherwise
4660 # - symbolic true if files should be symlinked, copied otherwise
4661 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4663 func_create_testdir ()
4667 if test -z "$modules"; then
4668 # All modules together.
4669 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4670 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4671 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4672 modules=`func_all_modules`
4673 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4675 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
4677 # Unlike in func_import, here we want to include all kinds of tests.
4680 # Check that the license of every module is consistent with the license of
4682 saved_modules="$modules"
4683 saved_inctests="$inctests"
4684 # When computing transitive closures, don't consider $module to depend on
4685 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4686 # on GPL modules - therefore we don't want a warning in this case.
4688 for requested_module in $saved_modules; do
4689 requested_license=`func_get_license "$requested_module"`
4690 if test "$requested_license" != GPL; then
4691 # Here we use func_modules_transitive_closure, not just
4692 # func_get_dependencies, so that we also detect weird situations like
4693 # an LGPL module which depends on a GPLed build tool module which depends
4695 modules="$requested_module"
4696 func_modules_transitive_closure
4697 for module in $modules; do
4698 license=`func_get_license "$module"`
4700 'GPLed build tool') ;;
4701 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4703 case "$requested_license" in
4706 GPLv2+ | LGPLv2+) ;;
4707 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4713 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4719 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4728 modules="$saved_modules"
4729 inctests="$saved_inctests"
4731 # Subdirectory names.
4741 # Determine final module list.
4742 func_modules_transitive_closure
4743 if test $verbose -ge 0; then
4744 echo "Module list with included dependencies:"
4745 echo "$modules" | sed -e 's/^/ /'
4748 # Add the dummy module if needed.
4749 func_modules_add_dummy
4751 # Show banner notice of every module.
4754 # Determine final file list.
4755 func_modules_to_filelist
4756 if test $verbose -ge 0; then
4758 echo "$files" | sed -e 's/^/ /'
4761 rewritten='%REWRITTEN%'
4762 sed_rewrite_files="\
4763 s,^build-aux/,$rewritten$auxdir/,
4764 s,^doc/,$rewritten$docbase/,
4765 s,^lib/,$rewritten$sourcebase/,
4766 s,^m4/,$rewritten$m4base/,
4767 s,^tests/,$rewritten$testsbase/,
4771 # Create directories.
4772 for f in $files; do echo $f; done \
4773 | sed -e "$sed_rewrite_files" \
4774 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4775 | LC_ALL=C sort -u \
4777 { # Rearrange file descriptors. Needed because "while ... done < ..."
4778 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4779 exec 5<&0 < "$tmp"/dirs
4781 mkdir -p "$testdir/$d"
4786 # Copy files or make symbolic links.
4788 for f in $files; do echo $f; done \
4789 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4792 { # Rearrange file descriptors. Needed because "while ... done < ..."
4793 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4794 exec 5<&0 < "$tmp"/files
4796 func_lookup_file "$f"
4797 if test -n "$lookedup_tmp"; then
4798 cp -p "$lookedup_file" "$testdir/$g"
4800 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4801 if { test -n "$symbolic" \
4802 || { test -n "$lsymbolic" \
4803 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4804 func_ln "$lookedup_file" "$testdir/$g"
4806 cp -p "$lookedup_file" "$testdir/$g"
4813 # Create Makefile.ams that are for testing.
4816 # No special edits are needed.
4819 # Create $sourcebase/Makefile.am.
4820 mkdir -p "$testdir/$sourcebase"
4821 destfile="$sourcebase/Makefile.am"
4822 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4823 any_uses_subdirs="$uses_subdirs"
4825 # Create $m4base/Makefile.am.
4826 mkdir -p "$testdir/$m4base"
4827 (echo "## Process this file with automake to produce Makefile.in."
4833 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4836 ) > "$testdir/$m4base/Makefile.am"
4838 subdirs="$sourcebase $m4base"
4839 subdirs_with_configure_ac=""
4841 if false && test -f "$testdir"/$m4base/gettext.m4; then
4842 # Avoid stupid error message from automake:
4843 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4844 mkdir -p "$testdir/po"
4845 (echo "## Process this file with automake to produce Makefile.in."
4846 ) > "$testdir/po/Makefile.am"
4847 func_append subdirs " po"
4850 if test -n "$inctests"; then
4851 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4852 # Viewed from the $testsbase subdirectory, $auxdir is different.
4853 saved_auxdir="$auxdir"
4854 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4855 # Create $testsbase/Makefile.am.
4857 destfile="$testsbase/Makefile.am"
4858 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
4859 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4860 # Create $testsbase/configure.ac.
4861 (echo "# Process this file with autoconf to produce a configure script."
4862 echo "AC_INIT([dummy], [0])"
4863 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4864 echo "AM_INIT_AUTOMAKE"
4866 echo "AC_CONFIG_HEADERS([config.h])"
4869 echo "AC_PROG_INSTALL"
4870 echo "AC_PROG_MAKE_SET"
4871 echo "AC_PROG_RANLIB"
4873 if test -n "$uses_subdirs"; then
4874 echo "AM_PROG_CC_C_O"
4877 for module in $modules; do
4879 if test -n "$module"; then
4881 gnumakefile | maintainer-makefile)
4882 # These modules are meant to be used only in the top-level directory.
4885 func_get_autoconf_early_snippet "$module"
4890 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4891 if test "$libtool" = true; then
4892 echo "LT_INIT([win32-dll])"
4893 echo "LT_LANG([C++])"
4894 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4895 echo "gl_cond_libtool=true"
4897 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4898 echo "gl_cond_libtool=false"
4900 echo "gl_ltlibdeps="
4902 # Wrap the set of autoconf snippets into an autoconf macro that is then
4903 # invoked. This is needed because autoconf does not support AC_REQUIRE
4905 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4906 # but we want the AC_REQUIRE to have its normal meaning (provide one
4907 # expansion of the required macro before the current point, and only one
4909 echo "AC_DEFUN([gl_INIT], ["
4910 sed_replace_build_aux='
4912 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4913 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4916 echo "gl_m4_base='../$m4base'"
4917 func_emit_initmacro_start $macro_prefix
4918 # We don't have explicit ordering constraints between the various
4919 # autoconf snippets. It's cleanest to put those of the library before
4920 # those of the tests.
4921 echo "gl_source_base='../$sourcebase'"
4922 for module in $modules; do
4923 func_verify_nontests_module
4924 if test -n "$module"; then
4926 gnumakefile | maintainer-makefile)
4927 # These modules are meant to be used only in the top-level directory.
4930 func_get_autoconf_snippet "$module" \
4931 | sed -e "$sed_replace_build_aux"
4936 echo "gl_source_base='.'"
4937 for module in $modules; do
4938 func_verify_tests_module
4939 if test -n "$module"; then
4940 func_get_autoconf_snippet "$module" \
4941 | sed -e "$sed_replace_build_aux"
4944 func_emit_initmacro_end $macro_prefix
4945 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4946 # created using libtool, because libtool already handles the dependencies.
4947 if test "$libtool" != true; then
4948 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4949 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4950 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4951 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4952 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4955 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4959 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4960 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4961 echo "AH_TOP([#include \"../config.h\"])"
4963 echo "AC_CONFIG_FILES([Makefile])"
4965 ) > "$testdir/$testsbase/configure.ac"
4966 auxdir="$saved_auxdir"
4967 func_append subdirs " $testsbase"
4968 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4971 # Create Makefile.am.
4972 (echo "## Process this file with automake to produce Makefile.in."
4974 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4976 echo "SUBDIRS = $subdirs"
4978 echo "ACLOCAL_AMFLAGS = -I $m4base"
4979 ) > "$testdir/Makefile.am"
4981 # Create configure.ac.
4982 (echo "# Process this file with autoconf to produce a configure script."
4983 echo "AC_INIT([dummy], [0])"
4984 if test "$auxdir" != "."; then
4985 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4987 echo "AM_INIT_AUTOMAKE"
4989 echo "AC_CONFIG_HEADERS([config.h])"
4992 echo "AC_PROG_INSTALL"
4993 echo "AC_PROG_MAKE_SET"
4995 echo "# For autobuild."
4996 echo "AC_CANONICAL_BUILD"
4997 echo "AC_CANONICAL_HOST"
4999 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5000 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5001 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5002 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5004 echo "AC_PROG_RANLIB"
5006 if test -n "$any_uses_subdirs"; then
5007 echo "AM_PROG_CC_C_O"
5010 for module in $modules; do
5011 func_verify_nontests_module
5012 if test -n "$module"; then
5013 func_get_autoconf_early_snippet "$module"
5016 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5017 if test "$libtool" = true; then
5018 echo "LT_INIT([win32-dll])"
5019 echo "LT_LANG([C++])"
5020 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5021 echo "gl_cond_libtool=true"
5023 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5024 echo "gl_cond_libtool=false"
5026 echo "gl_ltlibdeps="
5028 # Wrap the set of autoconf snippets into an autoconf macro that is then
5029 # invoked. This is needed because autoconf does not support AC_REQUIRE
5031 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5032 # but we want the AC_REQUIRE to have its normal meaning (provide one
5033 # expansion of the required macro before the current point, and only one
5035 echo "AC_DEFUN([gl_INIT], ["
5036 if test "$auxdir" != "build-aux"; then
5037 sed_replace_build_aux='
5039 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5040 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5044 sed_replace_build_aux="$sed_noop"
5046 echo "gl_m4_base='$m4base'"
5047 func_emit_initmacro_start $macro_prefix
5048 echo "gl_source_base='$sourcebase'"
5049 for module in $modules; do
5050 func_verify_nontests_module
5051 if test -n "$module"; then
5052 func_get_autoconf_snippet "$module" \
5053 | sed -e "$sed_replace_build_aux"
5056 func_emit_initmacro_end $macro_prefix
5057 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5058 # created using libtool, because libtool already handles the dependencies.
5059 if test "$libtool" != true; then
5060 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5061 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5062 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5063 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5064 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5067 func_emit_initmacro_done $macro_prefix $sourcebase
5071 if test -n "$subdirs_with_configure_ac"; then
5072 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5074 makefiles="Makefile"
5075 for d in $subdirs; do
5076 # For subdirs that have a configure.ac by their own, it's the subdir's
5077 # configure.ac which creates the subdir's Makefile.am, not this one.
5078 case " $subdirs_with_configure_ac " in
5080 *) func_append makefiles " $d/Makefile" ;;
5083 echo "AC_CONFIG_FILES([$makefiles])"
5085 ) > "$testdir/configure.ac"
5087 # Create autogenerated files.
5089 # Do not use "${AUTORECONF} --force --install", because it may invoke
5090 # autopoint, which brings in older versions of some of our .m4 files.
5091 if test -f $m4base/gettext.m4; then
5092 func_execute_command ${AUTOPOINT} --force || func_exit 1
5093 for f in $m4base/*.m4~; do
5095 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5099 if test "$libtool" = true; then
5100 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5102 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5103 if ! test -d build-aux; then
5104 func_execute_command mkdir build-aux || func_exit 1
5106 func_execute_command ${AUTOCONF} || func_exit 1
5107 func_execute_command ${AUTOHEADER} || func_exit 1
5108 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5110 if test -n "$inctests"; then
5111 # Create autogenerated files.
5112 (cd "$testdir/$testsbase" || func_exit 1
5113 # Do not use "${AUTORECONF} --force --install", because it may invoke
5114 # autopoint, which brings in older versions of some of our .m4 files.
5115 if test -f ../$m4base/gettext.m4; then
5116 func_execute_command ${AUTOPOINT} --force || func_exit 1
5117 for f in ../$m4base/*.m4~; do
5119 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5123 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5124 if ! test -d ../build-aux; then
5125 func_execute_command mkdir ../build-aux
5127 func_execute_command ${AUTOCONF} || func_exit 1
5128 func_execute_command ${AUTOHEADER} || func_exit 1
5129 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5132 # Need to run configure and make once, to create built files that are to be
5133 # distributed (such as getdate.c).
5134 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5135 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5136 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5137 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5138 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5139 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5140 # such $(FOO_H) because they don't refer to distributed files.
5141 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5142 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5143 | sed -e "$sed_remove_make_variables"`
5144 distributed_built_sources=`for file in $built_sources; do
5145 case "$cleaned_files" in
5150 tests_distributed_built_sources=
5151 if test -n "$inctests"; then
5152 # Likewise for built files in the $testsbase directory.
5153 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5154 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5155 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5156 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5157 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5158 | sed -e "$sed_remove_make_variables"`
5159 tests_distributed_built_sources=`for file in $tests_built_sources; do
5160 case "$tests_cleaned_files" in
5166 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5168 ./configure || func_exit 1
5169 if test -n "$distributed_built_sources"; then
5171 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5172 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5177 if test -n "$tests_distributed_built_sources"; then
5179 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5180 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5185 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5192 # func_create_megatestdir megatestdir allmodules
5194 # - local_gnulib_dir from --local-dir
5195 # - modcache true or false, from --cache-modules/--no-cache-modules
5196 # - auxdir directory relative to destdir where to place build aux files
5197 func_create_megatestdir ()
5201 if test -z "$allmodules"; then
5202 allmodules=`func_all_modules`
5206 # First, all modules one by one.
5207 for onemodule in $allmodules; do
5208 func_create_testdir "$megatestdir/$onemodule" $onemodule
5209 func_append megasubdirs "$onemodule "
5211 # Then, all modules all together.
5212 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5213 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5214 func_create_testdir "$megatestdir/ALL" "$allmodules"
5215 func_append megasubdirs "ALL"
5218 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5219 vc_witness="$gnulib_dir/CVS/Entries"; \
5221 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5223 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5224 | sed -e 's,January,01,' -e 's,Jan,01,' \
5225 -e 's,February,02,' -e 's,Feb,02,' \
5226 -e 's,March,03,' -e 's,Mar,03,' \
5227 -e 's,April,04,' -e 's,Apr,04,' \
5229 -e 's,June,06,' -e 's,Jun,06,' \
5230 -e 's,July,07,' -e 's,Jul,07,' \
5231 -e 's,August,08,' -e 's,Aug,08,' \
5232 -e 's,September,09,' -e 's,Sep,09,' \
5233 -e 's,October,10,' -e 's,Oct,10,' \
5234 -e 's,November,11,' -e 's,Nov,11,' \
5235 -e 's,December,12,' -e 's,Dec,12,' \
5236 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5237 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5239 echo "CVSDATE=$cvsdate"
5240 echo ": \${MAKE=make}"
5241 echo "test -d logs || mkdir logs"
5242 echo "for module in $megasubdirs; do"
5243 echo " echo \"Working on module \$module...\""
5244 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5245 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5248 echo " : autobuild project... \$module"
5249 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5250 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5251 echo " : autobuild hostname... \`hostname\`"
5252 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5254 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5256 ) > "$megatestdir/do-autobuild"
5257 chmod a+x "$megatestdir/do-autobuild"
5259 # Create Makefile.am.
5260 (echo "## Process this file with automake to produce Makefile.in."
5262 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5264 echo "SUBDIRS = $megasubdirs"
5266 echo "EXTRA_DIST = do-autobuild"
5267 ) > "$megatestdir/Makefile.am"
5269 # Create configure.ac.
5270 (echo "# Process this file with autoconf to produce a configure script."
5271 echo "AC_INIT([dummy], [0])"
5272 if test "$auxdir" != "."; then
5273 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5275 echo "AM_INIT_AUTOMAKE"
5277 echo "AC_PROG_MAKE_SET"
5279 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5280 echo "AC_CONFIG_FILES([Makefile])"
5282 ) > "$megatestdir/configure.ac"
5284 # Create autogenerated files.
5286 # Do not use "${AUTORECONF} --install", because autoreconf operates
5287 # recursively, but the subdirectories are already finished, therefore
5288 # calling autoreconf here would only waste lots of CPU time.
5289 func_execute_command ${ACLOCAL} || func_exit 1
5290 func_execute_command mkdir build-aux
5291 func_execute_command ${AUTOCONF} || func_exit 1
5292 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5298 func_fatal_error "no mode specified" ;;
5305 # sed expression that converts a literal to a basic regular expression.
5306 # Needs to handle . [ \ * ^ $.
5307 sed_literal_to_basic_regex='s/\\/\\\\/g
5313 if test -f "$gnulib_dir/$filename" \
5314 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5315 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5316 filename_line_regex='^'"$filename_anywhere_regex"'$'
5319 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5320 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5321 (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$,,')
5324 | func_sanitize_modulelist \
5327 for module in $module_candidates; do
5328 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5333 func_warning "file $filename does not exist"
5341 if test -z "$destdir"; then
5344 test -d "$destdir" \
5345 || func_fatal_error "destination directory does not exist: $destdir"
5347 # Prefer configure.ac to configure.in.
5348 if test -f "$destdir"/configure.ac; then
5349 configure_ac="$destdir/configure.ac"
5351 if test -f "$destdir"/configure.in; then
5352 configure_ac="$destdir/configure.in"
5354 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5358 # Analyze configure.ac.
5360 guessed_libtool=false
5365 /AC_CONFIG_AUX_DIR/ {
5366 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5368 /A[CM]_PROG_LIBTOOL/ {
5369 s,^.*$,guessed_libtool=true,p
5371 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5373 if test -z "$auxdir"; then
5374 auxdir="$guessed_auxdir"
5377 # Determine where to apply func_import.
5378 if test -n "$m4base"; then
5379 # Apply func_import to a particular gnulib directory.
5380 # Any number of additional modules can be given.
5381 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5382 # First use of gnulib in the given m4base.
5383 test -n "$supplied_libname" || supplied_libname=true
5384 test -n "$sourcebase" || sourcebase="lib"
5385 test -n "$docbase" || docbase="doc"
5386 test -n "$testsbase" || testsbase="tests"
5387 test -n "$macro_prefix" || macro_prefix="gl"
5391 # Apply func_import to all gnulib directories.
5392 # To get this list of directories, look at Makefile.am. (Not at
5393 # configure, because it may be omitted from CVS. Also, don't run
5394 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5397 if test -f "$destdir"/Makefile.am; then
5398 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5400 for arg in $aclocal_amflags; do
5401 if test -n "$m4dir_is_next"; then
5402 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5406 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5407 func_append m4dirs " $arg"
5408 m4dirs_count=`expr $m4dirs_count + 1`
5414 if test "X$arg" = "X-I"; then
5422 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5423 if test -f "$destdir"/aclocal.m4; then
5424 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5425 sedexpr2='s,^[^/]*$,.,'
5426 sedexpr3='s,/[^/]*$,,'
5427 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5428 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5431 if test $m4dirs_count = 0; then
5432 # First use of gnulib in a package.
5433 # Any number of additional modules can be given.
5434 test -n "$supplied_libname" || supplied_libname=true
5435 test -n "$sourcebase" || sourcebase="lib"
5437 test -n "$docbase" || docbase="doc"
5438 test -n "$testsbase" || testsbase="tests"
5439 test -n "$macro_prefix" || macro_prefix="gl"
5442 if test $m4dirs_count = 1; then
5443 # There's only one use of gnulib here. Assume the user means it.
5444 # Any number of additional modules can be given.
5445 for m4base in $m4dirs; do
5449 # Ambiguous - guess what the user meant.
5450 if test $# = 0; then
5451 # No further arguments. Guess the user wants to update all of them.
5452 for m4base in $m4dirs; do
5453 # Perform func_import in a subshell, so that variable values
5455 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5456 # inc_longrunning_tests, inc_privileged_tests,
5457 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5458 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5459 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5460 # don't propagate from one directory to another.
5461 (func_import) || func_exit 1
5465 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5473 if test -z "$destdir"; then
5474 func_fatal_error "please specify --dir option"
5477 test -d "$destdir" \
5478 || func_fatal_error "could not create destination directory"
5479 test -n "$auxdir" || auxdir="build-aux"
5480 func_create_testdir "$destdir" "$*"
5483 create-megatestdir )
5484 if test -z "$destdir"; then
5485 func_fatal_error "please specify --dir option"
5487 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5488 test -n "$auxdir" || auxdir="build-aux"
5489 func_create_megatestdir "$destdir" "$*"
5493 test -n "$destdir" || destdir=testdir$$
5494 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5495 test -n "$auxdir" || auxdir="build-aux"
5496 func_create_testdir "$destdir" "$*"
5500 ../configure || func_exit 1
5501 $MAKE || func_exit 1
5502 $MAKE check || func_exit 1
5503 $MAKE distclean || func_exit 1
5504 remaining=`find . -type f -print`
5505 if test -n "$remaining"; then
5506 echo "Remaining files:" $remaining 1>&2
5507 echo "gnulib-tool: *** Stop." 1>&2
5516 test -n "$destdir" || destdir=testdir$$
5517 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5518 test -n "$auxdir" || auxdir="build-aux"
5519 func_create_megatestdir "$destdir" "$*"
5527 remaining=`find . -type f -print`
5528 if test -n "$remaining"; then
5529 echo "Remaining files:" $remaining 1>&2
5530 echo "gnulib-tool: *** Stop." 1>&2
5538 extract-description )
5542 if test -n "$module"; then
5543 func_get_description "$module"
5552 if test -n "$module"; then
5553 func_get_comment "$module"
5562 if test -n "$module"; then
5563 func_get_status "$module"
5572 if test -n "$module"; then
5573 func_get_notice "$module"
5578 extract-applicability )
5582 if test -n "$module"; then
5583 func_get_applicability "$module"
5592 if test -n "$module"; then
5593 func_get_filelist "$module"
5598 extract-dependencies )
5602 if test -n "$module"; then
5603 func_get_dependencies "$module"
5608 extract-autoconf-snippet )
5612 if test -n "$module"; then
5613 func_get_autoconf_snippet "$module"
5618 extract-automake-snippet )
5622 if test -n "$module"; then
5623 func_get_automake_snippet "$module"
5628 extract-include-directive )
5632 if test -n "$module"; then
5633 func_get_include_directive "$module"
5638 extract-link-directive )
5642 if test -n "$module"; then
5643 func_get_link_directive "$module"
5652 if test -n "$module"; then
5653 func_get_license "$module"
5658 extract-maintainer )
5662 if test -n "$module"; then
5663 func_get_maintainer "$module"
5668 extract-tests-module )
5672 if test -n "$module"; then
5673 func_get_tests_module "$module"
5679 # Verify the number of arguments.
5680 if test $# -lt 1 || test $# -gt 2; then
5681 func_fatal_error "invalid number of arguments for --$mode"
5684 # The first argument is the file to be copied.
5686 # Verify the file exists.
5687 func_lookup_file "$f"
5689 # The second argument is the destination; either a directory ot a file.
5690 # It defaults to the current directory.
5692 test -n "$dest" || dest='.'
5693 test -n "$sourcebase" || sourcebase="lib"
5694 test -n "$m4base" || m4base="m4"
5695 test -n "$docbase" || docbase="doc"
5696 test -n "$testsbase" || testsbase="tests"
5697 test -n "$auxdir" || auxdir="build-aux"
5698 rewritten='%REWRITTEN%'
5699 sed_rewrite_files="\
5700 s,^build-aux/,$rewritten$auxdir/,
5701 s,^doc/,$rewritten$docbase/,
5702 s,^lib/,$rewritten$sourcebase/,
5703 s,^m4/,$rewritten$m4base/,
5704 s,^tests/,$rewritten$testsbase/,
5707 if test -d "$dest"; then
5709 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5711 destdir=`dirname "$dest"`
5712 g=`basename "$dest"`
5715 # Create the directory for destfile.
5716 d=`dirname "$destdir/$g"`
5718 if test -n "$d" && test ! -d "$d"; then
5719 mkdir -p "$d" || func_fatal_error "failed"
5723 func_dest_tmpfilename "$g"
5724 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5725 already_present=true
5726 if test -f "$destdir/$g"; then
5727 # The file already exists.
5731 # Don't protest if the file should be there but isn't: it happens
5732 # frequently that developers don't put autogenerated files into CVS.
5739 func_fatal_error "unknown operation mode --$mode" ;;
5743 # Undo the effect of the previous 'trap' command. Some shellology:
5744 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5745 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5746 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5747 # 128 + signal number and is set before the trap-registered command is run.
5749 trap 'func_exit $?' 1 2 3 13 15
5754 # indent-tabs-mode: nil
5755 # whitespace-check-buffer-indent: nil