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"' *$/{s/^.*$/true/p}'
2698 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p}'
2699 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2700 if test "$condition" = true; then
2703 if test -n "$condition"; then
2704 func_conddep_add_module "$module" "$dep" "$condition"
2706 if $conditional; then
2707 func_conddep_add_module "$module" "$dep" true
2709 func_uncond_add_module "$dep"
2718 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2719 # Remove $handledmodules from $inmodules.
2720 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2721 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2722 fmtc_inc_all_tests="$inc_all_indirect_tests"
2724 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2725 rm -f "$tmp"/queued-modules
2728 # func_show_module_list
2730 # - specified_modules list of specified modules (one per line, sorted)
2731 # - modules complete list of modules (one per line, sorted)
2732 # - tmp pathname of a temporary directory
2733 func_show_module_list ()
2739 # Assume xterm compatible escape sequences.
2740 bold_on=`printf '\x1b[1m'`
2741 bold_off=`printf '\x1b[0m'`
2746 echo "Module list with included dependencies (indented):"
2747 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2748 echo "$modules" | sed -e '/^$/d' \
2749 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2750 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2753 # func_modules_add_dummy
2755 # - local_gnulib_dir from --local-dir
2756 # - modcache true or false, from --cache-modules/--no-cache-modules
2757 # - modules list of modules, including dependencies
2759 # - modules list of modules, including 'dummy' if needed
2760 func_modules_add_dummy ()
2762 # Determine whether any module provides a lib_SOURCES augmentation.
2764 sed_remove_backslash_newline=':a
2771 for module in $modules; do
2772 func_verify_nontests_module
2773 if test -n "$module"; then
2774 # Extract the value of "lib_SOURCES += ...".
2775 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2776 # Ignore .h files since they are not compiled.
2780 have_lib_SOURCES=yes
2787 # Add the dummy module, to make sure the library will be non-empty.
2788 if test -z "$have_lib_SOURCES"; then
2789 if func_acceptable "dummy"; then
2790 func_append modules " dummy"
2795 # func_modules_notice
2797 # - local_gnulib_dir from --local-dir
2798 # - modcache true or false, from --cache-modules/--no-cache-modules
2799 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2800 # - modules list of modules, including dependencies
2801 func_modules_notice ()
2803 if test $verbose -ge -1; then
2804 for module in $modules; do
2806 if test -n "$module"; then
2807 msg=`func_get_notice $module`
2808 if test -n "$msg"; then
2809 echo "Notice from module $module:"
2810 echo "$msg" | sed -e 's/^/ /'
2817 # func_modules_to_filelist
2819 # - local_gnulib_dir from --local-dir
2820 # - modcache true or false, from --cache-modules/--no-cache-modules
2821 # - modules list of modules, including dependencies
2823 # - files list of files
2824 func_modules_to_filelist ()
2827 for module in $modules; do
2829 if test -n "$module"; then
2830 fs=`func_get_filelist $module`
2831 func_append files " $fs"
2834 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2837 # func_execute_command command [args...]
2838 # Executes a command.
2839 # Uses also the variables
2840 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2841 func_execute_command ()
2843 if test $verbose -ge 0; then
2847 # Commands like automake produce output to stderr even when they succeed.
2848 # Turn this output off if the command succeeds.
2849 "$@" > "$tmp"/cmdout 2>&1
2851 if test $cmdret = 0; then
2855 cat "$tmp"/cmdout 1>&2
2862 # func_dest_tmpfilename file
2863 # determines the name of a temporary file (file is relative to destdir).
2865 # - destdir target directory
2866 # - doit : if actions shall be executed, false if only to be printed
2867 # - tmp pathname of a temporary directory
2869 # - tmpfile absolute filename of the temporary file
2870 func_dest_tmpfilename ()
2873 # Put the new contents of $file in a file in the same directory (needed
2874 # to guarantee that an 'mv' to "$destdir/$file" works).
2875 tmpfile="$destdir/$1.tmp"
2877 # Put the new contents of $file in a file in a temporary directory
2878 # (because the directory of "$file" might not exist).
2879 tmpfile="$tmp"/`basename "$1"`.tmp
2884 # copies a file from gnulib into the destination directory. The destination
2885 # is known to not exist.
2887 # - destdir target directory
2888 # - local_gnulib_dir from --local-dir
2889 # - modcache true or false, from --cache-modules/--no-cache-modules
2890 # - f the original file name
2891 # - lookedup_file name of the merged (combined) file
2892 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2893 # - g the rewritten file name
2894 # - tmpfile absolute filename of the temporary file
2895 # - doit : if actions shall be executed, false if only to be printed
2896 # - symbolic true if files should be symlinked, copied otherwise
2897 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2902 echo "Copying file $g"
2903 if { test -n "$symbolic" \
2904 || { test -n "$lsymbolic" \
2905 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2906 && test -z "$lookedup_tmp" \
2907 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2908 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2910 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2918 # copies a file from gnulib into the destination directory. The destination
2919 # is known to exist.
2921 # - destdir target directory
2922 # - local_gnulib_dir from --local-dir
2923 # - modcache true or false, from --cache-modules/--no-cache-modules
2924 # - f the original file name
2925 # - lookedup_file name of the merged (combined) file
2926 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2927 # - g the rewritten file name
2928 # - tmpfile absolute filename of the temporary file
2929 # - doit : if actions shall be executed, false if only to be printed
2930 # - symbolic true if files should be symlinked, copied otherwise
2931 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2933 # - already_present nonempty if the file should already exist, empty otherwise
2936 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2937 : # The file has not changed.
2941 if test -n "$already_present"; then
2942 echo "Updating file $g (backup in ${g}~)"
2944 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2946 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2947 if { test -n "$symbolic" \
2948 || { test -n "$lsymbolic" \
2949 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2950 && test -z "$lookedup_tmp" \
2951 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2952 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2954 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2957 if test -n "$already_present"; then
2958 echo "Update file $g (backup in ${g}~)"
2960 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2966 # func_emit_lib_Makefile_am
2967 # emits the contents of library makefile to standard output.
2969 # - local_gnulib_dir from --local-dir
2970 # - modcache true or false, from --cache-modules/--no-cache-modules
2971 # - modules list of modules, including dependencies
2972 # - libname library name
2973 # - pobase directory relative to destdir where to place *.po files
2974 # - auxdir directory relative to destdir where to place build aux files
2975 # - makefile_name from --makefile-name
2976 # - libtool true if libtool will be used, false or blank otherwise
2977 # - macro_prefix prefix of gl_LIBOBJS macros to use
2978 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2979 # - actioncmd (optional) command that will reproduce this invocation
2980 # - for_test true if creating a package for testing, false otherwise
2981 # - destfile filename relative to destdir of makefile being generated
2983 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2984 # list of edits to be done to Makefile.am variables
2986 # - uses_subdirs nonempty if object files in subdirs exist
2987 func_emit_lib_Makefile_am ()
2989 # When creating an includable Makefile.am snippet, augment variables with
2990 # += instead of assigning them.
2991 if test -n "$makefile_name"; then
2996 if test "$libtool" = true; then
2999 sed_eliminate_LDFLAGS="$sed_noop"
3003 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3006 # When creating a package for testing: Attempt to provoke failures,
3007 # especially link errors, already during "make" rather than during
3008 # "make check", because "make check" is not possible in a cross-compiling
3009 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3010 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3012 sed_transform_check_PROGRAMS="$sed_noop"
3014 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3015 echo "## Process this file with automake to produce Makefile.in."
3016 func_emit_copyright_notice
3017 if test -n "$actioncmd"; then
3018 # The maximum line length (excluding the terminating newline) of any file
3019 # that is to be preprocessed by config.status is 3070. config.status uses
3020 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3021 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3022 len=`echo "$actioncmd" | wc -c`
3023 if test -n "$len" && test "$len" -le 3000; then
3024 echo "# Reproduce by: $actioncmd"
3030 for module in $modules; do
3031 func_verify_nontests_module
3032 if test -n "$module"; then
3034 func_get_automake_snippet_conditional "$module" |
3036 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3037 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3038 -e "$sed_eliminate_LDFLAGS" \
3039 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3040 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3041 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3042 -e "$sed_transform_check_PROGRAMS"
3043 if test "$module" = 'alloca'; then
3044 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3045 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3047 } > "$tmp"/amsnippet1
3049 func_get_automake_snippet_unconditional "$module" |
3050 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3051 } > "$tmp"/amsnippet2
3052 # Skip the contents if it's entirely empty.
3053 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3054 echo "## begin gnulib module $module"
3056 if test -n "$cond_dependencies"; then
3057 if func_cond_module_p "$module"; then
3058 func_module_conditional_name "$module"
3059 echo "if $conditional"
3062 cat "$tmp"/amsnippet1
3063 if test -n "$cond_dependencies"; then
3064 if func_cond_module_p "$module"; then
3068 cat "$tmp"/amsnippet2
3069 echo "## end gnulib module $module"
3072 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3073 # Test whether there are some source files in subdirectories.
3074 for f in `func_get_filelist "$module"`; do
3084 } > "$tmp"/allsnippets
3085 if test -z "$makefile_name"; then
3086 # If there are source files in subdirectories, prevent collision of the
3087 # object files (example: hash.c and libxml/hash.c).
3089 if test -n "$uses_subdirs"; then
3090 subdir_options=' subdir-objects'
3092 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
3095 if test -z "$makefile_name"; then
3097 echo "noinst_HEADERS ="
3098 echo "noinst_LIBRARIES ="
3099 echo "noinst_LTLIBRARIES ="
3100 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3101 # if you specify pkgdata_DATA to empty. This is a workaround.
3102 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3103 echo "pkgdata_DATA ="
3106 echo "BUILT_SOURCES ="
3109 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3110 if test -z "$makefile_name"; then
3111 echo "MOSTLYCLEANDIRS ="
3113 echo "DISTCLEANFILES ="
3114 echo "MAINTAINERCLEANFILES ="
3116 # Execute edits that apply to the Makefile.am being generated.
3118 while test $edit != $makefile_am_edits; do
3119 edit=`expr $edit + 1`
3120 eval dir=\"\$makefile_am_edit${edit}_dir\"
3121 eval var=\"\$makefile_am_edit${edit}_var\"
3122 eval val=\"\$makefile_am_edit${edit}_val\"
3123 if test -n "$var"; then
3124 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3125 echo "${var} += ${val}"
3126 eval "makefile_am_edit${edit}_var="
3130 if test -z "$makefile_name"; then
3133 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
3135 echo "AM_CPPFLAGS ="
3140 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3141 || { test -n "$makefile_name" \
3142 && test -f "$sourcebase/Makefile.am" \
3143 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3145 # One of the snippets or the user's Makefile.am already specifies an
3146 # installation location for the library. Don't confuse automake by saying
3147 # it should not be installed.
3150 # By default, the generated library should not be installed.
3151 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3154 echo "${libname}_${libext}_SOURCES ="
3155 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3156 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3157 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3158 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3159 echo "EXTRA_${libname}_${libext}_SOURCES ="
3160 if test "$libtool" = true; then
3161 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3162 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3163 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3164 # the link dependencies of all modules.
3165 for module in $modules; do
3166 func_verify_nontests_module
3167 if test -n "$module"; then
3168 func_get_link_directive "$module"
3171 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3172 | LC_ALL=C sort -u \
3173 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3176 if test -n "$pobase"; then
3177 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3180 cat "$tmp"/allsnippets \
3181 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3183 echo "mostlyclean-local: mostlyclean-generic"
3184 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3185 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3186 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3190 rm -f "$tmp"/allsnippets
3193 # func_emit_po_Makevars
3194 # emits the contents of po/ makefile parameterization to standard output.
3196 # - local_gnulib_dir from --local-dir
3197 # - modcache true or false, from --cache-modules/--no-cache-modules
3198 # - sourcebase directory relative to destdir where to place source code
3199 # - pobase directory relative to destdir where to place *.po files
3200 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3201 func_emit_po_Makevars ()
3203 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3204 func_emit_copyright_notice
3206 echo "# Usually the message domain is the same as the package name."
3207 echo "# But here it has a '-gnulib' suffix."
3208 echo "DOMAIN = ${po_domain}-gnulib"
3210 echo "# These two variables depend on the location of this directory."
3211 echo "subdir = ${pobase}"
3212 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3215 # These options get passed to xgettext.
3216 XGETTEXT_OPTIONS = \
3217 --keyword=_ --flag=_:1:pass-c-format \
3218 --keyword=N_ --flag=N_:1:pass-c-format \
3219 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3220 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3221 --flag=error:3:c-format --flag=error_at_line:5:c-format
3223 # This is the copyright holder that gets inserted into the header of the
3224 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3225 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3227 # This is the email address or URL to which the translators shall report
3228 # bugs in the untranslated strings:
3229 # - Strings which are not entire sentences, see the maintainer guidelines
3230 # in the GNU gettext documentation, section 'Preparing Strings'.
3231 # - Strings which use unclear terms or require additional context to be
3233 # - Strings which make invalid assumptions about notation of date, time or
3235 # - Pluralisation problems.
3236 # - Incorrect English spelling.
3237 # - Incorrect formatting.
3238 # It can be your email address, or a mailing list address where translators
3239 # can write to without being subscribed, or the URL of a web page through
3240 # which the translators can contact you.
3241 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3243 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3244 # message catalogs shall be used. It is usually empty.
3245 EXTRA_LOCALE_CATEGORIES =
3247 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3248 # context. Possible values are "yes" and "no". Set this to yes if the
3249 # package uses functions taking also a message context, like pgettext(), or
3250 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3255 # func_emit_po_POTFILES_in
3256 # emits the file list to be passed to xgettext to standard output.
3258 # - local_gnulib_dir from --local-dir
3259 # - modcache true or false, from --cache-modules/--no-cache-modules
3260 # - sourcebase directory relative to destdir where to place source code
3261 # - files list of new files
3262 func_emit_po_POTFILES_in ()
3264 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3265 func_emit_copyright_notice
3267 echo "# List of files which contain translatable strings."
3268 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3271 # func_emit_tests_Makefile_am witness_macro
3272 # emits the contents of tests makefile to standard output.
3274 # - local_gnulib_dir from --local-dir
3275 # - modcache true or false, from --cache-modules/--no-cache-modules
3276 # - modules list of modules, including dependencies
3277 # - libname library name
3278 # - auxdir directory relative to destdir where to place build aux files
3279 # - makefile_name from --makefile-name
3280 # - libtool true if libtool will be used, false or blank otherwise
3281 # - sourcebase relative directory containing lib source code
3282 # - m4base relative directory containing autoconf macros
3283 # - testsbase relative directory containing unit test code
3284 # - macro_prefix prefix of gl_LIBOBJS macros to use
3285 # - for_test true if creating a package for testing, false otherwise
3286 # - use_libtests true if a libtests.a should be built, false otherwise
3287 # - destfile filename relative to destdir of makefile being generated
3289 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3290 # list of edits to be done to Makefile.am variables
3292 # - uses_subdirs nonempty if object files in subdirs exist
3293 func_emit_tests_Makefile_am ()
3296 if test "$libtool" = true; then
3298 sed_eliminate_LDFLAGS="$sed_noop"
3301 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3304 # When creating a package for testing: Attempt to provoke failures,
3305 # especially link errors, already during "make" rather than during
3306 # "make check", because "make check" is not possible in a cross-compiling
3307 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3308 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3310 sed_transform_check_PROGRAMS="$sed_noop"
3312 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3313 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3314 echo "## Process this file with automake to produce Makefile.in."
3315 func_emit_copyright_notice
3319 for module in $modules; do
3321 func_verify_tests_module
3325 if test -n "$module"; then
3327 func_get_automake_snippet "$module" |
3329 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3330 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3331 -e "$sed_eliminate_LDFLAGS" \
3332 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3333 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3334 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3335 -e "$sed_transform_check_PROGRAMS"
3336 if $use_libtests && test "$module" = 'alloca'; then
3337 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3338 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3340 } > "$tmp"/amsnippet
3341 # Skip the contents if it's entirely empty.
3342 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3343 # Mention long-running tests at the end.
3345 for word in `func_get_status "$module"`; do
3346 if test "$word" = 'longrunning-test'; then
3351 { echo "## begin gnulib module $module"
3353 cat "$tmp"/amsnippet
3354 echo "## end gnulib module $module"
3358 rm -f "$tmp"/amsnippet
3359 # Test whether there are some source files in subdirectories.
3360 for f in `func_get_filelist "$module"`; do
3362 lib/*/*.c | tests/*/*.c)
3370 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3371 # Generate dependencies here, since it eases the debugging of test failures.
3372 # If there are source files in subdirectories, prevent collision of the
3373 # object files (example: hash.c and libxml/hash.c).
3375 if test -n "$uses_subdirs"; then
3376 subdir_options=' subdir-objects'
3378 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3381 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3384 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3385 # variable is needed to avoid an error from automake:
3386 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3389 echo "XFAIL_TESTS ="
3390 echo "TESTS_ENVIRONMENT ="
3391 echo "noinst_PROGRAMS ="
3392 if ! $for_test; then
3393 echo "check_PROGRAMS ="
3395 echo "noinst_HEADERS ="
3396 echo "noinst_LIBRARIES ="
3397 if $use_libtests; then
3399 echo "noinst_LIBRARIES += libtests.a"
3401 echo "check_LIBRARIES = libtests.a"
3404 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3405 # if you specify pkgdata_DATA to empty. This is a workaround.
3406 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3407 echo "pkgdata_DATA ="
3410 echo "BUILT_SOURCES ="
3412 echo "MOSTLYCLEANFILES = core *.stackdump"
3413 echo "MOSTLYCLEANDIRS ="
3415 echo "DISTCLEANFILES ="
3416 echo "MAINTAINERCLEANFILES ="
3417 # Execute edits that apply to the Makefile.am being generated.
3419 while test $edit != $makefile_am_edits; do
3420 edit=`expr $edit + 1`
3421 eval dir=\"\$makefile_am_edit${edit}_dir\"
3422 eval var=\"\$makefile_am_edit${edit}_var\"
3423 eval val=\"\$makefile_am_edit${edit}_val\"
3424 if test -n "$var"; then
3425 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3426 echo "${var} += ${val}"
3427 eval "makefile_am_edit${edit}_var="
3432 echo "AM_CPPFLAGS = \\"
3434 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3436 if test -n "${witness_macro}"; then
3437 echo " -D@${witness_macro}@=1 \\"
3439 echo " -I. -I\$(srcdir) \\"
3440 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3441 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3443 local_ldadd_before=''
3444 local_ldadd_after=''
3445 if $use_libtests; then
3446 # All test programs need to be linked with libtests.a.
3447 # It needs to be passed to the linker before ${libname}.${libext}, since
3448 # the tests-related modules depend on the main modules.
3449 # It also needs to be passed to the linker after ${libname}.${libext}
3450 # because the latter might contain incomplete modules (such as the 'error'
3451 # module whose dependency to 'progname' is voluntarily omitted).
3452 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3454 local_ldadd_before=' libtests.a'
3455 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3457 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3459 if $use_libtests; then
3460 echo "libtests_a_SOURCES ="
3461 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3462 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3463 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3464 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3465 echo "EXTRA_libtests_a_SOURCES ="
3466 # The circular dependency in LDADD requires this.
3467 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3470 # Many test scripts use ${EXEEXT} or ${srcdir}.
3471 # EXEEXT is defined by AC_PROG_CC through autoconf.
3472 # srcdir is defined by autoconf and automake.
3473 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3475 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3476 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3477 echo "# Clean up after Solaris cc."
3479 echo " rm -rf SunWS_cache"
3481 echo "mostlyclean-local: mostlyclean-generic"
3482 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3483 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3484 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3488 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3491 # func_emit_initmacro_start macro_prefix
3492 # emits the first few statements of the gl_INIT macro to standard output.
3493 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3494 func_emit_initmacro_start ()
3496 macro_prefix_arg="$1"
3497 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3498 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3499 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3500 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3502 # Furthermore it avoids an automake error like this when a Makefile.am
3503 # that uses pieces of gnulib also uses $(LIBOBJ):
3504 # automatically discovered file `error.c' should not be explicitly mentioned
3505 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3506 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3507 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3508 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3509 # automatically discovered file `error.c' should not be explicitly mentioned
3510 # We let automake know about the files to be distributed through the
3511 # EXTRA_lib_SOURCES variable.
3512 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3513 # Create data variables for checking the presence of files that are mentioned
3514 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3515 # because we want the check to happen when the configure file is created,
3516 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3517 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3518 # in which to expect them.
3519 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3520 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3524 # func_emit_initmacro_end macro_prefix
3525 # emits the last few statements of the gl_INIT macro to standard output.
3526 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3527 func_emit_initmacro_end ()
3529 macro_prefix_arg="$1"
3530 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3531 # The check is performed only when autoconf is run from the directory where
3532 # the configure.ac resides; if it is run from a different directory, the
3534 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3535 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3536 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3537 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3538 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3542 echo " m4_if(m4_sysval, [0], [],"
3543 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3545 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3546 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3547 echo " m4_popdef([AC_LIBSOURCES])"
3548 echo " m4_popdef([AC_REPLACE_FUNCS])"
3549 echo " m4_popdef([AC_LIBOBJ])"
3550 echo " AC_CONFIG_COMMANDS_PRE(["
3551 echo " ${macro_prefix_arg}_libobjs="
3552 echo " ${macro_prefix_arg}_ltlibobjs="
3553 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3554 echo " # Remove the extension."
3555 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3556 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3557 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3558 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3561 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3562 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3566 # func_emit_initmacro_done macro_prefix sourcebase
3567 # emits a few statements after the gl_INIT macro to standard output.
3568 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3569 # - sourcebase directory relative to destdir where to place source code
3570 func_emit_initmacro_done ()
3572 macro_prefix_arg="$1"
3575 echo "# Like AC_LIBOBJ, except that the module name goes"
3576 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3577 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3578 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3579 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3582 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3583 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3584 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3585 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3586 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3589 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3590 echo "# expected is derived from the gnulib-tool parameterization,"
3591 echo "# and alloca is special cased (for the alloca-opt module)."
3592 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3593 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3594 echo " m4_foreach([_gl_NAME], [\$1], ["
3595 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3596 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3597 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3603 # func_emit_autoconf_snippet indentation
3604 # emits the autoconf snippet of a module.
3606 # - local_gnulib_dir from --local-dir
3607 # - modcache true or false, from --cache-modules/--no-cache-modules
3608 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3609 # - module the module name
3610 # - toplevel true or false. 'false' means a subordinate use of
3612 # - disable_libtool true or false. It tells whether to disable libtool
3613 # handling even if it has been specified through the
3614 # command line options.
3615 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3617 # - indentation spaces to prepend on each line
3618 func_emit_autoconf_snippet ()
3620 if { case $module in
3621 gnumakefile | maintainer-makefile)
3622 # These modules are meant to be used only in the top-level directory.
3628 func_get_autoconf_snippet "$module" \
3629 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3630 -e "$sed_replace_build_aux" \
3631 | { if $disable_libtool; then
3632 sed -e 's/\$gl_cond_libtool/false/g' \
3633 -e 's/gl_libdeps/gltests_libdeps/g' \
3634 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3639 | { if $disable_gettext; then
3640 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3645 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3646 echo 'changequote(,)dnl'
3647 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3648 echo 'changequote([, ])dnl'
3649 echo 'AC_SUBST([LTALLOCA])'
3654 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3655 # collects and emit the autoconf snippets of a set of modules.
3657 # - local_gnulib_dir from --local-dir
3658 # - modcache true or false, from --cache-modules/--no-cache-modules
3659 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3660 # - modules the list of modules.
3661 # - verifier one of func_verify_module, func_verify_nontests_module,
3662 # func_verify_tests_module. It selects the subset of
3663 # $modules to consider.
3664 # - toplevel true or false. 'false' means a subordinate use of
3666 # - disable_libtool true or false. It tells whether to disable libtool
3667 # handling even if it has been specified through the
3668 # command line options.
3669 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3671 func_emit_autoconf_snippets ()
3675 disable_libtool="$4"
3676 disable_gettext="$5"
3677 if test -n "$cond_dependencies"; then
3678 # Emit the autoconf code for the unconditional modules.
3679 for module in $1; do
3681 if test -n "$module"; then
3682 if func_cond_module_p "$module"; then
3685 func_emit_autoconf_snippet " "
3689 # Initialize the shell variables indicating that the modules are enabled.
3690 for module in $1; do
3692 if test -n "$module"; then
3693 if func_cond_module_p "$module"; then
3694 func_module_shellvar_name "$module"
3695 echo " $shellvar=false"
3699 # Emit the autoconf code for the conditional modules, each in a separate
3700 # function. This makes it possible to support cycles among conditional
3702 for module in $1; do
3704 if test -n "$module"; then
3705 if func_cond_module_p "$module"; then
3706 func_module_shellfunc_name "$module"
3707 func_module_shellvar_name "$module"
3708 echo " $shellfunc ()"
3710 echo " if ! \$$shellvar; then"
3711 func_emit_autoconf_snippet " "
3712 echo " $shellvar=true"
3713 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3714 for dep in $deps; do
3715 if func_cond_module_p "$dep"; then
3716 func_module_shellfunc_name "$dep"
3717 func_cond_module_condition "$module" "$dep"
3718 if test "$condition" != true; then
3719 echo ' if $condition; then'
3726 # The autoconf code for $dep has already been emitted above and
3727 # therefore is already executed when this function is run.
3736 # Emit the dependencies from the unconditional to the conditional modules.
3737 for module in $1; do
3739 if test -n "$module"; then
3740 if func_cond_module_p "$module"; then
3743 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3744 for dep in $deps; do
3745 if func_cond_module_p "$dep"; then
3746 func_module_shellfunc_name "$dep"
3747 func_cond_module_condition "$module" "$dep"
3748 if test "$condition" != true; then
3749 echo " if $condition; then"
3756 # The autoconf code for $dep has already been emitted above and
3757 # therefore is already executed when this code is run.
3764 # Define the Automake conditionals.
3765 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
3766 for module in $1; do
3768 if test -n "$module"; then
3769 if func_cond_module_p "$module"; then
3770 func_module_conditional_name "$module"
3771 func_module_shellvar_name "$module"
3772 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
3777 # Ignore the conditions, and enable all modules unconditionally.
3778 for module in $1; do
3780 if test -n "$module"; then
3781 func_emit_autoconf_snippet " "
3787 # func_import modules
3788 # Uses also the variables
3789 # - mode import or add-import or remove-import or update
3790 # - destdir target directory
3791 # - local_gnulib_dir from --local-dir
3792 # - modcache true or false, from --cache-modules/--no-cache-modules
3793 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3794 # - libname library name
3795 # - supplied_libname true if --lib was given, blank otherwise
3796 # - sourcebase directory relative to destdir where to place source code
3797 # - m4base directory relative to destdir where to place *.m4 macros
3798 # - pobase directory relative to destdir where to place *.po files
3799 # - docbase directory relative to destdir where to place doc files
3800 # - testsbase directory relative to destdir where to place unit test code
3801 # - auxdir directory relative to destdir where to place build aux files
3802 # - inctests true if --with-tests was given, blank otherwise
3803 # - incobsolete true if --with-obsolete was given, blank otherwise
3804 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3805 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3807 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3809 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3811 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3812 # - avoidlist list of modules to avoid, from --avoid
3813 # - cond_dependencies true if conditional dependencies shall be supported,
3815 # - lgpl yes or a number if library's license shall be LGPL,
3817 # - makefile_name from --makefile-name
3818 # - libtool true if --libtool was given, false if --no-libtool was
3819 # given, blank otherwise
3820 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3821 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3822 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3823 # - vc_files true if --vc-files was given, false if --no-vc-files was
3824 # given, blank otherwise
3825 # - autoconf_minversion minimum supported autoconf version
3826 # - doit : if actions shall be executed, false if only to be printed
3827 # - symbolic true if files should be symlinked, copied otherwise
3828 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3830 # - do_copyrights true if copyright notices in files should be replaced,
3834 # Get the cached settings.
3835 # In 'import' mode, we read them only for the purpose of knowing the old
3836 # installed file list, and don't use them as defaults.
3837 cached_local_gnulib_dir=
3838 cached_specified_modules=
3840 cached_inc_cxx_tests=
3841 cached_inc_longrunning_tests=
3842 cached_inc_privileged_tests=
3843 cached_inc_unportable_tests=
3844 cached_inc_all_tests=
3854 cached_makefile_name=
3856 cached_macro_prefix=
3860 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3861 cached_libtool=false
3867 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3877 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3879 /gl_WITH_OBSOLETE/ {
3880 s,^.*$,cached_incobsolete=true,p
3882 /gl_WITH_CXX_TESTS/ {
3883 s,^.*$,cached_inc_cxx_tests=true,p
3885 /gl_WITH_LONGRUNNING_TESTS/ {
3886 s,^.*$,cached_inc_longrunning_tests=true,p
3888 /gl_WITH_PRIVILEGED_TESTS/ {
3889 s,^.*$,cached_inc_privileged_tests=true,p
3891 /gl_WITH_UNPORTABLE_TESTS/ {
3892 s,^.*$,cached_inc_unportable_tests=true,p
3894 /gl_WITH_ALL_TESTS/ {
3895 s,^.*$,cached_inc_all_tests=true,p
3898 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3901 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3904 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3907 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3910 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3913 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3916 s,^.*$,cached_inctests=true,p
3919 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3922 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3925 s,^.*$,cached_lgpl=yes,p
3927 /gl_MAKEFILE_NAME(/ {
3928 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3931 s,^.*$,cached_libtool=true,p
3933 /gl_MACRO_PREFIX(/ {
3934 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3937 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3940 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3942 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3943 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3948 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3949 s,^.*$,cached_files=",p
3962 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3966 if test "$mode" = import; then
3967 # In 'import' mode, the new set of specified modules overrides the cached
3968 # set of modules. Ignore the cached settings.
3969 specified_modules="$1"
3971 # Merge the cached settings with the specified ones.
3972 # The m4base must be the same as expected from the pathname.
3973 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3974 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3976 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3977 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3978 if test -z "$local_gnulib_dir"; then
3979 if test -n "$cached_local_gnulib_dir"; then
3982 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3984 case "$cached_local_gnulib_dir" in
3986 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3988 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3989 local_gnulib_dir="$relconcat" ;;
3996 # Append the cached and the specified module names. So that
3997 # "gnulib-tool --add-import foo" means to add the module foo.
3998 specified_modules="$cached_specified_modules $1"
4001 # Take the cached module names, minus the specified module names.
4003 if $have_associative; then
4004 # Use an associative array, for O(N) worst-case run time.
4005 declare -A to_remove
4007 eval 'to_remove[$m]=yes'
4009 for module in $cached_specified_modules; do
4010 if eval 'test -z "${to_remove[$module]}"'; then
4011 func_append specified_modules "$module "
4015 # This loop has O(N²) worst-case run time.
4016 for module in $cached_specified_modules; do
4019 if test "$m" = "$module"; then
4024 if test -z "$to_remove"; then
4025 func_append specified_modules "$module "
4031 # Take the cached module names. There are no specified module names.
4032 specified_modules="$cached_specified_modules"
4035 # Included obsolete modules among the dependencies if specified either way.
4036 if test -z "$incobsolete"; then
4037 incobsolete="$cached_incobsolete"
4039 # Included special kinds of tests modules among the dependencies if specified
4041 if test -z "$inc_cxx_tests"; then
4042 inc_cxx_tests="$cached_inc_cxx_tests"
4044 if test -z "$inc_longrunning_tests"; then
4045 inc_longrunning_tests="$cached_inc_longrunning_tests"
4047 if test -z "$inc_privileged_tests"; then
4048 inc_privileged_tests="$cached_inc_privileged_tests"
4050 if test -z "$inc_unportable_tests"; then
4051 inc_unportable_tests="$cached_inc_unportable_tests"
4053 if test -z "$inc_all_tests"; then
4054 inc_all_tests="$cached_inc_all_tests"
4056 # Append the cached and the specified avoidlist. This is probably better
4057 # than dropping the cached one when --avoid is specified at least once.
4058 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4059 avoidlist=`echo $avoidlist`
4061 # The sourcebase defaults to the cached one.
4062 if test -z "$sourcebase"; then
4063 sourcebase="$cached_sourcebase"
4064 if test -z "$sourcebase"; then
4065 func_fatal_error "missing --source-base option"
4068 # The pobase defaults to the cached one.
4069 if test -z "$pobase"; then
4070 pobase="$cached_pobase"
4072 # The docbase defaults to the cached one.
4073 if test -z "$docbase"; then
4074 docbase="$cached_docbase"
4075 if test -z "$docbase"; then
4076 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."
4079 # The testsbase defaults to the cached one.
4080 if test -z "$testsbase"; then
4081 testsbase="$cached_testsbase"
4082 if test -z "$testsbase"; then
4083 func_fatal_error "missing --tests-base option"
4086 # Require the tests if specified either way.
4087 if test -z "$inctests"; then
4088 inctests="$cached_inctests"
4090 # The libname defaults to the cached one.
4091 if test -z "$supplied_libname"; then
4092 libname="$cached_libname"
4093 if test -z "$libname"; then
4094 func_fatal_error "missing --lib option"
4097 # Require LGPL if specified either way.
4098 if test -z "$lgpl"; then
4101 # The makefile_name defaults to the cached one.
4102 if test -z "$makefile_name"; then
4103 makefile_name="$cached_makefile_name"
4105 # Use libtool if specified either way, or if guessed.
4106 if test -z "$libtool"; then
4107 if test -n "$cached_m4base"; then
4108 libtool="$cached_libtool"
4110 libtool="$guessed_libtool"
4113 # The macro_prefix defaults to the cached one.
4114 if test -z "$macro_prefix"; then
4115 macro_prefix="$cached_macro_prefix"
4116 if test -z "$macro_prefix"; then
4117 func_fatal_error "missing --macro-prefix option"
4120 # The po_domain defaults to the cached one.
4121 if test -z "$po_domain"; then
4122 po_domain="$cached_po_domain"
4124 # The vc_files defaults to the cached one.
4125 if test -z "$vc_files"; then
4126 vc_files="$cached_vc_files"
4129 # --without-*-tests options are not supported here.
4131 excl_longrunning_tests=
4132 excl_privileged_tests=
4133 excl_unportable_tests=
4135 # Canonicalize the list of specified modules.
4136 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4138 # Include all kinds of tests modules if --with-all-tests was specified.
4139 inc_all_direct_tests="$inc_all_tests"
4140 inc_all_indirect_tests="$inc_all_tests"
4142 # Determine final module list.
4143 modules="$specified_modules"
4144 func_modules_transitive_closure
4145 if test $verbose -ge 0; then
4146 func_show_module_list
4148 final_modules="$modules"
4150 # Determine main module list and tests-related module list separately.
4151 # The main module list is the transitive closure of the specified modules,
4152 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
4153 # is specified, it will consist only of LGPLed source.
4154 # The tests-related module list is the transitive closure of the specified
4155 # modules, including tests modules, minus the main module list excluding
4156 # modules of applicability 'all'. Its lib/* sources (brought in through
4157 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
4158 # source, even if --lgpl is specified.
4159 # Determine main module list.
4160 saved_inctests="$inctests"
4162 modules="$specified_modules"
4163 func_modules_transitive_closure
4164 main_modules="$modules"
4165 inctests="$saved_inctests"
4166 if test $verbose -ge 1; then
4167 echo "Main module list:"
4168 echo "$main_modules" | sed -e 's/^/ /'
4170 # Determine tests-related module list.
4171 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
4172 testsrelated_modules=`for module in $main_modules; do
4173 if test \`func_get_applicability $module\` = main; then
4177 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
4178 if test $verbose -ge 1; then
4179 echo "Tests-related module list:"
4180 echo "$testsrelated_modules" | sed -e 's/^/ /'
4183 # Add the dummy module to the main module list if needed.
4184 modules="$main_modules"
4185 func_modules_add_dummy
4186 main_modules="$modules"
4188 # Determine whether a $testsbase/libtests.a is needed.
4190 for module in $testsrelated_modules; do
4191 func_verify_nontests_module
4192 if test -n "$module"; then
4193 all_files=`func_get_filelist $module`
4194 # Test whether some file in $all_files lies in lib/.
4195 for f in $all_files; do
4206 # Add the dummy module to the tests-related module list if needed.
4207 if $use_libtests; then
4208 modules="$testsrelated_modules"
4209 func_modules_add_dummy
4210 testsrelated_modules="$modules"
4213 # If --lgpl, verify that the licenses of modules are compatible.
4214 if test -n "$lgpl"; then
4215 license_incompatibilities=
4216 for module in $main_modules; do
4217 license=`func_get_license $module`
4219 'GPLed build tool') ;;
4220 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4225 LGPL | LGPLv2+ | LGPLv3+) ;;
4226 *) func_append license_incompatibilities "$module $license$nl" ;;
4232 *) func_append license_incompatibilities "$module $license$nl" ;;
4235 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4240 if test -n "$license_incompatibilities"; then
4241 # Format the license incompatibilities as a table.
4242 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4243 s,^\(.................................................[^ ]*\) *, \1 ,'
4244 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4245 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4249 # Show banner notice of every module.
4250 modules="$main_modules"
4253 # Determine script to apply to imported library files.
4254 sed_transform_lib_file=
4255 for module in $main_modules; do
4256 if test $module = config-h; then
4257 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4258 sed_transform_lib_file=$sed_transform_lib_file'
4259 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4264 sed_transform_main_lib_file="$sed_transform_lib_file"
4265 if test -n "$do_copyrights"; then
4266 if test -n "$lgpl"; then
4270 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4271 s/GNU General/GNU Lesser General/g
4272 s/General Public License/Lesser General Public License/g
4273 s/Lesser Lesser General Public License/Lesser General Public License/g
4277 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4278 s/GNU General/GNU Lesser General/g
4279 s/General Public License/Lesser General Public License/g
4280 s/Lesser Lesser General Public License/Lesser General Public License/g
4282 s/version [23]\([ ,]\)/version 2.1\1/g
4285 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4289 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4290 s/GNU Lesser General/GNU General/g
4291 s/Lesser General Public License/General Public License/g
4293 s/GNU Library General/GNU General/g
4294 s/Library General Public License/General Public License/g
4296 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4301 # Determine script to apply to auxiliary files that go into $auxdir/.
4302 sed_transform_build_aux_file=
4303 if test -n "$do_copyrights"; then
4305 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4306 s/GNU Lesser General/GNU General/g
4307 s/Lesser General Public License/General Public License/g
4309 s/GNU Library General/GNU General/g
4310 s/Library General Public License/General Public License/g
4312 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4316 # Determine script to apply to library files that go into $testsbase/.
4317 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4318 if test -n "$do_copyrights"; then
4320 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4321 s/GNU Lesser General/GNU General/g
4322 s/Lesser General Public License/General Public License/g
4324 s/GNU Library General/GNU General/g
4325 s/Library General Public License/General Public License/g
4327 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4331 # Determine the final file lists.
4332 # They must be computed separately, because files in lib/* go into
4333 # $sourcebase/ if they are in the main file list but into $testsbase/
4334 # if they are in the tests-related file list. Furthermore lib/dummy.c
4336 # Determine final main file list.
4337 modules="$main_modules"
4338 func_modules_to_filelist
4340 # Determine final tests-related file list.
4341 modules="$testsrelated_modules"
4342 func_modules_to_filelist
4343 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
4344 # Merge both file lists.
4345 sed_remove_empty_lines='/^$/d'
4346 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
4347 if test $verbose -ge 0; then
4349 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
4350 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
4354 || func_fatal_error "refusing to do nothing"
4356 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4357 new_files="$files m4/gnulib-tool.m4"
4358 old_files="$cached_files"
4359 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4360 func_append old_files " m4/gnulib-tool.m4"
4363 rewritten='%REWRITTEN%'
4364 sed_rewrite_old_files="\
4365 s,^build-aux/,$rewritten$auxdir/,
4366 s,^doc/,$rewritten$cached_docbase/,
4367 s,^lib/,$rewritten$cached_sourcebase/,
4368 s,^m4/,$rewritten$cached_m4base/,
4369 s,^tests/,$rewritten$cached_testsbase/,
4370 s,^tests=lib/,$rewritten$cached_testsbase/,
4373 sed_rewrite_new_files="\
4374 s,^build-aux/,$rewritten$auxdir/,
4375 s,^doc/,$rewritten$docbase/,
4376 s,^lib/,$rewritten$sourcebase/,
4377 s,^m4/,$rewritten$m4base/,
4378 s,^tests/,$rewritten$testsbase/,
4379 s,^tests=lib/,$rewritten$testsbase/,
4383 # Create directories.
4384 { echo "$sourcebase"
4386 if test -n "$pobase"; then
4389 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4390 if test -n "$docfiles"; then
4393 if test -n "$inctests"; then
4397 for f in $files; do echo $f; done \
4398 | sed -e "$sed_rewrite_new_files" \
4399 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4402 { # Rearrange file descriptors. Needed because "while ... done < ..."
4403 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4404 exec 5<&0 < "$tmp"/dirs
4406 if test ! -d "$destdir/$d"; then
4408 echo "Creating directory $destdir/$d"
4409 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4411 echo "Create directory $destdir/$d"
4418 # Copy files or make symbolic links. Remove obsolete files.
4422 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4423 # representing the files according to the last gnulib-tool invocation.
4424 for f in $old_files; do echo $f; done \
4425 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4428 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4429 # representing the files after this gnulib-tool invocation.
4430 for f in $new_files; do echo $f; done \
4431 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4434 # First the files that are in old-files, but not in new-files:
4435 sed_take_first_column='s,'"$delimiter"'.*,,'
4436 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4437 # Remove the file. Do nothing if the user already removed it.
4438 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4440 echo "Removing file $g (backup in ${g}~)"
4441 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4443 echo "Remove file $g (backup in ${g}~)"
4445 func_append removed_files "$g$nl"
4448 # func_add_or_update handles a file that ought to be present afterwards.
4450 # - f the original file name
4451 # - g the rewritten file name
4452 # - already_present nonempty if the file should already exist, empty
4454 func_add_or_update ()
4458 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4460 func_dest_tmpfilename "$g"
4461 func_lookup_file "$f"
4462 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4463 if test -n "$sed_transform_main_lib_file"; then
4466 sed -e "$sed_transform_main_lib_file" \
4467 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4471 if test -n "$sed_transform_build_aux_file"; then
4474 sed -e "$sed_transform_build_aux_file" \
4475 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4479 if test -n "$sed_transform_testsrelated_lib_file"; then
4482 sed -e "$sed_transform_testsrelated_lib_file" \
4483 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4487 if test -f "$destdir/$g"; then
4488 # The file already exists.
4492 # Don't protest if the file should be there but isn't: it happens
4493 # frequently that developers don't put autogenerated files under version control.
4495 func_append added_files "$g$nl"
4499 # Then the files that are in new-files, but not in old-files:
4500 sed_take_last_column='s,^.*'"$delimiter"',,'
4502 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4503 | sed -e "$sed_take_last_column" \
4504 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4505 { # Rearrange file descriptors. Needed because "while ... done < ..."
4506 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4507 exec 5<&0 < "$tmp"/added-files
4513 # Then the files that are in new-files and in old-files:
4514 already_present=true
4515 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4516 | sed -e "$sed_take_last_column" \
4517 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4518 { # Rearrange file descriptors. Needed because "while ... done < ..."
4519 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4520 exec 5<&0 < "$tmp"/kept-files
4527 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4528 actioncmd="gnulib-tool --import"
4529 func_append actioncmd " --dir=$destdir"
4530 if test -n "$local_gnulib_dir"; then
4531 func_append actioncmd " --local-dir=$local_gnulib_dir"
4533 func_append actioncmd " --lib=$libname"
4534 func_append actioncmd " --source-base=$sourcebase"
4535 func_append actioncmd " --m4-base=$m4base"
4536 if test -n "$pobase"; then
4537 func_append actioncmd " --po-base=$pobase"
4539 func_append actioncmd " --doc-base=$docbase"
4540 func_append actioncmd " --tests-base=$testsbase"
4541 func_append actioncmd " --aux-dir=$auxdir"
4542 if test -n "$inctests"; then
4543 func_append actioncmd " --with-tests"
4545 if test -n "$incobsolete"; then
4546 func_append actioncmd " --with-obsolete"
4548 if test -n "$inc_cxx_tests"; then
4549 func_append actioncmd " --with-c++-tests"
4551 if test -n "$inc_longrunning_tests"; then
4552 func_append actioncmd " --with-longrunning-tests"
4554 if test -n "$inc_privileged_tests"; then
4555 func_append actioncmd " --with-privileged-tests"
4557 if test -n "$inc_unportable_tests"; then
4558 func_append actioncmd " --with-unportable-tests"
4560 if test -n "$inc_all_tests"; then
4561 func_append actioncmd " --with-all-tests"
4563 for module in $avoidlist; do
4564 func_append actioncmd " --avoid=$module"
4566 if test -n "$lgpl"; then
4567 if test "$lgpl" = yes; then
4568 func_append actioncmd " --lgpl"
4570 func_append actioncmd " --lgpl=$lgpl"
4573 if test -n "$makefile_name"; then
4574 func_append actioncmd " --makefile-name=$makefile_name"
4576 if test "$libtool" = true; then
4577 func_append actioncmd " --libtool"
4579 func_append actioncmd " --no-libtool"
4581 func_append actioncmd " --macro-prefix=$macro_prefix"
4582 if test -n "$po_domain"; then
4583 func_append actioncmd " --po-domain=$po_domain"
4585 if test -n "$vc_files"; then
4586 if test "$vc_files" = true; then
4587 func_append actioncmd " --vc-files"
4589 func_append actioncmd " --no-vc-files"
4592 func_append actioncmd " `echo $specified_modules`"
4594 # Default the makefile name to Makefile.am.
4595 if test -n "$makefile_name"; then
4596 makefile_am=$makefile_name
4598 makefile_am=Makefile.am
4601 # Create normal Makefile.ams.
4604 # Setup list of Makefile.am edits that are to be performed afterwards.
4605 # Some of these edits apply to files that we will generate; others are
4606 # under the responsibility of the developer.
4608 # func_note_Makefile_am_edit dir var value
4609 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4611 func_note_Makefile_am_edit ()
4613 makefile_am_edits=`expr $makefile_am_edits + 1`
4614 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4615 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4616 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4618 if test "$makefile_am" = Makefile.am; then
4619 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4620 sourcebase_base=`basename "$sourcebase"`
4621 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4623 if test -n "$pobase"; then
4624 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4625 pobase_base=`basename "$pobase"`
4626 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4628 if test -n "$inctests"; then
4629 if test "$makefile_am" = Makefile.am; then
4630 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4631 testsbase_base=`basename "$testsbase"`
4632 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4635 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4637 # Find the first parent directory of $m4base that contains or will contain
4639 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4641 sed_butlast='s,[^/][^/]*//*$,,'
4642 dir1="${m4base}/"; dir2=""
4643 while test -n "$dir1" \
4644 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4645 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4646 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4647 || { test -n "$inctests" \
4648 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4649 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4650 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4651 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4653 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4656 # Create library makefile.
4657 func_dest_tmpfilename $sourcebase/$makefile_am
4658 destfile="$sourcebase/$makefile_am"
4659 modules="$main_modules"
4660 func_emit_lib_Makefile_am > "$tmpfile"
4661 if test -f "$destdir"/$sourcebase/$makefile_am; then
4662 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4666 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4667 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4668 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4670 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4676 echo "Creating $sourcebase/$makefile_am"
4677 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4679 echo "Create $sourcebase/$makefile_am"
4682 func_append added_files "$sourcebase/$makefile_am$nl"
4685 # Create po/ directory.
4686 if test -n "$pobase"; then
4687 # Create po makefile and auxiliary files.
4688 for file in Makefile.in.in remove-potcdate.sin; do
4689 func_dest_tmpfilename $pobase/$file
4690 func_lookup_file build-aux/po/$file
4691 cat "$lookedup_file" > "$tmpfile"
4692 if test -f "$destdir"/$pobase/$file; then
4693 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4697 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4698 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4699 mv -f "$tmpfile" "$destdir"/$pobase/$file
4701 echo "Update $pobase/$file (backup in $pobase/$file~)"
4707 echo "Creating $pobase/$file"
4708 mv -f "$tmpfile" "$destdir"/$pobase/$file
4710 echo "Create $pobase/$file"
4713 func_append added_files "$pobase/$file$nl"
4716 # Create po makefile parameterization, part 1.
4717 func_dest_tmpfilename $pobase/Makevars
4718 func_emit_po_Makevars > "$tmpfile"
4719 if test -f "$destdir"/$pobase/Makevars; then
4720 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4724 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4725 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4726 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4728 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4734 echo "Creating $pobase/Makevars"
4735 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4737 echo "Create $pobase/Makevars"
4740 func_append added_files "$pobase/Makevars$nl"
4742 # Create po makefile parameterization, part 2.
4743 func_dest_tmpfilename $pobase/POTFILES.in
4744 func_emit_po_POTFILES_in > "$tmpfile"
4745 if test -f "$destdir"/$pobase/POTFILES.in; then
4746 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4750 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4751 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4752 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4754 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4760 echo "Creating $pobase/POTFILES.in"
4761 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4763 echo "Create $pobase/POTFILES.in"
4766 func_append added_files "$pobase/POTFILES.in$nl"
4769 TP_URL="http://translationproject.org/latest/"
4770 TP_RSYNC_URI="translationproject.org::tp/latest/"
4772 echo "Fetching gnulib PO files from $TP_URL"
4773 (cd "$destdir"/$pobase \
4774 && { # Prefer rsync over wget if it is available, since it consumes
4775 # less network bandwidth, due to compression.
4776 if type rsync 2>/dev/null | grep / > /dev/null; then
4777 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4779 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4784 echo "Fetch gnulib PO files from $TP_URL"
4786 # Create po/LINGUAS.
4788 func_dest_tmpfilename $pobase/LINGUAS
4789 (cd "$destdir"/$pobase \
4790 && { echo '# Set of available languages.'
4791 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4794 if test -f "$destdir"/$pobase/LINGUAS; then
4795 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4798 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4799 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4800 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4803 echo "Creating $pobase/LINGUAS"
4804 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4805 func_append added_files "$pobase/LINGUAS$nl"
4808 if test -f "$destdir"/$pobase/LINGUAS; then
4809 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4811 echo "Create $pobase/LINGUAS"
4816 # Create m4/gnulib-cache.m4.
4817 func_dest_tmpfilename $m4base/gnulib-cache.m4
4819 func_emit_copyright_notice
4821 echo "# This file represents the specification of how gnulib-tool is used."
4822 echo "# It acts as a cache: It is written and read by gnulib-tool."
4823 echo "# In projects that use version control, this file is meant to be put under"
4824 echo "# version control, like the configure.ac and various Makefile.am files."
4827 echo "# Specification in the form of a command-line invocation:"
4830 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4831 # Store the local_gnulib_dir relative to destdir.
4832 case "$local_gnulib_dir" in
4834 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4837 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4839 # destdir, local_gnulib_dir are both relative.
4840 func_relativize "$destdir" "$local_gnulib_dir"
4841 relative_local_gnulib_dir="$reldir" ;;
4844 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4846 echo "$specified_modules" | sed -e 's/^/ /g'
4848 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4849 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4850 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4851 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4852 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4853 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4854 echo "gl_AVOID([$avoidlist])"
4855 echo "gl_SOURCE_BASE([$sourcebase])"
4856 echo "gl_M4_BASE([$m4base])"
4857 echo "gl_PO_BASE([$pobase])"
4858 echo "gl_DOC_BASE([$docbase])"
4859 echo "gl_TESTS_BASE([$testsbase])"
4860 test -z "$inctests" || echo "gl_WITH_TESTS"
4861 echo "gl_LIB([$libname])"
4862 if test -n "$lgpl"; then
4863 if test "$lgpl" = yes; then
4866 echo "gl_LGPL([$lgpl])"
4869 echo "gl_MAKEFILE_NAME([$makefile_name])"
4870 if test "$libtool" = true; then
4873 echo "gl_MACRO_PREFIX([$macro_prefix])"
4874 echo "gl_PO_DOMAIN([$po_domain])"
4875 if test -n "$vc_files"; then
4876 echo "gl_VC_FILES([$vc_files])"
4879 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4880 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4884 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4885 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4886 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4888 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4892 echo "# gnulib-cache.m4 ends here"
4899 echo "Creating $m4base/gnulib-cache.m4"
4900 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4902 echo "Create $m4base/gnulib-cache.m4"
4908 # Create m4/gnulib-comp.m4.
4909 func_dest_tmpfilename $m4base/gnulib-comp.m4
4911 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4912 func_emit_copyright_notice
4914 echo "# This file represents the compiled summary of the specification in"
4915 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4916 echo "# to be invoked from configure.ac."
4917 echo "# In projects that use version control, this file can be treated like"
4918 echo "# other built files."
4921 echo "# This macro should be invoked from $configure_ac, in the section"
4922 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4923 echo "# any checks for libraries, header files, types and library functions."
4924 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4926 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4927 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4928 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4929 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4930 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4931 if test -n "$uses_subdirs"; then
4932 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4934 for module in $final_modules; do
4936 if test -n "$module"; then
4937 echo "# Code from module $module:"
4938 func_get_autoconf_early_snippet "$module"
4941 | sed -e '/^$/d;' -e 's/^/ /'
4944 echo "# This macro should be invoked from $configure_ac, in the section"
4945 echo "# \"Check for header files, types and library functions\"."
4946 echo "AC_DEFUN([${macro_prefix}_INIT],"
4948 if test "$libtool" = true; then
4949 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4950 echo " gl_cond_libtool=true"
4952 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4953 echo " gl_cond_libtool=false"
4955 echo " gl_ltlibdeps="
4957 if test "$auxdir" != "build-aux"; then
4958 sed_replace_build_aux='
4960 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4961 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4965 sed_replace_build_aux="$sed_noop"
4967 echo " gl_m4_base='$m4base'"
4968 func_emit_initmacro_start $macro_prefix
4969 echo " gl_source_base='$sourcebase'"
4970 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
4971 echo " # End of code from modules"
4972 func_emit_initmacro_end $macro_prefix
4973 echo " gltests_libdeps="
4974 echo " gltests_ltlibdeps="
4975 func_emit_initmacro_start ${macro_prefix}tests
4976 echo " gl_source_base='$testsbase'"
4977 # Define a tests witness macro that depends on the package.
4978 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4979 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4980 echo "changequote(,)dnl"
4981 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"
4982 echo "changequote([, ])dnl"
4983 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4984 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4985 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4986 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
4987 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4988 func_emit_initmacro_end ${macro_prefix}tests
4989 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4990 # created using libtool, because libtool already handles the dependencies.
4991 if test "$libtool" != true; then
4992 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
4993 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4994 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4995 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4996 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4998 if $use_libtests; then
4999 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5000 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5003 func_emit_initmacro_done $macro_prefix $sourcebase
5004 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5006 echo "# This macro records the list of files which have been installed by"
5007 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5008 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5009 echo "$files" | sed -e 's,^, ,'
5012 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5013 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
5017 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5018 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5019 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5021 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5025 echo "# gnulib-comp.m4 ends here"
5032 echo "Creating $m4base/gnulib-comp.m4"
5033 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5035 echo "Create $m4base/gnulib-comp.m4"
5041 if test -n "$inctests"; then
5042 # Create tests makefile.
5043 func_dest_tmpfilename $testsbase/$makefile_am
5044 destfile="$testsbase/$makefile_am"
5045 modules="$testsrelated_modules"
5046 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5047 if test -f "$destdir"/$testsbase/$makefile_am; then
5048 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
5052 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5053 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5054 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5056 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5062 echo "Creating $testsbase/$makefile_am"
5063 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5065 echo "Create $testsbase/$makefile_am"
5068 func_append added_files "$testsbase/$makefile_am$nl"
5072 if test "$vc_files" != false; then
5073 # Update the .cvsignore and .gitignore files.
5074 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5075 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5076 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5077 echo "$m4base/|A|gnulib-comp.m4"
5078 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5079 { # Rearrange file descriptors. Needed because "while ... done < ..."
5080 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5081 exec 5<&0 < "$tmp"/fileset-changes
5082 func_update_ignorelist ()
5085 if test "$ignore" = .gitignore; then
5086 # In a .gitignore file, "foo" applies to the current directory and all
5087 # subdirectories, whereas "/foo" applies to the current directory only.
5090 doubly_escaped_anchor='\\/'
5094 doubly_escaped_anchor=''
5096 if test -f "$destdir/$dir$ignore"; then
5097 if test -n "$dir_added" || test -n "$dir_removed"; then
5098 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5099 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5100 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5101 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5102 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
5104 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5106 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5107 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5108 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5109 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5110 } > "$tmp"/sed-ignore-removed
5111 { cat "$destdir/$dir$ignore"~
5112 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5113 } | sed -f "$tmp"/sed-ignore-removed \
5114 > "$destdir/$dir$ignore"
5116 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5121 if test -n "$dir_added"; then
5123 echo "Creating $destdir/$dir$ignore"
5125 if test "$ignore" = .cvsignore; then
5127 # Automake generates Makefile rules that create .dirstamp files.
5130 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5131 } > "$destdir/$dir$ignore"
5133 echo "Create $destdir/$dir$ignore"
5143 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5144 func_update_ignorelist .cvsignore
5146 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5147 func_update_ignorelist .gitignore
5154 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5155 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5156 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5157 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5158 if test "$next_dir" != "$last_dir"; then
5159 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5160 last_dir="$next_dir"
5165 A) func_append last_dir_added "$file$nl";;
5166 R) func_append last_dir_removed "$file$nl";;
5169 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5176 echo "You may need to add #include directives for the following .h files."
5177 # Intersect $specified_modules and $main_modules
5178 # (since $specified_modules is not necessarily of subset of $main_modules
5179 # - some may have been skipped through --avoid, and since the elements of
5180 # $main_modules but not in $specified_modules can go away without explicit
5181 # notice - through changes in the module dependencies).
5182 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5183 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5184 # First the #include <...> directives without #ifs, sorted for convenience,
5185 # then the #include "..." directives without #ifs, sorted for convenience,
5186 # then the #include directives that are surrounded by #ifs. Not sorted.
5187 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5188 include_directive=`func_get_include_directive "$module"`
5189 case "$nl$include_directive" in
5191 echo "$include_directive" 1>&5
5194 echo "$include_directive" | grep -v 'include "' 1>&6
5195 echo "$include_directive" | grep 'include "' 1>&7
5198 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5200 LC_ALL=C sort -u "$tmp"/include-angles
5201 LC_ALL=C sort -u "$tmp"/include-quotes
5202 cat "$tmp"/include-if
5203 ) | sed -e '/^$/d' -e 's/^/ /'
5204 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5206 for module in $main_modules; do
5207 func_get_link_directive "$module"
5209 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5210 if test `wc -l < "$tmp"/link` != 0; then
5212 echo "You may need to use the following Makefile variables when linking."
5213 echo "Use them in <program>_LDADD when linking a program, or"
5214 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5220 echo "Don't forget to"
5221 if test "$makefile_am" = Makefile.am; then
5222 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5224 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5226 if test -n "$pobase"; then
5227 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5229 if test -n "$inctests"; then
5230 if test "$makefile_am" = Makefile.am; then
5231 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5233 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5237 while test $edit != $makefile_am_edits; do
5238 edit=`expr $edit + 1`
5239 eval dir=\"\$makefile_am_edit${edit}_dir\"
5240 eval var=\"\$makefile_am_edit${edit}_var\"
5241 eval val=\"\$makefile_am_edit${edit}_val\"
5242 if test -n "$var"; then
5243 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5246 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
5247 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5250 # func_create_testdir testdir modules
5252 # - local_gnulib_dir from --local-dir
5253 # - modcache true or false, from --cache-modules/--no-cache-modules
5254 # - auxdir directory relative to destdir where to place build aux files
5255 # - inctests true if tests should be included, blank otherwise
5256 # - incobsolete true if obsolete modules among dependencies should be
5257 # included, blank otherwise
5258 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5260 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5262 # - excl_privileged_tests true if tests that require root privileges should be
5263 # excluded, blank otherwise
5264 # - excl_unportable_tests true if tests that fail on some platforms should be
5265 # excluded, blank otherwise
5266 # - avoidlist list of modules to avoid
5267 # - cond_dependencies true if conditional dependencies shall be supported,
5269 # - libtool true if --libtool was given, false if --no-libtool was
5270 # given, blank otherwise
5271 # - symbolic true if files should be symlinked, copied otherwise
5272 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5274 func_create_testdir ()
5278 if test -z "$modules"; then
5279 # All modules together.
5280 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5281 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5282 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5283 modules=`func_all_modules`
5284 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5286 specified_modules="$modules"
5288 # Canonicalize the list of specified modules.
5289 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5291 # Unlike in func_import, here we want to include all kinds of tests for the
5292 # directly specified modules, but not for dependencies.
5293 inc_all_direct_tests=true
5294 inc_all_indirect_tests="$inc_all_tests"
5296 # Check that the license of every module is consistent with the license of
5298 saved_inctests="$inctests"
5299 # When computing transitive closures, don't consider $module to depend on
5300 # $module-tests. Need this becauses tests are implicitly GPL and may depend
5301 # on GPL modules - therefore we don't want a warning in this case.
5303 for requested_module in $specified_modules; do
5304 requested_license=`func_get_license "$requested_module"`
5305 if test "$requested_license" != GPL; then
5306 # Here we use func_modules_transitive_closure, not just
5307 # func_get_dependencies, so that we also detect weird situations like
5308 # an LGPL module which depends on a GPLed build tool module which depends
5310 modules="$requested_module"
5311 func_modules_transitive_closure
5312 for module in $modules; do
5313 license=`func_get_license "$module"`
5315 'GPLed build tool') ;;
5316 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5318 case "$requested_license" in
5321 GPLv2+ | LGPLv2+) ;;
5322 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5328 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5334 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5343 inctests="$saved_inctests"
5345 # Subdirectory names.
5355 # Determine final module list.
5356 modules="$specified_modules"
5357 func_modules_transitive_closure
5358 if test $verbose -ge 0; then
5359 func_show_module_list
5362 # Add the dummy module if needed.
5363 func_modules_add_dummy
5365 # Show banner notice of every module.
5368 # Determine final file list.
5369 func_modules_to_filelist
5370 if test $verbose -ge 0; then
5372 echo "$files" | sed -e 's/^/ /'
5374 # Add files for which the copy in gnulib is newer than the one that
5375 # "automake --add-missing --copy" would provide.
5376 files="$files build-aux/config.guess"
5377 files="$files build-aux/config.sub"
5378 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5380 rewritten='%REWRITTEN%'
5381 sed_rewrite_files="\
5382 s,^build-aux/,$rewritten$auxdir/,
5383 s,^doc/,$rewritten$docbase/,
5384 s,^lib/,$rewritten$sourcebase/,
5385 s,^m4/,$rewritten$m4base/,
5386 s,^tests/,$rewritten$testsbase/,
5390 # Create directories.
5391 for f in $files; do echo $f; done \
5392 | sed -e "$sed_rewrite_files" \
5393 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5394 | LC_ALL=C sort -u \
5396 { # Rearrange file descriptors. Needed because "while ... done < ..."
5397 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5398 exec 5<&0 < "$tmp"/dirs
5400 mkdir -p "$testdir/$d"
5405 # Copy files or make symbolic links.
5407 for f in $files; do echo $f; done \
5408 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5411 { # Rearrange file descriptors. Needed because "while ... done < ..."
5412 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5413 exec 5<&0 < "$tmp"/files
5415 func_lookup_file "$f"
5416 if test -n "$lookedup_tmp"; then
5417 cp -p "$lookedup_file" "$testdir/$g"
5419 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5420 if { test -n "$symbolic" \
5421 || { test -n "$lsymbolic" \
5422 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5423 func_ln "$lookedup_file" "$testdir/$g"
5425 cp -p "$lookedup_file" "$testdir/$g"
5432 # Create Makefile.ams that are for testing.
5435 # No special edits are needed.
5438 # Create $sourcebase/Makefile.am.
5439 mkdir -p "$testdir/$sourcebase"
5440 destfile="$sourcebase/Makefile.am"
5441 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5442 any_uses_subdirs="$uses_subdirs"
5444 # Create $m4base/Makefile.am.
5445 mkdir -p "$testdir/$m4base"
5446 (echo "## Process this file with automake to produce Makefile.in."
5452 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5455 ) > "$testdir/$m4base/Makefile.am"
5457 subdirs="$sourcebase $m4base"
5458 subdirs_with_configure_ac=""
5460 if false && test -f "$testdir"/$m4base/gettext.m4; then
5461 # Avoid stupid error message from automake:
5462 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5463 mkdir -p "$testdir/po"
5464 (echo "## Process this file with automake to produce Makefile.in."
5465 ) > "$testdir/po/Makefile.am"
5466 func_append subdirs " po"
5469 if test -n "$inctests"; then
5470 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5471 # Viewed from the $testsbase subdirectory, $auxdir is different.
5472 saved_auxdir="$auxdir"
5473 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5474 # Create $testsbase/Makefile.am.
5476 destfile="$testsbase/Makefile.am"
5477 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5478 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5479 # Create $testsbase/configure.ac.
5480 (echo "# Process this file with autoconf to produce a configure script."
5481 echo "AC_INIT([dummy], [0])"
5482 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5483 echo "AM_INIT_AUTOMAKE"
5485 echo "AC_CONFIG_HEADERS([config.h])"
5488 echo "AC_PROG_INSTALL"
5489 echo "AC_PROG_MAKE_SET"
5490 echo "AC_PROG_RANLIB"
5492 if test -n "$uses_subdirs"; then
5493 echo "AM_PROG_CC_C_O"
5496 for module in $modules; do
5498 if test -n "$module"; then
5500 gnumakefile | maintainer-makefile)
5501 # These modules are meant to be used only in the top-level directory.
5504 func_get_autoconf_early_snippet "$module"
5509 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5510 if test "$libtool" = true; then
5511 echo "LT_INIT([win32-dll])"
5512 echo "LT_LANG([C++])"
5513 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5514 echo "gl_cond_libtool=true"
5516 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5517 echo "gl_cond_libtool=false"
5519 echo "gl_ltlibdeps="
5521 # Wrap the set of autoconf snippets into an autoconf macro that is then
5522 # invoked. This is needed because autoconf does not support AC_REQUIRE
5524 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5525 # but we want the AC_REQUIRE to have its normal meaning (provide one
5526 # expansion of the required macro before the current point, and only one
5528 echo "AC_DEFUN([gl_INIT], ["
5529 sed_replace_build_aux='
5531 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5532 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5535 echo "gl_m4_base='../$m4base'"
5536 func_emit_initmacro_start $macro_prefix
5537 # We don't have explicit ordering constraints between the various
5538 # autoconf snippets. It's cleanest to put those of the library before
5539 # those of the tests.
5540 echo "gl_source_base='../$sourcebase'"
5541 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5542 echo "gl_source_base='.'"
5543 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5544 func_emit_initmacro_end $macro_prefix
5545 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5546 # created using libtool, because libtool already handles the dependencies.
5547 if test "$libtool" != true; then
5548 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5549 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5550 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5551 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5552 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5555 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5559 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5560 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5561 echo "AH_TOP([#include \"../config.h\"])"
5563 echo "AC_CONFIG_FILES([Makefile])"
5565 ) > "$testdir/$testsbase/configure.ac"
5566 auxdir="$saved_auxdir"
5567 func_append subdirs " $testsbase"
5568 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5571 # Create Makefile.am.
5572 (echo "## Process this file with automake to produce Makefile.in."
5574 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5576 echo "SUBDIRS = $subdirs"
5578 echo "ACLOCAL_AMFLAGS = -I $m4base"
5579 ) > "$testdir/Makefile.am"
5581 # Create configure.ac.
5582 (echo "# Process this file with autoconf to produce a configure script."
5583 echo "AC_INIT([dummy], [0])"
5584 if test "$auxdir" != "."; then
5585 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5587 echo "AM_INIT_AUTOMAKE"
5589 echo "AC_CONFIG_HEADERS([config.h])"
5592 echo "AC_PROG_INSTALL"
5593 echo "AC_PROG_MAKE_SET"
5595 echo "# For autobuild."
5596 echo "AC_CANONICAL_BUILD"
5597 echo "AC_CANONICAL_HOST"
5599 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5600 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5601 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5602 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5604 echo "AC_PROG_RANLIB"
5606 if test -n "$any_uses_subdirs"; then
5607 echo "AM_PROG_CC_C_O"
5610 for module in $modules; do
5611 func_verify_nontests_module
5612 if test -n "$module"; then
5613 func_get_autoconf_early_snippet "$module"
5616 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5617 if test "$libtool" = true; then
5618 echo "LT_INIT([win32-dll])"
5619 echo "LT_LANG([C++])"
5620 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5621 echo "gl_cond_libtool=true"
5623 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5624 echo "gl_cond_libtool=false"
5626 echo "gl_ltlibdeps="
5628 # Wrap the set of autoconf snippets into an autoconf macro that is then
5629 # invoked. This is needed because autoconf does not support AC_REQUIRE
5631 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5632 # but we want the AC_REQUIRE to have its normal meaning (provide one
5633 # expansion of the required macro before the current point, and only one
5635 echo "AC_DEFUN([gl_INIT], ["
5636 if test "$auxdir" != "build-aux"; then
5637 sed_replace_build_aux='
5639 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5640 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5644 sed_replace_build_aux="$sed_noop"
5646 echo "gl_m4_base='$m4base'"
5647 func_emit_initmacro_start $macro_prefix
5648 echo "gl_source_base='$sourcebase'"
5649 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5650 func_emit_initmacro_end $macro_prefix
5651 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5652 # created using libtool, because libtool already handles the dependencies.
5653 if test "$libtool" != true; then
5654 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5655 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5656 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5657 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5658 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5661 func_emit_initmacro_done $macro_prefix $sourcebase
5665 if test -n "$subdirs_with_configure_ac"; then
5666 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5668 makefiles="Makefile"
5669 for d in $subdirs; do
5670 # For subdirs that have a configure.ac by their own, it's the subdir's
5671 # configure.ac which creates the subdir's Makefile.am, not this one.
5672 case " $subdirs_with_configure_ac " in
5674 *) func_append makefiles " $d/Makefile" ;;
5677 echo "AC_CONFIG_FILES([$makefiles])"
5679 ) > "$testdir/configure.ac"
5681 # Create autogenerated files.
5683 # Do not use "${AUTORECONF} --force --install", because it may invoke
5684 # autopoint, which brings in older versions of some of our .m4 files.
5685 if test -f $m4base/gettext.m4; then
5686 func_execute_command ${AUTOPOINT} --force || func_exit 1
5687 for f in $m4base/*.m4~; do
5689 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5693 if test "$libtool" = true; then
5694 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5696 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5697 if ! test -d build-aux; then
5698 func_execute_command mkdir build-aux || func_exit 1
5700 func_execute_command ${AUTOCONF} || func_exit 1
5701 func_execute_command ${AUTOHEADER} || func_exit 1
5702 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5704 if test -n "$inctests"; then
5705 # Create autogenerated files.
5706 (cd "$testdir/$testsbase" || func_exit 1
5707 # Do not use "${AUTORECONF} --force --install", because it may invoke
5708 # autopoint, which brings in older versions of some of our .m4 files.
5709 if test -f ../$m4base/gettext.m4; then
5710 func_execute_command ${AUTOPOINT} --force || func_exit 1
5711 for f in ../$m4base/*.m4~; do
5713 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5717 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5718 if ! test -d ../build-aux; then
5719 func_execute_command mkdir ../build-aux
5721 func_execute_command ${AUTOCONF} || func_exit 1
5722 func_execute_command ${AUTOHEADER} || func_exit 1
5723 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5726 # Need to run configure and make once, to create built files that are to be
5727 # distributed (such as parse-datetime.c).
5728 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5729 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5730 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5731 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5732 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5733 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5734 # such $(FOO_H) because they don't refer to distributed files.
5735 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5736 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5737 | sed -e "$sed_remove_make_variables"`
5738 distributed_built_sources=`for file in $built_sources; do
5739 case "$cleaned_files" in
5744 tests_distributed_built_sources=
5745 if test -n "$inctests"; then
5746 # Likewise for built files in the $testsbase directory.
5747 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5748 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5749 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5750 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5751 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5752 | sed -e "$sed_remove_make_variables"`
5753 tests_distributed_built_sources=`for file in $tests_built_sources; do
5754 case "$tests_cleaned_files" in
5760 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5762 ./configure || func_exit 1
5763 if test -n "$distributed_built_sources"; then
5765 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5766 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5771 if test -n "$tests_distributed_built_sources"; then
5773 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5774 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5779 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5786 # func_create_megatestdir megatestdir allmodules
5788 # - local_gnulib_dir from --local-dir
5789 # - modcache true or false, from --cache-modules/--no-cache-modules
5790 # - auxdir directory relative to destdir where to place build aux files
5791 func_create_megatestdir ()
5795 if test -z "$allmodules"; then
5796 allmodules=`func_all_modules`
5800 # First, all modules one by one.
5801 for onemodule in $allmodules; do
5802 func_create_testdir "$megatestdir/$onemodule" $onemodule
5803 func_append megasubdirs "$onemodule "
5805 # Then, all modules all together.
5806 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5807 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5808 func_create_testdir "$megatestdir/ALL" "$allmodules"
5809 func_append megasubdirs "ALL"
5812 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5813 vc_witness="$gnulib_dir/CVS/Entries"; \
5815 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5817 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5818 | sed -e 's,January,01,' -e 's,Jan,01,' \
5819 -e 's,February,02,' -e 's,Feb,02,' \
5820 -e 's,March,03,' -e 's,Mar,03,' \
5821 -e 's,April,04,' -e 's,Apr,04,' \
5823 -e 's,June,06,' -e 's,Jun,06,' \
5824 -e 's,July,07,' -e 's,Jul,07,' \
5825 -e 's,August,08,' -e 's,Aug,08,' \
5826 -e 's,September,09,' -e 's,Sep,09,' \
5827 -e 's,October,10,' -e 's,Oct,10,' \
5828 -e 's,November,11,' -e 's,Nov,11,' \
5829 -e 's,December,12,' -e 's,Dec,12,' \
5830 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5831 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5833 echo "CVSDATE=$cvsdate"
5834 echo ": \${MAKE=make}"
5835 echo "test -d logs || mkdir logs"
5836 echo "for module in $megasubdirs; do"
5837 echo " echo \"Working on module \$module...\""
5838 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5839 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5842 echo " : autobuild project... \$module"
5843 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5844 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5845 echo " : autobuild hostname... \`hostname\`"
5846 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5848 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5850 ) > "$megatestdir/do-autobuild"
5851 chmod a+x "$megatestdir/do-autobuild"
5853 # Create Makefile.am.
5854 (echo "## Process this file with automake to produce Makefile.in."
5856 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5858 echo "SUBDIRS = $megasubdirs"
5860 echo "EXTRA_DIST = do-autobuild"
5861 ) > "$megatestdir/Makefile.am"
5863 # Create configure.ac.
5864 (echo "# Process this file with autoconf to produce a configure script."
5865 echo "AC_INIT([dummy], [0])"
5866 if test "$auxdir" != "."; then
5867 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5869 echo "AM_INIT_AUTOMAKE"
5871 echo "AC_PROG_MAKE_SET"
5873 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5874 echo "AC_CONFIG_FILES([Makefile])"
5876 ) > "$megatestdir/configure.ac"
5878 # Create autogenerated files.
5880 # Do not use "${AUTORECONF} --install", because autoreconf operates
5881 # recursively, but the subdirectories are already finished, therefore
5882 # calling autoreconf here would only waste lots of CPU time.
5883 func_execute_command ${ACLOCAL} || func_exit 1
5884 func_execute_command mkdir build-aux
5885 func_execute_command ${AUTOCONF} || func_exit 1
5886 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5892 func_fatal_error "no mode specified" ;;
5899 # sed expression that converts a literal to a basic regular expression.
5900 # Needs to handle . [ \ * ^ $.
5901 sed_literal_to_basic_regex='s/\\/\\\\/g
5907 if test -f "$gnulib_dir/$filename" \
5908 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5909 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5910 filename_line_regex='^'"$filename_anywhere_regex"'$'
5913 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5914 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5915 (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$,,')
5918 | func_sanitize_modulelist \
5921 for module in $module_candidates; do
5922 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5927 func_warning "file $filename does not exist"
5932 import | add-import | remove-import | update )
5935 if test -z "$destdir"; then
5938 test -d "$destdir" \
5939 || func_fatal_error "destination directory does not exist: $destdir"
5941 # Prefer configure.ac to configure.in.
5942 if test -f "$destdir"/configure.ac; then
5943 configure_ac="$destdir/configure.ac"
5945 if test -f "$destdir"/configure.in; then
5946 configure_ac="$destdir/configure.in"
5948 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5952 # Analyze configure.ac.
5954 guessed_libtool=false
5959 /AC_CONFIG_AUX_DIR/ {
5960 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5962 /A[CM]_PROG_LIBTOOL/ {
5963 s,^.*$,guessed_libtool=true,p
5965 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5967 if test -z "$auxdir"; then
5968 auxdir="$guessed_auxdir"
5971 # Determine where to apply func_import.
5972 if test "$mode" = import; then
5973 # Apply func_import to a particular gnulib directory.
5974 # The command line contains the complete specification; don't look at
5975 # the contents of gnulib-cache.m4.
5976 test -n "$supplied_libname" || supplied_libname=true
5977 test -n "$sourcebase" || sourcebase="lib"
5978 test -n "$m4base" || m4base="m4"
5979 test -n "$docbase" || docbase="doc"
5980 test -n "$testsbase" || testsbase="tests"
5981 test -n "$macro_prefix" || macro_prefix="gl"
5984 if test -n "$m4base"; then
5985 # Apply func_import to a particular gnulib directory.
5986 # Any number of additional modules can be given.
5987 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5988 # First use of gnulib in the given m4base.
5989 test -n "$supplied_libname" || supplied_libname=true
5990 test -n "$sourcebase" || sourcebase="lib"
5991 test -n "$docbase" || docbase="doc"
5992 test -n "$testsbase" || testsbase="tests"
5993 test -n "$macro_prefix" || macro_prefix="gl"
5997 # Apply func_import to all gnulib directories.
5998 # To get this list of directories, look at Makefile.am. (Not at
5999 # configure, because it may be omitted from version control. Also,
6000 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6004 if test -f "$destdir"/Makefile.am; then
6005 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6007 for arg in $aclocal_amflags; do
6008 if test -n "$m4dir_is_next"; then
6009 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6013 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6014 func_append m4dirs " $arg"
6015 m4dirs_count=`expr $m4dirs_count + 1`
6021 if test "X$arg" = "X-I"; then
6029 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6030 if test -f "$destdir"/aclocal.m4; then
6031 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6032 sedexpr2='s,^[^/]*$,.,'
6033 sedexpr3='s,/[^/]*$,,'
6034 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6035 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6036 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6039 if test $m4dirs_count = 0; then
6040 # First use of gnulib in a package.
6041 # Any number of additional modules can be given.
6042 test -n "$supplied_libname" || supplied_libname=true
6043 test -n "$sourcebase" || sourcebase="lib"
6045 test -n "$docbase" || docbase="doc"
6046 test -n "$testsbase" || testsbase="tests"
6047 test -n "$macro_prefix" || macro_prefix="gl"
6050 if test $m4dirs_count = 1; then
6051 # There's only one use of gnulib here. Assume the user means it.
6052 # Any number of additional modules can be given.
6053 for m4base in $m4dirs; do
6057 # Ambiguous - guess what the user meant.
6058 if test $# = 0; then
6059 # No further arguments. Guess the user wants to update all of them.
6060 for m4base in $m4dirs; do
6061 # Perform func_import in a subshell, so that variable values
6063 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6064 # inc_longrunning_tests, inc_privileged_tests,
6065 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6066 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6067 # makefile_name, libtool, macro_prefix, po_domain, vc_files
6068 # don't propagate from one directory to another.
6069 (func_import) || func_exit 1
6073 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6082 if test -z "$destdir"; then
6083 func_fatal_error "please specify --dir option"
6086 test -d "$destdir" \
6087 || func_fatal_error "could not create destination directory"
6088 test -n "$auxdir" || auxdir="build-aux"
6089 func_create_testdir "$destdir" "$*"
6092 create-megatestdir )
6093 if test -z "$destdir"; then
6094 func_fatal_error "please specify --dir option"
6096 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6097 test -n "$auxdir" || auxdir="build-aux"
6098 func_create_megatestdir "$destdir" "$*"
6102 test -n "$destdir" || destdir=testdir$$
6103 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6104 test -n "$auxdir" || auxdir="build-aux"
6105 func_create_testdir "$destdir" "$*"
6109 ../configure || func_exit 1
6110 $MAKE || func_exit 1
6111 $MAKE check || func_exit 1
6112 $MAKE distclean || func_exit 1
6113 remaining=`find . -type f -print`
6114 if test -n "$remaining"; then
6115 echo "Remaining files:" $remaining 1>&2
6116 echo "gnulib-tool: *** Stop." 1>&2
6125 test -n "$destdir" || destdir=testdir$$
6126 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6127 test -n "$auxdir" || auxdir="build-aux"
6128 func_create_megatestdir "$destdir" "$*"
6136 remaining=`find . -type f -print`
6137 if test -n "$remaining"; then
6138 echo "Remaining files:" $remaining 1>&2
6139 echo "gnulib-tool: *** Stop." 1>&2
6147 extract-description )
6151 if test -n "$module"; then
6152 func_get_description "$module"
6161 if test -n "$module"; then
6162 func_get_comment "$module"
6171 if test -n "$module"; then
6172 func_get_status "$module"
6181 if test -n "$module"; then
6182 func_get_notice "$module"
6187 extract-applicability )
6191 if test -n "$module"; then
6192 func_get_applicability "$module"
6201 if test -n "$module"; then
6202 func_get_filelist "$module"
6207 extract-dependencies )
6211 if test -n "$module"; then
6212 func_get_dependencies "$module"
6217 extract-autoconf-snippet )
6221 if test -n "$module"; then
6222 func_get_autoconf_snippet "$module"
6227 extract-automake-snippet )
6231 if test -n "$module"; then
6232 func_get_automake_snippet "$module"
6237 extract-include-directive )
6241 if test -n "$module"; then
6242 func_get_include_directive "$module"
6247 extract-link-directive )
6251 if test -n "$module"; then
6252 func_get_link_directive "$module"
6261 if test -n "$module"; then
6262 func_get_license "$module"
6267 extract-maintainer )
6271 if test -n "$module"; then
6272 func_get_maintainer "$module"
6277 extract-tests-module )
6281 if test -n "$module"; then
6282 func_get_tests_module "$module"
6288 # Verify the number of arguments.
6289 if test $# -lt 1 || test $# -gt 2; then
6290 func_fatal_error "invalid number of arguments for --$mode"
6293 # The first argument is the file to be copied.
6295 # Verify the file exists.
6296 func_lookup_file "$f"
6298 # The second argument is the destination; either a directory ot a file.
6299 # It defaults to the current directory.
6301 test -n "$dest" || dest='.'
6302 test -n "$sourcebase" || sourcebase="lib"
6303 test -n "$m4base" || m4base="m4"
6304 test -n "$docbase" || docbase="doc"
6305 test -n "$testsbase" || testsbase="tests"
6306 test -n "$auxdir" || auxdir="build-aux"
6307 rewritten='%REWRITTEN%'
6308 sed_rewrite_files="\
6309 s,^build-aux/,$rewritten$auxdir/,
6310 s,^doc/,$rewritten$docbase/,
6311 s,^lib/,$rewritten$sourcebase/,
6312 s,^m4/,$rewritten$m4base/,
6313 s,^tests/,$rewritten$testsbase/,
6316 if test -d "$dest"; then
6318 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6320 destdir=`dirname "$dest"`
6321 g=`basename "$dest"`
6324 # Create the directory for destfile.
6325 d=`dirname "$destdir/$g"`
6327 if test -n "$d" && test ! -d "$d"; then
6328 mkdir -p "$d" || func_fatal_error "failed"
6332 func_dest_tmpfilename "$g"
6333 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6334 already_present=true
6335 if test -f "$destdir/$g"; then
6336 # The file already exists.
6340 # Don't protest if the file should be there but isn't: it happens
6341 # frequently that developers don't put autogenerated files under version
6349 func_fatal_error "unknown operation mode --$mode" ;;
6353 # Undo the effect of the previous 'trap' command. Some shellology:
6354 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6355 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6356 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6357 # 128 + signal number and is set before the trap-registered command is run.
6359 trap 'func_exit $?' 1 2 3 13 15
6364 # indent-tabs-mode: nil
6365 # whitespace-check-buffer-indent: nil