3 # Copyright (C) 2002-2011 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
130 gnulib-tool --add-import [module1 ... moduleN]
131 gnulib-tool --remove-import [module1 ... moduleN]
133 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
134 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
135 gnulib-tool --test --dir=directory module1 ... moduleN
136 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
137 gnulib-tool --extract-description module
138 gnulib-tool --extract-comment module
139 gnulib-tool --extract-status module
140 gnulib-tool --extract-notice module
141 gnulib-tool --extract-applicability module
142 gnulib-tool --extract-filelist module
143 gnulib-tool --extract-dependencies module
144 gnulib-tool --extract-autoconf-snippet module
145 gnulib-tool --extract-automake-snippet module
146 gnulib-tool --extract-include-directive module
147 gnulib-tool --extract-link-directive module
148 gnulib-tool --extract-license module
149 gnulib-tool --extract-maintainer module
150 gnulib-tool --extract-tests-module module
151 gnulib-tool --copy-file file [destination]
155 --list print the available module names
156 --find find the modules which contain the specified file
157 --import import the given modules into the current package
158 --add-import augment the list of imports from gnulib into the
159 current package, by adding the given modules;
160 if no modules are specified, update the current
161 package from the current gnulib
162 --remove-import reduce the list of imports from gnulib into the
163 current package, by removing the given modules
164 --update update the current package, restore files omitted
166 --create-testdir create a scratch package with the given modules
167 --create-megatestdir create a mega scratch package with the given modules
168 one by one and all together
169 --test test the combination of the given modules
170 (recommended to use CC=\"gcc -Wall\" here)
171 --megatest test the given modules one by one and all together
172 (recommended to use CC=\"gcc -Wall\" here)
173 --extract-description extract the description
174 --extract-comment extract the comment
175 --extract-status extract the status (obsolete etc.)
176 --extract-notice extract the notice or banner
177 --extract-applicability extract the applicability
178 --extract-filelist extract the list of files
179 --extract-dependencies extract the dependencies
180 --extract-autoconf-snippet extract the snippet for configure.ac
181 --extract-automake-snippet extract the snippet for library makefile
182 --extract-include-directive extract the #include directive
183 --extract-link-directive extract the linker directive
184 --extract-license report the license terms of the source files
186 --extract-maintainer report the maintainer(s) inside gnulib
187 --extract-tests-module report the unit test module, if it exists
188 --copy-file copy a file that is not part of any module
192 --dir=DIRECTORY Specify the target directory.
193 For --import, this specifies where your
194 configure.ac can be found. Defaults to current
196 --local-dir=DIRECTORY Specify a local override directory where to look
197 up files before looking in gnulib's directory.
198 --cache-modules Enable module caching optimization.
199 --no-cache-modules Disable module caching optimization.
200 --verbose Increase verbosity. May be repeated.
201 --quiet Decrease verbosity. May be repeated.
203 Options for --import, --add/remove-import, --update:
205 --dry-run Only print what would have been done.
207 Options for --import, --add/remove-import,
208 --create-[mega]testdir, --[mega]test:
210 --with-tests Include unit tests for the included modules.
211 --with-obsolete Include obsolete modules when they occur among the
212 dependencies. By default, dependencies to obsolete
214 --with-c++-tests Include even unit tests for C++ interoperability.
215 --with-longrunning-tests
216 Include even unit tests that are long-runners.
217 --with-privileged-tests
218 Include even unit tests that require root
220 --with-unportable-tests
221 Include even unit tests that fail on some platforms.
222 --with-all-tests Include all kinds of problematic unit tests.
223 --avoid=MODULE Avoid including the given MODULE. Useful if you
224 have code that provides equivalent functionality.
225 This option can be repeated.
226 --conditional-dependencies
227 Support conditional dependencies (experimental,
228 may save configure time and object code, not
229 compatible with --with-tests).
230 --libtool Use libtool rules.
231 --no-libtool Don't use libtool rules.
233 Options for --import, --add/remove-import:
235 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
236 --source-base=DIRECTORY
237 Directory relative to --dir where source code is
238 placed (default \"lib\").
239 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
240 placed (default \"m4\").
241 --po-base=DIRECTORY Directory relative to --dir where *.po files are
242 placed (default \"po\").
243 --doc-base=DIRECTORY Directory relative to --dir where doc files are
244 placed (default \"doc\").
245 --tests-base=DIRECTORY
246 Directory relative to --dir where unit tests are
247 placed (default \"tests\").
248 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
249 tools are placed (default comes from configure.ac).
250 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
251 Also modify license template from GPL to LGPL.
252 The version number of the LGPL can be specified;
253 the default is currently LGPLv3.
254 --makefile-name=NAME Name of makefile in automake syntax in the
255 source-base and tests-base directories
256 (default \"Makefile.am\").
257 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
258 'gl_INIT'. Default is 'gl'.
259 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
260 the package name. A suffix '-gnulib' is appended.
261 --vc-files Update version control related files.
262 --no-vc-files Don't update version control related files
263 (.gitignore and/or .cvsignore).
264 --no-changelog Don't update or create ChangeLog files.
266 Options for --create-[mega]testdir, --[mega]test:
268 --without-c++-tests Exclude unit tests for C++ interoperability.
269 --without-longrunning-tests
270 Exclude unit tests that are long-runners.
271 --without-privileged-tests
272 Exclude unit tests that require root privileges.
273 --without-unportable-tests
274 Exclude unit tests that fail on some platforms.
276 Options for --import, --add/remove-import, --update,
277 --create-[mega]testdir, --[mega]test:
279 -s, --symbolic, --symlink Make symbolic links instead of copying files.
280 --local-symlink Make symbolic links instead of copying files, only
281 for files from the local override directory.
283 Options for --import, --add/remove-import, --update:
285 -S, --more-symlinks Make symbolic links instead of copying files, and
286 don't replace copyright notices.
288 Report bugs to <bug-gnulib@gnu.org>."
292 # outputs to stdout the --version message.
296 if test -d "$gnulib_dir"/.git \
297 && (git --version) >/dev/null 2>/dev/null \
298 && (date --version) >/dev/null 2>/dev/null; then
299 # gnulib checked out from git.
300 sed_extract_first_date='/^Date/{
304 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
305 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
306 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
307 date=`echo "$date" | sed -e "$sed_year_before_time"`
308 # Use GNU date to compute the time in GMT.
309 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
310 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
312 if test -d "$gnulib_dir"/CVS \
313 && (cvs --version) >/dev/null 2>/dev/null; then
314 # gnulib checked out from CVS.
315 sed_extract_first_date='/^date: /{
316 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
319 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
321 # gnulib copy without versioning information.
322 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
326 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
328 gnulib-tool (GNU $package $date)$version
329 Copyright (C) $year Free Software Foundation, Inc.
330 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
331 This is free software: you are free to change and redistribute it.
332 There is NO WARRANTY, to the extent permitted by law.
334 Written by" "Bruno Haible" "and" "Simon Josefsson"
337 # func_emit_copyright_notice
338 # outputs to stdout a header for a generated file.
339 func_emit_copyright_notice ()
341 sed -n -e '/Copyright/ {
344 }' < "$self_abspathname"
346 echo "# This file is free software, distributed under the terms of the GNU"
347 echo "# General Public License. As a special exception to the GNU General"
348 echo "# Public License, this file may be distributed as part of a program"
349 echo "# that contains a configuration script generated by Autoconf, under"
350 echo "# the same distribution terms as the rest of that program."
352 echo "# Generated by gnulib-tool."
356 # exits with a given status.
357 # This function needs to be used, rather than 'exit', when a 'trap' handler is
358 # in effect that refers to $?.
365 # locates the directory where the gnulib repository lives
367 # - progname name of this program
369 # - self_abspathname absolute pathname of gnulib-tool
370 # - gnulib_dir absolute pathname of gnulib repository
374 /*) self_abspathname="$progname" ;;
375 */*) self_abspathname=`pwd`/"$progname" ;;
378 # Iterate through the elements of $PATH.
379 # We use IFS=: instead of
380 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
381 # because the latter does not work when some PATH element contains spaces.
382 # We use a canonicalized $pathx instead of $PATH, because empty PATH
383 # elements are by definition equivalent to '.', however field splitting
384 # according to IFS=: loses empty fields in many shells:
385 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
386 # beginning, at the end, and in the middle),
387 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
388 # at the beginning and at the end,
389 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
390 # Solaris lose empty fields at the end.
391 # The 'case' statement is an optimization, to avoid evaluating the
392 # explicit canonicalization command when $PATH contains no empty fields.
394 if test "${PATH_SEPARATOR+set}" != set; then
395 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
396 # contains only /bin. Note that ksh looks also at the FPATH variable,
397 # so we have to set that as well for the test.
399 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
400 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
401 || PATH_SEPARATOR=';'
404 if test "$PATH_SEPARATOR" = ";"; then
405 # On Windows, programs are searched in "." before $PATH.
408 # On Unix, we have to convert empty PATH elements to ".".
412 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
417 IFS="$PATH_SEPARATOR"
421 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
422 self_abspathname="$d/$progname"
427 if test -z "$self_abspathname"; then
428 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
432 while test -h "$self_abspathname"; do
433 # Resolve symbolic link.
434 linkval=`func_readlink "$self_abspathname"`
435 test -n "$linkval" || break
437 /* ) self_abspathname="$linkval" ;;
438 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
441 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
445 # creates a temporary directory.
447 # - progname name of this program
449 # - tmp pathname of freshly created temporary directory
452 # Use the environment variable TMPDIR, falling back to /tmp. This allows
453 # users to specify a different temporary directory, for example, if their
454 # /tmp is filled up or too small.
457 # Use the mktemp program if available. If not available, hide the error
459 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
460 test -n "$tmp" && test -d "$tmp"
463 # Use a simple mkdir command. It is guaranteed to fail if the directory
464 # already exists. $RANDOM is bash specific and expands to empty in shells
465 # other than bash, ksh and zsh. Its use does not increase security;
466 # rather, it minimizes the probability of failure in a very cluttered /tmp
468 tmp=$TMPDIR/gl$$-$RANDOM
469 (umask 077 && mkdir "$tmp")
472 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
477 # func_append var value
478 # appends the given value to the shell variable var.
479 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
480 # Use bash's += operator. It reduces complexity of appending repeatedly to
481 # a single variable from O(n^2) to O(n).
486 fast_func_append=true
490 eval "$1=\"\$$1\$2\""
492 fast_func_append=false
495 # func_remove_prefix var prefix
496 # removes the given prefix 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 # prefix should not contain the characters "$`\{}[]^|.
500 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
501 func_remove_prefix ()
505 fast_func_remove_prefix=true
507 func_remove_prefix ()
509 eval "value=\"\$$1\""
513 sed_escape_dots='s/\([.]\)/\\\1/g'
514 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
517 value=`echo "$value" | sed -e "s|^${prefix}||"`
518 eval "$1=\"\$value\""
520 fast_func_remove_prefix=false
523 # func_remove_suffix var suffix
524 # removes the given suffix from the value of the shell variable var.
525 # var should be the name of a shell variable.
526 # Its value should not contain a newline and not start or end with whitespace.
527 # suffix should not contain the characters "$`\{}[]^|.
528 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
529 func_remove_suffix ()
533 fast_func_remove_suffix=true
535 func_remove_suffix ()
537 eval "value=\"\$$1\""
541 sed_escape_dots='s/\([.]\)/\\\1/g'
542 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
545 value=`echo "$value" | sed -e "s|${suffix}\$||"`
546 eval "$1=\"\$value\""
548 fast_func_remove_suffix=false
551 # func_fatal_error message
552 # outputs to stderr a fatal error message, and terminates the program.
554 # - progname name of this program
557 echo "$progname: *** $1" 1>&2
558 echo "$progname: *** Stop." 1>&2
562 # func_warning message
563 # Outputs to stderr a warning message,
566 echo "gnulib-tool: warning: $1" 1>&2
569 # func_readlink SYMLINK
570 # outputs the target of the given symlink.
571 if (type -p readlink) > /dev/null 2>&1; then
574 # Use the readlink program from GNU coreutils.
580 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
581 # would do the wrong thing if the link target contains " -> ".
582 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
586 # func_relativize DIR1 DIR2
587 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
589 # - DIR1 relative pathname, relative to the current directory
590 # - DIR2 relative pathname, relative to the current directory
592 # - reldir relative pathname of DIR2, relative to DIR1
598 sed_first='s,^\([^/]*\)/.*$,\1,'
599 sed_rest='s,^[^/]*/*,,'
600 sed_last='s,^.*/\([^/]*\)$,\1,'
601 sed_butlast='s,/*[^/]*$,,'
602 while test -n "$dir1"; do
603 first=`echo "$dir1" | sed -e "$sed_first"`
604 if test "$first" != "."; then
605 if test "$first" = ".."; then
606 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
607 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
609 first2=`echo "$dir2" | sed -e "$sed_first"`
610 if test "$first2" = "$first"; then
611 dir2=`echo "$dir2" | sed -e "$sed_rest"`
615 dir0="$dir0"/"$first"
618 dir1=`echo "$dir1" | sed -e "$sed_rest"`
623 # func_relconcat DIR1 DIR2
624 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
626 # - DIR1 relative pathname, relative to the current directory
627 # - DIR2 relative pathname, relative to DIR1
629 # - relconcat DIR1/DIR2, relative to the current directory
634 sed_first='s,^\([^/]*\)/.*$,\1,'
635 sed_rest='s,^[^/]*/*,,'
636 sed_last='s,^.*/\([^/]*\)$,\1,'
637 sed_butlast='s,/*[^/]*$,,'
639 first=`echo "$dir2" | sed -e "$sed_first"`
640 if test "$first" = "."; then
641 dir2=`echo "$dir2" | sed -e "$sed_rest"`
642 if test -z "$dir2"; then
647 last=`echo "$dir1" | sed -e "$sed_last"`
648 while test "$last" = "."; do
649 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
650 last=`echo "$dir1" | sed -e "$sed_last"`
652 if test -z "$dir1"; then
656 if test "$first" = ".."; then
657 if test "$last" = ".."; then
658 relconcat="$dir1/$dir2"
661 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
662 dir2=`echo "$dir2" | sed -e "$sed_rest"`
663 if test -z "$dir1"; then
667 if test -z "$dir2"; then
672 relconcat="$dir1/$dir2"
680 # Like ln -s, except that SRC is given relative to the current directory (or
681 # absolute), not given relative to the directory of DEST.
687 *) # SRC is relative.
690 ln -s "`pwd`/$1" "$2" ;;
691 *) # DEST is relative too.
692 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
693 test -n "$ln_destdir" || ln_destdir="."
694 func_relativize "$ln_destdir" "$1"
702 # func_ln_if_changed SRC DEST
703 # Like func_ln, but avoids munging timestamps if the link is correct.
704 func_ln_if_changed ()
706 if test $# -ne 2; then
707 echo "usage: func_ln_if_changed SRC DEST" >&2
709 ln_target=`func_readlink "$2"`
710 if test -h "$2" && test "$1" = "$ln_target"; then
718 # Ensure an 'echo' command that
719 # 1. does not interpret backslashes and
720 # 2. does not print an error message "broken pipe" when writing into a pipe
723 # Test cases for problem 1:
724 # echo '\n' | wc -l prints 1 when OK, 2 when KO
725 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
726 # Test cases for problem 2:
727 # echo hi | true frequently prints
728 # "bash: echo: write error: Broken pipe"
729 # to standard error in bash 3.2.
731 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
732 # BSD echo interprets '-n' as an option, which is also not desirable).
733 # Nowadays the problem occurs in 4 situations:
734 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
735 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
736 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
737 # - in zsh, when sh-emulation is not set,
738 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
739 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
740 # - in Solaris /bin/sh and OSF/1 /bin/sh.
741 # We try the following workarounds:
742 # - for all: respawn using $CONFIG_SHELL if that is set and works.
743 # - for bash >= 2.04: unset the shell option xpg_echo.
744 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
745 # - for bash < 2.0: define echo to a function that uses cat of a here document.
746 # - for zsh: turn sh-emulation on.
747 # - for ksh: alias echo to 'print -r'.
748 # - for ksh: alias echo to a function that uses cat of a here document.
749 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
750 # the ksh workaround.
751 # - otherwise: respawn using /bin/sh and rely on the workarounds.
752 # When respawning, we pass --no-reexec as first argument, so as to avoid
753 # turning this script into a fork bomb in unlucky situations.
755 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
756 # the 'printf' built-in. See
757 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
758 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
759 # The workaround is: define echo to a function that uses the printf built-in.
761 if echo '\t' | grep t > /dev/null; then
762 have_echo=yes # Lucky!
764 # Try the workarounds.
765 # Respawn using $CONFIG_SHELL if that is set and works.
766 if test -z "$have_echo" \
767 && test "X$1" != "X--no-reexec" \
768 && test -n "$CONFIG_SHELL" \
769 && test -f "$CONFIG_SHELL" \
770 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
771 exec $CONFIG_SHELL "$0" --no-reexec "$@"
774 # For bash >= 2.04: unset the shell option xpg_echo.
775 if test -z "$have_echo" \
776 && test -n "$BASH_VERSION" \
777 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
781 # For bash >= 2.0: define echo to a function that uses the printf built-in.
782 # For bash < 2.0: define echo to a function that uses cat of a here document.
783 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
784 # Also handle problem 2, specific to bash 3.2, here.
785 if { test -z "$have_echo" \
786 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
788 && test -n "$BASH_VERSION"; then \
789 if type printf 2>/dev/null | grep / > /dev/null; then
790 # 'printf' is not a shell built-in.
798 # 'printf' is a shell built-in.
804 if echo '\t' | grep t > /dev/null; then
808 # For zsh: turn sh-emulation on.
809 if test -z "$have_echo" \
810 && test -n "$ZSH_VERSION" \
811 && (emulate sh) >/dev/null 2>&1; then
814 # For ksh: alias echo to 'print -r'.
815 if test -z "$have_echo" \
816 && (type print) >/dev/null 2>&1; then
817 # A 'print' command exists.
818 if type print 2>/dev/null | grep / > /dev/null; then
821 # 'print' is a shell built-in.
822 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
823 # 'print' is the ksh shell built-in.
824 alias echo='print -r'
828 if test -z "$have_echo" \
829 && echo '\t' | grep t > /dev/null; then
832 # For ksh: alias echo to a function that uses cat of a here document.
833 # The ksh manual page says:
834 # "Aliasing is performed when scripts are read, not while they are executed.
835 # Therefore, for an alias to take effect, the alias definition command has
836 # to be executed before the command which references the alias is read."
837 # Because of this, we have to play strange tricks with have_echo, to ensure
838 # that the top-level statement containing the test starts after the 'alias'
840 if test -z "$have_echo"; then
847 if (alias echo=bsd_echo) 2>/dev/null; then
848 alias echo=bsd_echo 2>/dev/null
851 if test -z "$have_echo" \
852 && echo '\t' | grep t > /dev/null; then
855 if test -z "$have_echo"; then
856 if (alias echo=bsd_echo) 2>/dev/null; then
857 unalias echo 2>/dev/null
860 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
861 if test -z "$have_echo" \
862 && test "X$1" != "X--no-reexec" \
863 && test -f /bin/ksh; then
864 exec /bin/ksh "$0" --no-reexec "$@"
867 # Otherwise: respawn using /bin/sh.
868 if test -z "$have_echo" \
869 && test "X$1" != "X--no-reexec" \
870 && test -f /bin/sh; then
871 exec /bin/sh "$0" --no-reexec "$@"
874 if test -z "$have_echo"; then
875 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
877 if echo '\t' | grep t > /dev/null; then
880 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
882 if test "X$1" = "X--no-reexec"; then
886 # Command-line option processing.
887 # Removes the OPTIONS from the arguments. Sets the variables:
888 # - mode list or import or add-import or remove-import or update
889 # or create-testdir or create-megatestdir
890 # - destdir from --dir
891 # - local_gnulib_dir from --local-dir
892 # - modcache true or false, from --cache-modules/--no-cache-modules
893 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
894 # - libname, supplied_libname from --lib
895 # - sourcebase from --source-base
896 # - m4base from --m4-base
897 # - pobase from --po-base
898 # - docbase from --doc-base
899 # - testsbase from --tests-base
900 # - auxdir from --aux-dir
901 # - inctests true if --with-tests was given, blank otherwise
902 # - incobsolete true if --with-obsolete was given, blank otherwise
903 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
904 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
906 # - inc_privileged_tests true if --with-privileged-tests was given, blank
908 # - inc_unportable_tests true if --with-unportable-tests was given, blank
910 # - inc_all_tests true if --with-all-tests was given, blank otherwise
911 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
912 # - excl_longrunning_tests true if --without-longrunning-tests was given,
914 # - excl_privileged_tests true if --without-privileged-tests was given, blank
916 # - excl_unportable_tests true if --without-unportable-tests was given, blank
918 # - avoidlist list of modules to avoid, from --avoid
919 # - cond_dependencies true if --conditional-dependencies was given, blank
921 # - lgpl yes or a number if --lgpl was given, blank otherwise
922 # - makefile_name from --makefile-name
923 # - libtool true if --libtool was given, false if --no-libtool was
924 # given, blank otherwise
925 # - macro_prefix from --macro-prefix
926 # - po_domain from --po-domain
927 # - vc_files true if --vc-files was given, false if --no-vc-files was
928 # given, blank otherwise
929 # - autoconf_minversion minimum supported autoconf version
930 # - do_changelog false if --no-changelog was given, : otherwise
931 # - doit : if actions shall be executed, false if only to be printed
932 # - symbolic true if --symlink or --more-symlinks was given, blank
934 # - lsymbolic true if --local-symlink was given, blank otherwise
935 # - do_copyrights blank if --more-symlinks was given, true otherwise
953 inc_longrunning_tests=
954 inc_privileged_tests=
955 inc_unportable_tests=
958 excl_longrunning_tests=
959 excl_privileged_tests=
960 excl_unportable_tests=
977 while test $# -gt 0; do
982 --find | --fin | --fi | --f )
985 --import | --impor | --impo | --imp | --im | --i )
988 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
991 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
994 --update | --updat | --upda | --upd | --up | --u )
997 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1000 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1001 mode=create-megatestdir
1003 --test | --tes | --te | --t )
1006 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1010 mode=`echo "X$1" | sed -e 's/^X--//'`
1012 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1017 if test $# = 0; then
1018 func_fatal_error "missing argument for --dir"
1023 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1027 if test $# = 0; then
1028 func_fatal_error "missing argument for --local-dir"
1033 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1035 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1038 --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 )
1041 --verbose | --verbos | --verbo | --verb )
1042 verbose=`expr $verbose + 1`
1044 --quiet | --quie | --qui | --qu | --q )
1045 verbose=`expr $verbose - 1`
1049 if test $# = 0; then
1050 func_fatal_error "missing argument for --lib"
1053 supplied_libname=true
1056 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1057 supplied_libname=true
1061 if test $# = 0; then
1062 func_fatal_error "missing argument for --source-base"
1067 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1071 if test $# = 0; then
1072 func_fatal_error "missing argument for --m4-base"
1077 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1081 if test $# = 0; then
1082 func_fatal_error "missing argument for --po-base"
1087 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1091 if test $# = 0; then
1092 func_fatal_error "missing argument for --doc-base"
1097 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1101 if test $# = 0; then
1102 func_fatal_error "missing argument for --tests-base"
1107 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1111 if test $# = 0; then
1112 func_fatal_error "missing argument for --aux-dir"
1117 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1119 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1122 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1125 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1128 --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)
1129 inc_longrunning_tests=true
1131 --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)
1132 inc_privileged_tests=true
1134 --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)
1135 inc_unportable_tests=true
1137 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1140 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1143 --without-longrunning-tests | --without-longrunning-test | --without-longrunning-tes | --without-longrunning-te | --without-longrunning-t | --without-longrunning- | --without-longrunning | --without-longrunnin | --without-longrunni | --without-longrunn | --without-longrun | --without-longru | --without-longr | --without-long | --without-lon | --without-lo | --without-l)
1144 excl_longrunning_tests=true
1146 --without-privileged-tests | --without-privileged-test | --without-privileged-tes | --without-privileged-te | --without-privileged-t | --without-privileged- | --without-privileged | --without-privilege | --without-privileg | --without-privile | --without-privil | --without-privi | --without-priv | --without-pri | --without-pr | --without-p)
1147 excl_privileged_tests=true
1149 --without-unportable-tests | --without-unportable-test | --without-unportable-tes | --without-unportable-te | --without-unportable-t | --without-unportable- | --without-unportable | --without-unportabl | --without-unportab | --without-unporta | --without-unport | --without-unpor | --without-unpo | --without-unp | --without-un | --without-u)
1150 excl_unportable_tests=true
1154 if test $# = 0; then
1155 func_fatal_error "missing argument for --avoid"
1157 func_append avoidlist " $1"
1160 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1161 func_append avoidlist " $arg"
1163 --conditional-dependencies | --conditional-dependencie | --conditional-dependenci | --conditional-dependenc | --conditional-dependen | --conditional-depende | --conditional-depend | --conditional-depen | --conditional-depe | --conditional-dep | --conditional-de | --conditional-d | --conditional- | --conditional | --conditiona | --condition | --conditio | --conditi | --condit | --condi | --cond | --con)
1164 cond_dependencies=true
1170 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1173 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1179 if test $# = 0; then
1180 func_fatal_error "missing argument for --makefile-name"
1185 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1195 if test $# = 0; then
1196 func_fatal_error "missing argument for --macro-prefix"
1201 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1205 if test $# = 0; then
1206 func_fatal_error "missing argument for --po-domain"
1211 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1219 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1225 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1228 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1231 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1235 --help | --hel | --he | --h )
1238 --version | --versio | --versi | --vers )
1242 # Stop option processing
1246 echo "gnulib-tool: unknown option $1" 1>&2
1247 echo "Try 'gnulib-tool --help' for more information." 1>&2
1254 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1255 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1256 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then
1257 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1258 echo "Try 'gnulib-tool --help' for more information." 1>&2
1262 # This code helps migrating from --import to --add-import or --update. It can
1263 # be removed on 2012-01-01.
1264 if test "$mode" = import && test $# = 0; then
1265 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1266 echo "The meaning of the option '--import' has changed." 1>&2
1267 echo "See the documentation at" 1>&2
1268 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1269 echo "For updating to a newer version of gnulib, use" 1>&2
1270 echo " gnulib-tool --add-import" 1>&2
1271 echo "For restoring files that were omitted from version control, use" 1>&2
1272 echo " gnulib-tool --update" 1>&2
1275 if test "$mode" = update; then
1276 if test $# != 0; then
1277 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1278 echo "Try 'gnulib-tool --help' for more information." 1>&2
1279 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1280 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1283 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1284 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1285 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1286 || test -n "$inctests" || test -n "$incobsolete" \
1287 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1288 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1289 || test -n "$inc_all_tests" \
1290 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1291 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1292 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1293 || test -n "$macro_prefix" || test -n "$po_domain" \
1294 || test -n "$vc_files"; then
1295 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1296 echo "Try 'gnulib-tool --help' for more information." 1>&2
1297 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1298 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1303 if test -n "$pobase" && test -z "$po_domain"; then
1304 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1305 echo "Try 'gnulib-tool --help' for more information." 1>&2
1308 if test -z "$pobase" && test -n "$po_domain"; then
1309 func_warning "--po-domain has no effect without a --po-base option"
1311 if test -n "$cond_dependencies" && test -n "$inctests"; then
1312 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1316 # Determine the minimum supported autoconf version from the project's
1318 DEFAULT_AUTOCONF_MINVERSION="2.59"
1319 autoconf_minversion=
1321 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1322 && test -n "$destdir"; then
1323 if test -f "$destdir"/configure.ac; then
1324 configure_ac="$destdir/configure.ac"
1326 if test -f "$destdir"/configure.in; then
1327 configure_ac="$destdir/configure.in"
1331 if test -f configure.ac; then
1332 configure_ac="configure.ac"
1334 if test -f configure.in; then
1335 configure_ac="configure.in"
1339 if test -n "$configure_ac"; then
1340 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1341 # because when some m4 files are omitted from a version control repository,
1342 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1343 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1344 # autom4te: m4 failed with exit status: 1
1351 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1353 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1354 if test -n "$prereqs"; then
1355 autoconf_minversion=`
1356 for version in $prereqs; do echo $version; done |
1357 LC_ALL=C sort -nru | sed -e 1q
1361 if test -z "$autoconf_minversion"; then
1362 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1364 case "$autoconf_minversion" in
1365 1.* | 2.[0-4]* | 2.5[0-8]*)
1366 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1369 # Remove trailing slashes from the directory names. This is necessary for
1370 # m4base (to avoid an error in func_import) and optional for the others.
1371 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1372 case "$local_gnulib_dir" in
1373 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1375 case "$sourcebase" in
1376 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1379 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1382 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1385 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1387 case "$testsbase" in
1388 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1391 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1397 trap 'exit_status=$?
1398 if test "$signal" != 0; then
1399 echo "caught signal $signal" >&2
1402 exit $exit_status' 0
1403 for signal in 1 2 3 13 15; do
1404 trap '{ signal='$signal'; func_exit 1; }' $signal
1408 # Note: The 'eval' silences stderr output in dash.
1409 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1410 # Zsh 4 and Bash 4 have associative arrays.
1411 have_associative=true
1413 # For other shells, use 'eval' with computed shell variable names.
1414 have_associative=false
1417 # func_lookup_file file
1418 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1421 # - local_gnulib_dir from --local-dir
1423 # - lookedup_file name of the merged (combined) file
1424 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1428 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1429 lookedup_file="$local_gnulib_dir/$lkfile"
1432 if test -f "$gnulib_dir/$lkfile"; then
1433 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1434 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1435 rm -f "$tmp/$lkbase"
1436 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1437 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1438 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1439 lookedup_file="$tmp/$lkbase"
1442 lookedup_file="$gnulib_dir/$lkfile"
1446 func_fatal_error "file $gnulib_dir/$lkfile not found"
1451 # func_sanitize_modulelist
1452 # receives a list of possible module names on standard input, one per line.
1453 # It removes those which are just file names unrelated to modules, and outputs
1454 # the resulting list to standard output, one per line.
1455 func_sanitize_modulelist ()
1457 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1458 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1459 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1460 -e '/^README$/d' -e '/\/README$/d' \
1461 -e '/^TEMPLATE$/d' \
1462 -e '/^TEMPLATE-EXTENDED$/d' \
1463 -e '/^TEMPLATE-TESTS$/d' \
1470 # - local_gnulib_dir from --local-dir
1473 # Filter out metainformation files like README, which are not modules.
1474 # Filter out unit test modules; they can be retrieved through
1475 # --extract-tests-module if desired.
1477 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1478 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1479 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1482 | func_sanitize_modulelist \
1483 | sed -e '/-tests$/d' \
1487 # func_exists_module module
1488 # tests whether a module, given by name, exists
1490 # - local_gnulib_dir from --local-dir
1491 func_exists_module ()
1493 { test -f "$gnulib_dir/modules/$1" \
1494 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1495 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1496 && test "CVS" != "$1" \
1497 && test "ChangeLog" != "$1" \
1498 && test "COPYING" != "$1" \
1499 && test "README" != "$1" \
1500 && test "TEMPLATE" != "$1" \
1501 && test "TEMPLATE-EXTENDED" != "$1" \
1502 && test "TEMPLATE-TESTS" != "$1"
1505 # func_verify_module
1506 # verifies a module name
1508 # - local_gnulib_dir from --local-dir
1509 # - module module name argument
1510 func_verify_module ()
1512 if func_exists_module "$module"; then
1513 # OK, $module is a correct module name.
1514 # Verify that building the module description with 'patch' succeeds.
1515 func_lookup_file "modules/$module"
1517 func_warning "module $module doesn't exist"
1522 # func_verify_nontests_module
1523 # verifies a module name, excluding tests modules
1525 # - local_gnulib_dir from --local-dir
1526 # - module module name argument
1527 func_verify_nontests_module ()
1530 *-tests ) module= ;;
1531 * ) func_verify_module ;;
1535 # func_verify_tests_module
1536 # verifies a module name, considering only tests modules
1538 # - local_gnulib_dir from --local-dir
1539 # - module module name argument
1540 func_verify_tests_module ()
1543 *-tests ) func_verify_module ;;
1548 # Suffix of a sed expression that extracts a particular field from a
1549 # module description.
1550 # A field starts with a line that contains a keyword, such as 'Description',
1551 # followed by a colon and optional whitespace. All following lines, up to
1552 # the next field (or end of file if there is none) form the contents of the
1554 # An absent field is equivalent to a field with empty contents.
1555 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1556 sed_extract_prog=':[ ]*$/ {
1559 s/^Description:[ ]*$//
1563 s/^Applicability:[ ]*$//
1565 s/^Depends-on:[ ]*$//
1566 s/^configure\.ac-early:[ ]*$//
1567 s/^configure\.ac:[ ]*$//
1568 s/^Makefile\.am:[ ]*$//
1572 s/^Maintainer:[ ]*$//
1579 # Piece of a sed expression that converts a field header line to a shell
1581 # NOTE: Keep this in sync with sed_extract_prog above!
1582 sed_extract_field_header='
1583 s/^Description:[ ]*$/description/
1584 s/^Comment:[ ]*$/comment/
1585 s/^Status:[ ]*$/status/
1586 s/^Notice:[ ]*$/notice/
1587 s/^Applicability:[ ]*$/applicability/
1588 s/^Files:[ ]*$/files/
1589 s/^Depends-on:[ ]*$/dependson/
1590 s/^configure\.ac-early:[ ]*$/configureac_early/
1591 s/^configure\.ac:[ ]*$/configureac/
1592 s/^Makefile\.am:[ ]*$/makefile/
1593 s/^Include:[ ]*$/include/
1595 s/^License:[ ]*$/license/
1596 s/^Maintainer:[ ]*$/maintainer/'
1600 if $have_associative; then
1602 # Declare the associative arrays.
1603 declare -A modcache_cached
1604 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1605 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1606 eval "$declare_script"
1610 # func_cache_var module
1611 # computes the cache variable name corresponding to $module.
1612 # Note: This computation can map different module names to the same
1613 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1614 # to protect against this case.
1616 # - cachevar a shell variable name
1617 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1618 # Bash 2.0 and newer, ksh, and zsh support the syntax
1619 # ${param//pattern/replacement}
1620 # as a shorthand for
1621 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1622 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1623 eval 'func_cache_var ()
1625 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1632 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1641 # func_init_sed_convert_to_cache_statements
1643 # - modcachevar_assignment
1645 # - sed_convert_to_cache_statements
1646 func_init_sed_convert_to_cache_statements ()
1648 # 'sed' script that turns a module description into shell script
1649 # assignments, suitable to be eval'ed. All active characters are escaped.
1652 # Some module's description
1657 # modcache_description[$1]=\
1658 # 'Some module'"'"'s description
1660 # modcache_files[$1]=\
1663 # c_MODULE_description_set=set; c_MODULE_description=\
1664 # 'Some module'"'"'s description
1666 # c_MODULE_files_set=set; c_MODULE_files=\
1668 # The script consists of two parts:
1669 # 1) Ignore the lines before the first field header.
1670 # 2) A loop, treating non-field-header lines by escaping single quotes
1671 # and adding a closing quote in the last line,
1672 sed_convert_to_cache_statements="
1674 # Here we have not yet seen a field header.
1676 # See if the current line contains a field header.
1679 ${sed_extract_field_header}
1682 # No field header. Ignore the line.
1684 # Read the next line. Upon EOF, just exit.
1689 # The current line contains a field header.
1691 # Turn it into the beginning of an assignment.
1692 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1694 # Move it to the hold space. Don't print it yet,
1695 # because we want no assignment if the field is empty.
1698 # Read the next line.
1699 # Upon EOF, the field was empty. Print no assignment. Just exit.
1702 # See if the current line contains a field header.
1705 ${sed_extract_field_header}
1706 # If it is, the previous field was empty. Print no assignment.
1709 # Not a field header.
1711 # Print the previous line, held in the hold space.
1716 # Transform single quotes.
1719 # Prepend a single quote.
1724 # Move it to the hold space.
1727 # Read the next line.
1734 # See if the current line contains a field header.
1737 ${sed_extract_field_header}
1740 # Print the previous line, held in the hold space.
1745 # Transform single quotes.
1752 # Print the previous line, held in the hold space, with a single quote
1753 # to end the assignment.
1763 # Print the previous line, held in the hold space, with a single quote
1764 # to end the assignment.
1771 if ! $sed_comments; then
1773 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1774 | sed -e 's/^ *//' -e 's/^#.*//'`
1778 if $have_associative; then
1779 # sed_convert_to_cache_statements does not depend on the module.
1780 modcachevar_assignment='modcache_\1[$1]='
1781 func_init_sed_convert_to_cache_statements
1784 # func_cache_lookup_module module
1786 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1787 # of its relevant data in a cache in the memory of the processing shell. If
1788 # already cached, it does not look it up again, thus saving file access time.
1790 # - module non-empty string
1791 # Output if $have_associative:
1792 # - modcache_cached[$module] set to yes
1793 # - modcache_description[$module] ==
1794 # - modcache_status[$module] \ set to the field's value, minus the
1795 # - ... / final newline,
1796 # - modcache_maintainer[$module] == or unset if the field's value is empty
1797 # Output if ! $have_associative:
1798 # - cachevar a shell variable name
1799 # - ${cachevar}_cached set to $module
1800 # - ${cachevar}_description ==
1801 # - ${cachevar}_status \ set to the field's value, minus the
1802 # - ... / final newline,
1803 # - ${cachevar}_maintainer == or unset if the field's value is empty
1804 # - ${cachevar}_description_set ==
1805 # - ${cachevar}_status_set \ set to non-empty if the field's value
1806 # - ... / is non-empty,
1807 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1808 func_cache_lookup_module ()
1810 if $have_associative; then
1811 eval 'cached=${modcache_cached[$1]}'
1814 eval "cached=\"\$${cachevar}_cached\""
1816 if test -z "$cached"; then
1817 # Not found in cache. Look it up on the file system.
1818 func_lookup_file "modules/$1"
1819 if $have_associative; then
1820 eval 'modcache_cached[$1]=yes'
1822 eval "${cachevar}_cached=\"\$1\""
1824 if ! $have_associative; then
1825 # sed_convert_to_cache_statements depends on the module.
1826 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1827 func_init_sed_convert_to_cache_statements
1829 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1830 eval "$cache_statements"
1832 if ! $have_associative; then
1833 if test "$1" != "$cached"; then
1834 func_fatal_error "cache variable collision between $1 and $cached"
1842 # func_get_description module
1844 # - local_gnulib_dir from --local-dir
1845 # - modcache true or false, from --cache-modules/--no-cache-modules
1846 func_get_description ()
1848 if ! $modcache; then
1849 func_lookup_file "modules/$1"
1850 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1852 func_cache_lookup_module "$1"
1853 # Output the field's value, including the final newline (if any).
1854 if $have_associative; then
1855 if eval 'test -n "${modcache_description[$1]+set}"'; then
1856 eval 'echo "${modcache_description[$1]}"'
1859 eval "field_set=\"\$${cachevar}_description_set\""
1860 if test -n "$field_set"; then
1861 eval "field_value=\"\$${cachevar}_description\""
1862 echo "${field_value}"
1868 # func_get_comment module
1870 # - local_gnulib_dir from --local-dir
1871 # - modcache true or false, from --cache-modules/--no-cache-modules
1874 if ! $modcache; then
1875 func_lookup_file "modules/$1"
1876 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1878 func_cache_lookup_module "$1"
1879 # Output the field's value, including the final newline (if any).
1880 if $have_associative; then
1881 if eval 'test -n "${modcache_comment[$1]+set}"'; then
1882 eval 'echo "${modcache_comment[$1]}"'
1885 eval "field_set=\"\$${cachevar}_comment_set\""
1886 if test -n "$field_set"; then
1887 eval "field_value=\"\$${cachevar}_comment\""
1888 echo "${field_value}"
1894 # func_get_status module
1896 # - local_gnulib_dir from --local-dir
1897 # - modcache true or false, from --cache-modules/--no-cache-modules
1900 if ! $modcache; then
1901 func_lookup_file "modules/$1"
1902 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1904 func_cache_lookup_module "$1"
1905 # Output the field's value, including the final newline (if any).
1906 if $have_associative; then
1907 if eval 'test -n "${modcache_status[$1]+set}"'; then
1908 eval 'echo "${modcache_status[$1]}"'
1911 eval "field_set=\"\$${cachevar}_status_set\""
1912 if test -n "$field_set"; then
1913 eval "field_value=\"\$${cachevar}_status\""
1914 echo "${field_value}"
1920 # func_get_notice module
1922 # - local_gnulib_dir from --local-dir
1923 # - modcache true or false, from --cache-modules/--no-cache-modules
1926 if ! $modcache; then
1927 func_lookup_file "modules/$1"
1928 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1930 func_cache_lookup_module "$1"
1931 # Output the field's value, including the final newline (if any).
1932 if $have_associative; then
1933 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1934 eval 'echo "${modcache_notice[$1]}"'
1937 eval "field_set=\"\$${cachevar}_notice_set\""
1938 if test -n "$field_set"; then
1939 eval "field_value=\"\$${cachevar}_notice\""
1940 echo "${field_value}"
1946 # func_get_applicability module
1948 # - local_gnulib_dir from --local-dir
1949 # - modcache true or false, from --cache-modules/--no-cache-modules
1950 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1951 func_get_applicability ()
1953 if ! $modcache; then
1954 func_lookup_file "modules/$1"
1955 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1957 func_cache_lookup_module "$1"
1958 # Get the field's value, without the final newline.
1959 if $have_associative; then
1960 eval 'my_applicability="${modcache_applicability[$1]}"'
1962 eval "my_applicability=\"\$${cachevar}_applicability\""
1965 if test -n "$my_applicability"; then
1966 echo $my_applicability
1968 # The default is 'main' or 'tests', depending on the module's name.
1970 *-tests) echo "tests";;
1976 # func_get_filelist module
1978 # - local_gnulib_dir from --local-dir
1979 # - modcache true or false, from --cache-modules/--no-cache-modules
1980 func_get_filelist ()
1982 if ! $modcache; then
1983 func_lookup_file "modules/$1"
1984 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1986 func_cache_lookup_module "$1"
1987 # Output the field's value, including the final newline (if any).
1988 if $have_associative; then
1989 if eval 'test -n "${modcache_files[$1]+set}"'; then
1990 eval 'echo "${modcache_files[$1]}"'
1993 eval "field_set=\"\$${cachevar}_files_set\""
1994 if test -n "$field_set"; then
1995 eval "field_value=\"\$${cachevar}_files\""
1996 echo "${field_value}"
2001 echo m4/gnulib-common.m4
2002 case "$autoconf_minversion" in
2009 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2010 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2011 # elements starting with prefix and ending with suffix are considered.
2012 # Processing: removed_prefix and removed_suffix are removed from each element,
2013 # added_prefix and added_suffix are added to each element.
2014 # prefix, suffix should not contain shell-special characters.
2015 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2016 # added_prefix, added_suffix should not contain the characters \|&.
2017 func_filter_filelist ()
2019 if test "$2" != "$nl" \
2020 || { $fast_func_append \
2021 && { test -z "$6" || $fast_func_remove_prefix; } \
2022 && { test -z "$7" || $fast_func_remove_suffix; }; \
2026 # Do not quote possibly-empty parameters in case patterns,
2027 # AIX and HP-UX ksh won't match them if they are empty.
2030 if test -n "$6"; then
2031 func_remove_prefix fff "$6"
2033 if test -n "$7"; then
2034 func_remove_suffix fff "$7"
2037 if test -z "$ffflist"; then
2040 func_append ffflist "$2${fff}"
2046 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2047 ffflist=`for fff in $3; do
2049 $4*$5) echo "$fff" ;;
2051 done | sed -e "$sed_fff_filter"`
2053 eval "$1=\"\$ffflist\""
2056 # func_get_dependencies module
2058 # - local_gnulib_dir from --local-dir
2059 # - modcache true or false, from --cache-modules/--no-cache-modules
2060 func_get_dependencies ()
2062 # ${module}-tests implicitly depends on ${module}, if that module exists.
2066 func_remove_suffix fgd1 '-tests'
2067 if func_exists_module "$fgd1"; then
2072 # Then the explicit dependencies listed in the module description.
2073 if ! $modcache; then
2074 func_lookup_file "modules/$1"
2075 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2077 func_cache_lookup_module "$1"
2078 # Output the field's value, including the final newline (if any).
2079 if $have_associative; then
2080 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2081 eval 'echo "${modcache_dependson[$1]}"'
2084 eval "field_set=\"\$${cachevar}_dependson_set\""
2085 if test -n "$field_set"; then
2086 eval "field_value=\"\$${cachevar}_dependson\""
2087 echo "${field_value}"
2093 # func_get_autoconf_early_snippet module
2095 # - local_gnulib_dir from --local-dir
2096 # - modcache true or false, from --cache-modules/--no-cache-modules
2097 func_get_autoconf_early_snippet ()
2099 if ! $modcache; then
2100 func_lookup_file "modules/$1"
2101 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2103 func_cache_lookup_module "$1"
2104 # Output the field's value, including the final newline (if any).
2105 if $have_associative; then
2106 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2107 eval 'echo "${modcache_configureac_early[$1]}"'
2110 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2111 if test -n "$field_set"; then
2112 eval "field_value=\"\$${cachevar}_configureac_early\""
2113 echo "${field_value}"
2119 # func_get_autoconf_snippet module
2121 # - local_gnulib_dir from --local-dir
2122 # - modcache true or false, from --cache-modules/--no-cache-modules
2123 func_get_autoconf_snippet ()
2125 if ! $modcache; then
2126 func_lookup_file "modules/$1"
2127 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2129 func_cache_lookup_module "$1"
2130 # Output the field's value, including the final newline (if any).
2131 if $have_associative; then
2132 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2133 eval 'echo "${modcache_configureac[$1]}"'
2136 eval "field_set=\"\$${cachevar}_configureac_set\""
2137 if test -n "$field_set"; then
2138 eval "field_value=\"\$${cachevar}_configureac\""
2139 echo "${field_value}"
2145 # func_get_automake_snippet_conditional module
2146 # returns the part of the Makefile.am snippet that can be put inside Automake
2149 # - local_gnulib_dir from --local-dir
2150 # - modcache true or false, from --cache-modules/--no-cache-modules
2151 func_get_automake_snippet_conditional ()
2153 if ! $modcache; then
2154 func_lookup_file "modules/$1"
2155 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2157 func_cache_lookup_module "$1"
2158 # Output the field's value, including the final newline (if any).
2159 if $have_associative; then
2160 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2161 eval 'echo "${modcache_makefile[$1]}"'
2164 eval "field_set=\"\$${cachevar}_makefile_set\""
2165 if test -n "$field_set"; then
2166 eval "field_value=\"\$${cachevar}_makefile\""
2167 echo "${field_value}"
2173 # func_get_automake_snippet_unconditional module
2174 # returns the part of the Makefile.am snippet that must stay outside of
2175 # Automake conditionals.
2177 # - local_gnulib_dir from --local-dir
2178 # - modcache true or false, from --cache-modules/--no-cache-modules
2179 func_get_automake_snippet_unconditional ()
2183 # *-tests module live in tests/, not lib/.
2184 # Synthesize an EXTRA_DIST augmentation.
2185 all_files=`func_get_filelist $1`
2186 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2187 extra_files="$tests_files"
2188 if test -n "$extra_files"; then
2189 echo "EXTRA_DIST +=" $extra_files
2194 # Synthesize an EXTRA_DIST augmentation.
2195 sed_combine_lines='/\\$/{
2202 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2203 already_mentioned_files=` \
2204 { if ! $modcache; then
2205 func_lookup_file "modules/$1"
2206 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2208 func_cache_lookup_module "$1"
2209 if $have_associative; then
2210 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2211 eval 'echo "${modcache_makefile[$1]}"'
2214 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2215 if test -n "$field_set"; then
2216 eval 'field_value="$'"${cachevar}"'_makefile"'
2217 echo "${field_value}"
2222 | sed -e "$sed_combine_lines" \
2223 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2224 all_files=`func_get_filelist $1`
2225 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2226 # Remove $already_mentioned_files from $lib_files.
2227 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2228 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2229 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2230 if test -n "$extra_files"; then
2231 echo "EXTRA_DIST +=" $extra_files
2234 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2235 # This is necessary so that automake can generate the right list of
2237 # A possible approach would be to use autom4te --trace of the redefined
2238 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2239 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2240 # inside autoconf's built-in macros are not missed).
2241 # But it's simpler and more robust to do it here, based on the file list.
2242 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2243 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2244 # automake will generate a useless dependency; this is harmless.
2246 relocatable-prog-wrapper) ;;
2249 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2250 if test -n "$extra_files"; then
2251 echo "EXTRA_lib_SOURCES +=" $extra_files
2256 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2257 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2258 if test -n "$buildaux_files"; then
2259 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2260 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2263 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2264 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2265 if test -n "$top_files"; then
2266 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2267 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2274 # func_get_automake_snippet module
2276 # - local_gnulib_dir from --local-dir
2277 # - modcache true or false, from --cache-modules/--no-cache-modules
2278 func_get_automake_snippet ()
2280 func_get_automake_snippet_conditional "$1"
2281 func_get_automake_snippet_unconditional "$1"
2284 # func_get_include_directive module
2286 # - local_gnulib_dir from --local-dir
2287 # - modcache true or false, from --cache-modules/--no-cache-modules
2288 func_get_include_directive ()
2291 if ! $modcache; then
2292 func_lookup_file "modules/$1"
2293 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2295 func_cache_lookup_module "$1"
2296 # Output the field's value, including the final newline (if any).
2297 if $have_associative; then
2298 if eval 'test -n "${modcache_include[$1]+set}"'; then
2299 eval 'echo "${modcache_include[$1]}"'
2302 eval "field_set=\"\$${cachevar}_include_set\""
2303 if test -n "$field_set"; then
2304 eval "field_value=\"\$${cachevar}_include\""
2305 echo "${field_value}"
2309 } | sed -e 's/^\(["<]\)/#include \1/'
2312 # func_get_link_directive module
2314 # - local_gnulib_dir from --local-dir
2315 # - modcache true or false, from --cache-modules/--no-cache-modules
2316 func_get_link_directive ()
2318 if ! $modcache; then
2319 func_lookup_file "modules/$1"
2320 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2322 func_cache_lookup_module "$1"
2323 # Output the field's value, including the final newline (if any).
2324 if $have_associative; then
2325 if eval 'test -n "${modcache_link[$1]+set}"'; then
2326 eval 'echo "${modcache_link[$1]}"'
2329 eval "field_set=\"\$${cachevar}_link_set\""
2330 if test -n "$field_set"; then
2331 eval "field_value=\"\$${cachevar}_link\""
2332 echo "${field_value}"
2338 # func_get_license module
2340 # - local_gnulib_dir from --local-dir
2341 # - modcache true or false, from --cache-modules/--no-cache-modules
2345 if ! $modcache; then
2346 func_lookup_file "modules/$1"
2347 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2349 func_cache_lookup_module "$1"
2350 # Output the field's value, including the final newline (if any).
2351 if $have_associative; then
2352 if eval 'test -n "${modcache_license[$1]+set}"'; then
2353 eval 'echo "${modcache_license[$1]}"'
2356 eval "field_set=\"\$${cachevar}_license_set\""
2357 if test -n "$field_set"; then
2358 eval "field_value=\"\$${cachevar}_license\""
2359 echo "${field_value}"
2363 # The default is GPL.
2365 } | sed -e 's,^ *$,,' | sed -e 1q
2368 # func_get_maintainer module
2370 # - local_gnulib_dir from --local-dir
2371 # - modcache true or false, from --cache-modules/--no-cache-modules
2372 func_get_maintainer ()
2374 if ! $modcache; then
2375 func_lookup_file "modules/$1"
2376 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2378 func_cache_lookup_module "$1"
2379 # Output the field's value, including the final newline (if any).
2380 if $have_associative; then
2381 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2382 eval 'echo "${modcache_maintainer[$1]}"'
2385 eval "field_set=\"\$${cachevar}_maintainer_set\""
2386 if test -n "$field_set"; then
2387 eval "field_value=\"\$${cachevar}_maintainer\""
2388 echo "${field_value}"
2394 # func_get_tests_module module
2396 # - local_gnulib_dir from --local-dir
2397 func_get_tests_module ()
2399 # The naming convention for tests modules is hardwired: ${module}-tests.
2400 if test -f "$gnulib_dir/modules/$1"-tests \
2401 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2402 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2407 # func_acceptable module
2408 # tests whether a module is acceptable.
2410 # - avoidlist list of modules to avoid
2413 for avoid in $avoidlist; do
2414 if test "$avoid" = "$1"; then
2421 # sed expression to keep the first 32 characters of each line.
2422 sed_first_32_chars='s/^\(................................\).*/\1/'
2424 # func_module_shellfunc_name module
2425 # computes the shell function name that will contain the m4 macros for the module.
2427 # - macro_prefix prefix to use
2429 # - shellfunc shell function name
2430 func_module_shellfunc_name ()
2434 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2436 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2440 # func_module_shellvar_name module
2441 # computes the shell variable name the will be set to true once the m4 macros
2442 # for the module have been executed.
2444 # - shellvar shell variable name
2445 func_module_shellvar_name ()
2449 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2451 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2455 # func_module_conditional_name module
2456 # computes the automake conditional name for the module.
2458 # - conditional name of automake conditional
2459 func_module_conditional_name ()
2463 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2465 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2469 # func_uncond_add_module B
2470 # notes the presence of B as an unconditional module.
2472 # func_conddep_add_module A B cond
2473 # notes the presence of a conditional dependency from module A to module B,
2474 # subject to the condition that A is enabled and cond is true.
2476 # func_cond_module_p B
2477 # tests whether module B is conditional.
2479 # func_cond_module_condition A B
2480 # returns the condition when B should be enabled as a dependency of A, once the
2481 # m4 code for A has been executed.
2482 # Output: - condition
2484 if $have_associative; then
2485 declare -A conddep_isuncond
2486 declare -A conddep_dependers
2487 declare -A conddep_condition
2488 func_uncond_add_module ()
2490 eval 'conddep_isuncond[$1]=true'
2491 eval 'unset conddep_dependers[$1]'
2493 func_conddep_add_module ()
2495 eval 'isuncond="${conddep_isuncond[$2]}"'
2496 if test -z "$isuncond"; then
2497 # No unconditional dependency to B known at this point.
2498 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2499 eval 'conddep_condition[$1---$2]="$3"'
2502 func_cond_module_p ()
2504 eval 'previous_dependers="${conddep_dependers[$1]}"'
2505 test -n "$previous_dependers"
2507 func_cond_module_condition ()
2509 eval 'condition="${conddep_condition[$1---$2]}"'
2512 func_uncond_add_module ()
2516 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2520 eval 'conddep_isuncond_'"$suffix"'=true'
2521 eval 'unset conddep_dependers_'"$suffix"
2523 func_conddep_add_module ()
2527 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2531 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2532 if test -z "$isuncond"; then
2533 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2534 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2535 eval 'conddep_condition_'"$suffix"'="$3"'
2538 func_cond_module_p ()
2542 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2546 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2547 test -n "$previous_dependers"
2549 func_cond_module_condition ()
2551 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2552 eval 'condition="${conddep_condition_'"$suffix"'}"'
2556 sed_dependencies_without_conditions='s/ *\[.*//'
2558 # func_modules_transitive_closure
2560 # - local_gnulib_dir from --local-dir
2561 # - modcache true or false, from --cache-modules/--no-cache-modules
2562 # - modules list of specified modules
2563 # - inctests true if tests should be included, blank otherwise
2564 # - incobsolete true if obsolete modules among dependencies should be
2565 # included, blank otherwise
2566 # - inc_cxx_tests true if C++ interoperability tests should be included,
2568 # - inc_longrunning_tests true if long-runnings tests should be included,
2570 # - inc_privileged_tests true if tests that require root privileges should be
2571 # included, blank otherwise
2572 # - inc_unportable_tests true if tests that fail on some platforms should be
2573 # included, blank otherwise
2574 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2575 # the unit tests of the specified modules should be
2576 # included, blank otherwise
2577 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2578 # the unit tests of the dependencies should be
2579 # included, blank otherwise
2580 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2582 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2584 # - excl_privileged_tests true if tests that require root privileges should be
2585 # excluded, blank otherwise
2586 # - excl_unportable_tests true if tests that fail on some platforms should be
2587 # excluded, blank otherwise
2588 # - avoidlist list of modules to avoid
2589 # - cond_dependencies true if conditional dependencies shall be supported,
2591 # - tmp pathname of a temporary directory
2593 # - modules list of modules, including dependencies
2594 # - conddep_dependers, conddep_condition information about conditionally
2596 func_modules_transitive_closure ()
2598 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2599 # In order to process every module only once (for speed), process an "input
2600 # list" of modules, producing an "output list" of modules. During each round,
2601 # more modules can be queued in the input list. Once a module on the input
2602 # list has been processed, it is added to the "handled list", so we can avoid
2603 # to process it again.
2605 inmodules="$modules"
2607 fmtc_inc_all_tests="$inc_all_direct_tests"
2608 if test -n "$cond_dependencies"; then
2609 for module in $inmodules; do
2611 if test -n "$module"; then
2612 if func_acceptable $module; then
2613 func_uncond_add_module $module
2618 while test -n "$inmodules"; do
2619 inmodules_this_round="$inmodules"
2620 inmodules= # Accumulator, queue for next round
2621 for module in $inmodules_this_round; do
2623 if test -n "$module"; then
2624 if func_acceptable $module; then
2625 func_append outmodules " $module"
2626 if test -n "$cond_dependencies"; then
2627 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2628 # A module whose Makefile.am snippet contains a reference to an
2629 # automake conditional. If we were to use it conditionally, we
2630 # would get an error
2631 # configure: error: conditional "..." was never defined.
2632 # because automake 1.11.1 does not handle nested conditionals
2633 # correctly. As a workaround, make the module unconditional.
2634 func_uncond_add_module $module
2636 if func_cond_module_p $module; then
2642 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2643 # Duplicate dependencies are harmless, but Jim wants a warning.
2644 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2645 if test -n "$duplicated_deps"; then
2646 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2648 if test -n "$inctests"; then
2649 testsmodule=`func_get_tests_module $module`
2650 if test -n "$testsmodule"; then
2651 deps="$deps $testsmodule"
2654 for dep in $deps; do
2655 # Determine whether to include the dependency or tests module.
2657 for word in `func_get_status $dep`; do
2660 test -n "$incobsolete" \
2664 test -z "$excl_cxx_tests" \
2666 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2670 test -z "$excl_longrunning_tests" \
2672 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2676 test -z "$excl_privileged_tests" \
2678 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2682 test -z "$excl_unportable_tests" \
2684 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2688 test -n "$fmtc_inc_all_tests" \
2694 func_append inmodules " $dep"
2695 if test -n "$cond_dependencies"; then
2696 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2697 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2700 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2701 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2703 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2704 if test "$condition" = true; then
2707 if test -n "$condition"; then
2708 func_conddep_add_module "$module" "$dep" "$condition"
2710 if $conditional; then
2711 func_conddep_add_module "$module" "$dep" true
2713 func_uncond_add_module "$dep"
2722 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2723 # Remove $handledmodules from $inmodules.
2724 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2725 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2726 fmtc_inc_all_tests="$inc_all_indirect_tests"
2728 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2729 rm -f "$tmp"/queued-modules
2732 # func_show_module_list
2734 # - specified_modules list of specified modules (one per line, sorted)
2735 # - modules complete list of modules (one per line, sorted)
2736 # - tmp pathname of a temporary directory
2737 func_show_module_list ()
2743 # Assume xterm compatible escape sequences.
2744 bold_on=`printf '\x1b[1m'`
2745 bold_off=`printf '\x1b[0m'`
2750 echo "Module list with included dependencies (indented):"
2751 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2752 echo "$modules" | sed -e '/^$/d' \
2753 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2754 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2757 # func_modules_add_dummy
2759 # - local_gnulib_dir from --local-dir
2760 # - modcache true or false, from --cache-modules/--no-cache-modules
2761 # - modules list of modules, including dependencies
2763 # - modules list of modules, including 'dummy' if needed
2764 func_modules_add_dummy ()
2766 # Determine whether any module provides a lib_SOURCES augmentation.
2768 sed_remove_backslash_newline=':a
2775 for module in $modules; do
2776 func_verify_nontests_module
2777 if test -n "$module"; then
2778 # Extract the value of "lib_SOURCES += ...".
2779 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2780 # Ignore .h files since they are not compiled.
2784 have_lib_SOURCES=yes
2791 # Add the dummy module, to make sure the library will be non-empty.
2792 if test -z "$have_lib_SOURCES"; then
2793 if func_acceptable "dummy"; then
2794 func_append modules " dummy"
2799 # func_modules_notice
2801 # - local_gnulib_dir from --local-dir
2802 # - modcache true or false, from --cache-modules/--no-cache-modules
2803 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2804 # - modules list of modules, including dependencies
2805 func_modules_notice ()
2807 if test $verbose -ge -1; then
2808 for module in $modules; do
2810 if test -n "$module"; then
2811 msg=`func_get_notice $module`
2812 if test -n "$msg"; then
2813 echo "Notice from module $module:"
2814 echo "$msg" | sed -e 's/^/ /'
2821 # func_modules_to_filelist
2823 # - local_gnulib_dir from --local-dir
2824 # - modcache true or false, from --cache-modules/--no-cache-modules
2825 # - modules list of modules, including dependencies
2827 # - files list of files
2828 func_modules_to_filelist ()
2831 for module in $modules; do
2833 if test -n "$module"; then
2834 fs=`func_get_filelist $module`
2835 func_append files " $fs"
2838 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2841 # func_execute_command command [args...]
2842 # Executes a command.
2843 # Uses also the variables
2844 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2845 func_execute_command ()
2847 if test $verbose -ge 0; then
2851 # Commands like automake produce output to stderr even when they succeed.
2852 # Turn this output off if the command succeeds.
2853 "$@" > "$tmp"/cmdout 2>&1
2855 if test $cmdret = 0; then
2859 cat "$tmp"/cmdout 1>&2
2866 # func_dest_tmpfilename file
2867 # determines the name of a temporary file (file is relative to destdir).
2869 # - destdir target directory
2870 # - doit : if actions shall be executed, false if only to be printed
2871 # - tmp pathname of a temporary directory
2873 # - tmpfile absolute filename of the temporary file
2874 func_dest_tmpfilename ()
2877 # Put the new contents of $file in a file in the same directory (needed
2878 # to guarantee that an 'mv' to "$destdir/$file" works).
2879 tmpfile="$destdir/$1.tmp"
2881 # Put the new contents of $file in a file in a temporary directory
2882 # (because the directory of "$file" might not exist).
2883 tmpfile="$tmp"/`basename "$1"`.tmp
2888 # copies a file from gnulib into the destination directory. The destination
2889 # is known to not exist.
2891 # - destdir target directory
2892 # - local_gnulib_dir from --local-dir
2893 # - modcache true or false, from --cache-modules/--no-cache-modules
2894 # - f the original file name
2895 # - lookedup_file name of the merged (combined) file
2896 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2897 # - g the rewritten file name
2898 # - tmpfile absolute filename of the temporary file
2899 # - doit : if actions shall be executed, false if only to be printed
2900 # - symbolic true if files should be symlinked, copied otherwise
2901 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2906 echo "Copying file $g"
2907 if { test -n "$symbolic" \
2908 || { test -n "$lsymbolic" \
2909 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2910 && test -z "$lookedup_tmp" \
2911 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2912 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2914 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2922 # copies a file from gnulib into the destination directory. The destination
2923 # is known to exist.
2925 # - destdir target directory
2926 # - local_gnulib_dir from --local-dir
2927 # - modcache true or false, from --cache-modules/--no-cache-modules
2928 # - f the original file name
2929 # - lookedup_file name of the merged (combined) file
2930 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2931 # - g the rewritten file name
2932 # - tmpfile absolute filename of the temporary file
2933 # - doit : if actions shall be executed, false if only to be printed
2934 # - symbolic true if files should be symlinked, copied otherwise
2935 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2937 # - already_present nonempty if the file should already exist, empty otherwise
2940 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2941 : # The file has not changed.
2945 if test -n "$already_present"; then
2946 echo "Updating file $g (backup in ${g}~)"
2948 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2950 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2951 if { test -n "$symbolic" \
2952 || { test -n "$lsymbolic" \
2953 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2954 && test -z "$lookedup_tmp" \
2955 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2956 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2958 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2961 if test -n "$already_present"; then
2962 echo "Update file $g (backup in ${g}~)"
2964 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2970 # func_emit_lib_Makefile_am
2971 # emits the contents of library makefile to standard output.
2973 # - local_gnulib_dir from --local-dir
2974 # - modcache true or false, from --cache-modules/--no-cache-modules
2975 # - modules list of modules, including dependencies
2976 # - libname library name
2977 # - pobase directory relative to destdir where to place *.po files
2978 # - auxdir directory relative to destdir where to place build aux files
2979 # - makefile_name from --makefile-name
2980 # - libtool true if libtool will be used, false or blank otherwise
2981 # - macro_prefix prefix of gl_LIBOBJS macros to use
2982 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2983 # - actioncmd (optional) command that will reproduce this invocation
2984 # - for_test true if creating a package for testing, false otherwise
2985 # - destfile filename relative to destdir of makefile being generated
2987 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2988 # list of edits to be done to Makefile.am variables
2990 # - uses_subdirs nonempty if object files in subdirs exist
2991 func_emit_lib_Makefile_am ()
2993 # When creating an includable Makefile.am snippet, augment variables with
2994 # += instead of assigning them.
2995 if test -n "$makefile_name"; then
3000 if test "$libtool" = true; then
3003 sed_eliminate_LDFLAGS="$sed_noop"
3007 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3010 # When creating a package for testing: Attempt to provoke failures,
3011 # especially link errors, already during "make" rather than during
3012 # "make check", because "make check" is not possible in a cross-compiling
3013 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3014 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3016 sed_transform_check_PROGRAMS="$sed_noop"
3018 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3019 echo "## Process this file with automake to produce Makefile.in."
3020 func_emit_copyright_notice
3021 if test -n "$actioncmd"; then
3022 # The maximum line length (excluding the terminating newline) of any file
3023 # that is to be preprocessed by config.status is 3070. config.status uses
3024 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3025 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3026 len=`echo "$actioncmd" | wc -c`
3027 if test -n "$len" && test "$len" -le 3000; then
3028 echo "# Reproduce by: $actioncmd"
3034 for module in $modules; do
3035 func_verify_nontests_module
3036 if test -n "$module"; then
3038 func_get_automake_snippet_conditional "$module" |
3040 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3041 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3042 -e "$sed_eliminate_LDFLAGS" \
3043 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3044 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3045 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3046 -e "$sed_transform_check_PROGRAMS"
3047 if test "$module" = 'alloca'; then
3048 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3049 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3051 } > "$tmp"/amsnippet1
3053 func_get_automake_snippet_unconditional "$module" |
3054 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3055 } > "$tmp"/amsnippet2
3056 # Skip the contents if it's entirely empty.
3057 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3058 echo "## begin gnulib module $module"
3060 if test -n "$cond_dependencies"; then
3061 if func_cond_module_p "$module"; then
3062 func_module_conditional_name "$module"
3063 echo "if $conditional"
3066 cat "$tmp"/amsnippet1
3067 if test -n "$cond_dependencies"; then
3068 if func_cond_module_p "$module"; then
3072 cat "$tmp"/amsnippet2
3073 echo "## end gnulib module $module"
3076 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3077 # Test whether there are some source files in subdirectories.
3078 for f in `func_get_filelist "$module"`; do
3088 } > "$tmp"/allsnippets
3089 if test -z "$makefile_name"; then
3090 # If there are source files in subdirectories, prevent collision of the
3091 # object files (example: hash.c and libxml/hash.c).
3093 if test -n "$uses_subdirs"; then
3094 subdir_options=' subdir-objects'
3096 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
3099 if test -z "$makefile_name"; then
3101 echo "noinst_HEADERS ="
3102 echo "noinst_LIBRARIES ="
3103 echo "noinst_LTLIBRARIES ="
3104 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3105 # if you specify pkgdata_DATA to empty. This is a workaround.
3106 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3107 echo "pkgdata_DATA ="
3110 echo "BUILT_SOURCES ="
3113 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3114 if test -z "$makefile_name"; then
3115 echo "MOSTLYCLEANDIRS ="
3117 echo "DISTCLEANFILES ="
3118 echo "MAINTAINERCLEANFILES ="
3120 # Execute edits that apply to the Makefile.am being generated.
3122 while test $edit != $makefile_am_edits; do
3123 edit=`expr $edit + 1`
3124 eval dir=\"\$makefile_am_edit${edit}_dir\"
3125 eval var=\"\$makefile_am_edit${edit}_var\"
3126 eval val=\"\$makefile_am_edit${edit}_val\"
3127 if test -n "$var"; then
3128 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3129 echo "${var} += ${val}"
3130 eval "makefile_am_edit${edit}_var="
3134 if test -z "$makefile_name"; then
3137 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
3139 echo "AM_CPPFLAGS ="
3144 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3145 || { test -n "$makefile_name" \
3146 && test -f "$sourcebase/Makefile.am" \
3147 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3149 # One of the snippets or the user's Makefile.am already specifies an
3150 # installation location for the library. Don't confuse automake by saying
3151 # it should not be installed.
3154 # By default, the generated library should not be installed.
3155 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3158 echo "${libname}_${libext}_SOURCES ="
3159 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3160 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3161 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3162 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3163 echo "EXTRA_${libname}_${libext}_SOURCES ="
3164 if test "$libtool" = true; then
3165 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3166 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3167 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3168 # the link dependencies of all modules.
3169 for module in $modules; do
3170 func_verify_nontests_module
3171 if test -n "$module"; then
3172 func_get_link_directive "$module"
3175 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3176 | LC_ALL=C sort -u \
3177 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3180 if test -n "$pobase"; then
3181 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3184 cat "$tmp"/allsnippets \
3185 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3187 echo "mostlyclean-local: mostlyclean-generic"
3188 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3189 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3190 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3194 rm -f "$tmp"/allsnippets
3197 # func_emit_po_Makevars
3198 # emits the contents of po/ makefile parameterization to standard output.
3200 # - local_gnulib_dir from --local-dir
3201 # - modcache true or false, from --cache-modules/--no-cache-modules
3202 # - sourcebase directory relative to destdir where to place source code
3203 # - pobase directory relative to destdir where to place *.po files
3204 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3205 func_emit_po_Makevars ()
3207 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3208 func_emit_copyright_notice
3210 echo "# Usually the message domain is the same as the package name."
3211 echo "# But here it has a '-gnulib' suffix."
3212 echo "DOMAIN = ${po_domain}-gnulib"
3214 echo "# These two variables depend on the location of this directory."
3215 echo "subdir = ${pobase}"
3216 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3219 # These options get passed to xgettext.
3220 XGETTEXT_OPTIONS = \
3221 --keyword=_ --flag=_:1:pass-c-format \
3222 --keyword=N_ --flag=N_:1:pass-c-format \
3223 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3224 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3225 --flag=error:3:c-format --flag=error_at_line:5:c-format
3227 # This is the copyright holder that gets inserted into the header of the
3228 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3229 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3231 # This is the email address or URL to which the translators shall report
3232 # bugs in the untranslated strings:
3233 # - Strings which are not entire sentences, see the maintainer guidelines
3234 # in the GNU gettext documentation, section 'Preparing Strings'.
3235 # - Strings which use unclear terms or require additional context to be
3237 # - Strings which make invalid assumptions about notation of date, time or
3239 # - Pluralisation problems.
3240 # - Incorrect English spelling.
3241 # - Incorrect formatting.
3242 # It can be your email address, or a mailing list address where translators
3243 # can write to without being subscribed, or the URL of a web page through
3244 # which the translators can contact you.
3245 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3247 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3248 # message catalogs shall be used. It is usually empty.
3249 EXTRA_LOCALE_CATEGORIES =
3251 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3252 # context. Possible values are "yes" and "no". Set this to yes if the
3253 # package uses functions taking also a message context, like pgettext(), or
3254 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3259 # func_emit_po_POTFILES_in
3260 # emits the file list to be passed to xgettext to standard output.
3262 # - local_gnulib_dir from --local-dir
3263 # - modcache true or false, from --cache-modules/--no-cache-modules
3264 # - sourcebase directory relative to destdir where to place source code
3265 # - files list of new files
3266 func_emit_po_POTFILES_in ()
3268 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3269 func_emit_copyright_notice
3271 echo "# List of files which contain translatable strings."
3272 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3275 # func_emit_tests_Makefile_am witness_macro
3276 # emits the contents of tests makefile to standard output.
3278 # - local_gnulib_dir from --local-dir
3279 # - modcache true or false, from --cache-modules/--no-cache-modules
3280 # - modules list of modules, including dependencies
3281 # - libname library name
3282 # - auxdir directory relative to destdir where to place build aux files
3283 # - makefile_name from --makefile-name
3284 # - libtool true if libtool will be used, false or blank otherwise
3285 # - sourcebase relative directory containing lib source code
3286 # - m4base relative directory containing autoconf macros
3287 # - testsbase relative directory containing unit test code
3288 # - macro_prefix prefix of gl_LIBOBJS macros to use
3289 # - for_test true if creating a package for testing, false otherwise
3290 # - use_libtests true if a libtests.a should be built, false otherwise
3291 # - destfile filename relative to destdir of makefile being generated
3293 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3294 # list of edits to be done to Makefile.am variables
3296 # - uses_subdirs nonempty if object files in subdirs exist
3297 func_emit_tests_Makefile_am ()
3300 if test "$libtool" = true; then
3302 sed_eliminate_LDFLAGS="$sed_noop"
3305 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3308 # When creating a package for testing: Attempt to provoke failures,
3309 # especially link errors, already during "make" rather than during
3310 # "make check", because "make check" is not possible in a cross-compiling
3311 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3312 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3314 sed_transform_check_PROGRAMS="$sed_noop"
3316 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3317 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3318 echo "## Process this file with automake to produce Makefile.in."
3319 func_emit_copyright_notice
3323 for module in $modules; do
3325 func_verify_tests_module
3329 if test -n "$module"; then
3331 func_get_automake_snippet "$module" |
3333 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3334 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3335 -e "$sed_eliminate_LDFLAGS" \
3336 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3337 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3338 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3339 -e "$sed_transform_check_PROGRAMS"
3340 if $use_libtests && test "$module" = 'alloca'; then
3341 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3342 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3344 } > "$tmp"/amsnippet
3345 # Skip the contents if it's entirely empty.
3346 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3347 # Mention long-running tests at the end.
3349 for word in `func_get_status "$module"`; do
3350 if test "$word" = 'longrunning-test'; then
3355 { echo "## begin gnulib module $module"
3357 cat "$tmp"/amsnippet
3358 echo "## end gnulib module $module"
3362 rm -f "$tmp"/amsnippet
3363 # Test whether there are some source files in subdirectories.
3364 for f in `func_get_filelist "$module"`; do
3366 lib/*/*.c | tests/*/*.c)
3374 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3375 # Generate dependencies here, since it eases the debugging of test failures.
3376 # If there are source files in subdirectories, prevent collision of the
3377 # object files (example: hash.c and libxml/hash.c).
3379 if test -n "$uses_subdirs"; then
3380 subdir_options=' subdir-objects'
3382 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3385 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3388 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3389 # variable is needed to avoid an error from automake:
3390 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3393 echo "XFAIL_TESTS ="
3394 echo "TESTS_ENVIRONMENT ="
3395 echo "noinst_PROGRAMS ="
3396 if ! $for_test; then
3397 echo "check_PROGRAMS ="
3399 echo "noinst_HEADERS ="
3400 echo "noinst_LIBRARIES ="
3401 if $use_libtests; then
3403 echo "noinst_LIBRARIES += libtests.a"
3405 echo "check_LIBRARIES = libtests.a"
3408 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3409 # if you specify pkgdata_DATA to empty. This is a workaround.
3410 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3411 echo "pkgdata_DATA ="
3414 echo "BUILT_SOURCES ="
3416 echo "MOSTLYCLEANFILES = core *.stackdump"
3417 echo "MOSTLYCLEANDIRS ="
3419 echo "DISTCLEANFILES ="
3420 echo "MAINTAINERCLEANFILES ="
3421 # Execute edits that apply to the Makefile.am being generated.
3423 while test $edit != $makefile_am_edits; do
3424 edit=`expr $edit + 1`
3425 eval dir=\"\$makefile_am_edit${edit}_dir\"
3426 eval var=\"\$makefile_am_edit${edit}_var\"
3427 eval val=\"\$makefile_am_edit${edit}_val\"
3428 if test -n "$var"; then
3429 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3430 echo "${var} += ${val}"
3431 eval "makefile_am_edit${edit}_var="
3436 echo "AM_CPPFLAGS = \\"
3438 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3440 if test -n "${witness_macro}"; then
3441 echo " -D@${witness_macro}@=1 \\"
3443 echo " -I. -I\$(srcdir) \\"
3444 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3445 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3447 local_ldadd_before=''
3448 local_ldadd_after=''
3449 if $use_libtests; then
3450 # All test programs need to be linked with libtests.a.
3451 # It needs to be passed to the linker before ${libname}.${libext}, since
3452 # the tests-related modules depend on the main modules.
3453 # It also needs to be passed to the linker after ${libname}.${libext}
3454 # because the latter might contain incomplete modules (such as the 'error'
3455 # module whose dependency to 'progname' is voluntarily omitted).
3456 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3458 local_ldadd_before=' libtests.a'
3459 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3461 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3463 if $use_libtests; then
3464 echo "libtests_a_SOURCES ="
3465 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3466 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3467 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3468 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3469 echo "EXTRA_libtests_a_SOURCES ="
3470 # The circular dependency in LDADD requires this.
3471 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3474 # Many test scripts use ${EXEEXT} or ${srcdir}.
3475 # EXEEXT is defined by AC_PROG_CC through autoconf.
3476 # srcdir is defined by autoconf and automake.
3477 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3479 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3480 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3481 echo "# Clean up after Solaris cc."
3483 echo " rm -rf SunWS_cache"
3485 echo "mostlyclean-local: mostlyclean-generic"
3486 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3487 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3488 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3492 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3495 # func_emit_initmacro_start macro_prefix
3496 # emits the first few statements of the gl_INIT macro to standard output.
3497 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3498 func_emit_initmacro_start ()
3500 macro_prefix_arg="$1"
3501 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3502 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3503 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3504 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3506 # Furthermore it avoids an automake error like this when a Makefile.am
3507 # that uses pieces of gnulib also uses $(LIBOBJ):
3508 # automatically discovered file `error.c' should not be explicitly mentioned
3509 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3510 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3511 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3512 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3513 # automatically discovered file `error.c' should not be explicitly mentioned
3514 # We let automake know about the files to be distributed through the
3515 # EXTRA_lib_SOURCES variable.
3516 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3517 # Create data variables for checking the presence of files that are mentioned
3518 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3519 # because we want the check to happen when the configure file is created,
3520 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3521 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3522 # in which to expect them.
3523 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3524 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3528 # func_emit_initmacro_end macro_prefix
3529 # emits the last few statements of the gl_INIT macro to standard output.
3530 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3531 func_emit_initmacro_end ()
3533 macro_prefix_arg="$1"
3534 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3535 # The check is performed only when autoconf is run from the directory where
3536 # the configure.ac resides; if it is run from a different directory, the
3538 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3539 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3540 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3541 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3542 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3546 echo " m4_if(m4_sysval, [0], [],"
3547 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3549 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3550 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3551 echo " m4_popdef([AC_LIBSOURCES])"
3552 echo " m4_popdef([AC_REPLACE_FUNCS])"
3553 echo " m4_popdef([AC_LIBOBJ])"
3554 echo " AC_CONFIG_COMMANDS_PRE(["
3555 echo " ${macro_prefix_arg}_libobjs="
3556 echo " ${macro_prefix_arg}_ltlibobjs="
3557 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3558 echo " # Remove the extension."
3559 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3560 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3561 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3562 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3565 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3566 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3570 # func_emit_initmacro_done macro_prefix sourcebase
3571 # emits a few statements after the gl_INIT macro to standard output.
3572 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3573 # - sourcebase directory relative to destdir where to place source code
3574 func_emit_initmacro_done ()
3576 macro_prefix_arg="$1"
3579 echo "# Like AC_LIBOBJ, except that the module name goes"
3580 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3581 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3582 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3583 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3586 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3587 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3588 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3589 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3590 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3593 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3594 echo "# expected is derived from the gnulib-tool parameterization,"
3595 echo "# and alloca is special cased (for the alloca-opt module)."
3596 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3597 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3598 echo " m4_foreach([_gl_NAME], [\$1], ["
3599 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3600 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3601 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3607 # func_emit_autoconf_snippet indentation
3608 # emits the autoconf snippet of a module.
3610 # - local_gnulib_dir from --local-dir
3611 # - modcache true or false, from --cache-modules/--no-cache-modules
3612 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3613 # - module the module name
3614 # - toplevel true or false. 'false' means a subordinate use of
3616 # - disable_libtool true or false. It tells whether to disable libtool
3617 # handling even if it has been specified through the
3618 # command line options.
3619 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3621 # - indentation spaces to prepend on each line
3622 func_emit_autoconf_snippet ()
3624 if { case $module in
3625 gnumakefile | maintainer-makefile)
3626 # These modules are meant to be used only in the top-level directory.
3632 func_get_autoconf_snippet "$module" \
3633 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3634 -e "$sed_replace_build_aux" \
3635 | { if $disable_libtool; then
3636 sed -e 's/\$gl_cond_libtool/false/g' \
3637 -e 's/gl_libdeps/gltests_libdeps/g' \
3638 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3643 | { if $disable_gettext; then
3644 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3649 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3650 echo 'changequote(,)dnl'
3651 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3652 echo 'changequote([, ])dnl'
3653 echo 'AC_SUBST([LTALLOCA])'
3658 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3659 # collects and emit the autoconf snippets of a set of modules.
3661 # - local_gnulib_dir from --local-dir
3662 # - modcache true or false, from --cache-modules/--no-cache-modules
3663 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3664 # - modules the list of modules.
3665 # - verifier one of func_verify_module, func_verify_nontests_module,
3666 # func_verify_tests_module. It selects the subset of
3667 # $modules to consider.
3668 # - toplevel true or false. 'false' means a subordinate use of
3670 # - disable_libtool true or false. It tells whether to disable libtool
3671 # handling even if it has been specified through the
3672 # command line options.
3673 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3675 func_emit_autoconf_snippets ()
3679 disable_libtool="$4"
3680 disable_gettext="$5"
3681 if test -n "$cond_dependencies"; then
3682 # Emit the autoconf code for the unconditional modules.
3683 for module in $1; do
3685 if test -n "$module"; then
3686 if func_cond_module_p "$module"; then
3689 func_emit_autoconf_snippet " "
3693 # Initialize the shell variables indicating that the modules are enabled.
3694 for module in $1; do
3696 if test -n "$module"; then
3697 if func_cond_module_p "$module"; then
3698 func_module_shellvar_name "$module"
3699 echo " $shellvar=false"
3703 # Emit the autoconf code for the conditional modules, each in a separate
3704 # function. This makes it possible to support cycles among conditional
3706 for module in $1; do
3708 if test -n "$module"; then
3709 if func_cond_module_p "$module"; then
3710 func_module_shellfunc_name "$module"
3711 func_module_shellvar_name "$module"
3712 echo " $shellfunc ()"
3714 echo " if ! \$$shellvar; then"
3715 func_emit_autoconf_snippet " "
3716 echo " $shellvar=true"
3717 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3718 for dep in $deps; do
3719 if func_cond_module_p "$dep"; then
3720 func_module_shellfunc_name "$dep"
3721 func_cond_module_condition "$module" "$dep"
3722 if test "$condition" != true; then
3723 echo ' if $condition; then'
3730 # The autoconf code for $dep has already been emitted above and
3731 # therefore is already executed when this function is run.
3740 # Emit the dependencies from the unconditional to the conditional modules.
3741 for module in $1; do
3743 if test -n "$module"; then
3744 if func_cond_module_p "$module"; then
3747 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3748 for dep in $deps; do
3749 if func_cond_module_p "$dep"; then
3750 func_module_shellfunc_name "$dep"
3751 func_cond_module_condition "$module" "$dep"
3752 if test "$condition" != true; then
3753 echo " if $condition; then"
3760 # The autoconf code for $dep has already been emitted above and
3761 # therefore is already executed when this code is run.
3768 # Define the Automake conditionals.
3769 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
3770 for module in $1; do
3772 if test -n "$module"; then
3773 if func_cond_module_p "$module"; then
3774 func_module_conditional_name "$module"
3775 func_module_shellvar_name "$module"
3776 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
3781 # Ignore the conditions, and enable all modules unconditionally.
3782 for module in $1; do
3784 if test -n "$module"; then
3785 func_emit_autoconf_snippet " "
3791 # func_import modules
3792 # Uses also the variables
3793 # - mode import or add-import or remove-import or update
3794 # - destdir target directory
3795 # - local_gnulib_dir from --local-dir
3796 # - modcache true or false, from --cache-modules/--no-cache-modules
3797 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3798 # - libname library name
3799 # - supplied_libname true if --lib was given, blank otherwise
3800 # - sourcebase directory relative to destdir where to place source code
3801 # - m4base directory relative to destdir where to place *.m4 macros
3802 # - pobase directory relative to destdir where to place *.po files
3803 # - docbase directory relative to destdir where to place doc files
3804 # - testsbase directory relative to destdir where to place unit test code
3805 # - auxdir directory relative to destdir where to place build aux files
3806 # - inctests true if --with-tests was given, blank otherwise
3807 # - incobsolete true if --with-obsolete was given, blank otherwise
3808 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3809 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3811 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3813 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3815 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3816 # - avoidlist list of modules to avoid, from --avoid
3817 # - cond_dependencies true if conditional dependencies shall be supported,
3819 # - lgpl yes or a number if library's license shall be LGPL,
3821 # - makefile_name from --makefile-name
3822 # - libtool true if --libtool was given, false if --no-libtool was
3823 # given, blank otherwise
3824 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3825 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3826 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3827 # - vc_files true if --vc-files was given, false if --no-vc-files was
3828 # given, blank otherwise
3829 # - autoconf_minversion minimum supported autoconf version
3830 # - doit : if actions shall be executed, false if only to be printed
3831 # - symbolic true if files should be symlinked, copied otherwise
3832 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3834 # - do_copyrights true if copyright notices in files should be replaced,
3838 # Get the cached settings.
3839 # In 'import' mode, we read them only for the purpose of knowing the old
3840 # installed file list, and don't use them as defaults.
3841 cached_local_gnulib_dir=
3842 cached_specified_modules=
3844 cached_inc_cxx_tests=
3845 cached_inc_longrunning_tests=
3846 cached_inc_privileged_tests=
3847 cached_inc_unportable_tests=
3848 cached_inc_all_tests=
3858 cached_makefile_name=
3860 cached_macro_prefix=
3864 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3865 cached_libtool=false
3871 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3881 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3883 /gl_WITH_OBSOLETE/ {
3884 s,^.*$,cached_incobsolete=true,p
3886 /gl_WITH_CXX_TESTS/ {
3887 s,^.*$,cached_inc_cxx_tests=true,p
3889 /gl_WITH_LONGRUNNING_TESTS/ {
3890 s,^.*$,cached_inc_longrunning_tests=true,p
3892 /gl_WITH_PRIVILEGED_TESTS/ {
3893 s,^.*$,cached_inc_privileged_tests=true,p
3895 /gl_WITH_UNPORTABLE_TESTS/ {
3896 s,^.*$,cached_inc_unportable_tests=true,p
3898 /gl_WITH_ALL_TESTS/ {
3899 s,^.*$,cached_inc_all_tests=true,p
3902 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3905 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3908 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3911 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3914 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3917 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3920 s,^.*$,cached_inctests=true,p
3923 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3926 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3929 s,^.*$,cached_lgpl=yes,p
3931 /gl_MAKEFILE_NAME(/ {
3932 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3935 s,^.*$,cached_libtool=true,p
3937 /gl_MACRO_PREFIX(/ {
3938 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3941 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3944 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3946 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3947 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3952 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3953 s,^.*$,cached_files=",p
3966 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3970 if test "$mode" = import; then
3971 # In 'import' mode, the new set of specified modules overrides the cached
3972 # set of modules. Ignore the cached settings.
3973 specified_modules="$1"
3975 # Merge the cached settings with the specified ones.
3976 # The m4base must be the same as expected from the pathname.
3977 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3978 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3980 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3981 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3982 if test -z "$local_gnulib_dir"; then
3983 if test -n "$cached_local_gnulib_dir"; then
3986 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3988 case "$cached_local_gnulib_dir" in
3990 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3992 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3993 local_gnulib_dir="$relconcat" ;;
4000 # Append the cached and the specified module names. So that
4001 # "gnulib-tool --add-import foo" means to add the module foo.
4002 specified_modules="$cached_specified_modules $1"
4005 # Take the cached module names, minus the specified module names.
4007 if $have_associative; then
4008 # Use an associative array, for O(N) worst-case run time.
4009 declare -A to_remove
4011 eval 'to_remove[$m]=yes'
4013 for module in $cached_specified_modules; do
4014 if eval 'test -z "${to_remove[$module]}"'; then
4015 func_append specified_modules "$module "
4019 # This loop has O(N²) worst-case run time.
4020 for module in $cached_specified_modules; do
4023 if test "$m" = "$module"; then
4028 if test -z "$to_remove"; then
4029 func_append specified_modules "$module "
4035 # Take the cached module names. There are no specified module names.
4036 specified_modules="$cached_specified_modules"
4039 # Included obsolete modules among the dependencies if specified either way.
4040 if test -z "$incobsolete"; then
4041 incobsolete="$cached_incobsolete"
4043 # Included special kinds of tests modules among the dependencies if specified
4045 if test -z "$inc_cxx_tests"; then
4046 inc_cxx_tests="$cached_inc_cxx_tests"
4048 if test -z "$inc_longrunning_tests"; then
4049 inc_longrunning_tests="$cached_inc_longrunning_tests"
4051 if test -z "$inc_privileged_tests"; then
4052 inc_privileged_tests="$cached_inc_privileged_tests"
4054 if test -z "$inc_unportable_tests"; then
4055 inc_unportable_tests="$cached_inc_unportable_tests"
4057 if test -z "$inc_all_tests"; then
4058 inc_all_tests="$cached_inc_all_tests"
4060 # Append the cached and the specified avoidlist. This is probably better
4061 # than dropping the cached one when --avoid is specified at least once.
4062 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4063 avoidlist=`echo $avoidlist`
4065 # The sourcebase defaults to the cached one.
4066 if test -z "$sourcebase"; then
4067 sourcebase="$cached_sourcebase"
4068 if test -z "$sourcebase"; then
4069 func_fatal_error "missing --source-base option"
4072 # The pobase defaults to the cached one.
4073 if test -z "$pobase"; then
4074 pobase="$cached_pobase"
4076 # The docbase defaults to the cached one.
4077 if test -z "$docbase"; then
4078 docbase="$cached_docbase"
4079 if test -z "$docbase"; then
4080 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."
4083 # The testsbase defaults to the cached one.
4084 if test -z "$testsbase"; then
4085 testsbase="$cached_testsbase"
4086 if test -z "$testsbase"; then
4087 func_fatal_error "missing --tests-base option"
4090 # Require the tests if specified either way.
4091 if test -z "$inctests"; then
4092 inctests="$cached_inctests"
4094 # The libname defaults to the cached one.
4095 if test -z "$supplied_libname"; then
4096 libname="$cached_libname"
4097 if test -z "$libname"; then
4098 func_fatal_error "missing --lib option"
4101 # Require LGPL if specified either way.
4102 if test -z "$lgpl"; then
4105 # The makefile_name defaults to the cached one.
4106 if test -z "$makefile_name"; then
4107 makefile_name="$cached_makefile_name"
4109 # Use libtool if specified either way, or if guessed.
4110 if test -z "$libtool"; then
4111 if test -n "$cached_m4base"; then
4112 libtool="$cached_libtool"
4114 libtool="$guessed_libtool"
4117 # The macro_prefix defaults to the cached one.
4118 if test -z "$macro_prefix"; then
4119 macro_prefix="$cached_macro_prefix"
4120 if test -z "$macro_prefix"; then
4121 func_fatal_error "missing --macro-prefix option"
4124 # The po_domain defaults to the cached one.
4125 if test -z "$po_domain"; then
4126 po_domain="$cached_po_domain"
4128 # The vc_files defaults to the cached one.
4129 if test -z "$vc_files"; then
4130 vc_files="$cached_vc_files"
4133 # --without-*-tests options are not supported here.
4135 excl_longrunning_tests=
4136 excl_privileged_tests=
4137 excl_unportable_tests=
4139 # Canonicalize the list of specified modules.
4140 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4142 # Include all kinds of tests modules if --with-all-tests was specified.
4143 inc_all_direct_tests="$inc_all_tests"
4144 inc_all_indirect_tests="$inc_all_tests"
4146 # Determine final module list.
4147 modules="$specified_modules"
4148 func_modules_transitive_closure
4149 if test $verbose -ge 0; then
4150 func_show_module_list
4152 final_modules="$modules"
4154 # Determine main module list and tests-related module list separately.
4155 # The main module list is the transitive closure of the specified modules,
4156 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
4157 # is specified, it will consist only of LGPLed source.
4158 # The tests-related module list is the transitive closure of the specified
4159 # modules, including tests modules, minus the main module list excluding
4160 # modules of applicability 'all'. Its lib/* sources (brought in through
4161 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
4162 # source, even if --lgpl is specified.
4163 # Determine main module list.
4164 saved_inctests="$inctests"
4166 modules="$specified_modules"
4167 func_modules_transitive_closure
4168 main_modules="$modules"
4169 inctests="$saved_inctests"
4170 if test $verbose -ge 1; then
4171 echo "Main module list:"
4172 echo "$main_modules" | sed -e 's/^/ /'
4174 # Determine tests-related module list.
4175 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
4176 testsrelated_modules=`for module in $main_modules; do
4177 if test \`func_get_applicability $module\` = main; then
4181 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
4182 if test $verbose -ge 1; then
4183 echo "Tests-related module list:"
4184 echo "$testsrelated_modules" | sed -e 's/^/ /'
4187 # Add the dummy module to the main module list if needed.
4188 modules="$main_modules"
4189 func_modules_add_dummy
4190 main_modules="$modules"
4192 # Determine whether a $testsbase/libtests.a is needed.
4194 for module in $testsrelated_modules; do
4195 func_verify_nontests_module
4196 if test -n "$module"; then
4197 all_files=`func_get_filelist $module`
4198 # Test whether some file in $all_files lies in lib/.
4199 for f in $all_files; do
4210 # Add the dummy module to the tests-related module list if needed.
4211 if $use_libtests; then
4212 modules="$testsrelated_modules"
4213 func_modules_add_dummy
4214 testsrelated_modules="$modules"
4217 # If --lgpl, verify that the licenses of modules are compatible.
4218 if test -n "$lgpl"; then
4219 license_incompatibilities=
4220 for module in $main_modules; do
4221 license=`func_get_license $module`
4223 'GPLed build tool') ;;
4224 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4229 LGPL | LGPLv2+ | LGPLv3+) ;;
4230 *) func_append license_incompatibilities "$module $license$nl" ;;
4236 *) func_append license_incompatibilities "$module $license$nl" ;;
4239 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4244 if test -n "$license_incompatibilities"; then
4245 # Format the license incompatibilities as a table.
4246 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4247 s,^\(.................................................[^ ]*\) *, \1 ,'
4248 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4249 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4253 # Show banner notice of every module.
4254 modules="$main_modules"
4257 # Determine script to apply to imported library files.
4258 sed_transform_lib_file=
4259 for module in $main_modules; do
4260 if test $module = config-h; then
4261 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4262 sed_transform_lib_file=$sed_transform_lib_file'
4263 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4268 sed_transform_main_lib_file="$sed_transform_lib_file"
4269 if test -n "$do_copyrights"; then
4270 if test -n "$lgpl"; then
4274 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4275 s/GNU General/GNU Lesser General/g
4276 s/General Public License/Lesser General Public License/g
4277 s/Lesser Lesser General Public License/Lesser General Public License/g
4281 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4282 s/GNU General/GNU Lesser General/g
4283 s/General Public License/Lesser General Public License/g
4284 s/Lesser Lesser General Public License/Lesser General Public License/g
4286 s/version [23]\([ ,]\)/version 2.1\1/g
4289 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4293 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4294 s/GNU Lesser General/GNU General/g
4295 s/Lesser General Public License/General Public License/g
4297 s/GNU Library General/GNU General/g
4298 s/Library General Public License/General Public License/g
4300 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4305 # Determine script to apply to auxiliary files that go into $auxdir/.
4306 sed_transform_build_aux_file=
4307 if test -n "$do_copyrights"; then
4309 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4310 s/GNU Lesser General/GNU General/g
4311 s/Lesser General Public License/General Public License/g
4313 s/GNU Library General/GNU General/g
4314 s/Library General Public License/General Public License/g
4316 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4320 # Determine script to apply to library files that go into $testsbase/.
4321 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4322 if test -n "$do_copyrights"; then
4324 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4325 s/GNU Lesser General/GNU General/g
4326 s/Lesser General Public License/General Public License/g
4328 s/GNU Library General/GNU General/g
4329 s/Library General Public License/General Public License/g
4331 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4335 # Determine the final file lists.
4336 # They must be computed separately, because files in lib/* go into
4337 # $sourcebase/ if they are in the main file list but into $testsbase/
4338 # if they are in the tests-related file list. Furthermore lib/dummy.c
4340 # Determine final main file list.
4341 modules="$main_modules"
4342 func_modules_to_filelist
4344 # Determine final tests-related file list.
4345 modules="$testsrelated_modules"
4346 func_modules_to_filelist
4347 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
4348 # Merge both file lists.
4349 sed_remove_empty_lines='/^$/d'
4350 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
4351 if test $verbose -ge 0; then
4353 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
4354 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
4358 || func_fatal_error "refusing to do nothing"
4360 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4361 new_files="$files m4/gnulib-tool.m4"
4362 old_files="$cached_files"
4363 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4364 func_append old_files " m4/gnulib-tool.m4"
4367 rewritten='%REWRITTEN%'
4368 sed_rewrite_old_files="\
4369 s,^build-aux/,$rewritten$auxdir/,
4370 s,^doc/,$rewritten$cached_docbase/,
4371 s,^lib/,$rewritten$cached_sourcebase/,
4372 s,^m4/,$rewritten$cached_m4base/,
4373 s,^tests/,$rewritten$cached_testsbase/,
4374 s,^tests=lib/,$rewritten$cached_testsbase/,
4377 sed_rewrite_new_files="\
4378 s,^build-aux/,$rewritten$auxdir/,
4379 s,^doc/,$rewritten$docbase/,
4380 s,^lib/,$rewritten$sourcebase/,
4381 s,^m4/,$rewritten$m4base/,
4382 s,^tests/,$rewritten$testsbase/,
4383 s,^tests=lib/,$rewritten$testsbase/,
4387 # Create directories.
4388 { echo "$sourcebase"
4390 if test -n "$pobase"; then
4393 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4394 if test -n "$docfiles"; then
4397 if test -n "$inctests"; then
4401 for f in $files; do echo $f; done \
4402 | sed -e "$sed_rewrite_new_files" \
4403 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4406 { # Rearrange file descriptors. Needed because "while ... done < ..."
4407 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4408 exec 5<&0 < "$tmp"/dirs
4410 if test ! -d "$destdir/$d"; then
4412 echo "Creating directory $destdir/$d"
4413 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4415 echo "Create directory $destdir/$d"
4422 # Copy files or make symbolic links. Remove obsolete files.
4426 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4427 # representing the files according to the last gnulib-tool invocation.
4428 for f in $old_files; do echo $f; done \
4429 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4432 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4433 # representing the files after this gnulib-tool invocation.
4434 for f in $new_files; do echo $f; done \
4435 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4438 # First the files that are in old-files, but not in new-files:
4439 sed_take_first_column='s,'"$delimiter"'.*,,'
4440 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4441 # Remove the file. Do nothing if the user already removed it.
4442 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4444 echo "Removing file $g (backup in ${g}~)"
4445 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4447 echo "Remove file $g (backup in ${g}~)"
4449 func_append removed_files "$g$nl"
4452 # func_add_or_update handles a file that ought to be present afterwards.
4454 # - f the original file name
4455 # - g the rewritten file name
4456 # - already_present nonempty if the file should already exist, empty
4458 func_add_or_update ()
4462 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4464 func_dest_tmpfilename "$g"
4465 func_lookup_file "$f"
4466 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4467 if test -n "$sed_transform_main_lib_file"; then
4470 sed -e "$sed_transform_main_lib_file" \
4471 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4475 if test -n "$sed_transform_build_aux_file"; then
4478 sed -e "$sed_transform_build_aux_file" \
4479 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4483 if test -n "$sed_transform_testsrelated_lib_file"; then
4486 sed -e "$sed_transform_testsrelated_lib_file" \
4487 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4491 if test -f "$destdir/$g"; then
4492 # The file already exists.
4496 # Don't protest if the file should be there but isn't: it happens
4497 # frequently that developers don't put autogenerated files under version control.
4499 func_append added_files "$g$nl"
4503 # Then the files that are in new-files, but not in old-files:
4504 sed_take_last_column='s,^.*'"$delimiter"',,'
4506 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4507 | sed -e "$sed_take_last_column" \
4508 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4509 { # Rearrange file descriptors. Needed because "while ... done < ..."
4510 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4511 exec 5<&0 < "$tmp"/added-files
4517 # Then the files that are in new-files and in old-files:
4518 already_present=true
4519 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4520 | sed -e "$sed_take_last_column" \
4521 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4522 { # Rearrange file descriptors. Needed because "while ... done < ..."
4523 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4524 exec 5<&0 < "$tmp"/kept-files
4531 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4532 actioncmd="gnulib-tool --import"
4533 func_append actioncmd " --dir=$destdir"
4534 if test -n "$local_gnulib_dir"; then
4535 func_append actioncmd " --local-dir=$local_gnulib_dir"
4537 func_append actioncmd " --lib=$libname"
4538 func_append actioncmd " --source-base=$sourcebase"
4539 func_append actioncmd " --m4-base=$m4base"
4540 if test -n "$pobase"; then
4541 func_append actioncmd " --po-base=$pobase"
4543 func_append actioncmd " --doc-base=$docbase"
4544 func_append actioncmd " --tests-base=$testsbase"
4545 func_append actioncmd " --aux-dir=$auxdir"
4546 if test -n "$inctests"; then
4547 func_append actioncmd " --with-tests"
4549 if test -n "$incobsolete"; then
4550 func_append actioncmd " --with-obsolete"
4552 if test -n "$inc_cxx_tests"; then
4553 func_append actioncmd " --with-c++-tests"
4555 if test -n "$inc_longrunning_tests"; then
4556 func_append actioncmd " --with-longrunning-tests"
4558 if test -n "$inc_privileged_tests"; then
4559 func_append actioncmd " --with-privileged-tests"
4561 if test -n "$inc_unportable_tests"; then
4562 func_append actioncmd " --with-unportable-tests"
4564 if test -n "$inc_all_tests"; then
4565 func_append actioncmd " --with-all-tests"
4567 for module in $avoidlist; do
4568 func_append actioncmd " --avoid=$module"
4570 if test -n "$lgpl"; then
4571 if test "$lgpl" = yes; then
4572 func_append actioncmd " --lgpl"
4574 func_append actioncmd " --lgpl=$lgpl"
4577 if test -n "$makefile_name"; then
4578 func_append actioncmd " --makefile-name=$makefile_name"
4580 if test "$libtool" = true; then
4581 func_append actioncmd " --libtool"
4583 func_append actioncmd " --no-libtool"
4585 func_append actioncmd " --macro-prefix=$macro_prefix"
4586 if test -n "$po_domain"; then
4587 func_append actioncmd " --po-domain=$po_domain"
4589 if test -n "$vc_files"; then
4590 if test "$vc_files" = true; then
4591 func_append actioncmd " --vc-files"
4593 func_append actioncmd " --no-vc-files"
4596 func_append actioncmd " `echo $specified_modules`"
4598 # Default the makefile name to Makefile.am.
4599 if test -n "$makefile_name"; then
4600 makefile_am=$makefile_name
4602 makefile_am=Makefile.am
4605 # Create normal Makefile.ams.
4608 # Setup list of Makefile.am edits that are to be performed afterwards.
4609 # Some of these edits apply to files that we will generate; others are
4610 # under the responsibility of the developer.
4612 # func_note_Makefile_am_edit dir var value
4613 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4615 func_note_Makefile_am_edit ()
4617 makefile_am_edits=`expr $makefile_am_edits + 1`
4618 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4619 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4620 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4622 if test "$makefile_am" = Makefile.am; then
4623 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4624 sourcebase_base=`basename "$sourcebase"`
4625 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4627 if test -n "$pobase"; then
4628 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4629 pobase_base=`basename "$pobase"`
4630 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4632 if test -n "$inctests"; then
4633 if test "$makefile_am" = Makefile.am; then
4634 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4635 testsbase_base=`basename "$testsbase"`
4636 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4639 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4641 # Find the first parent directory of $m4base that contains or will contain
4643 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4645 sed_butlast='s,[^/][^/]*//*$,,'
4646 dir1="${m4base}/"; dir2=""
4647 while test -n "$dir1" \
4648 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4649 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4650 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4651 || { test -n "$inctests" \
4652 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4653 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4654 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4655 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4657 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4660 # Create library makefile.
4661 func_dest_tmpfilename $sourcebase/$makefile_am
4662 destfile="$sourcebase/$makefile_am"
4663 modules="$main_modules"
4664 func_emit_lib_Makefile_am > "$tmpfile"
4665 if test -f "$destdir"/$sourcebase/$makefile_am; then
4666 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4670 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4671 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4672 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4674 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4680 echo "Creating $sourcebase/$makefile_am"
4681 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4683 echo "Create $sourcebase/$makefile_am"
4686 func_append added_files "$sourcebase/$makefile_am$nl"
4689 # Create po/ directory.
4690 if test -n "$pobase"; then
4691 # Create po makefile and auxiliary files.
4692 for file in Makefile.in.in remove-potcdate.sin; do
4693 func_dest_tmpfilename $pobase/$file
4694 func_lookup_file build-aux/po/$file
4695 cat "$lookedup_file" > "$tmpfile"
4696 if test -f "$destdir"/$pobase/$file; then
4697 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4701 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4702 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4703 mv -f "$tmpfile" "$destdir"/$pobase/$file
4705 echo "Update $pobase/$file (backup in $pobase/$file~)"
4711 echo "Creating $pobase/$file"
4712 mv -f "$tmpfile" "$destdir"/$pobase/$file
4714 echo "Create $pobase/$file"
4717 func_append added_files "$pobase/$file$nl"
4720 # Create po makefile parameterization, part 1.
4721 func_dest_tmpfilename $pobase/Makevars
4722 func_emit_po_Makevars > "$tmpfile"
4723 if test -f "$destdir"/$pobase/Makevars; then
4724 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4728 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4729 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4730 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4732 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4738 echo "Creating $pobase/Makevars"
4739 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4741 echo "Create $pobase/Makevars"
4744 func_append added_files "$pobase/Makevars$nl"
4746 # Create po makefile parameterization, part 2.
4747 func_dest_tmpfilename $pobase/POTFILES.in
4748 func_emit_po_POTFILES_in > "$tmpfile"
4749 if test -f "$destdir"/$pobase/POTFILES.in; then
4750 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4754 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4755 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4756 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4758 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4764 echo "Creating $pobase/POTFILES.in"
4765 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4767 echo "Create $pobase/POTFILES.in"
4770 func_append added_files "$pobase/POTFILES.in$nl"
4773 TP_URL="http://translationproject.org/latest/"
4774 TP_RSYNC_URI="translationproject.org::tp/latest/"
4776 echo "Fetching gnulib PO files from $TP_URL"
4777 (cd "$destdir"/$pobase \
4778 && { # Prefer rsync over wget if it is available, since it consumes
4779 # less network bandwidth, due to compression.
4780 if type rsync 2>/dev/null | grep / > /dev/null; then
4781 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4783 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4788 echo "Fetch gnulib PO files from $TP_URL"
4790 # Create po/LINGUAS.
4792 func_dest_tmpfilename $pobase/LINGUAS
4793 (cd "$destdir"/$pobase \
4794 && { echo '# Set of available languages.'
4795 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4798 if test -f "$destdir"/$pobase/LINGUAS; then
4799 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4802 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4803 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4804 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4807 echo "Creating $pobase/LINGUAS"
4808 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4809 func_append added_files "$pobase/LINGUAS$nl"
4812 if test -f "$destdir"/$pobase/LINGUAS; then
4813 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4815 echo "Create $pobase/LINGUAS"
4820 # Create m4/gnulib-cache.m4.
4821 func_dest_tmpfilename $m4base/gnulib-cache.m4
4823 func_emit_copyright_notice
4825 echo "# This file represents the specification of how gnulib-tool is used."
4826 echo "# It acts as a cache: It is written and read by gnulib-tool."
4827 echo "# In projects that use version control, this file is meant to be put under"
4828 echo "# version control, like the configure.ac and various Makefile.am files."
4831 echo "# Specification in the form of a command-line invocation:"
4834 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4835 # Store the local_gnulib_dir relative to destdir.
4836 case "$local_gnulib_dir" in
4838 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4841 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4843 # destdir, local_gnulib_dir are both relative.
4844 func_relativize "$destdir" "$local_gnulib_dir"
4845 relative_local_gnulib_dir="$reldir" ;;
4848 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4850 echo "$specified_modules" | sed -e 's/^/ /g'
4852 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4853 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4854 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4855 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4856 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4857 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4858 echo "gl_AVOID([$avoidlist])"
4859 echo "gl_SOURCE_BASE([$sourcebase])"
4860 echo "gl_M4_BASE([$m4base])"
4861 echo "gl_PO_BASE([$pobase])"
4862 echo "gl_DOC_BASE([$docbase])"
4863 echo "gl_TESTS_BASE([$testsbase])"
4864 test -z "$inctests" || echo "gl_WITH_TESTS"
4865 echo "gl_LIB([$libname])"
4866 if test -n "$lgpl"; then
4867 if test "$lgpl" = yes; then
4870 echo "gl_LGPL([$lgpl])"
4873 echo "gl_MAKEFILE_NAME([$makefile_name])"
4874 if test "$libtool" = true; then
4877 echo "gl_MACRO_PREFIX([$macro_prefix])"
4878 echo "gl_PO_DOMAIN([$po_domain])"
4879 if test -n "$vc_files"; then
4880 echo "gl_VC_FILES([$vc_files])"
4883 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4884 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4888 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4889 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4890 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4892 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4896 echo "# gnulib-cache.m4 ends here"
4903 echo "Creating $m4base/gnulib-cache.m4"
4904 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4906 echo "Create $m4base/gnulib-cache.m4"
4912 # Create m4/gnulib-comp.m4.
4913 func_dest_tmpfilename $m4base/gnulib-comp.m4
4915 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4916 func_emit_copyright_notice
4918 echo "# This file represents the compiled summary of the specification in"
4919 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4920 echo "# to be invoked from configure.ac."
4921 echo "# In projects that use version control, this file can be treated like"
4922 echo "# other built files."
4925 echo "# This macro should be invoked from $configure_ac, in the section"
4926 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4927 echo "# any checks for libraries, header files, types and library functions."
4928 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4930 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4931 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4932 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4933 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4934 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4935 if test -n "$uses_subdirs"; then
4936 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4938 for module in $final_modules; do
4940 if test -n "$module"; then
4941 echo "# Code from module $module:"
4942 func_get_autoconf_early_snippet "$module"
4945 | sed -e '/^$/d;' -e 's/^/ /'
4948 echo "# This macro should be invoked from $configure_ac, in the section"
4949 echo "# \"Check for header files, types and library functions\"."
4950 echo "AC_DEFUN([${macro_prefix}_INIT],"
4952 if test "$libtool" = true; then
4953 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4954 echo " gl_cond_libtool=true"
4956 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4957 echo " gl_cond_libtool=false"
4959 echo " gl_ltlibdeps="
4961 if test "$auxdir" != "build-aux"; then
4962 sed_replace_build_aux='
4964 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4965 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4969 sed_replace_build_aux="$sed_noop"
4971 echo " gl_m4_base='$m4base'"
4972 func_emit_initmacro_start $macro_prefix
4973 echo " gl_source_base='$sourcebase'"
4974 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
4975 echo " # End of code from modules"
4976 func_emit_initmacro_end $macro_prefix
4977 echo " gltests_libdeps="
4978 echo " gltests_ltlibdeps="
4979 func_emit_initmacro_start ${macro_prefix}tests
4980 echo " gl_source_base='$testsbase'"
4981 # Define a tests witness macro that depends on the package.
4982 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4983 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4984 echo "changequote(,)dnl"
4985 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"
4986 echo "changequote([, ])dnl"
4987 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4988 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4989 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4990 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
4991 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4992 func_emit_initmacro_end ${macro_prefix}tests
4993 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4994 # created using libtool, because libtool already handles the dependencies.
4995 if test "$libtool" != true; then
4996 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
4997 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4998 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4999 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5000 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5002 if $use_libtests; then
5003 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5004 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5007 func_emit_initmacro_done $macro_prefix $sourcebase
5008 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5010 echo "# This macro records the list of files which have been installed by"
5011 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5012 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5013 echo "$files" | sed -e 's,^, ,'
5016 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5017 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
5021 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5022 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5023 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5025 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5029 echo "# gnulib-comp.m4 ends here"
5036 echo "Creating $m4base/gnulib-comp.m4"
5037 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5039 echo "Create $m4base/gnulib-comp.m4"
5045 if test -n "$inctests"; then
5046 # Create tests makefile.
5047 func_dest_tmpfilename $testsbase/$makefile_am
5048 destfile="$testsbase/$makefile_am"
5049 modules="$testsrelated_modules"
5050 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5051 if test -f "$destdir"/$testsbase/$makefile_am; then
5052 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
5056 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5057 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5058 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5060 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5066 echo "Creating $testsbase/$makefile_am"
5067 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5069 echo "Create $testsbase/$makefile_am"
5072 func_append added_files "$testsbase/$makefile_am$nl"
5076 if test "$vc_files" != false; then
5077 # Update the .cvsignore and .gitignore files.
5078 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5079 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5080 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5081 echo "$m4base/|A|gnulib-comp.m4"
5082 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5083 { # Rearrange file descriptors. Needed because "while ... done < ..."
5084 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5085 exec 5<&0 < "$tmp"/fileset-changes
5086 func_update_ignorelist ()
5089 if test "$ignore" = .gitignore; then
5090 # In a .gitignore file, "foo" applies to the current directory and all
5091 # subdirectories, whereas "/foo" applies to the current directory only.
5094 doubly_escaped_anchor='\\/'
5098 doubly_escaped_anchor=''
5100 if test -f "$destdir/$dir$ignore"; then
5101 if test -n "$dir_added" || test -n "$dir_removed"; then
5102 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5103 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5104 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5105 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5106 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
5108 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5110 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5111 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5112 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5113 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5114 } > "$tmp"/sed-ignore-removed
5115 { cat "$destdir/$dir$ignore"~
5116 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5117 } | sed -f "$tmp"/sed-ignore-removed \
5118 > "$destdir/$dir$ignore"
5120 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5125 if test -n "$dir_added"; then
5127 echo "Creating $destdir/$dir$ignore"
5129 if test "$ignore" = .cvsignore; then
5131 # Automake generates Makefile rules that create .dirstamp files.
5134 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5135 } > "$destdir/$dir$ignore"
5137 echo "Create $destdir/$dir$ignore"
5147 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5148 func_update_ignorelist .cvsignore
5150 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5151 func_update_ignorelist .gitignore
5158 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5159 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5160 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5161 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5162 if test "$next_dir" != "$last_dir"; then
5163 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5164 last_dir="$next_dir"
5169 A) func_append last_dir_added "$file$nl";;
5170 R) func_append last_dir_removed "$file$nl";;
5173 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5180 echo "You may need to add #include directives for the following .h files."
5181 # Intersect $specified_modules and $main_modules
5182 # (since $specified_modules is not necessarily of subset of $main_modules
5183 # - some may have been skipped through --avoid, and since the elements of
5184 # $main_modules but not in $specified_modules can go away without explicit
5185 # notice - through changes in the module dependencies).
5186 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5187 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5188 # First the #include <...> directives without #ifs, sorted for convenience,
5189 # then the #include "..." directives without #ifs, sorted for convenience,
5190 # then the #include directives that are surrounded by #ifs. Not sorted.
5191 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5192 include_directive=`func_get_include_directive "$module"`
5193 case "$nl$include_directive" in
5195 echo "$include_directive" 1>&5
5198 echo "$include_directive" | grep -v 'include "' 1>&6
5199 echo "$include_directive" | grep 'include "' 1>&7
5202 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5204 LC_ALL=C sort -u "$tmp"/include-angles
5205 LC_ALL=C sort -u "$tmp"/include-quotes
5206 cat "$tmp"/include-if
5207 ) | sed -e '/^$/d' -e 's/^/ /'
5208 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5210 for module in $main_modules; do
5211 func_get_link_directive "$module"
5213 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5214 if test `wc -l < "$tmp"/link` != 0; then
5216 echo "You may need to use the following Makefile variables when linking."
5217 echo "Use them in <program>_LDADD when linking a program, or"
5218 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5224 echo "Don't forget to"
5225 if test "$makefile_am" = Makefile.am; then
5226 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5228 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5230 if test -n "$pobase"; then
5231 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5233 if test -n "$inctests"; then
5234 if test "$makefile_am" = Makefile.am; then
5235 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5237 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5241 while test $edit != $makefile_am_edits; do
5242 edit=`expr $edit + 1`
5243 eval dir=\"\$makefile_am_edit${edit}_dir\"
5244 eval var=\"\$makefile_am_edit${edit}_var\"
5245 eval val=\"\$makefile_am_edit${edit}_val\"
5246 if test -n "$var"; then
5247 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5250 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
5251 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5254 # func_create_testdir testdir modules
5256 # - local_gnulib_dir from --local-dir
5257 # - modcache true or false, from --cache-modules/--no-cache-modules
5258 # - auxdir directory relative to destdir where to place build aux files
5259 # - inctests true if tests should be included, blank otherwise
5260 # - incobsolete true if obsolete modules among dependencies should be
5261 # included, blank otherwise
5262 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5264 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5266 # - excl_privileged_tests true if tests that require root privileges should be
5267 # excluded, blank otherwise
5268 # - excl_unportable_tests true if tests that fail on some platforms should be
5269 # excluded, blank otherwise
5270 # - avoidlist list of modules to avoid
5271 # - cond_dependencies true if conditional dependencies shall be supported,
5273 # - libtool true if --libtool was given, false if --no-libtool was
5274 # given, blank otherwise
5275 # - symbolic true if files should be symlinked, copied otherwise
5276 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5278 func_create_testdir ()
5282 if test -z "$modules"; then
5283 # All modules together.
5284 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5285 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5286 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5287 modules=`func_all_modules`
5288 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5290 specified_modules="$modules"
5292 # Canonicalize the list of specified modules.
5293 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5295 # Unlike in func_import, here we want to include all kinds of tests for the
5296 # directly specified modules, but not for dependencies.
5297 inc_all_direct_tests=true
5298 inc_all_indirect_tests="$inc_all_tests"
5300 # Check that the license of every module is consistent with the license of
5302 saved_inctests="$inctests"
5303 # When computing transitive closures, don't consider $module to depend on
5304 # $module-tests. Need this becauses tests are implicitly GPL and may depend
5305 # on GPL modules - therefore we don't want a warning in this case.
5307 for requested_module in $specified_modules; do
5308 requested_license=`func_get_license "$requested_module"`
5309 if test "$requested_license" != GPL; then
5310 # Here we use func_modules_transitive_closure, not just
5311 # func_get_dependencies, so that we also detect weird situations like
5312 # an LGPL module which depends on a GPLed build tool module which depends
5314 modules="$requested_module"
5315 func_modules_transitive_closure
5316 for module in $modules; do
5317 license=`func_get_license "$module"`
5319 'GPLed build tool') ;;
5320 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5322 case "$requested_license" in
5325 GPLv2+ | LGPLv2+) ;;
5326 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5332 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5338 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5347 inctests="$saved_inctests"
5349 # Subdirectory names.
5359 # Determine final module list.
5360 modules="$specified_modules"
5361 func_modules_transitive_closure
5362 if test $verbose -ge 0; then
5363 func_show_module_list
5366 # Add the dummy module if needed.
5367 func_modules_add_dummy
5369 # Show banner notice of every module.
5372 # Determine final file list.
5373 func_modules_to_filelist
5374 if test $verbose -ge 0; then
5376 echo "$files" | sed -e 's/^/ /'
5378 # Add files for which the copy in gnulib is newer than the one that
5379 # "automake --add-missing --copy" would provide.
5380 files="$files build-aux/config.guess"
5381 files="$files build-aux/config.sub"
5382 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5384 rewritten='%REWRITTEN%'
5385 sed_rewrite_files="\
5386 s,^build-aux/,$rewritten$auxdir/,
5387 s,^doc/,$rewritten$docbase/,
5388 s,^lib/,$rewritten$sourcebase/,
5389 s,^m4/,$rewritten$m4base/,
5390 s,^tests/,$rewritten$testsbase/,
5394 # Create directories.
5395 for f in $files; do echo $f; done \
5396 | sed -e "$sed_rewrite_files" \
5397 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5398 | LC_ALL=C sort -u \
5400 { # Rearrange file descriptors. Needed because "while ... done < ..."
5401 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5402 exec 5<&0 < "$tmp"/dirs
5404 mkdir -p "$testdir/$d"
5409 # Copy files or make symbolic links.
5411 for f in $files; do echo $f; done \
5412 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5415 { # Rearrange file descriptors. Needed because "while ... done < ..."
5416 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5417 exec 5<&0 < "$tmp"/files
5419 func_lookup_file "$f"
5420 if test -n "$lookedup_tmp"; then
5421 cp -p "$lookedup_file" "$testdir/$g"
5423 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5424 if { test -n "$symbolic" \
5425 || { test -n "$lsymbolic" \
5426 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5427 func_ln "$lookedup_file" "$testdir/$g"
5429 cp -p "$lookedup_file" "$testdir/$g"
5436 # Create Makefile.ams that are for testing.
5439 # No special edits are needed.
5442 # Create $sourcebase/Makefile.am.
5443 mkdir -p "$testdir/$sourcebase"
5444 destfile="$sourcebase/Makefile.am"
5445 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5446 any_uses_subdirs="$uses_subdirs"
5448 # Create $m4base/Makefile.am.
5449 mkdir -p "$testdir/$m4base"
5450 (echo "## Process this file with automake to produce Makefile.in."
5456 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5459 ) > "$testdir/$m4base/Makefile.am"
5461 subdirs="$sourcebase $m4base"
5462 subdirs_with_configure_ac=""
5464 if false && test -f "$testdir"/$m4base/gettext.m4; then
5465 # Avoid stupid error message from automake:
5466 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5467 mkdir -p "$testdir/po"
5468 (echo "## Process this file with automake to produce Makefile.in."
5469 ) > "$testdir/po/Makefile.am"
5470 func_append subdirs " po"
5473 if test -n "$inctests"; then
5474 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5475 # Viewed from the $testsbase subdirectory, $auxdir is different.
5476 saved_auxdir="$auxdir"
5477 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5478 # Create $testsbase/Makefile.am.
5480 destfile="$testsbase/Makefile.am"
5481 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5482 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5483 # Create $testsbase/configure.ac.
5484 (echo "# Process this file with autoconf to produce a configure script."
5485 echo "AC_INIT([dummy], [0])"
5486 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5487 echo "AM_INIT_AUTOMAKE"
5489 echo "AC_CONFIG_HEADERS([config.h])"
5492 echo "AC_PROG_INSTALL"
5493 echo "AC_PROG_MAKE_SET"
5494 echo "AC_PROG_RANLIB"
5496 if test -n "$uses_subdirs"; then
5497 echo "AM_PROG_CC_C_O"
5500 for module in $modules; do
5502 if test -n "$module"; then
5504 gnumakefile | maintainer-makefile)
5505 # These modules are meant to be used only in the top-level directory.
5508 func_get_autoconf_early_snippet "$module"
5513 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5514 if test "$libtool" = true; then
5515 echo "LT_INIT([win32-dll])"
5516 echo "LT_LANG([C++])"
5517 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5518 echo "gl_cond_libtool=true"
5520 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5521 echo "gl_cond_libtool=false"
5523 echo "gl_ltlibdeps="
5525 # Wrap the set of autoconf snippets into an autoconf macro that is then
5526 # invoked. This is needed because autoconf does not support AC_REQUIRE
5528 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5529 # but we want the AC_REQUIRE to have its normal meaning (provide one
5530 # expansion of the required macro before the current point, and only one
5532 echo "AC_DEFUN([gl_INIT], ["
5533 sed_replace_build_aux='
5535 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5536 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5539 echo "gl_m4_base='../$m4base'"
5540 func_emit_initmacro_start $macro_prefix
5541 # We don't have explicit ordering constraints between the various
5542 # autoconf snippets. It's cleanest to put those of the library before
5543 # those of the tests.
5544 echo "gl_source_base='../$sourcebase'"
5545 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5546 echo "gl_source_base='.'"
5547 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5548 func_emit_initmacro_end $macro_prefix
5549 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5550 # created using libtool, because libtool already handles the dependencies.
5551 if test "$libtool" != true; then
5552 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5553 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5554 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5555 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5556 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5559 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5563 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5564 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5565 echo "AH_TOP([#include \"../config.h\"])"
5567 echo "AC_CONFIG_FILES([Makefile])"
5569 ) > "$testdir/$testsbase/configure.ac"
5570 auxdir="$saved_auxdir"
5571 func_append subdirs " $testsbase"
5572 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5575 # Create Makefile.am.
5576 (echo "## Process this file with automake to produce Makefile.in."
5578 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5580 echo "SUBDIRS = $subdirs"
5582 echo "ACLOCAL_AMFLAGS = -I $m4base"
5583 ) > "$testdir/Makefile.am"
5585 # Create configure.ac.
5586 (echo "# Process this file with autoconf to produce a configure script."
5587 echo "AC_INIT([dummy], [0])"
5588 if test "$auxdir" != "."; then
5589 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5591 echo "AM_INIT_AUTOMAKE"
5593 echo "AC_CONFIG_HEADERS([config.h])"
5596 echo "AC_PROG_INSTALL"
5597 echo "AC_PROG_MAKE_SET"
5599 echo "# For autobuild."
5600 echo "AC_CANONICAL_BUILD"
5601 echo "AC_CANONICAL_HOST"
5603 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5604 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5605 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5606 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5608 echo "AC_PROG_RANLIB"
5610 if test -n "$any_uses_subdirs"; then
5611 echo "AM_PROG_CC_C_O"
5614 for module in $modules; do
5615 func_verify_nontests_module
5616 if test -n "$module"; then
5617 func_get_autoconf_early_snippet "$module"
5620 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5621 if test "$libtool" = true; then
5622 echo "LT_INIT([win32-dll])"
5623 echo "LT_LANG([C++])"
5624 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5625 echo "gl_cond_libtool=true"
5627 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5628 echo "gl_cond_libtool=false"
5630 echo "gl_ltlibdeps="
5632 # Wrap the set of autoconf snippets into an autoconf macro that is then
5633 # invoked. This is needed because autoconf does not support AC_REQUIRE
5635 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5636 # but we want the AC_REQUIRE to have its normal meaning (provide one
5637 # expansion of the required macro before the current point, and only one
5639 echo "AC_DEFUN([gl_INIT], ["
5640 if test "$auxdir" != "build-aux"; then
5641 sed_replace_build_aux='
5643 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5644 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5648 sed_replace_build_aux="$sed_noop"
5650 echo "gl_m4_base='$m4base'"
5651 func_emit_initmacro_start $macro_prefix
5652 echo "gl_source_base='$sourcebase'"
5653 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5654 func_emit_initmacro_end $macro_prefix
5655 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5656 # created using libtool, because libtool already handles the dependencies.
5657 if test "$libtool" != true; then
5658 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5659 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5660 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5661 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5662 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5665 func_emit_initmacro_done $macro_prefix $sourcebase
5669 if test -n "$subdirs_with_configure_ac"; then
5670 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5672 makefiles="Makefile"
5673 for d in $subdirs; do
5674 # For subdirs that have a configure.ac by their own, it's the subdir's
5675 # configure.ac which creates the subdir's Makefile.am, not this one.
5676 case " $subdirs_with_configure_ac " in
5678 *) func_append makefiles " $d/Makefile" ;;
5681 echo "AC_CONFIG_FILES([$makefiles])"
5683 ) > "$testdir/configure.ac"
5685 # Create autogenerated files.
5687 # Do not use "${AUTORECONF} --force --install", because it may invoke
5688 # autopoint, which brings in older versions of some of our .m4 files.
5689 if test -f $m4base/gettext.m4; then
5690 func_execute_command ${AUTOPOINT} --force || func_exit 1
5691 for f in $m4base/*.m4~; do
5693 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5697 if test "$libtool" = true; then
5698 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5700 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5701 if ! test -d build-aux; then
5702 func_execute_command mkdir build-aux || func_exit 1
5704 func_execute_command ${AUTOCONF} || func_exit 1
5705 func_execute_command ${AUTOHEADER} || func_exit 1
5706 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5708 if test -n "$inctests"; then
5709 # Create autogenerated files.
5710 (cd "$testdir/$testsbase" || func_exit 1
5711 # Do not use "${AUTORECONF} --force --install", because it may invoke
5712 # autopoint, which brings in older versions of some of our .m4 files.
5713 if test -f ../$m4base/gettext.m4; then
5714 func_execute_command ${AUTOPOINT} --force || func_exit 1
5715 for f in ../$m4base/*.m4~; do
5717 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5721 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5722 if ! test -d ../build-aux; then
5723 func_execute_command mkdir ../build-aux
5725 func_execute_command ${AUTOCONF} || func_exit 1
5726 func_execute_command ${AUTOHEADER} || func_exit 1
5727 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5730 # Need to run configure and make once, to create built files that are to be
5731 # distributed (such as parse-datetime.c).
5732 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5733 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5734 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5735 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5736 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5737 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5738 # such $(FOO_H) because they don't refer to distributed files.
5739 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5740 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5741 | sed -e "$sed_remove_make_variables"`
5742 distributed_built_sources=`for file in $built_sources; do
5743 case "$cleaned_files" in
5748 tests_distributed_built_sources=
5749 if test -n "$inctests"; then
5750 # Likewise for built files in the $testsbase directory.
5751 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5752 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5753 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5754 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5755 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5756 | sed -e "$sed_remove_make_variables"`
5757 tests_distributed_built_sources=`for file in $tests_built_sources; do
5758 case "$tests_cleaned_files" in
5764 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5766 ./configure || func_exit 1
5767 if test -n "$distributed_built_sources"; then
5769 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5770 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5775 if test -n "$tests_distributed_built_sources"; then
5777 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5778 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5783 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5790 # func_create_megatestdir megatestdir allmodules
5792 # - local_gnulib_dir from --local-dir
5793 # - modcache true or false, from --cache-modules/--no-cache-modules
5794 # - auxdir directory relative to destdir where to place build aux files
5795 func_create_megatestdir ()
5799 if test -z "$allmodules"; then
5800 allmodules=`func_all_modules`
5804 # First, all modules one by one.
5805 for onemodule in $allmodules; do
5806 func_create_testdir "$megatestdir/$onemodule" $onemodule
5807 func_append megasubdirs "$onemodule "
5809 # Then, all modules all together.
5810 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5811 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5812 func_create_testdir "$megatestdir/ALL" "$allmodules"
5813 func_append megasubdirs "ALL"
5816 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5817 vc_witness="$gnulib_dir/CVS/Entries"; \
5819 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5821 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5822 | sed -e 's,January,01,' -e 's,Jan,01,' \
5823 -e 's,February,02,' -e 's,Feb,02,' \
5824 -e 's,March,03,' -e 's,Mar,03,' \
5825 -e 's,April,04,' -e 's,Apr,04,' \
5827 -e 's,June,06,' -e 's,Jun,06,' \
5828 -e 's,July,07,' -e 's,Jul,07,' \
5829 -e 's,August,08,' -e 's,Aug,08,' \
5830 -e 's,September,09,' -e 's,Sep,09,' \
5831 -e 's,October,10,' -e 's,Oct,10,' \
5832 -e 's,November,11,' -e 's,Nov,11,' \
5833 -e 's,December,12,' -e 's,Dec,12,' \
5834 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5835 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5837 echo "CVSDATE=$cvsdate"
5838 echo ": \${MAKE=make}"
5839 echo "test -d logs || mkdir logs"
5840 echo "for module in $megasubdirs; do"
5841 echo " echo \"Working on module \$module...\""
5842 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5843 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5846 echo " : autobuild project... \$module"
5847 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5848 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5849 echo " : autobuild hostname... \`hostname\`"
5850 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5852 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5854 ) > "$megatestdir/do-autobuild"
5855 chmod a+x "$megatestdir/do-autobuild"
5857 # Create Makefile.am.
5858 (echo "## Process this file with automake to produce Makefile.in."
5860 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5862 echo "SUBDIRS = $megasubdirs"
5864 echo "EXTRA_DIST = do-autobuild"
5865 ) > "$megatestdir/Makefile.am"
5867 # Create configure.ac.
5868 (echo "# Process this file with autoconf to produce a configure script."
5869 echo "AC_INIT([dummy], [0])"
5870 if test "$auxdir" != "."; then
5871 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5873 echo "AM_INIT_AUTOMAKE"
5875 echo "AC_PROG_MAKE_SET"
5877 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5878 echo "AC_CONFIG_FILES([Makefile])"
5880 ) > "$megatestdir/configure.ac"
5882 # Create autogenerated files.
5884 # Do not use "${AUTORECONF} --install", because autoreconf operates
5885 # recursively, but the subdirectories are already finished, therefore
5886 # calling autoreconf here would only waste lots of CPU time.
5887 func_execute_command ${ACLOCAL} || func_exit 1
5888 func_execute_command mkdir build-aux
5889 func_execute_command ${AUTOCONF} || func_exit 1
5890 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5896 func_fatal_error "no mode specified" ;;
5903 # sed expression that converts a literal to a basic regular expression.
5904 # Needs to handle . [ \ * ^ $.
5905 sed_literal_to_basic_regex='s/\\/\\\\/g
5911 if test -f "$gnulib_dir/$filename" \
5912 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5913 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5914 filename_line_regex='^'"$filename_anywhere_regex"'$'
5917 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5918 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5919 (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$,,')
5922 | func_sanitize_modulelist \
5925 for module in $module_candidates; do
5926 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5931 func_warning "file $filename does not exist"
5936 import | add-import | remove-import | update )
5939 if test -z "$destdir"; then
5942 test -d "$destdir" \
5943 || func_fatal_error "destination directory does not exist: $destdir"
5945 # Prefer configure.ac to configure.in.
5946 if test -f "$destdir"/configure.ac; then
5947 configure_ac="$destdir/configure.ac"
5949 if test -f "$destdir"/configure.in; then
5950 configure_ac="$destdir/configure.in"
5952 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5956 # Analyze configure.ac.
5958 guessed_libtool=false
5963 /AC_CONFIG_AUX_DIR/ {
5964 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5966 /A[CM]_PROG_LIBTOOL/ {
5967 s,^.*$,guessed_libtool=true,p
5969 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5971 if test -z "$auxdir"; then
5972 auxdir="$guessed_auxdir"
5975 # Determine where to apply func_import.
5976 if test "$mode" = import; then
5977 # Apply func_import to a particular gnulib directory.
5978 # The command line contains the complete specification; don't look at
5979 # the contents of gnulib-cache.m4.
5980 test -n "$supplied_libname" || supplied_libname=true
5981 test -n "$sourcebase" || sourcebase="lib"
5982 test -n "$m4base" || m4base="m4"
5983 test -n "$docbase" || docbase="doc"
5984 test -n "$testsbase" || testsbase="tests"
5985 test -n "$macro_prefix" || macro_prefix="gl"
5988 if test -n "$m4base"; then
5989 # Apply func_import to a particular gnulib directory.
5990 # Any number of additional modules can be given.
5991 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5992 # First use of gnulib in the given m4base.
5993 test -n "$supplied_libname" || supplied_libname=true
5994 test -n "$sourcebase" || sourcebase="lib"
5995 test -n "$docbase" || docbase="doc"
5996 test -n "$testsbase" || testsbase="tests"
5997 test -n "$macro_prefix" || macro_prefix="gl"
6001 # Apply func_import to all gnulib directories.
6002 # To get this list of directories, look at Makefile.am. (Not at
6003 # configure, because it may be omitted from version control. Also,
6004 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6008 if test -f "$destdir"/Makefile.am; then
6009 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6011 for arg in $aclocal_amflags; do
6012 if test -n "$m4dir_is_next"; then
6013 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6017 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6018 func_append m4dirs " $arg"
6019 m4dirs_count=`expr $m4dirs_count + 1`
6025 if test "X$arg" = "X-I"; then
6033 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6034 if test -f "$destdir"/aclocal.m4; then
6035 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6036 sedexpr2='s,^[^/]*$,.,'
6037 sedexpr3='s,/[^/]*$,,'
6038 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6039 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6040 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6043 if test $m4dirs_count = 0; then
6044 # First use of gnulib in a package.
6045 # Any number of additional modules can be given.
6046 test -n "$supplied_libname" || supplied_libname=true
6047 test -n "$sourcebase" || sourcebase="lib"
6049 test -n "$docbase" || docbase="doc"
6050 test -n "$testsbase" || testsbase="tests"
6051 test -n "$macro_prefix" || macro_prefix="gl"
6054 if test $m4dirs_count = 1; then
6055 # There's only one use of gnulib here. Assume the user means it.
6056 # Any number of additional modules can be given.
6057 for m4base in $m4dirs; do
6061 # Ambiguous - guess what the user meant.
6062 if test $# = 0; then
6063 # No further arguments. Guess the user wants to update all of them.
6064 for m4base in $m4dirs; do
6065 # Perform func_import in a subshell, so that variable values
6067 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6068 # inc_longrunning_tests, inc_privileged_tests,
6069 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6070 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6071 # makefile_name, libtool, macro_prefix, po_domain, vc_files
6072 # don't propagate from one directory to another.
6073 (func_import) || func_exit 1
6077 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6086 if test -z "$destdir"; then
6087 func_fatal_error "please specify --dir option"
6090 test -d "$destdir" \
6091 || func_fatal_error "could not create destination directory"
6092 test -n "$auxdir" || auxdir="build-aux"
6093 func_create_testdir "$destdir" "$*"
6096 create-megatestdir )
6097 if test -z "$destdir"; then
6098 func_fatal_error "please specify --dir option"
6100 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6101 test -n "$auxdir" || auxdir="build-aux"
6102 func_create_megatestdir "$destdir" "$*"
6106 test -n "$destdir" || destdir=testdir$$
6107 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6108 test -n "$auxdir" || auxdir="build-aux"
6109 func_create_testdir "$destdir" "$*"
6113 ../configure || func_exit 1
6114 $MAKE || func_exit 1
6115 $MAKE check || func_exit 1
6116 $MAKE distclean || func_exit 1
6117 remaining=`find . -type f -print`
6118 if test -n "$remaining"; then
6119 echo "Remaining files:" $remaining 1>&2
6120 echo "gnulib-tool: *** Stop." 1>&2
6129 test -n "$destdir" || destdir=testdir$$
6130 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6131 test -n "$auxdir" || auxdir="build-aux"
6132 func_create_megatestdir "$destdir" "$*"
6140 remaining=`find . -type f -print`
6141 if test -n "$remaining"; then
6142 echo "Remaining files:" $remaining 1>&2
6143 echo "gnulib-tool: *** Stop." 1>&2
6151 extract-description )
6155 if test -n "$module"; then
6156 func_get_description "$module"
6165 if test -n "$module"; then
6166 func_get_comment "$module"
6175 if test -n "$module"; then
6176 func_get_status "$module"
6185 if test -n "$module"; then
6186 func_get_notice "$module"
6191 extract-applicability )
6195 if test -n "$module"; then
6196 func_get_applicability "$module"
6205 if test -n "$module"; then
6206 func_get_filelist "$module"
6211 extract-dependencies )
6215 if test -n "$module"; then
6216 func_get_dependencies "$module"
6221 extract-autoconf-snippet )
6225 if test -n "$module"; then
6226 func_get_autoconf_snippet "$module"
6231 extract-automake-snippet )
6235 if test -n "$module"; then
6236 func_get_automake_snippet "$module"
6241 extract-include-directive )
6245 if test -n "$module"; then
6246 func_get_include_directive "$module"
6251 extract-link-directive )
6255 if test -n "$module"; then
6256 func_get_link_directive "$module"
6265 if test -n "$module"; then
6266 func_get_license "$module"
6271 extract-maintainer )
6275 if test -n "$module"; then
6276 func_get_maintainer "$module"
6281 extract-tests-module )
6285 if test -n "$module"; then
6286 func_get_tests_module "$module"
6292 # Verify the number of arguments.
6293 if test $# -lt 1 || test $# -gt 2; then
6294 func_fatal_error "invalid number of arguments for --$mode"
6297 # The first argument is the file to be copied.
6299 # Verify the file exists.
6300 func_lookup_file "$f"
6302 # The second argument is the destination; either a directory ot a file.
6303 # It defaults to the current directory.
6305 test -n "$dest" || dest='.'
6306 test -n "$sourcebase" || sourcebase="lib"
6307 test -n "$m4base" || m4base="m4"
6308 test -n "$docbase" || docbase="doc"
6309 test -n "$testsbase" || testsbase="tests"
6310 test -n "$auxdir" || auxdir="build-aux"
6311 rewritten='%REWRITTEN%'
6312 sed_rewrite_files="\
6313 s,^build-aux/,$rewritten$auxdir/,
6314 s,^doc/,$rewritten$docbase/,
6315 s,^lib/,$rewritten$sourcebase/,
6316 s,^m4/,$rewritten$m4base/,
6317 s,^tests/,$rewritten$testsbase/,
6320 if test -d "$dest"; then
6322 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6324 destdir=`dirname "$dest"`
6325 g=`basename "$dest"`
6328 # Create the directory for destfile.
6329 d=`dirname "$destdir/$g"`
6331 if test -n "$d" && test ! -d "$d"; then
6332 mkdir -p "$d" || func_fatal_error "failed"
6336 func_dest_tmpfilename "$g"
6337 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6338 already_present=true
6339 if test -f "$destdir/$g"; then
6340 # The file already exists.
6344 # Don't protest if the file should be there but isn't: it happens
6345 # frequently that developers don't put autogenerated files under version
6353 func_fatal_error "unknown operation mode --$mode" ;;
6357 # Undo the effect of the previous 'trap' command. Some shellology:
6358 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6359 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6360 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6361 # 128 + signal number and is set before the trap-registered command is run.
6363 trap 'func_exit $?' 1 2 3 13 15
6368 # indent-tabs-mode: nil
6369 # whitespace-check-buffer-indent: nil