3 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # (The GNU autoconf doc says that sed comments are not portable, but does
113 # not say which 'sed' versions are affected.)
114 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
131 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
132 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
133 gnulib-tool --test --dir=directory module1 ... moduleN
134 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
135 gnulib-tool --extract-description module
136 gnulib-tool --extract-comment module
137 gnulib-tool --extract-status module
138 gnulib-tool --extract-notice module
139 gnulib-tool --extract-applicability module
140 gnulib-tool --extract-filelist module
141 gnulib-tool --extract-dependencies module
142 gnulib-tool --extract-autoconf-snippet module
143 gnulib-tool --extract-automake-snippet module
144 gnulib-tool --extract-include-directive module
145 gnulib-tool --extract-link-directive module
146 gnulib-tool --extract-license module
147 gnulib-tool --extract-maintainer module
148 gnulib-tool --extract-tests-module module
149 gnulib-tool --copy-file file [destination]
152 --list print the available module names
153 --find find the modules which contain the specified file
154 --import import the given modules into the current package;
155 if no modules are specified, update the current
156 package from the current gnulib
157 --update update the current package, restore files omitted
159 --create-testdir create a scratch package with the given modules
160 --create-megatestdir create a mega scratch package with the given modules
161 one by one and all together
162 --test test the combination of the given modules
163 (recommended to use CC=\"gcc -Wall\" here)
164 --megatest test the given modules one by one and all together
165 (recommended to use CC=\"gcc -Wall\" here)
166 --extract-description extract the description
167 --extract-comment extract the comment
168 --extract-status extract the status (obsolete etc.)
169 --extract-notice extract the notice or banner
170 --extract-applicability extract the applicability
171 --extract-filelist extract the list of files
172 --extract-dependencies extract the dependencies
173 --extract-autoconf-snippet extract the snippet for configure.ac
174 --extract-automake-snippet extract the snippet for library makefile
175 --extract-include-directive extract the #include directive
176 --extract-link-directive extract the linker directive
177 --extract-license report the license terms of the source files
179 --extract-maintainer report the maintainer(s) inside gnulib
180 --extract-tests-module report the unit test module, if it exists
181 --copy-file copy a file that is not part of any module
184 --dir=DIRECTORY Specify the target directory.
185 For --import, this specifies where your
186 configure.ac can be found. Defaults to current
188 --local-dir=DIRECTORY Specify a local override directory where to look
189 up files before looking in gnulib's directory.
190 --cache-modules Enable module caching optimization.
191 --no-cache-modules Disable module caching optimization.
192 --verbose Increase verbosity. May be repeated.
193 --quiet Decrease verbosity. May be repeated.
195 Options for --import, --update:
196 --dry-run Only print what would have been done.
198 Options for --import, --create-[mega]testdir, --[mega]test:
199 --with-tests Include unit tests for the included modules.
200 --with-obsolete Include obsolete modules when they occur among the
201 dependencies. By default, dependencies to obsolete
203 --avoid=MODULE Avoid including the given MODULE. Useful if you
204 have code that provides equivalent functionality.
205 This option can be repeated.
206 --libtool Use libtool rules.
207 --no-libtool Don't use libtool rules.
209 Options for --import:
210 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
211 --source-base=DIRECTORY
212 Directory relative to --dir where source code is
213 placed (default \"lib\").
214 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
215 placed (default \"m4\").
216 --po-base=DIRECTORY Directory relative to --dir where *.po files are
217 placed (default \"po\").
218 --doc-base=DIRECTORY Directory relative to --dir where doc files are
219 placed (default \"doc\").
220 --tests-base=DIRECTORY
221 Directory relative to --dir where unit tests are
222 placed (default \"tests\").
223 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
224 tools are placed (default \"build-aux\").
225 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
226 Also modify license template from GPL to LGPL.
227 The version number of the LGPL can be specified;
228 the default is currently LGPLv3.
229 --makefile-name=NAME Name of makefile in automake syntax in the
230 source-base and tests-base directories
231 (default \"Makefile.am\").
232 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
233 'gl_INIT'. Default is 'gl'.
234 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
235 the package name. A suffix '-gnulib' is appended.
236 --with-c++-tests Include even unit tests for C++ interoperability.
237 --with-longrunning-tests
238 Include even unit tests that are long-runners.
239 --with-privileged-tests
240 Include even unit tests that require root
242 --with-unportable-tests
243 Include even unit tests that fail on some platforms.
244 --with-all-tests Include all kinds of problematic unit tests.
245 --vc-files Update version control related files.
246 --no-vc-files Don't update version control related files
247 (.gitignore and/or .cvsignore).
248 --no-changelog Don't update or create ChangeLog files.
250 Options for --import, --update, --create-[mega]testdir, --[mega]test:
251 -s, --symbolic, --symlink Make symbolic links instead of copying files.
252 --local-symlink Make symbolic links instead of copying files, only
253 for files from the local override directory.
255 Options for --import, --update:
256 -S, --more-symlinks Make symbolic links instead of copying files, and
257 don't replace copyright notices.
259 Report bugs to <bug-gnulib@gnu.org>."
263 # outputs to stdout the --version message.
267 if test -d "$gnulib_dir"/.git \
268 && (git --version) >/dev/null 2>/dev/null \
269 && (date --version) >/dev/null 2>/dev/null; then
270 # gnulib checked out from git.
271 sed_extract_first_date='/^Date/{
275 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
276 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
277 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
278 date=`echo "$date" | sed -e "$sed_year_before_time"`
279 # Use GNU date to compute the time in GMT.
280 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
281 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
283 if test -d "$gnulib_dir"/CVS \
284 && (cvs --version) >/dev/null 2>/dev/null; then
285 # gnulib checked out from CVS.
286 sed_extract_first_date='/^date: /{
287 s/^date: \([0-9][0-9][0-9][0-9]\).\([0-9][0-9]\).\([0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1-\2-\3 \4/p
290 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
292 # gnulib copy without versioning information.
293 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
297 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
299 gnulib-tool (GNU $package $date)$version
300 Copyright (C) $year Free Software Foundation, Inc.
301 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
302 This is free software: you are free to change and redistribute it.
303 There is NO WARRANTY, to the extent permitted by law.
305 Written by" "Bruno Haible" "and" "Simon Josefsson"
308 # func_emit_copyright_notice
309 # outputs to stdout a header for a generated file.
310 func_emit_copyright_notice ()
312 sed -n -e '/Copyright/ {
315 }' < "$self_abspathname"
317 echo "# This file is free software, distributed under the terms of the GNU"
318 echo "# General Public License. As a special exception to the GNU General"
319 echo "# Public License, this file may be distributed as part of a program"
320 echo "# that contains a configuration script generated by Autoconf, under"
321 echo "# the same distribution terms as the rest of that program."
323 echo "# Generated by gnulib-tool."
327 # exits with a given status.
328 # This function needs to be used, rather than 'exit', when a 'trap' handler is
329 # in effect that refers to $?.
336 # locates the directory where the gnulib repository lives
338 # - progname name of this program
340 # - self_abspathname absolute pathname of gnulib-tool
341 # - gnulib_dir absolute pathname of gnulib repository
345 /*) self_abspathname="$progname" ;;
346 */*) self_abspathname=`pwd`/"$progname" ;;
349 # Iterate through the elements of $PATH.
350 # We use IFS=: instead of
351 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
352 # because the latter does not work when some PATH element contains spaces.
353 # We use a canonicalized $pathx instead of $PATH, because empty PATH
354 # elements are by definition equivalent to '.', however field splitting
355 # according to IFS=: loses empty fields in many shells:
356 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
357 # beginning, at the end, and in the middle),
358 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
359 # at the beginning and at the end,
360 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
361 # Solaris lose empty fields at the end.
362 # The 'case' statement is an optimization, to avoid evaluating the
363 # explicit canonicalization command when $PATH contains no empty fields.
365 if test "${PATH_SEPARATOR+set}" != set; then
367 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
368 chmod +x "$tmp"/conf.sh
369 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
376 if test "$PATH_SEPARATOR" = ";"; then
377 # On Windows, programs are searched in "." before $PATH.
380 # On Unix, we have to convert empty PATH elements to ".".
384 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
389 IFS="$PATH_SEPARATOR"
393 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
394 self_abspathname="$d/$progname"
399 if test -z "$self_abspathname"; then
400 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
404 while test -h "$self_abspathname"; do
405 # Resolve symbolic link.
406 linkval=`func_readlink "$self_abspathname"`
407 test -n "$linkval" || break
409 /* ) self_abspathname="$linkval" ;;
410 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
413 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
417 # creates a temporary directory.
419 # - progname name of this program
421 # - tmp pathname of freshly created temporary directory
424 # Use the environment variable TMPDIR, falling back to /tmp. This allows
425 # users to specify a different temporary directory, for example, if their
426 # /tmp is filled up or too small.
429 # Use the mktemp program if available. If not available, hide the error
431 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
432 test -n "$tmp" && test -d "$tmp"
435 # Use a simple mkdir command. It is guaranteed to fail if the directory
436 # already exists. $RANDOM is bash specific and expands to empty in shells
437 # other than bash, ksh and zsh. Its use does not increase security;
438 # rather, it minimizes the probability of failure in a very cluttered /tmp
440 tmp=$TMPDIR/gl$$-$RANDOM
441 (umask 077 && mkdir "$tmp")
444 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
449 # func_append var value
450 # appends the given value to the shell variable var.
451 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
452 # Use bash's += operator. It reduces complexity of appending repeatedly to
453 # a single variable from O(n^2) to O(n).
458 fast_func_append=true
462 eval "$1=\"\$$1\$2\""
464 fast_func_append=false
467 # func_remove_prefix var prefix
468 # removes the given prefix from the value of the shell variable var.
469 # var should be the name of a shell variable.
470 # Its value should not contain a newline and not start or end with whitespace.
471 # prefix should not contain the characters "$`\{}[]^|.
472 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
473 func_remove_prefix ()
477 fast_func_remove_prefix=true
479 func_remove_prefix ()
481 eval "value=\"\$$1\""
485 sed_escape_dots='s/\([.]\)/\\\1/g'
486 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
489 value=`echo "$value" | sed -e "s|^${prefix}||"`
490 eval "$1=\"\$value\""
492 fast_func_remove_prefix=false
495 # func_remove_suffix var suffix
496 # removes the given suffix from the value of the shell variable var.
497 # var should be the name of a shell variable.
498 # Its value should not contain a newline and not start or end with whitespace.
499 # suffix should not contain the characters "$`\{}[]^|.
500 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
501 func_remove_suffix ()
505 fast_func_remove_suffix=true
507 func_remove_suffix ()
509 eval "value=\"\$$1\""
513 sed_escape_dots='s/\([.]\)/\\\1/g'
514 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
517 value=`echo "$value" | sed -e "s|${suffix}\$||"`
518 eval "$1=\"\$value\""
520 fast_func_remove_suffix=false
523 # func_fatal_error message
524 # outputs to stderr a fatal error message, and terminates the program.
526 # - progname name of this program
529 echo "$progname: *** $1" 1>&2
530 echo "$progname: *** Stop." 1>&2
534 # func_warning message
535 # Outputs to stderr a warning message,
538 echo "gnulib-tool: warning: $1" 1>&2
541 # func_readlink SYMLINK
542 # outputs the target of the given symlink.
543 if (type -p readlink) > /dev/null 2>&1; then
546 # Use the readlink program from GNU coreutils.
552 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
553 # would do the wrong thing if the link target contains " -> ".
554 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
558 # func_relativize DIR1 DIR2
559 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
561 # - DIR1 relative pathname, relative to the current directory
562 # - DIR2 relative pathname, relative to the current directory
564 # - reldir relative pathname of DIR2, relative to DIR1
570 sed_first='s,^\([^/]*\)/.*$,\1,'
571 sed_rest='s,^[^/]*/*,,'
572 sed_last='s,^.*/\([^/]*\)$,\1,'
573 sed_butlast='s,/*[^/]*$,,'
574 while test -n "$dir1"; do
575 first=`echo "$dir1" | sed -e "$sed_first"`
576 if test "$first" != "."; then
577 if test "$first" = ".."; then
578 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
579 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
581 first2=`echo "$dir2" | sed -e "$sed_first"`
582 if test "$first2" = "$first"; then
583 dir2=`echo "$dir2" | sed -e "$sed_rest"`
587 dir0="$dir0"/"$first"
590 dir1=`echo "$dir1" | sed -e "$sed_rest"`
595 # func_relconcat DIR1 DIR2
596 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
598 # - DIR1 relative pathname, relative to the current directory
599 # - DIR2 relative pathname, relative to DIR1
601 # - relconcat DIR1/DIR2, relative to the current directory
606 sed_first='s,^\([^/]*\)/.*$,\1,'
607 sed_rest='s,^[^/]*/*,,'
608 sed_last='s,^.*/\([^/]*\)$,\1,'
609 sed_butlast='s,/*[^/]*$,,'
611 first=`echo "$dir2" | sed -e "$sed_first"`
612 if test "$first" = "."; then
613 dir2=`echo "$dir2" | sed -e "$sed_rest"`
614 if test -z "$dir2"; then
619 last=`echo "$dir1" | sed -e "$sed_last"`
620 while test "$last" = "."; do
621 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
622 last=`echo "$dir1" | sed -e "$sed_last"`
624 if test -z "$dir1"; then
628 if test "$first" = ".."; then
629 if test "$last" = ".."; then
630 relconcat="$dir1/$dir2"
633 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
634 dir2=`echo "$dir2" | sed -e "$sed_rest"`
635 if test -z "$dir1"; then
639 if test -z "$dir2"; then
644 relconcat="$dir1/$dir2"
652 # Like ln -s, except that SRC is given relative to the current directory (or
653 # absolute), not given relative to the directory of DEST.
659 *) # SRC is relative.
662 ln -s "`pwd`/$1" "$2" ;;
663 *) # DEST is relative too.
664 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
665 test -n "$ln_destdir" || ln_destdir="."
666 func_relativize "$ln_destdir" "$1"
674 # func_ln_if_changed SRC DEST
675 # Like func_ln, but avoids munging timestamps if the link is correct.
676 func_ln_if_changed ()
678 if test $# -ne 2; then
679 echo "usage: func_ln_if_changed SRC DEST" >&2
681 ln_target=`func_readlink "$2"`
682 if test -h "$2" && test "$1" = "$ln_target"; then
690 # Ensure an 'echo' command that
691 # 1. does not interpret backslashes and
692 # 2. does not print an error message "broken pipe" when writing into a pipe
695 # Test cases for problem 1:
696 # echo '\n' | wc -l prints 1 when OK, 2 when KO
697 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
698 # Test cases for problem 2:
699 # echo hi | true frequently prints
700 # "bash: echo: write error: Broken pipe"
701 # to standard error in bash 3.2.
703 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
704 # BSD echo interprets '-n' as an option, which is also not desirable).
705 # Nowadays the problem occurs in 4 situations:
706 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
707 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
708 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
709 # - in zsh, when sh-emulation is not set,
710 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
711 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
712 # - in Solaris /bin/sh and OSF/1 /bin/sh.
713 # We try the following workarounds:
714 # - for all: respawn using $CONFIG_SHELL if that is set and works.
715 # - for bash >= 2.04: unset the shell option xpg_echo.
716 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
717 # - for bash < 2.0: define echo to a function that uses cat of a here document.
718 # - for zsh: turn sh-emulation on.
719 # - for ksh: alias echo to 'print -r'.
720 # - for ksh: alias echo to a function that uses cat of a here document.
721 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
722 # the ksh workaround.
723 # - otherwise: respawn using /bin/sh and rely on the workarounds.
724 # When respawning, we pass --no-reexec as first argument, so as to avoid
725 # turning this script into a fork bomb in unlucky situations.
727 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
728 # the 'printf' built-in. See
729 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
730 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
731 # The workaround is: define echo to a function that uses the printf built-in.
733 if echo '\t' | grep t > /dev/null; then
734 have_echo=yes # Lucky!
736 # Try the workarounds.
737 # Respawn using $CONFIG_SHELL if that is set and works.
738 if test -z "$have_echo" \
739 && test "X$1" != "X--no-reexec" \
740 && test -n "$CONFIG_SHELL" \
741 && test -f "$CONFIG_SHELL" \
742 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
743 exec $CONFIG_SHELL "$0" --no-reexec "$@"
746 # For bash >= 2.04: unset the shell option xpg_echo.
747 if test -z "$have_echo" \
748 && test -n "$BASH_VERSION" \
749 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
753 # For bash >= 2.0: define echo to a function that uses the printf built-in.
754 # For bash < 2.0: define echo to a function that uses cat of a here document.
755 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
756 # Also handle problem 2, specific to bash 3.2, here.
757 if { test -z "$have_echo" \
758 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
760 && test -n "$BASH_VERSION"; then \
761 if type printf 2>/dev/null | grep / > /dev/null; then
762 # 'printf' is not a shell built-in.
770 # 'printf' is a shell built-in.
776 if echo '\t' | grep t > /dev/null; then
780 # For zsh: turn sh-emulation on.
781 if test -z "$have_echo" \
782 && test -n "$ZSH_VERSION" \
783 && (emulate sh) >/dev/null 2>&1; then
786 # For ksh: alias echo to 'print -r'.
787 if test -z "$have_echo" \
788 && (type print) >/dev/null 2>&1; then
789 # A 'print' command exists.
790 if type print 2>/dev/null | grep / > /dev/null; then
793 # 'print' is a shell built-in.
794 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
795 # 'print' is the ksh shell built-in.
796 alias echo='print -r'
800 if test -z "$have_echo" \
801 && echo '\t' | grep t > /dev/null; then
804 # For ksh: alias echo to a function that uses cat of a here document.
805 # The ksh manual page says:
806 # "Aliasing is performed when scripts are read, not while they are executed.
807 # Therefore, for an alias to take effect, the alias definition command has
808 # to be executed before the command which references the alias is read."
809 # Because of this, we have to play strange tricks with have_echo, to ensure
810 # that the top-level statement containing the test starts after the 'alias'
812 if test -z "$have_echo"; then
819 alias echo=bsd_echo 2>/dev/null
821 if test -z "$have_echo" \
822 && echo '\t' | grep t > /dev/null; then
825 if test -z "$have_echo"; then
826 unalias echo 2>/dev/null
828 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
829 if test -z "$have_echo" \
830 && test "X$1" != "X--no-reexec" \
831 && test -f /bin/ksh; then
832 exec /bin/ksh "$0" --no-reexec "$@"
835 # Otherwise: respawn using /bin/sh.
836 if test -z "$have_echo" \
837 && test "X$1" != "X--no-reexec" \
838 && test -f /bin/sh; then
839 exec /bin/sh "$0" --no-reexec "$@"
842 if test -z "$have_echo"; then
843 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
845 if echo '\t' | grep t > /dev/null; then
848 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
850 if test "X$1" = "X--no-reexec"; then
854 # Command-line option processing.
855 # Removes the OPTIONS from the arguments. Sets the variables:
856 # - mode list or import or create-testdir or create-megatestdir
857 # - destdir from --dir
858 # - local_gnulib_dir from --local-dir
859 # - modcache true or false, from --cache-modules/--no-cache-modules
860 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
861 # - libname, supplied_libname from --lib
862 # - sourcebase from --source-base
863 # - m4base from --m4-base
864 # - pobase from --po-base
865 # - docbase from --doc-base
866 # - testsbase from --tests-base
867 # - auxdir from --aux-dir
868 # - inctests true if --with-tests was given, blank otherwise
869 # - incobsolete true if --with-obsolete was given, blank otherwise
870 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
871 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
873 # - inc_privileged_tests true if --with-privileged-tests was given, blank
875 # - inc_unportable_tests true if --with-unportable-tests was given, blank
877 # - inc_all_tests true if --with-all-tests was given, blank otherwise
878 # - avoidlist list of modules to avoid, from --avoid
879 # - lgpl yes or a number if --lgpl was given, blank otherwise
880 # - makefile_name from --makefile-name
881 # - libtool true if --libtool was given, false if --no-libtool was
882 # given, blank otherwise
883 # - macro_prefix from --macro-prefix
884 # - po_domain from --po-domain
885 # - vc_files true if --vc-files was given, false if --no-vc-files was
886 # given, blank otherwise
887 # - autoconf_minversion minimum supported autoconf version
888 # - do_changelog false if --no-changelog was given, : otherwise
889 # - doit : if actions shall be executed, false if only to be printed
890 # - symbolic true if --symlink or --more-symlinks was given, blank
892 # - lsymbolic true if --local-symlink was given, blank otherwise
893 # - do_copyrights blank if --more-symlinks was given, true otherwise
911 inc_longrunning_tests=
912 inc_privileged_tests=
913 inc_unportable_tests=
930 while test $# -gt 0; do
935 --find | --fin | --fi | --f )
938 --import | --impor | --impo | --imp | --im | --i )
941 --update | --updat | --upda | --upd | --up | --u )
944 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
947 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
948 mode=create-megatestdir
950 --test | --tes | --te | --t )
953 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
957 mode=`echo "X$1" | sed -e 's/^X--//'`
959 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
965 func_fatal_error "missing argument for --dir"
970 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
975 func_fatal_error "missing argument for --local-dir"
980 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
982 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
985 --no-cache-modules | --no-cache-module | --no-cache-modul | --no-cache-modu | --no-cache-mod | --no-cache-mo | --no-cache-m | --no-cache- | --no-cache | --no-cach | --no-cac | --no-ca )
988 --verbose | --verbos | --verbo | --verb )
989 verbose=`expr $verbose + 1`
991 --quiet | --quie | --qui | --qu | --q )
992 verbose=`expr $verbose - 1`
997 func_fatal_error "missing argument for --lib"
1000 supplied_libname=true
1003 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1004 supplied_libname=true
1008 if test $# = 0; then
1009 func_fatal_error "missing argument for --source-base"
1014 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1018 if test $# = 0; then
1019 func_fatal_error "missing argument for --m4-base"
1024 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1028 if test $# = 0; then
1029 func_fatal_error "missing argument for --po-base"
1034 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1038 if test $# = 0; then
1039 func_fatal_error "missing argument for --doc-base"
1044 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1048 if test $# = 0; then
1049 func_fatal_error "missing argument for --tests-base"
1054 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1058 if test $# = 0; then
1059 func_fatal_error "missing argument for --aux-dir"
1064 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1066 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1069 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1072 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1075 --with-longrunning-tests | --with-longrunning-test | --with-longrunning-tes | --with-longrunning-te | --with-longrunning-t | --with-longrunning- | --with-longrunning | --with-longrunnin | --with-longrunni | --with-longrunn | --with-longrun | --with-longru | --with-longr | --with-long | --with-lon | --with-lo | --with-l)
1076 inc_longrunning_tests=true
1078 --with-privileged-tests | --with-privileged-test | --with-privileged-tes | --with-privileged-te | --with-privileged-t | --with-privileged- | --with-privileged | --with-privilege | --with-privileg | --with-privile | --with-privil | --with-privi | --with-priv | --with-pri | --with-pr | --with-p)
1079 inc_privileged_tests=true
1081 --with-unportable-tests | --with-unportable-test | --with-unportable-tes | --with-unportable-te | --with-unportable-t | --with-unportable- | --with-unportable | --with-unportabl | --with-unportab | --with-unporta | --with-unport | --with-unpor | --with-unpo | --with-unp | --with-un | --with-u)
1082 inc_unportable_tests=true
1084 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1089 if test $# = 0; then
1090 func_fatal_error "missing argument for --avoid"
1092 func_append avoidlist " $1"
1095 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1096 func_append avoidlist " $arg"
1102 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1105 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1111 if test $# = 0; then
1112 func_fatal_error "missing argument for --makefile-name"
1117 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1127 if test $# = 0; then
1128 func_fatal_error "missing argument for --macro-prefix"
1133 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1137 if test $# = 0; then
1138 func_fatal_error "missing argument for --po-domain"
1143 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1151 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1157 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1160 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1163 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1167 --help | --hel | --he | --h )
1170 --version | --versio | --versi | --vers )
1174 # Stop option processing
1178 echo "gnulib-tool: unknown option $1" 1>&2
1179 echo "Try 'gnulib-tool --help' for more information." 1>&2
1186 if test "$mode" = update; then
1187 if test $# != 0; then
1188 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1189 echo "Try 'gnulib-tool --help' for more information." 1>&2
1190 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1191 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1194 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1195 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1196 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1197 || test -n "$inctests" || test -n "$incobsolete" \
1198 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1199 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1200 || test -n "$inc_all_tests" \
1201 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1202 || test -n "$macro_prefix" || test -n "$po_domain" \
1203 || test -n "$vc_files"; then
1204 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1205 echo "Try 'gnulib-tool --help' for more information." 1>&2
1206 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1207 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1212 if test -n "$pobase" && test -z "$po_domain"; then
1213 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1214 echo "Try 'gnulib-tool --help' for more information." 1>&2
1217 if test -z "$pobase" && test -n "$po_domain"; then
1218 func_warning "--po-domain has no effect without a --po-base option"
1221 # Determine the minimum supported autoconf version from the project's
1223 DEFAULT_AUTOCONF_MINVERSION="2.59"
1224 autoconf_minversion=
1226 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1227 if test -f "$destdir"/configure.ac; then
1228 configure_ac="$destdir/configure.ac"
1230 if test -f "$destdir"/configure.in; then
1231 configure_ac="$destdir/configure.in"
1235 if test -f configure.ac; then
1236 configure_ac="configure.ac"
1238 if test -f configure.in; then
1239 configure_ac="configure.in"
1243 if test -n "$configure_ac"; then
1244 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1245 # because when some m4 files are omitted from a CVS repository,
1246 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1247 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1248 # autom4te: m4 failed with exit status: 1
1255 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1257 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1258 if test -n "$prereqs"; then
1259 autoconf_minversion=`
1260 for version in $prereqs; do echo $version; done |
1261 LC_ALL=C sort -nru | sed -e 1q
1265 if test -z "$autoconf_minversion"; then
1266 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1268 case "$autoconf_minversion" in
1269 1.* | 2.[0-4]* | 2.5[0-8]*)
1270 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1273 # Remove trailing slashes from the directory names. This is necessary for
1274 # m4base (to avoid an error in func_import) and optional for the others.
1275 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1276 case "$local_gnulib_dir" in
1277 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1279 case "$sourcebase" in
1280 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1283 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1286 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1289 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1291 case "$testsbase" in
1292 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1295 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1301 trap 'exit_status=$?
1302 if test "$signal" != 0; then
1303 echo "caught signal $signal" >&2
1306 exit $exit_status' 0
1307 for signal in 1 2 3 13 15; do
1308 trap '{ signal='$signal'; func_exit 1; }' $signal
1312 # func_lookup_file file
1313 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1316 # - local_gnulib_dir from --local-dir
1318 # - lookedup_file name of the merged (combined) file
1319 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1323 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1324 lookedup_file="$local_gnulib_dir/$lkfile"
1327 if test -f "$gnulib_dir/$lkfile"; then
1328 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1329 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1330 rm -f "$tmp/$lkbase"
1331 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1332 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1333 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1334 lookedup_file="$tmp/$lkbase"
1337 lookedup_file="$gnulib_dir/$lkfile"
1341 func_fatal_error "file $gnulib_dir/$lkfile not found"
1346 # func_sanitize_modulelist
1347 # receives a list of possible module names on standard input, one per line.
1348 # It removes those which are just file names unrelated to modules, and outputs
1349 # the resulting list to standard output, one per line.
1350 func_sanitize_modulelist ()
1352 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1353 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1354 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1355 -e '/^README$/d' -e '/\/README$/d' \
1356 -e '/^TEMPLATE$/d' \
1357 -e '/^TEMPLATE-EXTENDED$/d' \
1358 -e '/^TEMPLATE-TESTS$/d' \
1365 # - local_gnulib_dir from --local-dir
1368 # Filter out metainformation files like README, which are not modules.
1369 # Filter out unit test modules; they can be retrieved through
1370 # --extract-tests-module if desired.
1372 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1373 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1374 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1377 | func_sanitize_modulelist \
1378 | sed -e '/-tests$/d' \
1382 # func_exists_module module
1383 # tests whether a module, given by name, exists
1385 # - local_gnulib_dir from --local-dir
1386 func_exists_module ()
1388 { test -f "$gnulib_dir/modules/$1" \
1389 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1390 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1391 && test "CVS" != "$1" \
1392 && test "ChangeLog" != "$1" \
1393 && test "COPYING" != "$1" \
1394 && test "README" != "$1" \
1395 && test "TEMPLATE" != "$1" \
1396 && test "TEMPLATE-EXTENDED" != "$1" \
1397 && test "TEMPLATE-TESTS" != "$1"
1400 # func_verify_module
1401 # verifies a module name
1403 # - local_gnulib_dir from --local-dir
1404 # - module module name argument
1405 func_verify_module ()
1407 if func_exists_module "$module"; then
1408 # OK, $module is a correct module name.
1409 # Verify that building the module description with 'patch' succeeds.
1410 func_lookup_file "modules/$module"
1412 func_warning "module $module doesn't exist"
1417 # func_verify_nontests_module
1418 # verifies a module name, excluding tests modules
1420 # - local_gnulib_dir from --local-dir
1421 # - module module name argument
1422 func_verify_nontests_module ()
1425 *-tests ) module= ;;
1426 * ) func_verify_module ;;
1430 # func_verify_tests_module
1431 # verifies a module name, considering only tests modules
1433 # - local_gnulib_dir from --local-dir
1434 # - module module name argument
1435 func_verify_tests_module ()
1438 *-tests ) func_verify_module ;;
1443 # Suffix of a sed expression that extracts a particular field from a
1444 # module description.
1445 # A field starts with a line that contains a keyword, such as 'Description',
1446 # followed by a colon and optional whitespace. All following lines, up to
1447 # the next field (or end of file if there is none) form the contents of the
1449 # An absent field is equivalent to a field with empty contents.
1450 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1451 sed_extract_prog=':[ ]*$/ {
1454 s/^Description:[ ]*$//
1458 s/^Applicability:[ ]*$//
1460 s/^Depends-on:[ ]*$//
1461 s/^configure\.ac-early:[ ]*$//
1462 s/^configure\.ac:[ ]*$//
1463 s/^Makefile\.am:[ ]*$//
1467 s/^Maintainer:[ ]*$//
1474 # Piece of a sed expression that converts a field header line to a shell
1476 # NOTE: Keep this in sync with sed_extract_prog above!
1477 sed_extract_field_header='
1478 s/^Description:[ ]*$/description/
1479 s/^Comment:[ ]*$/comment/
1480 s/^Status:[ ]*$/status/
1481 s/^Notice:[ ]*$/notice/
1482 s/^Applicability:[ ]*$/applicability/
1483 s/^Files:[ ]*$/files/
1484 s/^Depends-on:[ ]*$/dependson/
1485 s/^configure\.ac-early:[ ]*$/configureac_early/
1486 s/^configure\.ac:[ ]*$/configureac/
1487 s/^Makefile\.am:[ ]*$/makefile/
1488 s/^Include:[ ]*$/include/
1490 s/^License:[ ]*$/license/
1491 s/^Maintainer:[ ]*$/maintainer/'
1495 # Note: The 'eval' silences stderr output in dash.
1496 if declare -A x 2>/dev/null && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }; then
1497 # Zsh 4 and Bash 4 have associative arrays.
1498 have_associative=true
1500 # For other shells, use 'eval' with computed shell variable names.
1501 have_associative=false
1504 if $have_associative; then
1506 # Declare the associative arrays.
1507 declare -A modcache_cached
1508 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1509 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1510 eval "$declare_script"
1514 # func_cache_var module
1515 # computes the cache variable name corresponding to $module.
1516 # Note: This computation can map different module names to the same
1517 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1518 # to protect against this case.
1520 # - cachevar a shell variable name
1521 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1522 # Bash 2.0 and newer, ksh, and zsh support the syntax
1523 # ${param//pattern/replacement}
1524 # as a shorthand for
1525 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1526 # Note: The 'eval' above silences stderr output in dash.
1529 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1536 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1545 # func_init_sed_convert_to_cache_statements
1547 # - modcachevar_assignment
1549 # - sed_convert_to_cache_statements
1550 func_init_sed_convert_to_cache_statements ()
1552 # 'sed' script that turns a module description into shell script
1553 # assignments, suitable to be eval'ed. All active characters are escaped.
1556 # Some module's description
1561 # modcache_description[$1]=\
1562 # 'Some module'"'"'s description
1564 # modcache_files[$1]=\
1567 # c_MODULE_description_set=set; c_MODULE_description=\
1568 # 'Some module'"'"'s description
1570 # c_MODULE_files_set=set; c_MODULE_files=\
1572 # The script consists of two parts:
1573 # 1) Ignore the lines before the first field header.
1574 # 2) A loop, treating non-field-header lines by escaping single quotes
1575 # and adding a closing quote in the last line,
1576 sed_convert_to_cache_statements="
1578 # Here we have not yet seen a field header.
1580 # See if the current line contains a field header.
1583 ${sed_extract_field_header}
1586 # No field header. Ignore the line.
1588 # Read the next line. Upon EOF, just exit.
1593 # The current line contains a field header.
1595 # Turn it into the beginning of an assignment.
1596 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1598 # Move it to the hold space. Don't print it yet,
1599 # because we want no assignment if the field is empty.
1602 # Read the next line.
1603 # Upon EOF, the field was empty. Print no assignment. Just exit.
1606 # See if the current line contains a field header.
1609 ${sed_extract_field_header}
1610 # If it is, the previous field was empty. Print no assignment.
1613 # Not a field header.
1615 # Print the previous line, held in the hold space.
1620 # Transform single quotes.
1623 # Prepend a single quote.
1628 # Move it to the hold space.
1631 # Read the next line.
1638 # See if the current line contains a field header.
1641 ${sed_extract_field_header}
1644 # Print the previous line, held in the hold space.
1649 # Transform single quotes.
1656 # Print the previous line, held in the hold space, with a single quote
1657 # to end the assignment.
1667 # Print the previous line, held in the hold space, with a single quote
1668 # to end the assignment.
1675 if ! $sed_comments; then
1677 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1678 | sed -e 's/^ *//' -e 's/^#.*//'`
1682 if $have_associative; then
1683 # sed_convert_to_cache_statements does not depend on the module.
1684 modcachevar_assignment='modcache_\1[$1]='
1685 func_init_sed_convert_to_cache_statements
1688 # func_cache_lookup_module module
1690 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1691 # of its relevant data in a cache in the memory of the processing shell. If
1692 # already cached, it does not look it up again, thus saving file access time.
1694 # - module non-empty string
1695 # Output if $have_associative:
1696 # - modcache_cached[$module] set to yes
1697 # - modcache_description[$module] ==
1698 # - modcache_status[$module] \ set to the field's value, minus the
1699 # - ... / final newline,
1700 # - modcache_maintainer[$module] == or unset if the field's value is empty
1701 # Output if ! $have_associative:
1702 # - cachevar a shell variable name
1703 # - ${cachevar}_cached set to $module
1704 # - ${cachevar}_description ==
1705 # - ${cachevar}_status \ set to the field's value, minus the
1706 # - ... / final newline,
1707 # - ${cachevar}_maintainer == or unset if the field's value is empty
1708 # - ${cachevar}_description_set ==
1709 # - ${cachevar}_status_set \ set to non-empty if the field's value
1710 # - ... / is non-empty,
1711 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1712 func_cache_lookup_module ()
1714 if $have_associative; then
1715 cached=${modcache_cached[$1]}
1718 eval "cached=\"\$${cachevar}_cached\""
1720 if test -z "$cached"; then
1721 # Not found in cache. Look it up on the file system.
1722 func_lookup_file "modules/$1"
1723 if $have_associative; then
1724 modcache_cached[$1]=yes
1726 eval "${cachevar}_cached=\"\$1\""
1728 if ! $have_associative; then
1729 # sed_convert_to_cache_statements depends on the module.
1730 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1731 func_init_sed_convert_to_cache_statements
1733 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1734 eval "$cache_statements"
1736 if ! $have_associative; then
1737 if test "$1" != "$cached"; then
1738 func_fatal_error "cache variable collision between $1 and $cached"
1746 # func_get_description module
1748 # - local_gnulib_dir from --local-dir
1749 # - modcache true or false, from --cache-modules/--no-cache-modules
1750 func_get_description ()
1752 if ! $modcache; then
1753 func_lookup_file "modules/$1"
1754 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1756 func_cache_lookup_module "$1"
1757 # Output the field's value, including the final newline (if any).
1758 if $have_associative; then
1759 if test -n "${modcache_description[$1]+set}"; then
1760 echo "${modcache_description[$1]}"
1763 eval "field_set=\"\$${cachevar}_description_set\""
1764 if test -n "$field_set"; then
1765 eval "field_value=\"\$${cachevar}_description\""
1766 echo "${field_value}"
1772 # func_get_comment module
1774 # - local_gnulib_dir from --local-dir
1775 # - modcache true or false, from --cache-modules/--no-cache-modules
1778 if ! $modcache; then
1779 func_lookup_file "modules/$1"
1780 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1782 func_cache_lookup_module "$1"
1783 # Output the field's value, including the final newline (if any).
1784 if $have_associative; then
1785 if test -n "${modcache_comment[$1]+set}"; then
1786 echo "${modcache_comment[$1]}"
1789 eval "field_set=\"\$${cachevar}_comment_set\""
1790 if test -n "$field_set"; then
1791 eval "field_value=\"\$${cachevar}_comment\""
1792 echo "${field_value}"
1798 # func_get_status module
1800 # - local_gnulib_dir from --local-dir
1801 # - modcache true or false, from --cache-modules/--no-cache-modules
1804 if ! $modcache; then
1805 func_lookup_file "modules/$1"
1806 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1808 func_cache_lookup_module "$1"
1809 # Output the field's value, including the final newline (if any).
1810 if $have_associative; then
1811 if test -n "${modcache_status[$1]+set}"; then
1812 echo "${modcache_status[$1]}"
1815 eval "field_set=\"\$${cachevar}_status_set\""
1816 if test -n "$field_set"; then
1817 eval "field_value=\"\$${cachevar}_status\""
1818 echo "${field_value}"
1824 # func_get_notice module
1826 # - local_gnulib_dir from --local-dir
1827 # - modcache true or false, from --cache-modules/--no-cache-modules
1830 if ! $modcache; then
1831 func_lookup_file "modules/$1"
1832 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1834 func_cache_lookup_module "$1"
1835 # Output the field's value, including the final newline (if any).
1836 if $have_associative; then
1837 if test -n "${modcache_notice[$1]+set}"; then
1838 echo "${modcache_notice[$1]}"
1841 eval "field_set=\"\$${cachevar}_notice_set\""
1842 if test -n "$field_set"; then
1843 eval "field_value=\"\$${cachevar}_notice\""
1844 echo "${field_value}"
1850 # func_get_applicability module
1852 # - local_gnulib_dir from --local-dir
1853 # - modcache true or false, from --cache-modules/--no-cache-modules
1854 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1855 func_get_applicability ()
1857 if ! $modcache; then
1858 func_lookup_file "modules/$1"
1859 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1861 func_cache_lookup_module "$1"
1862 # Get the field's value, without the final newline.
1863 if $have_associative; then
1864 my_applicability="${modcache_applicability[$1]}"
1866 eval "my_applicability=\"\$${cachevar}_applicability\""
1869 if test -n "$my_applicability"; then
1870 echo $my_applicability
1872 # The default is 'main' or 'tests', depending on the module's name.
1874 *-tests) echo "tests";;
1880 # func_get_filelist module
1882 # - local_gnulib_dir from --local-dir
1883 # - modcache true or false, from --cache-modules/--no-cache-modules
1884 func_get_filelist ()
1886 if ! $modcache; then
1887 func_lookup_file "modules/$1"
1888 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1890 func_cache_lookup_module "$1"
1891 # Output the field's value, including the final newline (if any).
1892 if $have_associative; then
1893 if test -n "${modcache_files[$1]+set}"; then
1894 echo "${modcache_files[$1]}"
1897 eval "field_set=\"\$${cachevar}_files_set\""
1898 if test -n "$field_set"; then
1899 eval "field_value=\"\$${cachevar}_files\""
1900 echo "${field_value}"
1905 echo m4/gnulib-common.m4
1906 case "$autoconf_minversion" in
1913 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1914 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1915 # elements starting with prefix and ending with suffix are considered.
1916 # Processing: removed_prefix and removed_suffix are removed from each element,
1917 # added_prefix and added_suffix are added to each element.
1918 # prefix, suffix should not contain shell-special characters.
1919 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1920 # added_prefix, added_suffix should not contain the characters \|&.
1921 func_filter_filelist ()
1923 if test "$2" != "$nl" \
1924 || { $fast_func_append \
1925 && { test -z "$6" || $fast_func_remove_prefix; } \
1926 && { test -z "$7" || $fast_func_remove_suffix; }; \
1930 # Do not quote possibly-empty parameters in case patterns,
1931 # AIX and HP-UX ksh won't match them if they are empty.
1934 if test -n "$6"; then
1935 func_remove_prefix fff "$6"
1937 if test -n "$7"; then
1938 func_remove_suffix fff "$7"
1941 if test -z "$ffflist"; then
1944 func_append ffflist "$2${fff}"
1950 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1951 ffflist=`for fff in $3; do
1953 $4*$5) echo "$fff" ;;
1955 done | sed -e "$sed_fff_filter"`
1957 eval "$1=\"\$ffflist\""
1960 # func_get_dependencies module
1962 # - local_gnulib_dir from --local-dir
1963 # - modcache true or false, from --cache-modules/--no-cache-modules
1964 func_get_dependencies ()
1966 # ${module}-tests implicitly depends on ${module}, if that module exists.
1970 func_remove_suffix fgd1 '-tests'
1971 if func_exists_module "$fgd1"; then
1976 # Then the explicit dependencies listed in the module description.
1977 if ! $modcache; then
1978 func_lookup_file "modules/$1"
1979 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1981 func_cache_lookup_module "$1"
1982 # Output the field's value, including the final newline (if any).
1983 if $have_associative; then
1984 if test -n "${modcache_dependson[$1]+set}"; then
1985 echo "${modcache_dependson[$1]}"
1988 eval "field_set=\"\$${cachevar}_dependson_set\""
1989 if test -n "$field_set"; then
1990 eval "field_value=\"\$${cachevar}_dependson\""
1991 echo "${field_value}"
1997 # func_get_autoconf_early_snippet module
1999 # - local_gnulib_dir from --local-dir
2000 # - modcache true or false, from --cache-modules/--no-cache-modules
2001 func_get_autoconf_early_snippet ()
2003 if ! $modcache; then
2004 func_lookup_file "modules/$1"
2005 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2007 func_cache_lookup_module "$1"
2008 # Output the field's value, including the final newline (if any).
2009 if $have_associative; then
2010 if test -n "${modcache_configureac_early[$1]+set}"; then
2011 echo "${modcache_configureac_early[$1]}"
2014 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2015 if test -n "$field_set"; then
2016 eval "field_value=\"\$${cachevar}_configureac_early\""
2017 echo "${field_value}"
2023 # func_get_autoconf_snippet module
2025 # - local_gnulib_dir from --local-dir
2026 # - modcache true or false, from --cache-modules/--no-cache-modules
2027 func_get_autoconf_snippet ()
2029 if ! $modcache; then
2030 func_lookup_file "modules/$1"
2031 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2033 func_cache_lookup_module "$1"
2034 # Output the field's value, including the final newline (if any).
2035 if $have_associative; then
2036 if test -n "${modcache_configureac[$1]+set}"; then
2037 echo "${modcache_configureac[$1]}"
2040 eval "field_set=\"\$${cachevar}_configureac_set\""
2041 if test -n "$field_set"; then
2042 eval "field_value=\"\$${cachevar}_configureac\""
2043 echo "${field_value}"
2049 # func_get_automake_snippet module
2051 # - local_gnulib_dir from --local-dir
2052 # - modcache true or false, from --cache-modules/--no-cache-modules
2053 func_get_automake_snippet ()
2055 if ! $modcache; then
2056 func_lookup_file "modules/$1"
2057 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2059 func_cache_lookup_module "$1"
2060 # Output the field's value, including the final newline (if any).
2061 if $have_associative; then
2062 if test -n "${modcache_makefile[$1]+set}"; then
2063 echo "${modcache_makefile[$1]}"
2066 eval "field_set=\"\$${cachevar}_makefile_set\""
2067 if test -n "$field_set"; then
2068 eval "field_value=\"\$${cachevar}_makefile\""
2069 echo "${field_value}"
2075 # *-tests module live in tests/, not lib/.
2076 # Synthesize an EXTRA_DIST augmentation.
2077 all_files=`func_get_filelist $1`
2078 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2079 extra_files="$tests_files"
2080 if test -n "$extra_files"; then
2081 echo "EXTRA_DIST +=" $extra_files
2086 # Synthesize an EXTRA_DIST augmentation.
2087 sed_combine_lines='/\\$/{
2094 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2095 already_mentioned_files=` \
2096 { if ! $modcache; then
2097 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2099 if $have_associative; then
2100 if test -n "${modcache_makefile[$1]+set}"; then
2101 echo "${modcache_makefile[$1]}"
2104 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2105 if test -n "$field_set"; then
2106 eval 'field_value="$'"${cachevar}"'_makefile"'
2107 echo "${field_value}"
2112 | sed -e "$sed_combine_lines" \
2113 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2114 all_files=`func_get_filelist $1`
2115 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2116 # Remove $already_mentioned_files from $lib_files.
2117 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2118 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2119 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2120 if test -n "$extra_files"; then
2121 echo "EXTRA_DIST +=" $extra_files
2124 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2125 # This is necessary so that automake can generate the right list of
2127 # A possible approach would be to use autom4te --trace of the redefined
2128 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2129 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2130 # inside autoconf's built-in macros are not missed).
2131 # But it's simpler and more robust to do it here, based on the file list.
2132 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2133 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2134 # automake will generate a useless dependency; this is harmless.
2136 relocatable-prog-wrapper) ;;
2138 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2139 if test -n "$extra_files"; then
2140 echo "EXTRA_lib_SOURCES +=" $extra_files
2145 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2146 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2147 if test -n "$buildaux_files"; then
2148 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2149 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2152 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2153 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2154 if test -n "$top_files"; then
2155 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2156 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2163 # func_get_include_directive module
2165 # - local_gnulib_dir from --local-dir
2166 # - modcache true or false, from --cache-modules/--no-cache-modules
2167 func_get_include_directive ()
2170 if ! $modcache; then
2171 func_lookup_file "modules/$1"
2172 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2174 func_cache_lookup_module "$1"
2175 # Output the field's value, including the final newline (if any).
2176 if $have_associative; then
2177 if test -n "${modcache_include[$1]+set}"; then
2178 echo "${modcache_include[$1]}"
2181 eval "field_set=\"\$${cachevar}_include_set\""
2182 if test -n "$field_set"; then
2183 eval "field_value=\"\$${cachevar}_include\""
2184 echo "${field_value}"
2188 } | sed -e 's/^\(["<]\)/#include \1/'
2191 # func_get_link_directive module
2193 # - local_gnulib_dir from --local-dir
2194 # - modcache true or false, from --cache-modules/--no-cache-modules
2195 func_get_link_directive ()
2197 if ! $modcache; then
2198 func_lookup_file "modules/$1"
2199 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2201 func_cache_lookup_module "$1"
2202 # Output the field's value, including the final newline (if any).
2203 if $have_associative; then
2204 if test -n "${modcache_link[$1]+set}"; then
2205 echo "${modcache_link[$1]}"
2208 eval "field_set=\"\$${cachevar}_link_set\""
2209 if test -n "$field_set"; then
2210 eval "field_value=\"\$${cachevar}_link\""
2211 echo "${field_value}"
2217 # func_get_license module
2219 # - local_gnulib_dir from --local-dir
2220 # - modcache true or false, from --cache-modules/--no-cache-modules
2224 if ! $modcache; then
2225 func_lookup_file "modules/$1"
2226 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2228 func_cache_lookup_module "$1"
2229 # Output the field's value, including the final newline (if any).
2230 if $have_associative; then
2231 if test -n "${modcache_license[$1]+set}"; then
2232 echo "${modcache_license[$1]}"
2235 eval "field_set=\"\$${cachevar}_license_set\""
2236 if test -n "$field_set"; then
2237 eval "field_value=\"\$${cachevar}_license\""
2238 echo "${field_value}"
2242 # The default is GPL.
2244 } | sed -e 's,^ *$,,' | sed -e 1q
2247 # func_get_maintainer module
2249 # - local_gnulib_dir from --local-dir
2250 # - modcache true or false, from --cache-modules/--no-cache-modules
2251 func_get_maintainer ()
2253 if ! $modcache; then
2254 func_lookup_file "modules/$1"
2255 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2257 func_cache_lookup_module "$1"
2258 # Output the field's value, including the final newline (if any).
2259 if $have_associative; then
2260 if test -n "${modcache_maintainer[$1]+set}"; then
2261 echo "${modcache_maintainer[$1]}"
2264 eval "field_set=\"\$${cachevar}_maintainer_set\""
2265 if test -n "$field_set"; then
2266 eval "field_value=\"\$${cachevar}_maintainer\""
2267 echo "${field_value}"
2273 # func_get_tests_module module
2275 # - local_gnulib_dir from --local-dir
2276 func_get_tests_module ()
2278 # The naming convention for tests modules is hardwired: ${module}-tests.
2279 if test -f "$gnulib_dir/modules/$1"-tests \
2280 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2281 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2286 # func_acceptable module
2287 # tests whether a module is acceptable.
2289 # - inc_cxx_tests true if C++ interoperability tests should be included,
2291 # - inc_longrunning_tests true if long-runnings tests should be included,
2293 # - inc_privileged_tests true if tests that require root privileges should be
2294 # included, blank otherwise
2295 # - inc_unportable_tests true if tests that fail on some platforms should be
2296 # included, blank otherwise
2297 # - inc_all_tests true if all kinds of problematic unit tests should be
2298 # included, blank otherwise
2299 # - avoidlist list of modules to avoid
2302 for avoid in $avoidlist; do
2303 if test "$avoid" = "$1"; then
2310 for word in `func_get_status "$1"`; do
2313 test -n "$inc_all_tests" || test -n "$inc_cxx_tests" \
2317 test -n "$inc_all_tests" || test -n "$inc_longrunning_tests" \
2321 test -n "$inc_all_tests" || test -n "$inc_privileged_tests" \
2325 test -n "$inc_all_tests" || test -n "$inc_unportable_tests" \
2329 test -n "$inc_all_tests" \
2342 # func_modules_transitive_closure
2344 # - local_gnulib_dir from --local-dir
2345 # - modcache true or false, from --cache-modules/--no-cache-modules
2346 # - modules list of specified modules
2347 # - inctests true if tests should be included, blank otherwise
2348 # - incobsolete true if obsolete modules among dependencies should be
2349 # included, blank otherwise
2350 # - inc_cxx_tests true if C++ interoperability tests should be included,
2352 # - inc_longrunning_tests true if long-runnings tests should be included,
2354 # - inc_privileged_tests true if tests that require root privileges should be
2355 # included, blank otherwise
2356 # - inc_unportable_tests true if tests that fail on some platforms should be
2357 # included, blank otherwise
2358 # - inc_all_tests true if all kinds of problematic unit tests should be
2359 # included, blank otherwise
2360 # - avoidlist list of modules to avoid
2361 # - tmp pathname of a temporary directory
2363 # - modules list of modules, including dependencies
2364 func_modules_transitive_closure ()
2366 # In order to process every module only once (for speed), process an "input
2367 # list" of modules, producing an "output list" of modules. During each round,
2368 # more modules can be queued in the input list. Once a module on the input
2369 # list has been processed, it is added to the "handled list", so we can avoid
2370 # to process it again.
2372 inmodules="$modules"
2374 while test -n "$inmodules"; do
2375 inmodules_this_round="$inmodules"
2376 inmodules= # Accumulator, queue for next round
2377 for module in $inmodules_this_round; do
2379 if test -n "$module"; then
2380 if func_acceptable $module; then
2381 func_append outmodules " $module"
2382 deps=`func_get_dependencies $module`
2383 # Duplicate dependencies are harmless, but Jim wants a warning.
2384 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2385 if test -n "$duplicated_deps"; then
2386 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2388 for dep in $deps; do
2389 if test -n "$incobsolete" \
2391 for word in `func_get_status $dep`; do
2400 func_append inmodules " $dep"
2403 if test -n "$inctests"; then
2404 testsmodule=`func_get_tests_module $module`
2405 if test -n "$testsmodule"; then
2406 func_append inmodules " $testsmodule"
2412 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2413 # Remove $handledmodules from $inmodules.
2414 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2415 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2417 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2418 rm -f "$tmp"/queued-modules
2421 # func_modules_add_dummy
2423 # - local_gnulib_dir from --local-dir
2424 # - modcache true or false, from --cache-modules/--no-cache-modules
2425 # - modules list of modules, including dependencies
2427 # - modules list of modules, including 'dummy' if needed
2428 func_modules_add_dummy ()
2430 # Determine whether any module provides a lib_SOURCES augmentation.
2432 sed_remove_backslash_newline=':a
2439 for module in $modules; do
2440 func_verify_nontests_module
2441 if test -n "$module"; then
2442 # Extract the value of "lib_SOURCES += ...".
2443 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2444 # Ignore .h files since they are not compiled.
2448 have_lib_SOURCES=yes
2455 # Add the dummy module, to make sure the library will be non-empty.
2456 if test -z "$have_lib_SOURCES"; then
2457 if func_acceptable "dummy"; then
2458 func_append modules " dummy"
2463 # func_modules_notice
2465 # - local_gnulib_dir from --local-dir
2466 # - modcache true or false, from --cache-modules/--no-cache-modules
2467 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2468 # - modules list of modules, including dependencies
2469 func_modules_notice ()
2471 if test $verbose -ge -1; then
2472 for module in $modules; do
2474 if test -n "$module"; then
2475 msg=`func_get_notice $module`
2476 if test -n "$msg"; then
2477 echo "Notice from module $module:"
2478 echo "$msg" | sed -e 's/^/ /'
2485 # func_modules_to_filelist
2487 # - local_gnulib_dir from --local-dir
2488 # - modcache true or false, from --cache-modules/--no-cache-modules
2489 # - modules list of modules, including dependencies
2491 # - files list of files
2492 func_modules_to_filelist ()
2495 for module in $modules; do
2497 if test -n "$module"; then
2498 fs=`func_get_filelist $module`
2499 func_append files " $fs"
2502 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2505 # func_execute_command command [args...]
2506 # Executes a command.
2507 # Uses also the variables
2508 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2509 func_execute_command ()
2511 if test $verbose -ge 0; then
2515 # Commands like automake produce output to stderr even when they succeed.
2516 # Turn this output off if the command succeeds.
2517 "$@" > "$tmp"/cmdout 2>&1
2519 if test $cmdret = 0; then
2523 cat "$tmp"/cmdout 1>&2
2530 # func_dest_tmpfilename file
2531 # determines the name of a temporary file (file is relative to destdir).
2533 # - destdir target directory
2534 # - doit : if actions shall be executed, false if only to be printed
2535 # - tmp pathname of a temporary directory
2537 # - tmpfile absolute filename of the temporary file
2538 func_dest_tmpfilename ()
2541 # Put the new contents of $file in a file in the same directory (needed
2542 # to guarantee that an 'mv' to "$destdir/$file" works).
2543 tmpfile="$destdir/$1.tmp"
2545 # Put the new contents of $file in a file in a temporary directory
2546 # (because the directory of "$file" might not exist).
2547 tmpfile="$tmp"/`basename "$1"`.tmp
2552 # copies a file from gnulib into the destination directory. The destination
2553 # is known to not exist.
2555 # - destdir target directory
2556 # - local_gnulib_dir from --local-dir
2557 # - modcache true or false, from --cache-modules/--no-cache-modules
2558 # - f the original file name
2559 # - lookedup_file name of the merged (combined) file
2560 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2561 # - g the rewritten file name
2562 # - tmpfile absolute filename of the temporary file
2563 # - doit : if actions shall be executed, false if only to be printed
2564 # - symbolic true if files should be symlinked, copied otherwise
2565 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2570 echo "Copying file $g"
2571 if { test -n "$symbolic" \
2572 || { test -n "$lsymbolic" \
2573 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2574 && test -z "$lookedup_tmp" \
2575 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2576 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2578 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2586 # copies a file from gnulib into the destination directory. The destination
2587 # is known to exist.
2589 # - destdir target directory
2590 # - local_gnulib_dir from --local-dir
2591 # - modcache true or false, from --cache-modules/--no-cache-modules
2592 # - f the original file name
2593 # - lookedup_file name of the merged (combined) file
2594 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2595 # - g the rewritten file name
2596 # - tmpfile absolute filename of the temporary file
2597 # - doit : if actions shall be executed, false if only to be printed
2598 # - symbolic true if files should be symlinked, copied otherwise
2599 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2601 # - already_present nonempty if the file should already exist, empty otherwise
2604 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2605 : # The file has not changed.
2609 if test -n "$already_present"; then
2610 echo "Updating file $g (backup in ${g}~)"
2612 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2614 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2615 if { test -n "$symbolic" \
2616 || { test -n "$lsymbolic" \
2617 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2618 && test -z "$lookedup_tmp" \
2619 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2620 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2622 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2625 if test -n "$already_present"; then
2626 echo "Update file $g (backup in ${g}~)"
2628 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2634 # func_emit_lib_Makefile_am
2635 # emits the contents of library makefile to standard output.
2637 # - local_gnulib_dir from --local-dir
2638 # - modcache true or false, from --cache-modules/--no-cache-modules
2639 # - modules list of modules, including dependencies
2640 # - libname library name
2641 # - pobase directory relative to destdir where to place *.po files
2642 # - auxdir directory relative to destdir where to place build aux files
2643 # - makefile_name from --makefile-name
2644 # - libtool true if libtool will be used, false or blank otherwise
2645 # - macro_prefix prefix of gl_LIBOBJS macros to use
2646 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2647 # - actioncmd (optional) command that will reproduce this invocation
2648 # - for_test true if creating a package for testing, false otherwise
2649 # - destfile filename relative to destdir of makefile being generated
2651 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2652 # list of edits to be done to Makefile.am variables
2654 # - uses_subdirs nonempty if object files in subdirs exist
2655 func_emit_lib_Makefile_am ()
2657 # When creating an includable Makefile.am snippet, augment variables with
2658 # += instead of assigning them.
2659 if test -n "$makefile_name"; then
2664 if test "$libtool" = true; then
2667 sed_eliminate_LDFLAGS="$sed_noop"
2671 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2674 # When creating a package for testing: Attempt to provoke failures,
2675 # especially link errors, already during "make" rather than during
2676 # "make check", because "make check" is not possible in a cross-compiling
2677 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2678 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2680 sed_transform_check_PROGRAMS="$sed_noop"
2682 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2683 echo "## Process this file with automake to produce Makefile.in."
2684 func_emit_copyright_notice
2685 if test -n "$actioncmd"; then
2686 # The maximum line length (excluding the terminating newline) of any file
2687 # that is to be preprocessed by config.status is 3070. config.status uses
2688 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2689 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2690 len=`echo "$actioncmd" | wc -c`
2691 if test -n "$len" && test "$len" -le 3000; then
2692 echo "# Reproduce by: $actioncmd"
2698 for module in $modules; do
2699 func_verify_nontests_module
2700 if test -n "$module"; then
2702 func_get_automake_snippet "$module" |
2704 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2705 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2706 -e "$sed_eliminate_LDFLAGS" \
2707 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2708 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2709 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2710 -e "$sed_transform_check_PROGRAMS"
2711 if test "$module" = 'alloca'; then
2712 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2713 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2715 } > "$tmp"/amsnippet
2716 # Skip the contents if it's entirely empty.
2717 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2718 echo "## begin gnulib module $module"
2720 cat "$tmp"/amsnippet
2721 echo "## end gnulib module $module"
2724 rm -f "$tmp"/amsnippet
2725 # Test whether there are some source files in subdirectories.
2726 for f in `func_get_filelist "$module"`; do
2736 } > "$tmp"/allsnippets
2737 if test -z "$makefile_name"; then
2738 # If there are source files in subdirectories, prevent collision of the
2739 # object files (example: hash.c and libxml/hash.c).
2741 if test -n "$uses_subdirs"; then
2742 subdir_options=' subdir-objects'
2744 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2747 if test -z "$makefile_name"; then
2749 echo "noinst_HEADERS ="
2750 echo "noinst_LIBRARIES ="
2751 echo "noinst_LTLIBRARIES ="
2752 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2753 # if you specify pkgdata_DATA to empty. This is a workaround.
2754 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2755 echo "pkgdata_DATA ="
2758 echo "BUILT_SOURCES ="
2761 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2762 if test -z "$makefile_name"; then
2763 echo "MOSTLYCLEANDIRS ="
2765 echo "DISTCLEANFILES ="
2766 echo "MAINTAINERCLEANFILES ="
2768 # Execute edits that apply to the Makefile.am being generated.
2770 while test $edit != $makefile_am_edits; do
2771 edit=`expr $edit + 1`
2772 eval dir=\"\$makefile_am_edit${edit}_dir\"
2773 eval var=\"\$makefile_am_edit${edit}_var\"
2774 eval val=\"\$makefile_am_edit${edit}_val\"
2775 if test -n "$var"; then
2776 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2777 echo "${var} += ${val}"
2778 eval "makefile_am_edit${edit}_var="
2782 if test -z "$makefile_name"; then
2784 echo "AM_CPPFLAGS ="
2788 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2789 || { test -n "$makefile_name" \
2790 && test -f "$sourcebase/Makefile.am" \
2791 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2793 # One of the snippets or the user's Makefile.am already specifies an
2794 # installation location for the library. Don't confuse automake by saying
2795 # it should not be installed.
2798 # By default, the generated library should not be installed.
2799 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2802 echo "${libname}_${libext}_SOURCES ="
2803 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2804 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2805 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2806 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2807 echo "EXTRA_${libname}_${libext}_SOURCES ="
2808 if test "$libtool" = true; then
2809 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2812 if test -n "$pobase"; then
2813 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2816 cat "$tmp"/allsnippets \
2817 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2819 echo "mostlyclean-local: mostlyclean-generic"
2820 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2821 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2822 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2826 rm -f "$tmp"/allsnippets
2829 # func_emit_po_Makevars
2830 # emits the contents of po/ makefile parameterization to standard output.
2832 # - local_gnulib_dir from --local-dir
2833 # - modcache true or false, from --cache-modules/--no-cache-modules
2834 # - sourcebase directory relative to destdir where to place source code
2835 # - pobase directory relative to destdir where to place *.po files
2836 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2837 func_emit_po_Makevars ()
2839 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2840 func_emit_copyright_notice
2842 echo "# Usually the message domain is the same as the package name."
2843 echo "# But here it has a '-gnulib' suffix."
2844 echo "DOMAIN = ${po_domain}-gnulib"
2846 echo "# These two variables depend on the location of this directory."
2847 echo "subdir = ${pobase}"
2848 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2851 # These options get passed to xgettext.
2852 XGETTEXT_OPTIONS = \
2853 --keyword=_ --flag=_:1:pass-c-format \
2854 --keyword=N_ --flag=N_:1:pass-c-format \
2855 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2856 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2857 --flag=error:3:c-format --flag=error_at_line:5:c-format
2859 # This is the copyright holder that gets inserted into the header of the
2860 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2861 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2863 # This is the email address or URL to which the translators shall report
2864 # bugs in the untranslated strings:
2865 # - Strings which are not entire sentences, see the maintainer guidelines
2866 # in the GNU gettext documentation, section 'Preparing Strings'.
2867 # - Strings which use unclear terms or require additional context to be
2869 # - Strings which make invalid assumptions about notation of date, time or
2871 # - Pluralisation problems.
2872 # - Incorrect English spelling.
2873 # - Incorrect formatting.
2874 # It can be your email address, or a mailing list address where translators
2875 # can write to without being subscribed, or the URL of a web page through
2876 # which the translators can contact you.
2877 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2879 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2880 # message catalogs shall be used. It is usually empty.
2881 EXTRA_LOCALE_CATEGORIES =
2883 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2884 # context. Possible values are "yes" and "no". Set this to yes if the
2885 # package uses functions taking also a message context, like pgettext(), or
2886 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2891 # func_emit_po_POTFILES_in
2892 # emits the file list to be passed to xgettext to standard output.
2894 # - local_gnulib_dir from --local-dir
2895 # - modcache true or false, from --cache-modules/--no-cache-modules
2896 # - sourcebase directory relative to destdir where to place source code
2897 # - files list of new files
2898 func_emit_po_POTFILES_in ()
2900 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2901 func_emit_copyright_notice
2903 echo "# List of files which contain translatable strings."
2904 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2907 # func_emit_tests_Makefile_am witness_macro
2908 # emits the contents of tests makefile to standard output.
2910 # - local_gnulib_dir from --local-dir
2911 # - modcache true or false, from --cache-modules/--no-cache-modules
2912 # - modules list of modules, including dependencies
2913 # - libname library name
2914 # - auxdir directory relative to destdir where to place build aux files
2915 # - makefile_name from --makefile-name
2916 # - libtool true if libtool will be used, false or blank otherwise
2917 # - sourcebase relative directory containing lib source code
2918 # - m4base relative directory containing autoconf macros
2919 # - testsbase relative directory containing unit test code
2920 # - macro_prefix prefix of gl_LIBOBJS macros to use
2921 # - for_test true if creating a package for testing, false otherwise
2922 # - use_libtests true if a libtests.a should be built, false otherwise
2923 # - destfile filename relative to destdir of makefile being generated
2925 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2926 # list of edits to be done to Makefile.am variables
2928 # - uses_subdirs nonempty if object files in subdirs exist
2929 func_emit_tests_Makefile_am ()
2932 if test "$libtool" = true; then
2934 sed_eliminate_LDFLAGS="$sed_noop"
2937 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2940 # When creating a package for testing: Attempt to provoke failures,
2941 # especially link errors, already during "make" rather than during
2942 # "make check", because "make check" is not possible in a cross-compiling
2943 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2944 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2946 sed_transform_check_PROGRAMS="$sed_noop"
2948 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2949 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2950 echo "## Process this file with automake to produce Makefile.in."
2951 func_emit_copyright_notice
2955 for module in $modules; do
2957 func_verify_tests_module
2961 if test -n "$module"; then
2963 func_get_automake_snippet "$module" |
2965 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2966 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2967 -e "$sed_eliminate_LDFLAGS" \
2968 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2969 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2970 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2971 -e "$sed_transform_check_PROGRAMS"
2972 if $use_libtests && test "$module" = 'alloca'; then
2973 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2974 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2976 } > "$tmp"/amsnippet
2977 # Skip the contents if it's entirely empty.
2978 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2979 echo "## begin gnulib module $module"
2981 cat "$tmp"/amsnippet
2982 echo "## end gnulib module $module"
2985 rm -f "$tmp"/amsnippet
2986 # Test whether there are some source files in subdirectories.
2987 for f in `func_get_filelist "$module"`; do
2989 lib/*/*.c | tests/*/*.c)
2997 } > "$tmp"/allsnippets
2998 # Generate dependencies here, since it eases the debugging of test failures.
2999 # If there are source files in subdirectories, prevent collision of the
3000 # object files (example: hash.c and libxml/hash.c).
3002 if test -n "$uses_subdirs"; then
3003 subdir_options=' subdir-objects'
3005 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3008 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3011 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3012 # variable is needed to avoid an error from automake:
3013 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3016 echo "XFAIL_TESTS ="
3017 echo "TESTS_ENVIRONMENT ="
3018 echo "noinst_PROGRAMS ="
3019 if ! $for_test; then
3020 echo "check_PROGRAMS ="
3022 echo "noinst_HEADERS ="
3023 echo "noinst_LIBRARIES ="
3024 if $use_libtests; then
3026 echo "noinst_LIBRARIES += libtests.a"
3028 echo "check_LIBRARIES = libtests.a"
3031 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3032 # if you specify pkgdata_DATA to empty. This is a workaround.
3033 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3034 echo "pkgdata_DATA ="
3037 echo "BUILT_SOURCES ="
3039 echo "MOSTLYCLEANFILES = core *.stackdump"
3040 echo "MOSTLYCLEANDIRS ="
3042 echo "DISTCLEANFILES ="
3043 echo "MAINTAINERCLEANFILES ="
3044 # Execute edits that apply to the Makefile.am being generated.
3046 while test $edit != $makefile_am_edits; do
3047 edit=`expr $edit + 1`
3048 eval dir=\"\$makefile_am_edit${edit}_dir\"
3049 eval var=\"\$makefile_am_edit${edit}_var\"
3050 eval val=\"\$makefile_am_edit${edit}_val\"
3051 if test -n "$var"; then
3052 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3053 echo "${var} += ${val}"
3054 eval "makefile_am_edit${edit}_var="
3059 echo "AM_CPPFLAGS = \\"
3060 if test -n "${witness_macro}"; then
3061 echo " -D@${witness_macro}@=1 \\"
3063 echo " -I. -I\$(srcdir) \\"
3064 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3065 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3067 local_ldadd_before=''
3068 local_ldadd_after=''
3069 if $use_libtests; then
3070 # All test programs need to be linked with libtests.a.
3071 # It needs to be passed to the linker before ${libname}.${libext}, since
3072 # the tests-related modules depend on the main modules.
3073 # It also needs to be passed to the linker after ${libname}.${libext}
3074 # because the latter might contain incomplete modules (such as the 'error'
3075 # module whose dependency to 'progname' is voluntarily omitted).
3076 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3078 local_ldadd_before=' libtests.a'
3079 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3081 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3083 if $use_libtests; then
3084 echo "libtests_a_SOURCES ="
3085 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3086 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3087 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3088 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3089 echo "EXTRA_libtests_a_SOURCES ="
3090 # The circular dependency in LDADD requires this.
3091 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3094 # Many test scripts use ${EXEEXT} or ${srcdir}.
3095 # EXEEXT is defined by AC_PROG_CC through autoconf.
3096 # srcdir is defined by autoconf and automake.
3097 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3099 cat "$tmp"/allsnippets \
3100 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3101 echo "# Clean up after Solaris cc."
3103 echo " rm -rf SunWS_cache"
3105 echo "mostlyclean-local: mostlyclean-generic"
3106 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3107 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3108 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3112 rm -f "$tmp"/allsnippets
3115 # func_emit_initmacro_start macro_prefix
3116 # emits the first few statements of the gl_INIT macro to standard output.
3117 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3118 func_emit_initmacro_start ()
3120 macro_prefix_arg="$1"
3121 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3122 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3123 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3124 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3126 # Furthermore it avoids an automake error like this when a Makefile.am
3127 # that uses pieces of gnulib also uses $(LIBOBJ):
3128 # automatically discovered file `error.c' should not be explicitly mentioned
3129 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3130 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3131 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3132 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3133 # automatically discovered file `error.c' should not be explicitly mentioned
3134 # We let automake know about the files to be distributed through the
3135 # EXTRA_lib_SOURCES variable.
3136 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3137 # Create data variables for checking the presence of files that are mentioned
3138 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3139 # because we want the check to happen when the configure file is created,
3140 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3141 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3142 # in which to expect them.
3143 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3144 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3148 # func_emit_initmacro_end macro_prefix
3149 # emits the last few statements of the gl_INIT macro to standard output.
3150 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3151 func_emit_initmacro_end ()
3153 macro_prefix_arg="$1"
3154 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3155 # The check is performed only when autoconf is run from the directory where
3156 # the configure.ac resides; if it is run from a different directory, the
3158 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3159 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3160 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3161 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3162 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3166 echo " m4_if(m4_sysval, [0], [],"
3167 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3169 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3170 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3171 echo " m4_popdef([AC_LIBSOURCES])"
3172 echo " m4_popdef([AC_REPLACE_FUNCS])"
3173 echo " m4_popdef([AC_LIBOBJ])"
3174 echo " AC_CONFIG_COMMANDS_PRE(["
3175 echo " ${macro_prefix_arg}_libobjs="
3176 echo " ${macro_prefix_arg}_ltlibobjs="
3177 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3178 echo " # Remove the extension."
3179 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3180 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3181 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3182 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3185 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3186 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3190 # func_emit_initmacro_done macro_prefix sourcebase
3191 # emits a few statements after the gl_INIT macro to standard output.
3192 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3193 # - sourcebase directory relative to destdir where to place source code
3194 func_emit_initmacro_done ()
3196 macro_prefix_arg="$1"
3199 echo "# Like AC_LIBOBJ, except that the module name goes"
3200 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3201 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3202 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3203 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3206 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3207 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3208 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3209 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3210 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3213 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3214 echo "# expected is derived from the gnulib-tool parameterization,"
3215 echo "# and alloca is special cased (for the alloca-opt module)."
3216 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3217 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3218 echo " m4_foreach([_gl_NAME], [\$1], ["
3219 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3220 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3221 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3227 # func_import modules
3228 # Uses also the variables
3229 # - destdir target directory
3230 # - local_gnulib_dir from --local-dir
3231 # - modcache true or false, from --cache-modules/--no-cache-modules
3232 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3233 # - libname library name
3234 # - sourcebase directory relative to destdir where to place source code
3235 # - m4base directory relative to destdir where to place *.m4 macros
3236 # - pobase directory relative to destdir where to place *.po files
3237 # - docbase directory relative to destdir where to place doc files
3238 # - testsbase directory relative to destdir where to place unit test code
3239 # - auxdir directory relative to destdir where to place build aux files
3240 # - inctests true if --with-tests was given, blank otherwise
3241 # - incobsolete true if --with-obsolete was given, blank otherwise
3242 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3243 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3245 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3247 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3249 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3250 # - avoidlist list of modules to avoid, from --avoid
3251 # - lgpl yes or a number if library's license shall be LGPL,
3253 # - makefile_name from --makefile-name
3254 # - libtool true if --libtool was given, false if --no-libtool was
3255 # given, blank otherwise
3256 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3257 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3258 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3259 # - vc_files true if --vc-files was given, false if --no-vc-files was
3260 # given, blank otherwise
3261 # - autoconf_minversion minimum supported autoconf version
3262 # - doit : if actions shall be executed, false if only to be printed
3263 # - symbolic true if files should be symlinked, copied otherwise
3264 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3266 # - do_copyrights true if copyright notices in files should be replaced,
3270 # Get the cached settings.
3271 cached_local_gnulib_dir=
3272 cached_specified_modules=
3274 cached_inc_cxx_tests=
3275 cached_inc_longrunning_tests=
3276 cached_inc_privileged_tests=
3277 cached_inc_unportable_tests=
3278 cached_inc_all_tests=
3288 cached_makefile_name=
3290 cached_macro_prefix=
3294 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3295 cached_libtool=false
3301 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3311 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3313 /gl_WITH_OBSOLETE/ {
3314 s,^.*$,cached_incobsolete=true,p
3316 /gl_WITH_CXX_TESTS/ {
3317 s,^.*$,cached_inc_cxx_tests=true,p
3319 /gl_WITH_LONGRUNNING_TESTS/ {
3320 s,^.*$,cached_inc_longrunning_tests=true,p
3322 /gl_WITH_PRIVILEGED_TESTS/ {
3323 s,^.*$,cached_inc_privileged_tests=true,p
3325 /gl_WITH_UNPORTABLE_TESTS/ {
3326 s,^.*$,cached_inc_unportable_tests=true,p
3328 /gl_WITH_ALL_TESTS/ {
3329 s,^.*$,cached_inc_all_tests=true,p
3332 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3335 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3338 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3341 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3344 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3347 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3350 s,^.*$,cached_inctests=true,p
3353 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3356 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3359 s,^.*$,cached_lgpl=yes,p
3361 /gl_MAKEFILE_NAME(/ {
3362 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3365 s,^.*$,cached_libtool=true,p
3367 /gl_MACRO_PREFIX(/ {
3368 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3371 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3374 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3376 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3377 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3382 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3383 s,^.*$,cached_files=",p
3396 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3400 # Merge the cached settings with the specified ones.
3401 # The m4base must be the same as expected from the pathname.
3402 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3403 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3405 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3406 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3407 if test -z "$local_gnulib_dir"; then
3408 if test -n "$cached_local_gnulib_dir"; then
3411 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3413 case "$cached_local_gnulib_dir" in
3415 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3417 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3418 local_gnulib_dir="$relconcat" ;;
3423 # Append the cached and the specified module names. So that
3424 # "gnulib-tool --import foo" means to add the module foo.
3425 specified_modules="$cached_specified_modules $1"
3426 # Included obsolete modules among the dependencies if specified either way.
3427 if test -z "$incobsolete"; then
3428 incobsolete="$cached_incobsolete"
3430 # Included special kinds of tests modules among the dependencies if specified
3432 if test -z "$inc_cxx_tests"; then
3433 inc_cxx_tests="$cached_inc_cxx_tests"
3435 if test -z "$inc_longrunning_tests"; then
3436 inc_longrunning_tests="$cached_inc_longrunning_tests"
3438 if test -z "$inc_privileged_tests"; then
3439 inc_privileged_tests="$cached_inc_privileged_tests"
3441 if test -z "$inc_unportable_tests"; then
3442 inc_unportable_tests="$cached_inc_unportable_tests"
3444 if test -z "$inc_all_tests"; then
3445 inc_all_tests="$cached_inc_all_tests"
3447 # Append the cached and the specified avoidlist. This is probably better
3448 # than dropping the cached one when --avoid is specified at least once.
3449 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3450 avoidlist=`echo $avoidlist`
3452 # The sourcebase defaults to the cached one.
3453 if test -z "$sourcebase"; then
3454 sourcebase="$cached_sourcebase"
3455 if test -z "$sourcebase"; then
3456 func_fatal_error "missing --source-base option"
3459 # The pobase defaults to the cached one.
3460 if test -z "$pobase"; then
3461 pobase="$cached_pobase"
3463 # The docbase defaults to the cached one.
3464 if test -z "$docbase"; then
3465 docbase="$cached_docbase"
3466 if test -z "$docbase"; then
3467 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."
3470 # The testsbase defaults to the cached one.
3471 if test -z "$testsbase"; then
3472 testsbase="$cached_testsbase"
3473 if test -z "$testsbase"; then
3474 func_fatal_error "missing --tests-base option"
3477 # Require the tests if specified either way.
3478 if test -z "$inctests"; then
3479 inctests="$cached_inctests"
3481 # The libname defaults to the cached one.
3482 if test -z "$supplied_libname"; then
3483 libname="$cached_libname"
3484 if test -z "$libname"; then
3485 func_fatal_error "missing --lib option"
3488 # Require LGPL if specified either way.
3489 if test -z "$lgpl"; then
3492 # The makefile_name defaults to the cached one.
3493 if test -z "$makefile_name"; then
3494 makefile_name="$cached_makefile_name"
3496 # Use libtool if specified either way, or if guessed.
3497 if test -z "$libtool"; then
3498 if test -n "$cached_m4base"; then
3499 libtool="$cached_libtool"
3501 libtool="$guessed_libtool"
3504 # The macro_prefix defaults to the cached one.
3505 if test -z "$macro_prefix"; then
3506 macro_prefix="$cached_macro_prefix"
3507 if test -z "$macro_prefix"; then
3508 func_fatal_error "missing --macro-prefix option"
3511 # The po_domain defaults to the cached one.
3512 if test -z "$po_domain"; then
3513 po_domain="$cached_po_domain"
3515 # The vc_files defaults to the cached one.
3516 if test -z "$vc_files"; then
3517 vc_files="$cached_vc_files"
3520 # Canonicalize the list of specified modules.
3521 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3523 # Determine final module list.
3524 modules="$specified_modules"
3525 func_modules_transitive_closure
3526 if test $verbose -ge 0; then
3527 echo "Module list with included dependencies:"
3528 echo "$modules" | sed -e 's/^/ /'
3530 final_modules="$modules"
3532 # Determine main module list and tests-related module list separately.
3533 # The main module list is the transitive closure of the specified modules,
3534 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3535 # is specified, it will consist only of LGPLed source.
3536 # The tests-related module list is the transitive closure of the specified
3537 # modules, including tests modules, minus the main module list excluding
3538 # modules of applicability 'all'. Its lib/* sources (brought in through
3539 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3540 # source, even if --lgpl is specified.
3541 # Determine main module list.
3542 saved_inctests="$inctests"
3544 modules="$specified_modules"
3545 func_modules_transitive_closure
3546 main_modules="$modules"
3547 inctests="$saved_inctests"
3548 if test $verbose -ge 1; then
3549 echo "Main module list:"
3550 echo "$main_modules" | sed -e 's/^/ /'
3552 # Determine tests-related module list.
3553 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3554 testsrelated_modules=`for module in $main_modules; do
3555 if test \`func_get_applicability $module\` = main; then
3559 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3560 if test $verbose -ge 1; then
3561 echo "Tests-related module list:"
3562 echo "$testsrelated_modules" | sed -e 's/^/ /'
3565 # Add the dummy module to the main module list if needed.
3566 modules="$main_modules"
3567 func_modules_add_dummy
3568 main_modules="$modules"
3570 # Determine whether a $testsbase/libtests.a is needed.
3572 for module in $testsrelated_modules; do
3573 func_verify_nontests_module
3574 if test -n "$module"; then
3575 all_files=`func_get_filelist $module`
3576 # Test whether some file in $all_files lies in lib/.
3577 for f in $all_files; do
3588 # Add the dummy module to the tests-related module list if needed.
3589 if $use_libtests; then
3590 modules="$testsrelated_modules"
3591 func_modules_add_dummy
3592 testsrelated_modules="$modules"
3595 # If --lgpl, verify that the licenses of modules are compatible.
3596 if test -n "$lgpl"; then
3597 license_incompatibilities=
3598 for module in $main_modules; do
3599 license=`func_get_license $module`
3601 'GPLed build tool') ;;
3602 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3607 LGPL | LGPLv2+ | LGPLv3+) ;;
3608 *) func_append license_incompatibilities "$module $license$nl" ;;
3614 *) func_append license_incompatibilities "$module $license$nl" ;;
3617 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3622 if test -n "$license_incompatibilities"; then
3623 # Format the license incompatibilities as a table.
3624 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3625 s,^\(.................................................[^ ]*\) *, \1 ,'
3626 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3627 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3631 # Show banner notice of every module.
3632 modules="$main_modules"
3635 # Determine script to apply to imported library files.
3636 sed_transform_lib_file=
3637 for module in $main_modules; do
3638 if test $module = config-h; then
3639 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3640 sed_transform_lib_file=$sed_transform_lib_file'
3641 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3646 sed_transform_main_lib_file="$sed_transform_lib_file"
3647 if test -n "$do_copyrights"; then
3648 if test -n "$lgpl"; then
3652 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3653 s/GNU General/GNU Lesser General/g
3657 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3658 s/GNU General/GNU Lesser General/g
3659 s/version [23]\([ ,]\)/version 2.1\1/g
3662 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3666 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3667 s/GNU Lesser General/GNU General/g
3668 s/GNU Library General/GNU General/g
3669 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3674 # Determine script to apply to auxiliary files that go into $auxdir/.
3675 sed_transform_build_aux_file=
3676 if test -n "$do_copyrights"; then
3678 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3679 s/GNU Lesser General/GNU General/g
3680 s/GNU Library General/GNU General/g
3681 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3685 # Determine script to apply to library files that go into $testsbase/.
3686 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3687 if test -n "$do_copyrights"; then
3689 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3690 s/GNU Lesser General/GNU General/g
3691 s/GNU Library General/GNU General/g
3692 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3696 # Determine the final file lists.
3697 # They must be computed separately, because files in lib/* go into
3698 # $sourcebase/ if they are in the main file list but into $testsbase/
3699 # if they are in the tests-related file list. Furthermore lib/dummy.c
3701 # Determine final main file list.
3702 modules="$main_modules"
3703 func_modules_to_filelist
3705 # Determine final tests-related file list.
3706 modules="$testsrelated_modules"
3707 func_modules_to_filelist
3708 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3709 # Merge both file lists.
3710 sed_remove_empty_lines='/^$/d'
3711 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3712 if test $verbose -ge 0; then
3714 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3715 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3719 || func_fatal_error "refusing to do nothing"
3721 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3722 new_files="$files m4/gnulib-tool.m4"
3723 old_files="$cached_files"
3724 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3725 func_append old_files " m4/gnulib-tool.m4"
3728 rewritten='%REWRITTEN%'
3729 sed_rewrite_old_files="\
3730 s,^build-aux/,$rewritten$auxdir/,
3731 s,^doc/,$rewritten$cached_docbase/,
3732 s,^lib/,$rewritten$cached_sourcebase/,
3733 s,^m4/,$rewritten$cached_m4base/,
3734 s,^tests/,$rewritten$cached_testsbase/,
3735 s,^tests=lib/,$rewritten$cached_testsbase/,
3738 sed_rewrite_new_files="\
3739 s,^build-aux/,$rewritten$auxdir/,
3740 s,^doc/,$rewritten$docbase/,
3741 s,^lib/,$rewritten$sourcebase/,
3742 s,^m4/,$rewritten$m4base/,
3743 s,^tests/,$rewritten$testsbase/,
3744 s,^tests=lib/,$rewritten$testsbase/,
3748 # Create directories.
3749 { echo "$sourcebase"
3751 if test -n "$pobase"; then
3754 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3755 if test -n "$docfiles"; then
3758 if test -n "$inctests"; then
3762 for f in $files; do echo $f; done \
3763 | sed -e "$sed_rewrite_new_files" \
3764 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3767 { # Rearrange file descriptors. Needed because "while ... done < ..."
3768 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3769 exec 5<&0 < "$tmp"/dirs
3771 if test ! -d "$destdir/$d"; then
3773 echo "Creating directory $destdir/$d"
3774 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3776 echo "Create directory $destdir/$d"
3783 # Copy files or make symbolic links. Remove obsolete files.
3787 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3788 # representing the files according to the last gnulib-tool invocation.
3789 for f in $old_files; do echo $f; done \
3790 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3793 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3794 # representing the files after this gnulib-tool invocation.
3795 for f in $new_files; do echo $f; done \
3796 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3799 # First the files that are in old-files, but not in new-files:
3800 sed_take_first_column='s,'"$delimiter"'.*,,'
3801 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3802 # Remove the file. Do nothing if the user already removed it.
3803 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3805 echo "Removing file $g (backup in ${g}~)"
3806 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3808 echo "Remove file $g (backup in ${g}~)"
3810 func_append removed_files "$g$nl"
3813 # func_add_or_update handles a file that ought to be present afterwards.
3815 # - f the original file name
3816 # - g the rewritten file name
3817 # - already_present nonempty if the file should already exist, empty
3819 func_add_or_update ()
3823 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3825 func_dest_tmpfilename "$g"
3826 func_lookup_file "$f"
3827 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3828 if test -n "$sed_transform_main_lib_file"; then
3831 sed -e "$sed_transform_main_lib_file" \
3832 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3836 if test -n "$sed_transform_build_aux_file"; then
3839 sed -e "$sed_transform_build_aux_file" \
3840 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3844 if test -n "$sed_transform_testsrelated_lib_file"; then
3847 sed -e "$sed_transform_testsrelated_lib_file" \
3848 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3852 if test -f "$destdir/$g"; then
3853 # The file already exists.
3857 # Don't protest if the file should be there but isn't: it happens
3858 # frequently that developers don't put autogenerated files into CVS.
3860 func_append added_files "$g$nl"
3864 # Then the files that are in new-files, but not in old-files:
3865 sed_take_last_column='s,^.*'"$delimiter"',,'
3867 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3868 | sed -e "$sed_take_last_column" \
3869 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3870 { # Rearrange file descriptors. Needed because "while ... done < ..."
3871 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3872 exec 5<&0 < "$tmp"/added-files
3878 # Then the files that are in new-files and in old-files:
3879 already_present=true
3880 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3881 | sed -e "$sed_take_last_column" \
3882 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3883 { # Rearrange file descriptors. Needed because "while ... done < ..."
3884 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3885 exec 5<&0 < "$tmp"/kept-files
3892 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3893 actioncmd="gnulib-tool --import"
3894 func_append actioncmd " --dir=$destdir"
3895 if test -n "$local_gnulib_dir"; then
3896 func_append actioncmd " --local-dir=$local_gnulib_dir"
3898 func_append actioncmd " --lib=$libname"
3899 func_append actioncmd " --source-base=$sourcebase"
3900 func_append actioncmd " --m4-base=$m4base"
3901 if test -n "$pobase"; then
3902 func_append actioncmd " --po-base=$pobase"
3904 func_append actioncmd " --doc-base=$docbase"
3905 func_append actioncmd " --tests-base=$testsbase"
3906 func_append actioncmd " --aux-dir=$auxdir"
3907 if test -n "$inctests"; then
3908 func_append actioncmd " --with-tests"
3910 if test -n "$incobsolete"; then
3911 func_append actioncmd " --with-obsolete"
3913 if test -n "$inc_cxx_tests"; then
3914 func_append actioncmd " --with-c++-tests"
3916 if test -n "$inc_longrunning_tests"; then
3917 func_append actioncmd " --with-longrunning-tests"
3919 if test -n "$inc_privileged_tests"; then
3920 func_append actioncmd " --with-privileged-tests"
3922 if test -n "$inc_unportable_tests"; then
3923 func_append actioncmd " --with-unportable-tests"
3925 if test -n "$inc_all_tests"; then
3926 func_append actioncmd " --with-all-tests"
3928 for module in $avoidlist; do
3929 func_append actioncmd " --avoid=$module"
3931 if test -n "$lgpl"; then
3932 if test "$lgpl" = yes; then
3933 func_append actioncmd " --lgpl"
3935 func_append actioncmd " --lgpl=$lgpl"
3938 if test -n "$makefile_name"; then
3939 func_append actioncmd " --makefile-name=$makefile_name"
3941 if test "$libtool" = true; then
3942 func_append actioncmd " --libtool"
3944 func_append actioncmd " --no-libtool"
3946 func_append actioncmd " --macro-prefix=$macro_prefix"
3947 if test -n "$po_domain"; then
3948 func_append actioncmd " --po-domain=$po_domain"
3950 if test -n "$vc_files"; then
3951 if test "$vc_files" = true; then
3952 func_append actioncmd " --vc-files"
3954 func_append actioncmd " --no-vc-files"
3957 func_append actioncmd " `echo $specified_modules`"
3959 # Default the makefile name to Makefile.am.
3960 if test -n "$makefile_name"; then
3961 makefile_am=$makefile_name
3963 makefile_am=Makefile.am
3966 # Create normal Makefile.ams.
3969 # Setup list of Makefile.am edits that are to be performed afterwards.
3970 # Some of these edits apply to files that we will generate; others are
3971 # under the responsibility of the developer.
3973 # func_note_Makefile_am_edit dir var value
3974 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3976 func_note_Makefile_am_edit ()
3978 makefile_am_edits=`expr $makefile_am_edits + 1`
3979 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3980 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3981 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3983 if test "$makefile_am" = Makefile.am; then
3984 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3985 sourcebase_base=`basename "$sourcebase"`
3986 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3988 if test -n "$pobase"; then
3989 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3990 pobase_base=`basename "$pobase"`
3991 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3993 if test -n "$inctests"; then
3994 if test "$makefile_am" = Makefile.am; then
3995 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3996 testsbase_base=`basename "$testsbase"`
3997 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4000 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4002 # Find the first parent directory of $m4base that contains or will contain
4004 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4006 sed_butlast='s,[^/][^/]*//*$,,'
4007 dir1="${m4base}/"; dir2=""
4008 while test -n "$dir1" \
4009 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4010 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4011 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4012 || { test -n "$inctests" \
4013 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4014 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4015 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4016 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4018 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4021 # Create library makefile.
4022 func_dest_tmpfilename $sourcebase/$makefile_am
4023 destfile="$sourcebase/$makefile_am"
4024 modules="$main_modules"
4025 func_emit_lib_Makefile_am > "$tmpfile"
4026 if test -f "$destdir"/$sourcebase/$makefile_am; then
4027 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4031 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4032 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4033 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4035 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4041 echo "Creating $sourcebase/$makefile_am"
4042 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4044 echo "Create $sourcebase/$makefile_am"
4047 func_append added_files "$sourcebase/$makefile_am$nl"
4050 # Create po/ directory.
4051 if test -n "$pobase"; then
4052 # Create po makefile and auxiliary files.
4053 for file in Makefile.in.in remove-potcdate.sin; do
4054 func_dest_tmpfilename $pobase/$file
4055 func_lookup_file build-aux/po/$file
4056 cat "$lookedup_file" > "$tmpfile"
4057 if test -f "$destdir"/$pobase/$file; then
4058 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4062 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4063 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4064 mv -f "$tmpfile" "$destdir"/$pobase/$file
4066 echo "Update $pobase/$file (backup in $pobase/$file~)"
4072 echo "Creating $pobase/$file"
4073 mv -f "$tmpfile" "$destdir"/$pobase/$file
4075 echo "Create $pobase/$file"
4078 func_append added_files "$pobase/$file$nl"
4081 # Create po makefile parameterization, part 1.
4082 func_dest_tmpfilename $pobase/Makevars
4083 func_emit_po_Makevars > "$tmpfile"
4084 if test -f "$destdir"/$pobase/Makevars; then
4085 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4089 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4090 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4091 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4093 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4099 echo "Creating $pobase/Makevars"
4100 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4102 echo "Create $pobase/Makevars"
4105 func_append added_files "$pobase/Makevars$nl"
4107 # Create po makefile parameterization, part 2.
4108 func_dest_tmpfilename $pobase/POTFILES.in
4109 func_emit_po_POTFILES_in > "$tmpfile"
4110 if test -f "$destdir"/$pobase/POTFILES.in; then
4111 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4115 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4116 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4117 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4119 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4125 echo "Creating $pobase/POTFILES.in"
4126 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4128 echo "Create $pobase/POTFILES.in"
4131 func_append added_files "$pobase/POTFILES.in$nl"
4134 TP_URL="http://translationproject.org/latest/"
4135 TP_RSYNC_URI="translationproject.org::tp/latest/"
4137 echo "Fetching gnulib PO files from $TP_URL"
4138 (cd "$destdir"/$pobase \
4139 && { # Prefer rsync over wget if it is available, since it consumes
4140 # less network bandwidth, due to compression.
4141 if type rsync 2>/dev/null | grep / > /dev/null; then
4142 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4144 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4149 echo "Fetch gnulib PO files from $TP_URL"
4151 # Create po/LINGUAS.
4153 func_dest_tmpfilename $pobase/LINGUAS
4154 (cd "$destdir"/$pobase \
4155 && { echo '# Set of available languages.'
4156 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4159 if test -f "$destdir"/$pobase/LINGUAS; then
4160 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4163 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4164 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4165 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4168 echo "Creating $pobase/LINGUAS"
4169 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4170 func_append added_files "$pobase/LINGUAS$nl"
4173 if test -f "$destdir"/$pobase/LINGUAS; then
4174 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4176 echo "Create $pobase/LINGUAS"
4181 # Create m4/gnulib-cache.m4.
4182 func_dest_tmpfilename $m4base/gnulib-cache.m4
4184 func_emit_copyright_notice
4186 echo "# This file represents the specification of how gnulib-tool is used."
4187 echo "# It acts as a cache: It is written and read by gnulib-tool."
4188 echo "# In projects using CVS, this file is meant to be stored in CVS,"
4189 echo "# like the configure.ac and various Makefile.am files."
4192 echo "# Specification in the form of a command-line invocation:"
4195 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4196 # Store the local_gnulib_dir relative to destdir.
4197 case "$local_gnulib_dir" in
4199 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4202 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4204 # destdir, local_gnulib_dir are both relative.
4205 func_relativize "$destdir" "$local_gnulib_dir"
4206 relative_local_gnulib_dir="$reldir" ;;
4209 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4211 echo "$specified_modules" | sed -e 's/^/ /g'
4213 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4214 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4215 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4216 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4217 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4218 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4219 echo "gl_AVOID([$avoidlist])"
4220 echo "gl_SOURCE_BASE([$sourcebase])"
4221 echo "gl_M4_BASE([$m4base])"
4222 echo "gl_PO_BASE([$pobase])"
4223 echo "gl_DOC_BASE([$docbase])"
4224 echo "gl_TESTS_BASE([$testsbase])"
4225 test -z "$inctests" || echo "gl_WITH_TESTS"
4226 echo "gl_LIB([$libname])"
4227 if test -n "$lgpl"; then
4228 if test "$lgpl" = yes; then
4231 echo "gl_LGPL([$lgpl])"
4234 echo "gl_MAKEFILE_NAME([$makefile_name])"
4235 if test "$libtool" = true; then
4238 echo "gl_MACRO_PREFIX([$macro_prefix])"
4239 echo "gl_PO_DOMAIN([$po_domain])"
4240 if test -n "$vc_files"; then
4241 echo "gl_VC_FILES([$vc_files])"
4244 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4245 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4249 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4250 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4251 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4253 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4257 echo "# gnulib-cache.m4 ends here"
4264 echo "Creating $m4base/gnulib-cache.m4"
4265 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4267 echo "Create $m4base/gnulib-cache.m4"
4273 # Create m4/gnulib-comp.m4.
4274 func_dest_tmpfilename $m4base/gnulib-comp.m4
4276 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4277 func_emit_copyright_notice
4279 echo "# This file represents the compiled summary of the specification in"
4280 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4281 echo "# to be invoked from configure.ac."
4282 echo "# In projects using CVS, this file can be treated like other built files."
4285 echo "# This macro should be invoked from $configure_ac, in the section"
4286 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4287 echo "# any checks for libraries, header files, types and library functions."
4288 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4290 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4291 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4292 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4293 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4294 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4295 if test -n "$uses_subdirs"; then
4296 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4298 for module in $final_modules; do
4300 if test -n "$module"; then
4301 echo "# Code from module $module:"
4302 func_get_autoconf_early_snippet "$module"
4305 | sed -e '/^$/d;' -e 's/^/ /'
4308 echo "# This macro should be invoked from $configure_ac, in the section"
4309 echo "# \"Check for header files, types and library functions\"."
4310 echo "AC_DEFUN([${macro_prefix}_INIT],"
4312 if test "$libtool" = true; then
4313 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4314 echo " gl_cond_libtool=true"
4316 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4317 echo " gl_cond_libtool=false"
4319 echo " gl_ltlibdeps="
4321 if test "$auxdir" != "build-aux"; then
4322 sed_replace_build_aux='
4324 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4325 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4329 sed_replace_build_aux="$sed_noop"
4331 func_emit_initmacro_start $macro_prefix
4332 echo " gl_source_base='$sourcebase'"
4333 for module in $main_modules; do
4335 if test -n "$module"; then
4336 echo " # Code from module $module:"
4337 func_get_autoconf_snippet "$module" \
4338 | sed -e '/^$/d;' -e 's/^/ /' \
4339 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4340 -e "$sed_replace_build_aux"
4341 if test "$module" = 'alloca' && test "$libtool" = true; then
4342 echo 'changequote(,)dnl'
4343 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4344 echo 'changequote([, ])dnl'
4345 echo 'AC_SUBST([LTALLOCA])'
4349 echo " # End of code from modules"
4350 func_emit_initmacro_end $macro_prefix
4351 echo " gltests_libdeps="
4352 echo " gltests_ltlibdeps="
4353 func_emit_initmacro_start ${macro_prefix}tests
4354 echo " gl_source_base='$testsbase'"
4355 # Define a tests witness macro that depends on the package.
4356 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4357 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4358 echo "changequote(,)dnl"
4359 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"
4360 echo "changequote([, ])dnl"
4361 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4362 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4363 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4364 for module in $testsrelated_modules; do
4366 if test -n "$module"; then
4367 func_get_autoconf_snippet "$module" \
4368 | sed -e '/^$/d;' -e 's/^/ /' \
4369 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4370 -e "$sed_replace_build_aux" \
4371 -e 's/\$gl_cond_libtool/false/g' \
4372 -e 's/gl_libdeps/gltests_libdeps/g' \
4373 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4376 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4377 func_emit_initmacro_end ${macro_prefix}tests
4378 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4379 # created using libtool, because libtool already handles the dependencies.
4380 if test "$libtool" != true; then
4381 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4382 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4383 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4384 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4385 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4387 if $use_libtests; then
4388 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4389 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4392 func_emit_initmacro_done $macro_prefix $sourcebase
4393 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4395 echo "# This macro records the list of files which have been installed by"
4396 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4397 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4398 echo "$files" | sed -e 's,^, ,'
4401 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4402 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4406 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4407 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4408 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4410 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4414 echo "# gnulib-comp.m4 ends here"
4421 echo "Creating $m4base/gnulib-comp.m4"
4422 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4424 echo "Create $m4base/gnulib-comp.m4"
4430 if test -n "$inctests"; then
4431 # Create tests makefile.
4432 func_dest_tmpfilename $testsbase/$makefile_am
4433 destfile="$testsbase/$makefile_am"
4434 modules="$testsrelated_modules"
4435 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4436 if test -f "$destdir"/$testsbase/$makefile_am; then
4437 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4441 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4442 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4443 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4445 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4451 echo "Creating $testsbase/$makefile_am"
4452 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4454 echo "Create $testsbase/$makefile_am"
4457 func_append added_files "$testsbase/$makefile_am$nl"
4461 if test "$vc_files" != false; then
4462 # Update the .cvsignore and .gitignore files.
4463 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4464 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4465 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4466 echo "$m4base/|A|gnulib-comp.m4"
4467 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4468 { # Rearrange file descriptors. Needed because "while ... done < ..."
4469 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4470 exec 5<&0 < "$tmp"/fileset-changes
4471 func_update_ignorelist ()
4474 if test "$ignore" = .gitignore; then
4475 # In a .gitignore file, "foo" applies to the current directory and all
4476 # subdirectories, whereas "/foo" applies to the current directory only.
4479 doubly_escaped_anchor='\\/'
4483 doubly_escaped_anchor=''
4485 if test -f "$destdir/$dir$ignore"; then
4486 if test -n "$dir_added" || test -n "$dir_removed"; then
4487 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4488 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4489 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4490 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4491 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4493 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4495 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4496 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4497 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4498 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4499 } > "$tmp"/sed-ignore-removed
4500 { cat "$destdir/$dir$ignore"~
4501 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4502 } | sed -f "$tmp"/sed-ignore-removed \
4503 > "$destdir/$dir$ignore"
4505 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4510 if test -n "$dir_added"; then
4512 echo "Creating $destdir/$dir$ignore"
4514 if test "$ignore" = .cvsignore; then
4516 # Automake generates Makefile rules that create .dirstamp files.
4519 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4520 } > "$destdir/$dir$ignore"
4522 echo "Create $destdir/$dir$ignore"
4532 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4533 func_update_ignorelist .cvsignore
4535 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4536 func_update_ignorelist .gitignore
4543 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4544 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4545 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4546 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4547 if test "$next_dir" != "$last_dir"; then
4548 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4549 last_dir="$next_dir"
4554 A) func_append last_dir_added "$file$nl";;
4555 R) func_append last_dir_removed "$file$nl";;
4558 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4565 echo "You may need to add #include directives for the following .h files."
4566 # Intersect $specified_modules and $main_modules
4567 # (since $specified_modules is not necessarily of subset of $main_modules
4568 # - some may have been skipped through --avoid, and since the elements of
4569 # $main_modules but not in $specified_modules can go away without explicit
4570 # notice - through changes in the module dependencies).
4571 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4572 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4573 # First the #include <...> directives without #ifs, sorted for convenience,
4574 # then the #include "..." directives without #ifs, sorted for convenience,
4575 # then the #include directives that are surrounded by #ifs. Not sorted.
4576 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4577 include_directive=`func_get_include_directive "$module"`
4578 case "$nl$include_directive" in
4580 echo "$include_directive" 1>&5
4583 echo "$include_directive" | grep -v 'include "' 1>&6
4584 echo "$include_directive" | grep 'include "' 1>&7
4587 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4589 LC_ALL=C sort -u "$tmp"/include-angles
4590 LC_ALL=C sort -u "$tmp"/include-quotes
4591 cat "$tmp"/include-if
4592 ) | sed -e '/^$/d' -e 's/^/ /'
4593 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4595 for module in $main_modules; do
4596 func_get_link_directive "$module"
4598 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4599 if test `wc -l < "$tmp"/link` != 0; then
4601 echo "You may need to use the following Makefile variables when linking."
4602 echo "Use them in <program>_LDADD when linking a program, or"
4603 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4609 echo "Don't forget to"
4610 if test "$makefile_am" = Makefile.am; then
4611 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4613 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4615 if test -n "$pobase"; then
4616 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4618 if test -n "$inctests"; then
4619 if test "$makefile_am" = Makefile.am; then
4620 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4622 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4626 while test $edit != $makefile_am_edits; do
4627 edit=`expr $edit + 1`
4628 eval dir=\"\$makefile_am_edit${edit}_dir\"
4629 eval var=\"\$makefile_am_edit${edit}_var\"
4630 eval val=\"\$makefile_am_edit${edit}_val\"
4631 if test -n "$var"; then
4632 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4635 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4636 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4639 # func_create_testdir testdir modules
4641 # - local_gnulib_dir from --local-dir
4642 # - modcache true or false, from --cache-modules/--no-cache-modules
4643 # - auxdir directory relative to destdir where to place build aux files
4644 # - inctests true if tests should be included, blank otherwise
4645 # - incobsolete true if obsolete modules among dependencies should be
4646 # included, blank otherwise
4647 # - avoidlist list of modules to avoid
4648 # - libtool true if --libtool was given, false if --no-libtool was
4649 # given, blank otherwise
4650 # - symbolic true if files should be symlinked, copied otherwise
4651 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4653 func_create_testdir ()
4657 if test -z "$modules"; then
4658 # All modules together.
4659 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4660 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4661 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4662 modules=`func_all_modules`
4663 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4665 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
4667 # Unlike in func_import, here we want to include all kinds of tests.
4670 # Check that the license of every module is consistent with the license of
4672 saved_modules="$modules"
4673 saved_inctests="$inctests"
4674 # When computing transitive closures, don't consider $module to depend on
4675 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4676 # on GPL modules - therefore we don't want a warning in this case.
4678 for requested_module in $saved_modules; do
4679 requested_license=`func_get_license "$requested_module"`
4680 if test "$requested_license" != GPL; then
4681 # Here we use func_modules_transitive_closure, not just
4682 # func_get_dependencies, so that we also detect weird situations like
4683 # an LGPL module which depends on a GPLed build tool module which depends
4685 modules="$requested_module"
4686 func_modules_transitive_closure
4687 for module in $modules; do
4688 license=`func_get_license "$module"`
4690 'GPLed build tool') ;;
4691 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4693 case "$requested_license" in
4696 GPLv2+ | LGPLv2+) ;;
4697 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4703 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4709 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4718 modules="$saved_modules"
4719 inctests="$saved_inctests"
4721 # Subdirectory names.
4731 # Determine final module list.
4732 func_modules_transitive_closure
4733 if test $verbose -ge 0; then
4734 echo "Module list with included dependencies:"
4735 echo "$modules" | sed -e 's/^/ /'
4738 # Add the dummy module if needed.
4739 func_modules_add_dummy
4741 # Show banner notice of every module.
4744 # Determine final file list.
4745 func_modules_to_filelist
4746 if test $verbose -ge 0; then
4748 echo "$files" | sed -e 's/^/ /'
4751 rewritten='%REWRITTEN%'
4752 sed_rewrite_files="\
4753 s,^build-aux/,$rewritten$auxdir/,
4754 s,^doc/,$rewritten$docbase/,
4755 s,^lib/,$rewritten$sourcebase/,
4756 s,^m4/,$rewritten$m4base/,
4757 s,^tests/,$rewritten$testsbase/,
4761 # Create directories.
4762 for f in $files; do echo $f; done \
4763 | sed -e "$sed_rewrite_files" \
4764 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4765 | LC_ALL=C sort -u \
4767 { # Rearrange file descriptors. Needed because "while ... done < ..."
4768 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4769 exec 5<&0 < "$tmp"/dirs
4771 mkdir -p "$testdir/$d"
4776 # Copy files or make symbolic links.
4778 for f in $files; do echo $f; done \
4779 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4782 { # Rearrange file descriptors. Needed because "while ... done < ..."
4783 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4784 exec 5<&0 < "$tmp"/files
4786 func_lookup_file "$f"
4787 if test -n "$lookedup_tmp"; then
4788 cp -p "$lookedup_file" "$testdir/$g"
4790 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4791 if { test -n "$symbolic" \
4792 || { test -n "$lsymbolic" \
4793 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4794 func_ln "$lookedup_file" "$testdir/$g"
4796 cp -p "$lookedup_file" "$testdir/$g"
4803 # Create Makefile.ams that are for testing.
4806 # No special edits are needed.
4809 # Create $sourcebase/Makefile.am.
4810 mkdir -p "$testdir/$sourcebase"
4811 destfile="$sourcebase/Makefile.am"
4812 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4813 any_uses_subdirs="$uses_subdirs"
4815 # Create $m4base/Makefile.am.
4816 mkdir -p "$testdir/$m4base"
4817 (echo "## Process this file with automake to produce Makefile.in."
4823 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4826 ) > "$testdir/$m4base/Makefile.am"
4828 subdirs="$sourcebase $m4base"
4829 subdirs_with_configure_ac=""
4831 if false && test -f "$testdir"/$m4base/gettext.m4; then
4832 # Avoid stupid error message from automake:
4833 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4834 mkdir -p "$testdir/po"
4835 (echo "## Process this file with automake to produce Makefile.in."
4836 ) > "$testdir/po/Makefile.am"
4837 func_append subdirs " po"
4840 if test -n "$inctests"; then
4841 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4842 # Viewed from the $testsbase subdirectory, $auxdir is different.
4843 saved_auxdir="$auxdir"
4844 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4845 # Create $testsbase/Makefile.am.
4847 destfile="$testsbase/Makefile.am"
4848 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
4849 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4850 # Create $testsbase/configure.ac.
4851 (echo "# Process this file with autoconf to produce a configure script."
4852 echo "AC_INIT([dummy], [0])"
4853 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4854 echo "AM_INIT_AUTOMAKE"
4856 echo "AC_CONFIG_HEADERS([config.h])"
4859 echo "AC_PROG_INSTALL"
4860 echo "AC_PROG_MAKE_SET"
4861 echo "AC_PROG_RANLIB"
4863 if test -n "$uses_subdirs"; then
4864 echo "AM_PROG_CC_C_O"
4867 for module in $modules; do
4869 if test -n "$module"; then
4871 gnumakefile | maintainer-makefile)
4872 # These modules are meant to be used only in the top-level directory.
4875 func_get_autoconf_early_snippet "$module"
4880 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4881 if test "$libtool" = true; then
4882 echo "LT_INIT([win32-dll])"
4883 echo "LT_LANG([C++])"
4884 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4885 echo "gl_cond_libtool=true"
4887 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4888 echo "gl_cond_libtool=false"
4890 echo "gl_ltlibdeps="
4892 # Wrap the set of autoconf snippets into an autoconf macro that is then
4893 # invoked. This is needed because autoconf does not support AC_REQUIRE
4895 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4896 # but we want the AC_REQUIRE to have its normal meaning (provide one
4897 # expansion of the required macro before the current point, and only one
4899 echo "AC_DEFUN([gl_INIT], ["
4900 sed_replace_build_aux='
4902 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4903 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4906 func_emit_initmacro_start $macro_prefix
4907 # We don't have explicit ordering constraints between the various
4908 # autoconf snippets. It's cleanest to put those of the library before
4909 # those of the tests.
4910 echo "gl_source_base='../$sourcebase'"
4911 for module in $modules; do
4912 func_verify_nontests_module
4913 if test -n "$module"; then
4915 gnumakefile | maintainer-makefile)
4916 # These modules are meant to be used only in the top-level directory.
4919 func_get_autoconf_snippet "$module" \
4920 | sed -e "$sed_replace_build_aux"
4925 echo "gl_source_base='.'"
4926 for module in $modules; do
4927 func_verify_tests_module
4928 if test -n "$module"; then
4929 func_get_autoconf_snippet "$module" \
4930 | sed -e "$sed_replace_build_aux"
4933 func_emit_initmacro_end $macro_prefix
4934 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4935 # created using libtool, because libtool already handles the dependencies.
4936 if test "$libtool" != true; then
4937 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4938 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4939 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4940 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4941 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4944 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4948 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4949 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4950 echo "AH_TOP([#include \"../config.h\"])"
4952 echo "AC_CONFIG_FILES([Makefile])"
4954 ) > "$testdir/$testsbase/configure.ac"
4955 auxdir="$saved_auxdir"
4956 func_append subdirs " $testsbase"
4957 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4960 # Create Makefile.am.
4961 (echo "## Process this file with automake to produce Makefile.in."
4963 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4965 echo "SUBDIRS = $subdirs"
4967 echo "ACLOCAL_AMFLAGS = -I $m4base"
4968 ) > "$testdir/Makefile.am"
4970 # Create configure.ac.
4971 (echo "# Process this file with autoconf to produce a configure script."
4972 echo "AC_INIT([dummy], [0])"
4973 if test "$auxdir" != "."; then
4974 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4976 echo "AM_INIT_AUTOMAKE"
4978 echo "AC_CONFIG_HEADERS([config.h])"
4981 echo "AC_PROG_INSTALL"
4982 echo "AC_PROG_MAKE_SET"
4984 echo "# For autobuild."
4985 echo "AC_CANONICAL_BUILD"
4986 echo "AC_CANONICAL_HOST"
4988 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4989 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4990 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4991 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4993 echo "AC_PROG_RANLIB"
4995 if test -n "$any_uses_subdirs"; then
4996 echo "AM_PROG_CC_C_O"
4999 for module in $modules; do
5000 func_verify_nontests_module
5001 if test -n "$module"; then
5002 func_get_autoconf_early_snippet "$module"
5005 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5006 if test "$libtool" = true; then
5007 echo "LT_INIT([win32-dll])"
5008 echo "LT_LANG([C++])"
5009 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5010 echo "gl_cond_libtool=true"
5012 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5013 echo "gl_cond_libtool=false"
5015 echo "gl_ltlibdeps="
5017 # Wrap the set of autoconf snippets into an autoconf macro that is then
5018 # invoked. This is needed because autoconf does not support AC_REQUIRE
5020 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5021 # but we want the AC_REQUIRE to have its normal meaning (provide one
5022 # expansion of the required macro before the current point, and only one
5024 echo "AC_DEFUN([gl_INIT], ["
5025 if test "$auxdir" != "build-aux"; then
5026 sed_replace_build_aux='
5028 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5029 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5033 sed_replace_build_aux="$sed_noop"
5035 func_emit_initmacro_start $macro_prefix
5036 echo "gl_source_base='$sourcebase'"
5037 for module in $modules; do
5038 func_verify_nontests_module
5039 if test -n "$module"; then
5040 func_get_autoconf_snippet "$module" \
5041 | sed -e "$sed_replace_build_aux"
5044 func_emit_initmacro_end $macro_prefix
5045 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5046 # created using libtool, because libtool already handles the dependencies.
5047 if test "$libtool" != true; then
5048 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5049 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5050 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5051 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5052 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5055 func_emit_initmacro_done $macro_prefix $sourcebase
5059 if test -n "$subdirs_with_configure_ac"; then
5060 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5062 makefiles="Makefile"
5063 for d in $subdirs; do
5064 # For subdirs that have a configure.ac by their own, it's the subdir's
5065 # configure.ac which creates the subdir's Makefile.am, not this one.
5066 case " $subdirs_with_configure_ac " in
5068 *) func_append makefiles " $d/Makefile" ;;
5071 echo "AC_CONFIG_FILES([$makefiles])"
5073 ) > "$testdir/configure.ac"
5075 # Create autogenerated files.
5077 # Do not use "${AUTORECONF} --force --install", because it may invoke
5078 # autopoint, which brings in older versions of some of our .m4 files.
5079 if test -f $m4base/gettext.m4; then
5080 func_execute_command ${AUTOPOINT} --force || func_exit 1
5081 for f in $m4base/*.m4~; do
5083 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5087 if test "$libtool" = true; then
5088 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5090 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5091 if ! test -d build-aux; then
5092 func_execute_command mkdir build-aux || func_exit 1
5094 func_execute_command ${AUTOCONF} || func_exit 1
5095 func_execute_command ${AUTOHEADER} || func_exit 1
5096 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5098 if test -n "$inctests"; then
5099 # Create autogenerated files.
5100 (cd "$testdir/$testsbase" || func_exit 1
5101 # Do not use "${AUTORECONF} --force --install", because it may invoke
5102 # autopoint, which brings in older versions of some of our .m4 files.
5103 if test -f ../$m4base/gettext.m4; then
5104 func_execute_command ${AUTOPOINT} --force || func_exit 1
5105 for f in ../$m4base/*.m4~; do
5107 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5111 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5112 if ! test -d ../build-aux; then
5113 func_execute_command mkdir ../build-aux
5115 func_execute_command ${AUTOCONF} || func_exit 1
5116 func_execute_command ${AUTOHEADER} || func_exit 1
5117 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5120 # Need to run configure and make once, to create built files that are to be
5121 # distributed (such as getdate.c).
5122 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5123 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5124 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5125 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5126 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5127 # such $(FOO_H) because they don't refer to distributed files.
5128 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5129 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5130 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5131 | sed -e "$sed_remove_make_variables"`
5132 distributed_built_sources=`for file in $built_sources; do
5133 case "$cleaned_files" in
5138 if test -n "$distributed_built_sources"; then
5140 ./configure || func_exit 1
5142 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5143 $MAKE built_sources || func_exit 1
5145 $MAKE distclean || func_exit 1
5150 # func_create_megatestdir megatestdir allmodules
5152 # - local_gnulib_dir from --local-dir
5153 # - modcache true or false, from --cache-modules/--no-cache-modules
5154 # - auxdir directory relative to destdir where to place build aux files
5155 func_create_megatestdir ()
5159 if test -z "$allmodules"; then
5160 allmodules=`func_all_modules`
5164 # First, all modules one by one.
5165 for onemodule in $allmodules; do
5166 func_create_testdir "$megatestdir/$onemodule" $onemodule
5167 func_append megasubdirs "$onemodule "
5169 # Then, all modules all together.
5170 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5171 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5172 func_create_testdir "$megatestdir/ALL" "$allmodules"
5173 func_append megasubdirs "ALL"
5176 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5177 vc_witness="$gnulib_dir/CVS/Entries"; \
5179 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5181 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5182 | sed -e 's,January,01,' -e 's,Jan,01,' \
5183 -e 's,February,02,' -e 's,Feb,02,' \
5184 -e 's,March,03,' -e 's,Mar,03,' \
5185 -e 's,April,04,' -e 's,Apr,04,' \
5187 -e 's,June,06,' -e 's,Jun,06,' \
5188 -e 's,July,07,' -e 's,Jul,07,' \
5189 -e 's,August,08,' -e 's,Aug,08,' \
5190 -e 's,September,09,' -e 's,Sep,09,' \
5191 -e 's,October,10,' -e 's,Oct,10,' \
5192 -e 's,November,11,' -e 's,Nov,11,' \
5193 -e 's,December,12,' -e 's,Dec,12,' \
5194 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5195 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5197 echo "CVSDATE=$cvsdate"
5198 echo ": \${MAKE=make}"
5199 echo "test -d logs || mkdir logs"
5200 echo "for module in $megasubdirs; do"
5201 echo " echo \"Working on module \$module...\""
5202 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5203 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5206 echo " : autobuild project... \$module"
5207 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5208 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5209 echo " : autobuild hostname... \`hostname\`"
5210 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5212 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5214 ) > "$megatestdir/do-autobuild"
5215 chmod a+x "$megatestdir/do-autobuild"
5217 # Create Makefile.am.
5218 (echo "## Process this file with automake to produce Makefile.in."
5220 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5222 echo "SUBDIRS = $megasubdirs"
5224 echo "EXTRA_DIST = do-autobuild"
5225 ) > "$megatestdir/Makefile.am"
5227 # Create configure.ac.
5228 (echo "# Process this file with autoconf to produce a configure script."
5229 echo "AC_INIT([dummy], [0])"
5230 if test "$auxdir" != "."; then
5231 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5233 echo "AM_INIT_AUTOMAKE"
5235 echo "AC_PROG_MAKE_SET"
5237 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5238 echo "AC_CONFIG_FILES([Makefile])"
5240 ) > "$megatestdir/configure.ac"
5242 # Create autogenerated files.
5244 # Do not use "${AUTORECONF} --install", because autoreconf operates
5245 # recursively, but the subdirectories are already finished, therefore
5246 # calling autoreconf here would only waste lots of CPU time.
5247 func_execute_command ${ACLOCAL} || func_exit 1
5248 func_execute_command mkdir build-aux
5249 func_execute_command ${AUTOCONF} || func_exit 1
5250 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5256 func_fatal_error "no mode specified" ;;
5263 # sed expression that converts a literal to a basic regular expression.
5264 # Needs to handle . [ \ * ^ $.
5265 sed_literal_to_basic_regex='s/\\/\\\\/g
5271 if test -f "$gnulib_dir/$filename" \
5272 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5273 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5274 filename_line_regex='^'"$filename_anywhere_regex"'$'
5277 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5278 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5279 (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$,,')
5282 | func_sanitize_modulelist \
5285 for module in $module_candidates; do
5286 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5291 func_warning "file $filename does not exist"
5299 if test -z "$destdir"; then
5302 test -d "$destdir" \
5303 || func_fatal_error "destination directory does not exist: $destdir"
5305 # Prefer configure.ac to configure.in.
5306 if test -f "$destdir"/configure.ac; then
5307 configure_ac="$destdir/configure.ac"
5309 if test -f "$destdir"/configure.in; then
5310 configure_ac="$destdir/configure.in"
5312 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5316 # Analyze configure.ac.
5318 guessed_libtool=false
5323 /AC_CONFIG_AUX_DIR/ {
5324 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5326 /A[CM]_PROG_LIBTOOL/ {
5327 s,^.*$,guessed_libtool=true,p
5329 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5331 if test -z "$auxdir"; then
5332 auxdir="$guessed_auxdir"
5335 # Determine where to apply func_import.
5336 if test -n "$m4base"; then
5337 # Apply func_import to a particular gnulib directory.
5338 # Any number of additional modules can be given.
5339 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5340 # First use of gnulib in the given m4base.
5341 test -n "$supplied_libname" || supplied_libname=true
5342 test -n "$sourcebase" || sourcebase="lib"
5343 test -n "$docbase" || docbase="doc"
5344 test -n "$testsbase" || testsbase="tests"
5345 test -n "$macro_prefix" || macro_prefix="gl"
5349 # Apply func_import to all gnulib directories.
5350 # To get this list of directories, look at Makefile.am. (Not at
5351 # configure, because it may be omitted from CVS. Also, don't run
5352 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5355 if test -f "$destdir"/Makefile.am; then
5356 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5358 for arg in $aclocal_amflags; do
5359 if test -n "$m4dir_is_next"; then
5360 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5364 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5365 func_append m4dirs " $arg"
5366 m4dirs_count=`expr $m4dirs_count + 1`
5372 if test "X$arg" = "X-I"; then
5380 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5381 if test -f "$destdir"/aclocal.m4; then
5382 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5383 sedexpr2='s,^[^/]*$,.,'
5384 sedexpr3='s,/[^/]*$,,'
5385 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5386 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5389 if test $m4dirs_count = 0; then
5390 # First use of gnulib in a package.
5391 # Any number of additional modules can be given.
5392 test -n "$supplied_libname" || supplied_libname=true
5393 test -n "$sourcebase" || sourcebase="lib"
5395 test -n "$docbase" || docbase="doc"
5396 test -n "$testsbase" || testsbase="tests"
5397 test -n "$macro_prefix" || macro_prefix="gl"
5400 if test $m4dirs_count = 1; then
5401 # There's only one use of gnulib here. Assume the user means it.
5402 # Any number of additional modules can be given.
5403 for m4base in $m4dirs; do
5407 # Ambiguous - guess what the user meant.
5408 if test $# = 0; then
5409 # No further arguments. Guess the user wants to update all of them.
5410 for m4base in $m4dirs; do
5411 # Perform func_import in a subshell, so that variable values
5413 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5414 # inc_longrunning_tests, inc_privileged_tests,
5415 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5416 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5417 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5418 # don't propagate from one directory to another.
5419 (func_import) || func_exit 1
5423 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5431 if test -z "$destdir"; then
5432 func_fatal_error "please specify --dir option"
5435 test -d "$destdir" \
5436 || func_fatal_error "could not create destination directory"
5437 test -n "$auxdir" || auxdir="build-aux"
5438 func_create_testdir "$destdir" "$*"
5441 create-megatestdir )
5442 if test -z "$destdir"; then
5443 func_fatal_error "please specify --dir option"
5445 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5446 test -n "$auxdir" || auxdir="build-aux"
5447 func_create_megatestdir "$destdir" "$*"
5451 test -n "$destdir" || destdir=testdir$$
5452 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5453 test -n "$auxdir" || auxdir="build-aux"
5454 func_create_testdir "$destdir" "$*"
5458 ../configure || func_exit 1
5459 $MAKE || func_exit 1
5460 $MAKE check || func_exit 1
5461 $MAKE distclean || func_exit 1
5462 remaining=`find . -type f -print`
5463 if test -n "$remaining"; then
5464 echo "Remaining files:" $remaining 1>&2
5465 echo "gnulib-tool: *** Stop." 1>&2
5474 test -n "$destdir" || destdir=testdir$$
5475 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5476 test -n "$auxdir" || auxdir="build-aux"
5477 func_create_megatestdir "$destdir" "$*"
5485 remaining=`find . -type f -print`
5486 if test -n "$remaining"; then
5487 echo "Remaining files:" $remaining 1>&2
5488 echo "gnulib-tool: *** Stop." 1>&2
5496 extract-description )
5500 if test -n "$module"; then
5501 func_get_description "$module"
5510 if test -n "$module"; then
5511 func_get_comment "$module"
5520 if test -n "$module"; then
5521 func_get_status "$module"
5530 if test -n "$module"; then
5531 func_get_notice "$module"
5536 extract-applicability )
5540 if test -n "$module"; then
5541 func_get_applicability "$module"
5550 if test -n "$module"; then
5551 func_get_filelist "$module"
5556 extract-dependencies )
5560 if test -n "$module"; then
5561 func_get_dependencies "$module"
5566 extract-autoconf-snippet )
5570 if test -n "$module"; then
5571 func_get_autoconf_snippet "$module"
5576 extract-automake-snippet )
5580 if test -n "$module"; then
5581 func_get_automake_snippet "$module"
5586 extract-include-directive )
5590 if test -n "$module"; then
5591 func_get_include_directive "$module"
5596 extract-link-directive )
5600 if test -n "$module"; then
5601 func_get_link_directive "$module"
5610 if test -n "$module"; then
5611 func_get_license "$module"
5616 extract-maintainer )
5620 if test -n "$module"; then
5621 func_get_maintainer "$module"
5626 extract-tests-module )
5630 if test -n "$module"; then
5631 func_get_tests_module "$module"
5637 # Verify the number of arguments.
5638 if test $# -lt 1 || test $# -gt 2; then
5639 func_fatal_error "invalid number of arguments for --$mode"
5642 # The first argument is the file to be copied.
5644 # Verify the file exists.
5645 func_lookup_file "$f"
5647 # The second argument is the destination; either a directory ot a file.
5648 # It defaults to the current directory.
5650 test -n "$dest" || dest='.'
5651 test -n "$sourcebase" || sourcebase="lib"
5652 test -n "$m4base" || m4base="m4"
5653 test -n "$docbase" || docbase="doc"
5654 test -n "$testsbase" || testsbase="tests"
5655 test -n "$auxdir" || auxdir="build-aux"
5656 rewritten='%REWRITTEN%'
5657 sed_rewrite_files="\
5658 s,^build-aux/,$rewritten$auxdir/,
5659 s,^doc/,$rewritten$docbase/,
5660 s,^lib/,$rewritten$sourcebase/,
5661 s,^m4/,$rewritten$m4base/,
5662 s,^tests/,$rewritten$testsbase/,
5665 if test -d "$dest"; then
5667 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5669 destdir=`dirname "$dest"`
5670 g=`basename "$dest"`
5673 # Create the directory for destfile.
5674 d=`dirname "$destdir/$g"`
5676 if test -n "$d" && test ! -d "$d"; then
5677 mkdir -p "$d" || func_fatal_error "failed"
5681 func_dest_tmpfilename "$g"
5682 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5683 already_present=true
5684 if test -f "$destdir/$g"; then
5685 # The file already exists.
5689 # Don't protest if the file should be there but isn't: it happens
5690 # frequently that developers don't put autogenerated files into CVS.
5697 func_fatal_error "unknown operation mode --$mode" ;;
5701 # Undo the effect of the previous 'trap' command. Some shellology:
5702 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5703 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5704 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5705 # 128 + signal number and is set before the trap-registered command is run.
5707 trap 'func_exit $?' 1 2 3 13 15
5712 # indent-tabs-mode: nil
5713 # whitespace-check-buffer-indent: nil