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 or not)
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 --vc-files Update version control related files.
237 --no-vc-files Don't update version control related files
238 (.gitignore and/or .cvsignore).
239 --no-changelog Don't update or create ChangeLog files.
241 Options for --import, --update, --create-[mega]testdir, --[mega]test:
242 -s, --symbolic, --symlink Make symbolic links instead of copying files.
243 --local-symlink Make symbolic links instead of copying files, only
244 for files from the local override directory.
246 Options for --import, --update:
247 -S, --more-symlinks Make symbolic links instead of copying files, and
248 don't replace copyright notices.
250 Report bugs to <bug-gnulib@gnu.org>."
254 # outputs to stdout the --version message.
258 if test -d "$gnulib_dir"/.git \
259 && (git --version) >/dev/null 2>/dev/null \
260 && (date --version) >/dev/null 2>/dev/null; then
261 # gnulib checked out from git.
262 sed_extract_first_date='/^Date/{
266 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
267 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
268 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
269 date=`echo "$date" | sed -e "$sed_year_before_time"`
270 # Use GNU date to compute the time in GMT.
271 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
272 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
274 if test -d "$gnulib_dir"/CVS \
275 && (cvs --version) >/dev/null 2>/dev/null; then
276 # gnulib checked out from CVS.
277 sed_extract_first_date='/^date: /{
278 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
281 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
283 # gnulib copy without versioning information.
284 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
288 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
290 gnulib-tool (GNU $package $date)$version
291 Copyright (C) $year Free Software Foundation, Inc.
292 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
293 This is free software: you are free to change and redistribute it.
294 There is NO WARRANTY, to the extent permitted by law.
296 Written by" "Bruno Haible" "and" "Simon Josefsson"
299 # func_emit_copyright_notice
300 # outputs to stdout a header for a generated file.
301 func_emit_copyright_notice ()
303 sed -n -e '/Copyright/ {
306 }' < "$self_abspathname"
308 echo "# This file is free software, distributed under the terms of the GNU"
309 echo "# General Public License. As a special exception to the GNU General"
310 echo "# Public License, this file may be distributed as part of a program"
311 echo "# that contains a configuration script generated by Autoconf, under"
312 echo "# the same distribution terms as the rest of that program."
314 echo "# Generated by gnulib-tool."
318 # exits with a given status.
319 # This function needs to be used, rather than 'exit', when a 'trap' handler is
320 # in effect that refers to $?.
327 # locates the directory where the gnulib repository lives
329 # - progname name of this program
331 # - self_abspathname absolute pathname of gnulib-tool
332 # - gnulib_dir absolute pathname of gnulib repository
336 /*) self_abspathname="$progname" ;;
337 */*) self_abspathname=`pwd`/"$progname" ;;
340 # Iterate through the elements of $PATH.
341 # We use IFS=: instead of
342 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
343 # because the latter does not work when some PATH element contains spaces.
344 # We use a canonicalized $pathx instead of $PATH, because empty PATH
345 # elements are by definition equivalent to '.', however field splitting
346 # according to IFS=: loses empty fields in many shells:
347 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
348 # beginning, at the end, and in the middle),
349 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
350 # at the beginning and at the end,
351 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
352 # Solaris lose empty fields at the end.
353 # The 'case' statement is an optimization, to avoid evaluating the
354 # explicit canonicalization command when $PATH contains no empty fields.
356 if test "${PATH_SEPARATOR+set}" != set; then
358 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
359 chmod +x "$tmp"/conf.sh
360 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
367 if test "$PATH_SEPARATOR" = ";"; then
368 # On Windows, programs are searched in "." before $PATH.
371 # On Unix, we have to convert empty PATH elements to ".".
375 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
380 IFS="$PATH_SEPARATOR"
384 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
385 self_abspathname="$d/$progname"
390 if test -z "$self_abspathname"; then
391 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
395 while test -h "$self_abspathname"; do
396 # Resolve symbolic link.
397 linkval=`func_readlink "$self_abspathname"`
398 test -n "$linkval" || break
400 /* ) self_abspathname="$linkval" ;;
401 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
404 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
408 # creates a temporary directory.
410 # - progname name of this program
412 # - tmp pathname of freshly created temporary directory
415 # Use the environment variable TMPDIR, falling back to /tmp. This allows
416 # users to specify a different temporary directory, for example, if their
417 # /tmp is filled up or too small.
420 # Use the mktemp program if available. If not available, hide the error
422 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
423 test -n "$tmp" && test -d "$tmp"
426 # Use a simple mkdir command. It is guaranteed to fail if the directory
427 # already exists. $RANDOM is bash specific and expands to empty in shells
428 # other than bash, ksh and zsh. Its use does not increase security;
429 # rather, it minimizes the probability of failure in a very cluttered /tmp
431 tmp=$TMPDIR/gl$$-$RANDOM
432 (umask 077 && mkdir "$tmp")
435 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
440 # func_append var value
441 # appends the given value to the shell variable var.
442 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
443 # Use bash's += operator. It reduces complexity of appending repeatedly to
444 # a single variable from O(n^2) to O(n).
449 fast_func_append=true
453 eval "$1=\"\$$1\$2\""
455 fast_func_append=false
458 # func_remove_prefix var prefix
459 # removes the given prefix from the value of the shell variable var.
460 # var should be the name of a shell variable.
461 # Its value should not contain a newline and not start or end with whitespace.
462 # prefix should not contain the characters "$`\{}[]^|.
463 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
464 func_remove_prefix ()
468 fast_func_remove_prefix=true
470 func_remove_prefix ()
472 eval "value=\"\$$1\""
476 sed_escape_dots='s/\([.]\)/\\\1/g'
477 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
480 value=`echo "$value" | sed -e "s|^${prefix}||"`
481 eval "$1=\"\$value\""
483 fast_func_remove_prefix=false
486 # func_remove_suffix var suffix
487 # removes the given suffix from the value of the shell variable var.
488 # var should be the name of a shell variable.
489 # Its value should not contain a newline and not start or end with whitespace.
490 # suffix should not contain the characters "$`\{}[]^|.
491 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
492 func_remove_suffix ()
496 fast_func_remove_suffix=true
498 func_remove_suffix ()
500 eval "value=\"\$$1\""
504 sed_escape_dots='s/\([.]\)/\\\1/g'
505 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
508 value=`echo "$value" | sed -e "s|${suffix}\$||"`
509 eval "$1=\"\$value\""
511 fast_func_remove_suffix=false
514 # func_fatal_error message
515 # outputs to stderr a fatal error message, and terminates the program.
517 # - progname name of this program
520 echo "$progname: *** $1" 1>&2
521 echo "$progname: *** Stop." 1>&2
525 # func_warning message
526 # Outputs to stderr a warning message,
529 echo "gnulib-tool: warning: $1" 1>&2
532 # func_readlink SYMLINK
533 # outputs the target of the given symlink.
534 if (type -p readlink) > /dev/null 2>&1; then
537 # Use the readlink program from GNU coreutils.
543 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
544 # would do the wrong thing if the link target contains " -> ".
545 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
549 # func_relativize DIR1 DIR2
550 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
552 # - DIR1 relative pathname, relative to the current directory
553 # - DIR2 relative pathname, relative to the current directory
555 # - reldir relative pathname of DIR2, relative to DIR1
561 sed_first='s,^\([^/]*\)/.*$,\1,'
562 sed_rest='s,^[^/]*/*,,'
563 sed_last='s,^.*/\([^/]*\)$,\1,'
564 sed_butlast='s,/*[^/]*$,,'
565 while test -n "$dir1"; do
566 first=`echo "$dir1" | sed -e "$sed_first"`
567 if test "$first" != "."; then
568 if test "$first" = ".."; then
569 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
570 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
572 first2=`echo "$dir2" | sed -e "$sed_first"`
573 if test "$first2" = "$first"; then
574 dir2=`echo "$dir2" | sed -e "$sed_rest"`
578 dir0="$dir0"/"$first"
581 dir1=`echo "$dir1" | sed -e "$sed_rest"`
586 # func_relconcat DIR1 DIR2
587 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
589 # - DIR1 relative pathname, relative to the current directory
590 # - DIR2 relative pathname, relative to DIR1
592 # - relconcat DIR1/DIR2, relative to the current directory
597 sed_first='s,^\([^/]*\)/.*$,\1,'
598 sed_rest='s,^[^/]*/*,,'
599 sed_last='s,^.*/\([^/]*\)$,\1,'
600 sed_butlast='s,/*[^/]*$,,'
602 first=`echo "$dir2" | sed -e "$sed_first"`
603 if test "$first" = "."; then
604 dir2=`echo "$dir2" | sed -e "$sed_rest"`
605 if test -z "$dir2"; then
610 last=`echo "$dir1" | sed -e "$sed_last"`
611 while test "$last" = "."; do
612 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
613 last=`echo "$dir1" | sed -e "$sed_last"`
615 if test -z "$dir1"; then
619 if test "$first" = ".."; then
620 if test "$last" = ".."; then
621 relconcat="$dir1/$dir2"
624 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
625 dir2=`echo "$dir2" | sed -e "$sed_rest"`
626 if test -z "$dir1"; then
630 if test -z "$dir2"; then
635 relconcat="$dir1/$dir2"
643 # Like ln -s, except that SRC is given relative to the current directory (or
644 # absolute), not given relative to the directory of DEST.
650 *) # SRC is relative.
653 ln -s "`pwd`/$1" "$2" ;;
654 *) # DEST is relative too.
655 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
656 test -n "$ln_destdir" || ln_destdir="."
657 func_relativize "$ln_destdir" "$1"
665 # func_ln_if_changed SRC DEST
666 # Like func_ln, but avoids munging timestamps if the link is correct.
667 func_ln_if_changed ()
669 if test $# -ne 2; then
670 echo "usage: func_ln_if_changed SRC DEST" >&2
672 ln_target=`func_readlink "$2"`
673 if test -h "$2" && test "$1" = "$ln_target"; then
681 # Ensure an 'echo' command that
682 # 1. does not interpret backslashes and
683 # 2. does not print an error message "broken pipe" when writing into a pipe
686 # Test cases for problem 1:
687 # echo '\n' | wc -l prints 1 when OK, 2 when KO
688 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
689 # Test cases for problem 2:
690 # echo hi | true frequently prints
691 # "bash: echo: write error: Broken pipe"
692 # to standard error in bash 3.2.
694 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
695 # BSD echo interprets '-n' as an option, which is also not desirable).
696 # Nowadays the problem occurs in 4 situations:
697 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
698 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
699 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
700 # - in zsh, when sh-emulation is not set,
701 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
702 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
703 # - in Solaris /bin/sh and OSF/1 /bin/sh.
704 # We try the following workarounds:
705 # - for all: respawn using $CONFIG_SHELL if that is set and works.
706 # - for bash >= 2.04: unset the shell option xpg_echo.
707 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
708 # - for bash < 2.0: define echo to a function that uses cat of a here document.
709 # - for zsh: turn sh-emulation on.
710 # - for ksh: alias echo to 'print -r'.
711 # - for ksh: alias echo to a function that uses cat of a here document.
712 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
713 # the ksh workaround.
714 # - otherwise: respawn using /bin/sh and rely on the workarounds.
715 # When respawning, we pass --no-reexec as first argument, so as to avoid
716 # turning this script into a fork bomb in unlucky situations.
718 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
719 # the 'printf' built-in. See
720 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
721 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
722 # The workaround is: define echo to a function that uses the printf built-in.
724 if echo '\t' | grep t > /dev/null; then
725 have_echo=yes # Lucky!
727 # Try the workarounds.
728 # Respawn using $CONFIG_SHELL if that is set and works.
729 if test -z "$have_echo" \
730 && test "X$1" != "X--no-reexec" \
731 && test -n "$CONFIG_SHELL" \
732 && test -f "$CONFIG_SHELL" \
733 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
734 exec $CONFIG_SHELL "$0" --no-reexec "$@"
737 # For bash >= 2.04: unset the shell option xpg_echo.
738 if test -z "$have_echo" \
739 && test -n "$BASH_VERSION" \
740 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
744 # For bash >= 2.0: define echo to a function that uses the printf built-in.
745 # For bash < 2.0: define echo to a function that uses cat of a here document.
746 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
747 # Also handle problem 2, specific to bash 3.2, here.
748 if { test -z "$have_echo" \
749 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
751 && test -n "$BASH_VERSION"; then \
752 if type printf 2>/dev/null | grep / > /dev/null; then
753 # 'printf' is not a shell built-in.
761 # 'printf' is a shell built-in.
767 if echo '\t' | grep t > /dev/null; then
771 # For zsh: turn sh-emulation on.
772 if test -z "$have_echo" \
773 && test -n "$ZSH_VERSION" \
774 && (emulate sh) >/dev/null 2>&1; then
777 # For ksh: alias echo to 'print -r'.
778 if test -z "$have_echo" \
779 && (type print) >/dev/null 2>&1; then
780 # A 'print' command exists.
781 if type print 2>/dev/null | grep / > /dev/null; then
784 # 'print' is a shell built-in.
785 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
786 # 'print' is the ksh shell built-in.
787 alias echo='print -r'
791 if test -z "$have_echo" \
792 && echo '\t' | grep t > /dev/null; then
795 # For ksh: alias echo to a function that uses cat of a here document.
796 # The ksh manual page says:
797 # "Aliasing is performed when scripts are read, not while they are executed.
798 # Therefore, for an alias to take effect, the alias definition command has
799 # to be executed before the command which references the alias is read."
800 # Because of this, we have to play strange tricks with have_echo, to ensure
801 # that the top-level statement containing the test starts after the 'alias'
803 if test -z "$have_echo"; then
810 alias echo=bsd_echo 2>/dev/null
812 if test -z "$have_echo" \
813 && echo '\t' | grep t > /dev/null; then
816 if test -z "$have_echo"; then
817 unalias echo 2>/dev/null
819 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
820 if test -z "$have_echo" \
821 && test "X$1" != "X--no-reexec" \
822 && test -f /bin/ksh; then
823 exec /bin/ksh "$0" --no-reexec "$@"
826 # Otherwise: respawn using /bin/sh.
827 if test -z "$have_echo" \
828 && test "X$1" != "X--no-reexec" \
829 && test -f /bin/sh; then
830 exec /bin/sh "$0" --no-reexec "$@"
833 if test -z "$have_echo"; then
834 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
836 if echo '\t' | grep t > /dev/null; then
839 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
841 if test "X$1" = "X--no-reexec"; then
845 # Command-line option processing.
846 # Removes the OPTIONS from the arguments. Sets the variables:
847 # - mode list or import or create-testdir or create-megatestdir
848 # - destdir from --dir
849 # - local_gnulib_dir from --local-dir
850 # - modcache true or false, from --cache-modules/--no-cache-modules
851 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
852 # - libname, supplied_libname from --lib
853 # - sourcebase from --source-base
854 # - m4base from --m4-base
855 # - pobase from --po-base
856 # - docbase from --doc-base
857 # - testsbase from --tests-base
858 # - auxdir from --aux-dir
859 # - inctests true if --with-tests was given, blank otherwise
860 # - incobsolete true if --with-obsolete was given, blank otherwise
861 # - avoidlist list of modules to avoid, from --avoid
862 # - lgpl yes or a number if --lgpl was given, blank otherwise
863 # - makefile_name from --makefile-name
864 # - libtool true if --libtool was given, false if --no-libtool was
865 # given, blank otherwise
866 # - macro_prefix from --macro-prefix
867 # - po_domain from --po-domain
868 # - vc_files true if --vc-files was given, false if --no-vc-files was
869 # given, blank otherwise
870 # - autoconf_minversion minimum supported autoconf version
871 # - do_changelog false if --no-changelog was given, : otherwise
872 # - doit : if actions shall be executed, false if only to be printed
873 # - symbolic true if --symlink or --more-symlinks was given, blank
875 # - lsymbolic true if --local-symlink was given, blank otherwise
876 # - do_copyrights blank if --more-symlinks was given, true otherwise
908 while test $# -gt 0; do
913 --find | --fin | --fi | --f )
916 --import | --impor | --impo | --imp | --im | --i )
919 --update | --updat | --upda | --upd | --up | --u )
922 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
925 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
926 mode=create-megatestdir
928 --test | --tes | --te | --t )
931 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
935 mode=`echo "X$1" | sed -e 's/^X--//'`
937 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
943 func_fatal_error "missing argument for --dir"
948 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
953 func_fatal_error "missing argument for --local-dir"
958 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
960 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
963 --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 )
966 --verbose | --verbos | --verbo | --verb )
967 verbose=`expr $verbose + 1`
969 --quiet | --quie | --qui | --qu | --q )
970 verbose=`expr $verbose - 1`
975 func_fatal_error "missing argument for --lib"
978 supplied_libname=true
981 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
982 supplied_libname=true
987 func_fatal_error "missing argument for --source-base"
992 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
997 func_fatal_error "missing argument for --m4-base"
1002 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1006 if test $# = 0; then
1007 func_fatal_error "missing argument for --po-base"
1012 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1016 if test $# = 0; then
1017 func_fatal_error "missing argument for --doc-base"
1022 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1026 if test $# = 0; then
1027 func_fatal_error "missing argument for --tests-base"
1032 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1036 if test $# = 0; then
1037 func_fatal_error "missing argument for --aux-dir"
1042 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1052 if test $# = 0; then
1053 func_fatal_error "missing argument for --avoid"
1055 func_append avoidlist " $1"
1058 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1059 func_append avoidlist " $arg"
1065 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1068 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1074 if test $# = 0; then
1075 func_fatal_error "missing argument for --makefile-name"
1080 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1090 if test $# = 0; then
1091 func_fatal_error "missing argument for --macro-prefix"
1096 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1100 if test $# = 0; then
1101 func_fatal_error "missing argument for --po-domain"
1106 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1114 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1120 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1123 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1126 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1130 --help | --hel | --he | --h )
1133 --version | --versio | --versi | --vers )
1137 # Stop option processing
1141 echo "gnulib-tool: unknown option $1" 1>&2
1142 echo "Try 'gnulib-tool --help' for more information." 1>&2
1149 if test "$mode" = update; then
1150 if test $# != 0; then
1151 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1152 echo "Try 'gnulib-tool --help' for more information." 1>&2
1153 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1154 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1157 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1158 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1159 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1160 || test -n "$inctests" || test -n "$incobsolete" \
1161 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1162 || test -n "$macro_prefix" || test -n "$po_domain" \
1163 || test -n "$vc_files"; then
1164 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1165 echo "Try 'gnulib-tool --help' for more information." 1>&2
1166 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1167 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1172 if test -n "$pobase" && test -z "$po_domain"; then
1173 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1174 echo "Try 'gnulib-tool --help' for more information." 1>&2
1177 if test -z "$pobase" && test -n "$po_domain"; then
1178 func_warning "--po-domain has no effect without a --po-base option"
1181 # Determine the minimum supported autoconf version from the project's
1183 DEFAULT_AUTOCONF_MINVERSION="2.59"
1184 autoconf_minversion=
1186 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1187 if test -f "$destdir"/configure.ac; then
1188 configure_ac="$destdir/configure.ac"
1190 if test -f "$destdir"/configure.in; then
1191 configure_ac="$destdir/configure.in"
1195 if test -f configure.ac; then
1196 configure_ac="configure.ac"
1198 if test -f configure.in; then
1199 configure_ac="configure.in"
1203 if test -n "$configure_ac"; then
1204 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1205 # because when some m4 files are omitted from a CVS repository,
1206 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1207 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1208 # autom4te: m4 failed with exit status: 1
1215 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1217 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1218 if test -n "$prereqs"; then
1219 autoconf_minversion=`
1220 for version in $prereqs; do echo $version; done |
1221 LC_ALL=C sort -nru | sed -e 1q
1225 if test -z "$autoconf_minversion"; then
1226 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1228 case "$autoconf_minversion" in
1229 1.* | 2.[0-4]* | 2.5[0-8]*)
1230 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1233 # Remove trailing slashes from the directory names. This is necessary for
1234 # m4base (to avoid an error in func_import) and optional for the others.
1235 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1236 case "$local_gnulib_dir" in
1237 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1239 case "$sourcebase" in
1240 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1243 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1246 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1249 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1251 case "$testsbase" in
1252 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1255 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1261 trap 'exit_status=$?
1262 if test "$signal" != 0; then
1263 echo "caught signal $signal" >&2
1266 exit $exit_status' 0
1267 for signal in 1 2 3 13 15; do
1268 trap '{ signal='$signal'; func_exit 1; }' $signal
1272 # func_lookup_file file
1273 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1276 # - local_gnulib_dir from --local-dir
1278 # - lookedup_file name of the merged (combined) file
1279 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1283 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1284 lookedup_file="$local_gnulib_dir/$lkfile"
1287 if test -f "$gnulib_dir/$lkfile"; then
1288 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1289 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1290 rm -f "$tmp/$lkbase"
1291 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1292 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1293 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1294 lookedup_file="$tmp/$lkbase"
1297 lookedup_file="$gnulib_dir/$lkfile"
1301 func_fatal_error "file $gnulib_dir/$lkfile not found"
1306 # func_sanitize_modulelist
1307 # receives a list of possible module names on standard input, one per line.
1308 # It removes those which are just file names unrelated to modules, and outputs
1309 # the resulting list to standard output, one per line.
1310 func_sanitize_modulelist ()
1312 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1313 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1314 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1315 -e '/^README$/d' -e '/\/README$/d' \
1316 -e '/^TEMPLATE$/d' \
1317 -e '/^TEMPLATE-EXTENDED$/d' \
1318 -e '/^TEMPLATE-TESTS$/d' \
1325 # - local_gnulib_dir from --local-dir
1328 # Filter out metainformation files like README, which are not modules.
1329 # Filter out unit test modules; they can be retrieved through
1330 # --extract-tests-module if desired.
1332 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1333 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1334 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1337 | func_sanitize_modulelist \
1338 | sed -e '/-tests$/d' \
1342 # func_verify_module
1343 # verifies a module name
1345 # - local_gnulib_dir from --local-dir
1346 # - module module name argument
1347 func_verify_module ()
1349 if { test -f "$gnulib_dir/modules/$module" \
1350 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1351 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1352 && test "CVS" != "$module" \
1353 && test "ChangeLog" != "$module" \
1354 && test "COPYING" != "$module" \
1355 && test "README" != "$module" \
1356 && test "TEMPLATE" != "$module" \
1357 && test "TEMPLATE-EXTENDED" != "$module" \
1358 && test "TEMPLATE-TESTS" != "$module"; then
1359 # OK, $module is a correct module name.
1360 # Verify that building the module description with 'patch' succeeds.
1361 func_lookup_file "modules/$module"
1363 func_warning "module $module doesn't exist"
1368 # func_verify_nontests_module
1369 # verifies a module name, excluding tests modules
1371 # - local_gnulib_dir from --local-dir
1372 # - module module name argument
1373 func_verify_nontests_module ()
1376 *-tests ) module= ;;
1377 * ) func_verify_module ;;
1381 # func_verify_tests_module
1382 # verifies a module name, considering only tests modules
1384 # - local_gnulib_dir from --local-dir
1385 # - module module name argument
1386 func_verify_tests_module ()
1389 *-tests ) func_verify_module ;;
1394 # Suffix of a sed expression that extracts a particular field from a
1395 # module description.
1396 # A field starts with a line that contains a keyword, such as 'Description',
1397 # followed by a colon and optional whitespace. All following lines, up to
1398 # the next field (or end of file if there is none) form the contents of the
1400 # An absent field is equivalent to a field with empty contents.
1401 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1402 sed_extract_prog=':[ ]*$/ {
1405 s/^Description:[ ]*$//
1409 s/^Applicability:[ ]*$//
1411 s/^Depends-on:[ ]*$//
1412 s/^configure\.ac-early:[ ]*$//
1413 s/^configure\.ac:[ ]*$//
1414 s/^Makefile\.am:[ ]*$//
1418 s/^Maintainer:[ ]*$//
1425 # Piece of a sed expression that converts a field header line to a shell
1427 # NOTE: Keep this in sync with sed_extract_prog above!
1428 sed_extract_field_header='
1429 s/^Description:[ ]*$/description/
1430 s/^Comment:[ ]*$/comment/
1431 s/^Status:[ ]*$/status/
1432 s/^Notice:[ ]*$/notice/
1433 s/^Applicability:[ ]*$/applicability/
1434 s/^Files:[ ]*$/files/
1435 s/^Depends-on:[ ]*$/dependson/
1436 s/^configure\.ac-early:[ ]*$/configureac_early/
1437 s/^configure\.ac:[ ]*$/configureac/
1438 s/^Makefile\.am:[ ]*$/makefile/
1439 s/^Include:[ ]*$/include/
1441 s/^License:[ ]*$/license/
1442 s/^Maintainer:[ ]*$/maintainer/'
1446 # Note: The 'eval' silences stderr output in dash.
1447 if declare -A x 2>/dev/null && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }; then
1448 # Zsh 4 and Bash 4 have associative arrays.
1449 have_associative=true
1451 # For other shells, use 'eval' with computed shell variable names.
1452 have_associative=false
1455 if $have_associative; then
1457 # Declare the associative arrays.
1458 declare -A modcache_cached
1459 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1460 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1461 eval "$declare_script"
1465 # func_cache_var module
1466 # computes the cache variable name corresponding to $module.
1467 # Note: This computation can map different module names to the same
1468 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1469 # to protect against this case.
1471 # - cachevar a shell variable name
1472 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1473 # Bash 2.0 and newer, ksh, and zsh support the syntax
1474 # ${param//pattern/replacement}
1475 # as a shorthand for
1476 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1477 # Note: The 'eval' above silences stderr output in dash.
1480 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1487 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1496 # func_init_sed_convert_to_cache_statements
1498 # - modcachevar_assignment
1500 # - sed_convert_to_cache_statements
1501 func_init_sed_convert_to_cache_statements ()
1503 # 'sed' script that turns a module description into shell script
1504 # assignments, suitable to be eval'ed. All active characters are escaped.
1507 # Some module's description
1512 # modcache_description[$1]=\
1513 # 'Some module'"'"'s description
1515 # modcache_files[$1]=\
1518 # c_MODULE_description_set=set; c_MODULE_description=\
1519 # 'Some module'"'"'s description
1521 # c_MODULE_files_set=set; c_MODULE_files=\
1523 # The script consists of two parts:
1524 # 1) Ignore the lines before the first field header.
1525 # 2) A loop, treating non-field-header lines by escaping single quotes
1526 # and adding a closing quote in the last line,
1527 sed_convert_to_cache_statements="
1529 # Here we have not yet seen a field header.
1531 # See if the current line contains a field header.
1534 ${sed_extract_field_header}
1537 # No field header. Ignore the line.
1539 # Read the next line. Upon EOF, just exit.
1544 # The current line contains a field header.
1546 # Turn it into the beginning of an assignment.
1547 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1549 # Move it to the hold space. Don't print it yet,
1550 # because we want no assignment if the field is empty.
1553 # Read the next line.
1554 # Upon EOF, the field was empty. Print no assignment. Just exit.
1557 # See if the current line contains a field header.
1560 ${sed_extract_field_header}
1561 # If it is, the previous field was empty. Print no assignment.
1564 # Not a field header.
1566 # Print the previous line, held in the hold space.
1571 # Transform single quotes.
1574 # Prepend a single quote.
1579 # Move it to the hold space.
1582 # Read the next line.
1589 # See if the current line contains a field header.
1592 ${sed_extract_field_header}
1595 # Print the previous line, held in the hold space.
1600 # Transform single quotes.
1607 # Print the previous line, held in the hold space, with a single quote
1608 # to end the assignment.
1618 # Print the previous line, held in the hold space, with a single quote
1619 # to end the assignment.
1626 if ! $sed_comments; then
1628 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1629 | sed -e 's/^ *//' -e 's/^#.*//'`
1633 if $have_associative; then
1634 # sed_convert_to_cache_statements does not depend on the module.
1635 modcachevar_assignment='modcache_\1[$1]='
1636 func_init_sed_convert_to_cache_statements
1639 # func_cache_lookup_module module
1641 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1642 # of its relevant data in a cache in the memory of the processing shell. If
1643 # already cached, it does not look it up again, thus saving file access time.
1645 # - module non-empty string
1646 # Output if $have_associative:
1647 # - modcache_cached[$module] set to yes
1648 # - modcache_description[$module] ==
1649 # - modcache_status[$module] \ set to the field's value, minus the
1650 # - ... / final newline,
1651 # - modcache_maintainer[$module] == or unset if the field's value is empty
1652 # Output if ! $have_associative:
1653 # - cachevar a shell variable name
1654 # - ${cachevar}_cached set to $module
1655 # - ${cachevar}_description ==
1656 # - ${cachevar}_status \ set to the field's value, minus the
1657 # - ... / final newline,
1658 # - ${cachevar}_maintainer == or unset if the field's value is empty
1659 # - ${cachevar}_description_set ==
1660 # - ${cachevar}_status_set \ set to non-empty if the field's value
1661 # - ... / is non-empty,
1662 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1663 func_cache_lookup_module ()
1665 if $have_associative; then
1666 cached=${modcache_cached[$1]}
1669 eval "cached=\"\$${cachevar}_cached\""
1671 if test -z "$cached"; then
1672 # Not found in cache. Look it up on the file system.
1673 func_lookup_file "modules/$1"
1674 if $have_associative; then
1675 modcache_cached[$1]=yes
1677 eval "${cachevar}_cached=\"\$1\""
1679 if ! $have_associative; then
1680 # sed_convert_to_cache_statements depends on the module.
1681 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1682 func_init_sed_convert_to_cache_statements
1684 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1685 eval "$cache_statements"
1687 if ! $have_associative; then
1688 if test "$1" != "$cached"; then
1689 func_fatal_error "cache variable collision between $1 and $cached"
1697 # func_get_description module
1699 # - local_gnulib_dir from --local-dir
1700 # - modcache true or false, from --cache-modules/--no-cache-modules
1701 func_get_description ()
1703 if ! $modcache; then
1704 func_lookup_file "modules/$1"
1705 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1707 func_cache_lookup_module "$1"
1708 # Output the field's value, including the final newline (if any).
1709 if $have_associative; then
1710 if test -n "${modcache_description[$1]+set}"; then
1711 echo "${modcache_description[$1]}"
1714 eval "field_set=\"\$${cachevar}_description_set\""
1715 if test -n "$field_set"; then
1716 eval "field_value=\"\$${cachevar}_description\""
1717 echo "${field_value}"
1723 # func_get_comment module
1725 # - local_gnulib_dir from --local-dir
1726 # - modcache true or false, from --cache-modules/--no-cache-modules
1729 if ! $modcache; then
1730 func_lookup_file "modules/$1"
1731 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1733 func_cache_lookup_module "$1"
1734 # Output the field's value, including the final newline (if any).
1735 if $have_associative; then
1736 if test -n "${modcache_comment[$1]+set}"; then
1737 echo "${modcache_comment[$1]}"
1740 eval "field_set=\"\$${cachevar}_comment_set\""
1741 if test -n "$field_set"; then
1742 eval "field_value=\"\$${cachevar}_comment\""
1743 echo "${field_value}"
1749 # func_get_status module
1751 # - local_gnulib_dir from --local-dir
1752 # - modcache true or false, from --cache-modules/--no-cache-modules
1755 if ! $modcache; then
1756 func_lookup_file "modules/$1"
1757 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1759 func_cache_lookup_module "$1"
1760 # Output the field's value, including the final newline (if any).
1761 if $have_associative; then
1762 if test -n "${modcache_status[$1]+set}"; then
1763 echo "${modcache_status[$1]}"
1766 eval "field_set=\"\$${cachevar}_status_set\""
1767 if test -n "$field_set"; then
1768 eval "field_value=\"\$${cachevar}_status\""
1769 echo "${field_value}"
1775 # func_get_notice module
1777 # - local_gnulib_dir from --local-dir
1778 # - modcache true or false, from --cache-modules/--no-cache-modules
1781 if ! $modcache; then
1782 func_lookup_file "modules/$1"
1783 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1785 func_cache_lookup_module "$1"
1786 # Output the field's value, including the final newline (if any).
1787 if $have_associative; then
1788 if test -n "${modcache_notice[$1]+set}"; then
1789 echo "${modcache_notice[$1]}"
1792 eval "field_set=\"\$${cachevar}_notice_set\""
1793 if test -n "$field_set"; then
1794 eval "field_value=\"\$${cachevar}_notice\""
1795 echo "${field_value}"
1801 # func_get_applicability module
1803 # - local_gnulib_dir from --local-dir
1804 # - modcache true or false, from --cache-modules/--no-cache-modules
1805 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1806 func_get_applicability ()
1808 if ! $modcache; then
1809 func_lookup_file "modules/$1"
1810 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1812 func_cache_lookup_module "$1"
1813 # Get the field's value, without the final newline.
1814 if $have_associative; then
1815 my_applicability="${modcache_applicability[$1]}"
1817 eval "my_applicability=\"\$${cachevar}_applicability\""
1820 if test -n "$my_applicability"; then
1821 echo $my_applicability
1823 # The default is 'main' or 'tests', depending on the module's name.
1825 *-tests) echo "tests";;
1831 # func_get_filelist module
1833 # - local_gnulib_dir from --local-dir
1834 # - modcache true or false, from --cache-modules/--no-cache-modules
1835 func_get_filelist ()
1837 if ! $modcache; then
1838 func_lookup_file "modules/$1"
1839 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1841 func_cache_lookup_module "$1"
1842 # Output the field's value, including the final newline (if any).
1843 if $have_associative; then
1844 if test -n "${modcache_files[$1]+set}"; then
1845 echo "${modcache_files[$1]}"
1848 eval "field_set=\"\$${cachevar}_files_set\""
1849 if test -n "$field_set"; then
1850 eval "field_value=\"\$${cachevar}_files\""
1851 echo "${field_value}"
1856 echo m4/gnulib-common.m4
1857 case "$autoconf_minversion" in
1864 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1865 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1866 # elements starting with prefix and ending with suffix are considered.
1867 # Processing: removed_prefix and removed_suffix are removed from each element,
1868 # added_prefix and added_suffix are added to each element.
1869 # prefix, suffix should not contain shell-special characters.
1870 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1871 # added_prefix, added_suffix should not contain the characters \|&.
1872 func_filter_filelist ()
1874 if test "$2" != "$nl" \
1875 || { $fast_func_append \
1876 && { test -z "$6" || $fast_func_remove_prefix; } \
1877 && { test -z "$7" || $fast_func_remove_suffix; }; \
1881 # Do not quote possibly-empty parameters in case patterns,
1882 # AIX and HP-UX ksh won't match them if they are empty.
1885 if test -n "$6"; then
1886 func_remove_prefix fff "$6"
1888 if test -n "$7"; then
1889 func_remove_suffix fff "$7"
1892 if test -z "$ffflist"; then
1895 func_append ffflist "$2${fff}"
1901 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1902 ffflist=`for fff in $3; do
1904 $4*$5) echo "$fff" ;;
1906 done | sed -e "$sed_fff_filter"`
1908 eval "$1=\"\$ffflist\""
1911 # func_get_dependencies module
1913 # - local_gnulib_dir from --local-dir
1914 # - modcache true or false, from --cache-modules/--no-cache-modules
1915 func_get_dependencies ()
1917 # ${module}-tests always implicitly depends on ${module}.
1921 func_remove_suffix fgd1 '-tests'
1925 # Then the explicit dependencies listed in the module description.
1926 if ! $modcache; then
1927 func_lookup_file "modules/$1"
1928 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1930 func_cache_lookup_module "$1"
1931 # Output the field's value, including the final newline (if any).
1932 if $have_associative; then
1933 if test -n "${modcache_dependson[$1]+set}"; then
1934 echo "${modcache_dependson[$1]}"
1937 eval "field_set=\"\$${cachevar}_dependson_set\""
1938 if test -n "$field_set"; then
1939 eval "field_value=\"\$${cachevar}_dependson\""
1940 echo "${field_value}"
1946 # func_get_autoconf_early_snippet module
1948 # - local_gnulib_dir from --local-dir
1949 # - modcache true or false, from --cache-modules/--no-cache-modules
1950 func_get_autoconf_early_snippet ()
1952 if ! $modcache; then
1953 func_lookup_file "modules/$1"
1954 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1956 func_cache_lookup_module "$1"
1957 # Output the field's value, including the final newline (if any).
1958 if $have_associative; then
1959 if test -n "${modcache_configureac_early[$1]+set}"; then
1960 echo "${modcache_configureac_early[$1]}"
1963 eval "field_set=\"\$${cachevar}_configureac_early_set\""
1964 if test -n "$field_set"; then
1965 eval "field_value=\"\$${cachevar}_configureac_early\""
1966 echo "${field_value}"
1972 # func_get_autoconf_snippet module
1974 # - local_gnulib_dir from --local-dir
1975 # - modcache true or false, from --cache-modules/--no-cache-modules
1976 func_get_autoconf_snippet ()
1978 if ! $modcache; then
1979 func_lookup_file "modules/$1"
1980 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1982 func_cache_lookup_module "$1"
1983 # Output the field's value, including the final newline (if any).
1984 if $have_associative; then
1985 if test -n "${modcache_configureac[$1]+set}"; then
1986 echo "${modcache_configureac[$1]}"
1989 eval "field_set=\"\$${cachevar}_configureac_set\""
1990 if test -n "$field_set"; then
1991 eval "field_value=\"\$${cachevar}_configureac\""
1992 echo "${field_value}"
1998 # func_get_automake_snippet module
2000 # - local_gnulib_dir from --local-dir
2001 # - modcache true or false, from --cache-modules/--no-cache-modules
2002 func_get_automake_snippet ()
2004 if ! $modcache; then
2005 func_lookup_file "modules/$1"
2006 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2008 func_cache_lookup_module "$1"
2009 # Output the field's value, including the final newline (if any).
2010 if $have_associative; then
2011 if test -n "${modcache_makefile[$1]+set}"; then
2012 echo "${modcache_makefile[$1]}"
2015 eval "field_set=\"\$${cachevar}_makefile_set\""
2016 if test -n "$field_set"; then
2017 eval "field_value=\"\$${cachevar}_makefile\""
2018 echo "${field_value}"
2024 # *-tests module live in tests/, not lib/.
2025 # Synthesize an EXTRA_DIST augmentation.
2026 all_files=`func_get_filelist $1`
2027 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2028 extra_files="$tests_files"
2029 if test -n "$extra_files"; then
2030 echo "EXTRA_DIST +=" $extra_files
2035 # Synthesize an EXTRA_DIST augmentation.
2036 sed_combine_lines='/\\$/{
2043 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2044 already_mentioned_files=` \
2045 { if ! $modcache; then
2046 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2048 if $have_associative; then
2049 if test -n "${modcache_makefile[$1]+set}"; then
2050 echo "${modcache_makefile[$1]}"
2053 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2054 if test -n "$field_set"; then
2055 eval 'field_value="$'"${cachevar}"'_makefile"'
2056 echo "${field_value}"
2061 | sed -e "$sed_combine_lines" \
2062 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2063 all_files=`func_get_filelist $1`
2064 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2065 # Remove $already_mentioned_files from $lib_files.
2066 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2067 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2068 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2069 if test -n "$extra_files"; then
2070 echo "EXTRA_DIST +=" $extra_files
2073 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2074 # This is necessary so that automake can generate the right list of
2076 # A possible approach would be to use autom4te --trace of the redefined
2077 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2078 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2079 # inside autoconf's built-in macros are not missed).
2080 # But it's simpler and more robust to do it here, based on the file list.
2081 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2082 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2083 # automake will generate a useless dependency; this is harmless.
2085 relocatable-prog-wrapper) ;;
2087 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2088 if test -n "$extra_files"; then
2089 echo "EXTRA_lib_SOURCES +=" $extra_files
2094 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2095 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2096 if test -n "$buildaux_files"; then
2097 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2098 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2101 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2102 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2103 if test -n "$top_files"; then
2104 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2105 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2112 # func_get_include_directive module
2114 # - local_gnulib_dir from --local-dir
2115 # - modcache true or false, from --cache-modules/--no-cache-modules
2116 func_get_include_directive ()
2119 if ! $modcache; then
2120 func_lookup_file "modules/$1"
2121 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2123 func_cache_lookup_module "$1"
2124 # Output the field's value, including the final newline (if any).
2125 if $have_associative; then
2126 if test -n "${modcache_include[$1]+set}"; then
2127 echo "${modcache_include[$1]}"
2130 eval "field_set=\"\$${cachevar}_include_set\""
2131 if test -n "$field_set"; then
2132 eval "field_value=\"\$${cachevar}_include\""
2133 echo "${field_value}"
2137 } | sed -e 's/^\(["<]\)/#include \1/'
2140 # func_get_link_directive module
2142 # - local_gnulib_dir from --local-dir
2143 # - modcache true or false, from --cache-modules/--no-cache-modules
2144 func_get_link_directive ()
2146 if ! $modcache; then
2147 func_lookup_file "modules/$1"
2148 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2150 func_cache_lookup_module "$1"
2151 # Output the field's value, including the final newline (if any).
2152 if $have_associative; then
2153 if test -n "${modcache_link[$1]+set}"; then
2154 echo "${modcache_link[$1]}"
2157 eval "field_set=\"\$${cachevar}_link_set\""
2158 if test -n "$field_set"; then
2159 eval "field_value=\"\$${cachevar}_link\""
2160 echo "${field_value}"
2166 # func_get_license module
2168 # - local_gnulib_dir from --local-dir
2169 # - modcache true or false, from --cache-modules/--no-cache-modules
2173 if ! $modcache; then
2174 func_lookup_file "modules/$1"
2175 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2177 func_cache_lookup_module "$1"
2178 # Output the field's value, including the final newline (if any).
2179 if $have_associative; then
2180 if test -n "${modcache_license[$1]+set}"; then
2181 echo "${modcache_license[$1]}"
2184 eval "field_set=\"\$${cachevar}_license_set\""
2185 if test -n "$field_set"; then
2186 eval "field_value=\"\$${cachevar}_license\""
2187 echo "${field_value}"
2191 # The default is GPL.
2193 } | sed -e 's,^ *$,,' | sed -e 1q
2196 # func_get_maintainer module
2198 # - local_gnulib_dir from --local-dir
2199 # - modcache true or false, from --cache-modules/--no-cache-modules
2200 func_get_maintainer ()
2202 if ! $modcache; then
2203 func_lookup_file "modules/$1"
2204 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2206 func_cache_lookup_module "$1"
2207 # Output the field's value, including the final newline (if any).
2208 if $have_associative; then
2209 if test -n "${modcache_maintainer[$1]+set}"; then
2210 echo "${modcache_maintainer[$1]}"
2213 eval "field_set=\"\$${cachevar}_maintainer_set\""
2214 if test -n "$field_set"; then
2215 eval "field_value=\"\$${cachevar}_maintainer\""
2216 echo "${field_value}"
2222 # func_get_tests_module module
2224 # - local_gnulib_dir from --local-dir
2225 func_get_tests_module ()
2227 # The naming convention for tests modules is hardwired: ${module}-tests.
2228 if test -f "$gnulib_dir/modules/$1"-tests \
2229 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2230 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2235 # func_acceptable module
2236 # tests whether a module is acceptable.
2238 # - avoidlist list of modules to avoid
2241 for avoid in $avoidlist; do
2242 if test "$avoid" = "$1"; then
2249 # func_modules_transitive_closure
2251 # - local_gnulib_dir from --local-dir
2252 # - modcache true or false, from --cache-modules/--no-cache-modules
2253 # - modules list of specified modules
2254 # - inctests true if tests should be included, blank otherwise
2255 # - incobsolete true if obsolete modules among dependencies should be
2256 # included, blank otherwise
2257 # - avoidlist list of modules to avoid
2258 # - tmp pathname of a temporary directory
2260 # - modules list of modules, including dependencies
2261 func_modules_transitive_closure ()
2263 # In order to process every module only once (for speed), process an "input
2264 # list" of modules, producing an "output list" of modules. During each round,
2265 # more modules can be queued in the input list. Once a module on the input
2266 # list has been processed, it is added to the "handled list", so we can avoid
2267 # to process it again.
2269 inmodules="$modules"
2271 while test -n "$inmodules"; do
2272 inmodules_this_round="$inmodules"
2273 inmodules= # Accumulator, queue for next round
2274 for module in $inmodules_this_round; do
2276 if test -n "$module"; then
2277 if func_acceptable $module; then
2278 func_append outmodules " $module"
2279 deps=`func_get_dependencies $module`
2280 # Duplicate dependencies are harmless, but Jim wants a warning.
2281 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2282 if test -n "$duplicated_deps"; then
2283 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2285 for dep in $deps; do
2286 if test -n "$incobsolete" \
2287 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
2288 func_append inmodules " $dep"
2291 if test -n "$inctests"; then
2292 testsmodule=`func_get_tests_module $module`
2293 if test -n "$testsmodule"; then
2294 func_append inmodules " $testsmodule"
2300 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2301 # Remove $handledmodules from $inmodules.
2302 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2303 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2305 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2306 rm -f "$tmp"/queued-modules
2309 # func_modules_add_dummy
2311 # - local_gnulib_dir from --local-dir
2312 # - modcache true or false, from --cache-modules/--no-cache-modules
2313 # - modules list of modules, including dependencies
2315 # - modules list of modules, including 'dummy' if needed
2316 func_modules_add_dummy ()
2318 # Determine whether any module provides a lib_SOURCES augmentation.
2320 sed_remove_backslash_newline=':a
2327 for module in $modules; do
2328 func_verify_nontests_module
2329 if test -n "$module"; then
2330 # Extract the value of "lib_SOURCES += ...".
2331 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2332 # Ignore .h files since they are not compiled.
2336 have_lib_SOURCES=yes
2343 # Add the dummy module, to make sure the library will be non-empty.
2344 if test -z "$have_lib_SOURCES"; then
2345 if func_acceptable "dummy"; then
2346 func_append modules " dummy"
2351 # func_modules_notice
2353 # - local_gnulib_dir from --local-dir
2354 # - modcache true or false, from --cache-modules/--no-cache-modules
2355 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2356 # - modules list of modules, including dependencies
2357 func_modules_notice ()
2359 if test $verbose -ge -1; then
2360 for module in $modules; do
2362 if test -n "$module"; then
2363 msg=`func_get_notice $module`
2364 if test -n "$msg"; then
2365 echo "Notice from module $module:"
2366 echo "$msg" | sed -e 's/^/ /'
2373 # func_modules_to_filelist
2375 # - local_gnulib_dir from --local-dir
2376 # - modcache true or false, from --cache-modules/--no-cache-modules
2377 # - modules list of modules, including dependencies
2379 # - files list of files
2380 func_modules_to_filelist ()
2383 for module in $modules; do
2385 if test -n "$module"; then
2386 fs=`func_get_filelist $module`
2387 func_append files " $fs"
2390 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2393 # func_execute_command command [args...]
2394 # Executes a command.
2395 # Uses also the variables
2396 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2397 func_execute_command ()
2399 if test $verbose -ge 0; then
2403 # Commands like automake produce output to stderr even when they succeed.
2404 # Turn this output off if the command succeeds.
2405 "$@" > "$tmp"/cmdout 2>&1
2407 if test $cmdret = 0; then
2411 cat "$tmp"/cmdout 1>&2
2418 # func_dest_tmpfilename file
2419 # determines the name of a temporary file (file is relative to destdir).
2421 # - destdir target directory
2422 # - doit : if actions shall be executed, false if only to be printed
2423 # - tmp pathname of a temporary directory
2425 # - tmpfile absolute filename of the temporary file
2426 func_dest_tmpfilename ()
2429 # Put the new contents of $file in a file in the same directory (needed
2430 # to guarantee that an 'mv' to "$destdir/$file" works).
2431 tmpfile="$destdir/$1.tmp"
2433 # Put the new contents of $file in a file in a temporary directory
2434 # (because the directory of "$file" might not exist).
2435 tmpfile="$tmp"/`basename "$1"`.tmp
2440 # copies a file from gnulib into the destination directory. The destination
2441 # is known to not exist.
2443 # - destdir target directory
2444 # - local_gnulib_dir from --local-dir
2445 # - modcache true or false, from --cache-modules/--no-cache-modules
2446 # - f the original file name
2447 # - lookedup_file name of the merged (combined) file
2448 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2449 # - g the rewritten file name
2450 # - tmpfile absolute filename of the temporary file
2451 # - doit : if actions shall be executed, false if only to be printed
2452 # - symbolic true if files should be symlinked, copied otherwise
2453 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2458 echo "Copying file $g"
2459 if { test -n "$symbolic" \
2460 || { test -n "$lsymbolic" \
2461 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2462 && test -z "$lookedup_tmp" \
2463 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2464 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2466 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2474 # copies a file from gnulib into the destination directory. The destination
2475 # is known to exist.
2477 # - destdir target directory
2478 # - local_gnulib_dir from --local-dir
2479 # - modcache true or false, from --cache-modules/--no-cache-modules
2480 # - f the original file name
2481 # - lookedup_file name of the merged (combined) file
2482 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2483 # - g the rewritten file name
2484 # - tmpfile absolute filename of the temporary file
2485 # - doit : if actions shall be executed, false if only to be printed
2486 # - symbolic true if files should be symlinked, copied otherwise
2487 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2489 # - already_present nonempty if the file should already exist, empty otherwise
2492 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2493 : # The file has not changed.
2497 if test -n "$already_present"; then
2498 echo "Updating file $g (backup in ${g}~)"
2500 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2502 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2503 if { test -n "$symbolic" \
2504 || { test -n "$lsymbolic" \
2505 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2506 && test -z "$lookedup_tmp" \
2507 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2508 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2510 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2513 if test -n "$already_present"; then
2514 echo "Update file $g (backup in ${g}~)"
2516 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2522 # func_emit_lib_Makefile_am
2523 # emits the contents of library makefile to standard output.
2525 # - local_gnulib_dir from --local-dir
2526 # - modcache true or false, from --cache-modules/--no-cache-modules
2527 # - modules list of modules, including dependencies
2528 # - libname library name
2529 # - pobase directory relative to destdir where to place *.po files
2530 # - auxdir directory relative to destdir where to place build aux files
2531 # - makefile_name from --makefile-name
2532 # - libtool true if libtool will be used, false or blank otherwise
2533 # - macro_prefix prefix of gl_LIBOBJS macros to use
2534 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2535 # - actioncmd (optional) command that will reproduce this invocation
2536 # - for_test true if creating a package for testing, false otherwise
2537 # - destfile filename relative to destdir of makefile being generated
2539 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2540 # list of edits to be done to Makefile.am variables
2542 # - uses_subdirs nonempty if object files in subdirs exist
2543 func_emit_lib_Makefile_am ()
2545 # When creating an includable Makefile.am snippet, augment variables with
2546 # += instead of assigning them.
2547 if test -n "$makefile_name"; then
2552 if test "$libtool" = true; then
2555 sed_eliminate_LDFLAGS="$sed_noop"
2559 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2562 # When creating a package for testing: Attempt to provoke failures,
2563 # especially link errors, already during "make" rather than during
2564 # "make check", because "make check" is not possible in a cross-compiling
2565 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2566 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2568 sed_transform_check_PROGRAMS="$sed_noop"
2570 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2571 echo "## Process this file with automake to produce Makefile.in."
2572 func_emit_copyright_notice
2573 if test -n "$actioncmd"; then
2574 # The maximum line length (excluding the terminating newline) of any file
2575 # that is to be preprocessed by config.status is 3070. config.status uses
2576 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2577 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2578 len=`echo "$actioncmd" | wc -c`
2579 if test -n "$len" && test "$len" -le 3000; then
2580 echo "# Reproduce by: $actioncmd"
2586 for module in $modules; do
2587 func_verify_nontests_module
2588 if test -n "$module"; then
2590 func_get_automake_snippet "$module" |
2592 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2593 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2594 -e "$sed_eliminate_LDFLAGS" \
2595 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2596 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2597 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2598 -e "$sed_transform_check_PROGRAMS"
2599 if test "$module" = 'alloca'; then
2600 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2601 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2603 } > "$tmp"/amsnippet
2604 # Skip the contents if it's entirely empty.
2605 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2606 echo "## begin gnulib module $module"
2608 cat "$tmp"/amsnippet
2609 echo "## end gnulib module $module"
2612 rm -f "$tmp"/amsnippet
2613 # Test whether there are some source files in subdirectories.
2614 for f in `func_get_filelist "$module"`; do
2624 } > "$tmp"/allsnippets
2625 if test -z "$makefile_name"; then
2626 # If there are source files in subdirectories, prevent collision of the
2627 # object files (example: hash.c and libxml/hash.c).
2629 if test -n "$uses_subdirs"; then
2630 subdir_options=' subdir-objects'
2632 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2635 if test -z "$makefile_name"; then
2637 echo "noinst_HEADERS ="
2638 echo "noinst_LIBRARIES ="
2639 echo "noinst_LTLIBRARIES ="
2640 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2641 # if you specify pkgdata_DATA to empty. This is a workaround.
2642 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2643 echo "pkgdata_DATA ="
2646 echo "BUILT_SOURCES ="
2649 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2650 if test -z "$makefile_name"; then
2651 echo "MOSTLYCLEANDIRS ="
2653 echo "DISTCLEANFILES ="
2654 echo "MAINTAINERCLEANFILES ="
2656 # Execute edits that apply to the Makefile.am being generated.
2658 while test $edit != $makefile_am_edits; do
2659 edit=`expr $edit + 1`
2660 eval dir=\"\$makefile_am_edit${edit}_dir\"
2661 eval var=\"\$makefile_am_edit${edit}_var\"
2662 eval val=\"\$makefile_am_edit${edit}_val\"
2663 if test -n "$var"; then
2664 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2665 echo "${var} += ${val}"
2666 eval "makefile_am_edit${edit}_var="
2670 if test -z "$makefile_name"; then
2672 echo "AM_CPPFLAGS ="
2676 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2677 || { test -n "$makefile_name" \
2678 && test -f "$sourcebase/Makefile.am" \
2679 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2681 # One of the snippets or the user's Makefile.am already specifies an
2682 # installation location for the library. Don't confuse automake by saying
2683 # it should not be installed.
2686 # By default, the generated library should not be installed.
2687 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2690 echo "${libname}_${libext}_SOURCES ="
2691 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2692 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2693 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2694 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2695 echo "EXTRA_${libname}_${libext}_SOURCES ="
2696 if test "$libtool" = true; then
2697 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2700 if test -n "$pobase"; then
2701 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2704 cat "$tmp"/allsnippets \
2705 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2707 echo "mostlyclean-local: mostlyclean-generic"
2708 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2709 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2710 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2714 rm -f "$tmp"/allsnippets
2717 # func_emit_po_Makevars
2718 # emits the contents of po/ makefile parameterization to standard output.
2720 # - local_gnulib_dir from --local-dir
2721 # - modcache true or false, from --cache-modules/--no-cache-modules
2722 # - sourcebase directory relative to destdir where to place source code
2723 # - pobase directory relative to destdir where to place *.po files
2724 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2725 func_emit_po_Makevars ()
2727 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2728 func_emit_copyright_notice
2730 echo "# Usually the message domain is the same as the package name."
2731 echo "# But here it has a '-gnulib' suffix."
2732 echo "DOMAIN = ${po_domain}-gnulib"
2734 echo "# These two variables depend on the location of this directory."
2735 echo "subdir = ${pobase}"
2736 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2739 # These options get passed to xgettext.
2740 XGETTEXT_OPTIONS = \
2741 --keyword=_ --flag=_:1:pass-c-format \
2742 --keyword=N_ --flag=N_:1:pass-c-format \
2743 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2744 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2745 --flag=error:3:c-format --flag=error_at_line:5:c-format
2747 # This is the copyright holder that gets inserted into the header of the
2748 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2749 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2751 # This is the email address or URL to which the translators shall report
2752 # bugs in the untranslated strings:
2753 # - Strings which are not entire sentences, see the maintainer guidelines
2754 # in the GNU gettext documentation, section 'Preparing Strings'.
2755 # - Strings which use unclear terms or require additional context to be
2757 # - Strings which make invalid assumptions about notation of date, time or
2759 # - Pluralisation problems.
2760 # - Incorrect English spelling.
2761 # - Incorrect formatting.
2762 # It can be your email address, or a mailing list address where translators
2763 # can write to without being subscribed, or the URL of a web page through
2764 # which the translators can contact you.
2765 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2767 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2768 # message catalogs shall be used. It is usually empty.
2769 EXTRA_LOCALE_CATEGORIES =
2771 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2772 # context. Possible values are "yes" and "no". Set this to yes if the
2773 # package uses functions taking also a message context, like pgettext(), or
2774 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2779 # func_emit_po_POTFILES_in
2780 # emits the file list to be passed to xgettext to standard output.
2782 # - local_gnulib_dir from --local-dir
2783 # - modcache true or false, from --cache-modules/--no-cache-modules
2784 # - sourcebase directory relative to destdir where to place source code
2785 # - files list of new files
2786 func_emit_po_POTFILES_in ()
2788 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2789 func_emit_copyright_notice
2791 echo "# List of files which contain translatable strings."
2792 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2795 # func_emit_tests_Makefile_am witness_macro
2796 # emits the contents of tests makefile to standard output.
2798 # - local_gnulib_dir from --local-dir
2799 # - modcache true or false, from --cache-modules/--no-cache-modules
2800 # - modules list of modules, including dependencies
2801 # - libname library name
2802 # - auxdir directory relative to destdir where to place build aux files
2803 # - makefile_name from --makefile-name
2804 # - libtool true if libtool will be used, false or blank otherwise
2805 # - sourcebase relative directory containing lib source code
2806 # - m4base relative directory containing autoconf macros
2807 # - testsbase relative directory containing unit test code
2808 # - macro_prefix prefix of gl_LIBOBJS macros to use
2809 # - for_test true if creating a package for testing, false otherwise
2810 # - use_libtests true if a libtests.a should be built, false otherwise
2811 # - destfile filename relative to destdir of makefile being generated
2813 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2814 # list of edits to be done to Makefile.am variables
2816 # - uses_subdirs nonempty if object files in subdirs exist
2817 func_emit_tests_Makefile_am ()
2820 if test "$libtool" = true; then
2822 sed_eliminate_LDFLAGS="$sed_noop"
2825 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2828 # When creating a package for testing: Attempt to provoke failures,
2829 # especially link errors, already during "make" rather than during
2830 # "make check", because "make check" is not possible in a cross-compiling
2831 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2832 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2834 sed_transform_check_PROGRAMS="$sed_noop"
2836 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2837 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2838 echo "## Process this file with automake to produce Makefile.in."
2839 func_emit_copyright_notice
2843 for module in $modules; do
2845 func_verify_tests_module
2849 if test -n "$module"; then
2851 func_get_automake_snippet "$module" |
2853 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2854 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2855 -e "$sed_eliminate_LDFLAGS" \
2856 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2857 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2858 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2859 -e "$sed_transform_check_PROGRAMS"
2860 if $use_libtests && test "$module" = 'alloca'; then
2861 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2862 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2864 } > "$tmp"/amsnippet
2865 # Skip the contents if it's entirely empty.
2866 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2867 echo "## begin gnulib module $module"
2869 cat "$tmp"/amsnippet
2870 echo "## end gnulib module $module"
2873 rm -f "$tmp"/amsnippet
2874 # Test whether there are some source files in subdirectories.
2875 for f in `func_get_filelist "$module"`; do
2877 lib/*/*.c | tests/*/*.c)
2885 } > "$tmp"/allsnippets
2886 # Generate dependencies here, since it eases the debugging of test failures.
2887 # If there are source files in subdirectories, prevent collision of the
2888 # object files (example: hash.c and libxml/hash.c).
2890 if test -n "$uses_subdirs"; then
2891 subdir_options=' subdir-objects'
2893 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2896 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2899 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2900 # variable is needed to avoid an error from automake:
2901 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2904 echo "XFAIL_TESTS ="
2905 echo "TESTS_ENVIRONMENT ="
2906 echo "noinst_PROGRAMS ="
2907 if ! $for_test; then
2908 echo "check_PROGRAMS ="
2910 echo "noinst_HEADERS ="
2911 echo "noinst_LIBRARIES ="
2912 if $use_libtests; then
2914 echo "noinst_LIBRARIES += libtests.a"
2916 echo "check_LIBRARIES = libtests.a"
2919 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2920 # if you specify pkgdata_DATA to empty. This is a workaround.
2921 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2922 echo "pkgdata_DATA ="
2925 echo "BUILT_SOURCES ="
2927 echo "MOSTLYCLEANFILES = core *.stackdump"
2928 echo "MOSTLYCLEANDIRS ="
2930 echo "DISTCLEANFILES ="
2931 echo "MAINTAINERCLEANFILES ="
2932 # Execute edits that apply to the Makefile.am being generated.
2934 while test $edit != $makefile_am_edits; do
2935 edit=`expr $edit + 1`
2936 eval dir=\"\$makefile_am_edit${edit}_dir\"
2937 eval var=\"\$makefile_am_edit${edit}_var\"
2938 eval val=\"\$makefile_am_edit${edit}_val\"
2939 if test -n "$var"; then
2940 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2941 echo "${var} += ${val}"
2942 eval "makefile_am_edit${edit}_var="
2947 echo "AM_CPPFLAGS = \\"
2948 if test -n "${witness_macro}"; then
2949 echo " -D@${witness_macro}@=1 \\"
2951 echo " -I. -I\$(srcdir) \\"
2952 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2953 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2955 local_ldadd_before=''
2956 local_ldadd_after=''
2957 if $use_libtests; then
2958 # All test programs need to be linked with libtests.a.
2959 # It needs to be passed to the linker before ${libname}.${libext}, since
2960 # the tests-related modules depend on the main modules.
2961 # It also needs to be passed to the linker after ${libname}.${libext}
2962 # because the latter might contain incomplete modules (such as the 'error'
2963 # module whose dependency to 'progname' is voluntarily omitted).
2964 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2966 local_ldadd_before=' libtests.a'
2967 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2969 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2971 if $use_libtests; then
2972 echo "libtests_a_SOURCES ="
2973 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2974 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2975 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2976 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2977 echo "EXTRA_libtests_a_SOURCES ="
2978 # The circular dependency in LDADD requires this.
2979 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2982 # Many test scripts use ${EXEEXT} or ${srcdir}.
2983 # EXEEXT is defined by AC_PROG_CC through autoconf.
2984 # srcdir is defined by autoconf and automake.
2985 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
2987 cat "$tmp"/allsnippets \
2988 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2989 echo "# Clean up after Solaris cc."
2991 echo " rm -rf SunWS_cache"
2993 echo "mostlyclean-local: mostlyclean-generic"
2994 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2995 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2996 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3000 rm -f "$tmp"/allsnippets
3003 # func_emit_initmacro_start macro_prefix
3004 # emits the first few statements of the gl_INIT macro to standard output.
3005 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3006 func_emit_initmacro_start ()
3008 macro_prefix_arg="$1"
3009 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3010 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3011 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3012 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3014 # Furthermore it avoids an automake error like this when a Makefile.am
3015 # that uses pieces of gnulib also uses $(LIBOBJ):
3016 # automatically discovered file `error.c' should not be explicitly mentioned
3017 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3018 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3019 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3020 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3021 # automatically discovered file `error.c' should not be explicitly mentioned
3022 # We let automake know about the files to be distributed through the
3023 # EXTRA_lib_SOURCES variable.
3024 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3025 # Create data variables for checking the presence of files that are mentioned
3026 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3027 # because we want the check to happen when the configure file is created,
3028 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3029 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3030 # in which to expect them.
3031 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3032 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3036 # func_emit_initmacro_end macro_prefix
3037 # emits the last few statements of the gl_INIT macro to standard output.
3038 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3039 func_emit_initmacro_end ()
3041 macro_prefix_arg="$1"
3042 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3043 # The check is performed only when autoconf is run from the directory where
3044 # the configure.ac resides; if it is run from a different directory, the
3046 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3047 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3048 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3049 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3050 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3054 echo " m4_if(m4_sysval, [0], [],"
3055 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3057 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3058 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3059 echo " m4_popdef([AC_LIBSOURCES])"
3060 echo " m4_popdef([AC_REPLACE_FUNCS])"
3061 echo " m4_popdef([AC_LIBOBJ])"
3062 echo " AC_CONFIG_COMMANDS_PRE(["
3063 echo " ${macro_prefix_arg}_libobjs="
3064 echo " ${macro_prefix_arg}_ltlibobjs="
3065 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3066 echo " # Remove the extension."
3067 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3068 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3069 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3070 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3073 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3074 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3078 # func_emit_initmacro_done macro_prefix sourcebase
3079 # emits a few statements after the gl_INIT macro to standard output.
3080 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3081 # - sourcebase directory relative to destdir where to place source code
3082 func_emit_initmacro_done ()
3084 macro_prefix_arg="$1"
3087 echo "# Like AC_LIBOBJ, except that the module name goes"
3088 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3089 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3090 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3091 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3094 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3095 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3096 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3097 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3098 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3101 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3102 echo "# expected is derived from the gnulib-tool parameterization,"
3103 echo "# and alloca is special cased (for the alloca-opt module)."
3104 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3105 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3106 echo " m4_foreach([_gl_NAME], [\$1], ["
3107 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3108 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3109 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3115 # func_import modules
3116 # Uses also the variables
3117 # - destdir target directory
3118 # - local_gnulib_dir from --local-dir
3119 # - modcache true or false, from --cache-modules/--no-cache-modules
3120 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3121 # - libname library name
3122 # - sourcebase directory relative to destdir where to place source code
3123 # - m4base directory relative to destdir where to place *.m4 macros
3124 # - pobase directory relative to destdir where to place *.po files
3125 # - docbase directory relative to destdir where to place doc files
3126 # - testsbase directory relative to destdir where to place unit test code
3127 # - auxdir directory relative to destdir where to place build aux files
3128 # - inctests true if --with-tests was given, blank otherwise
3129 # - incobsolete true if --with-obsolete was given, blank otherwise
3130 # - avoidlist list of modules to avoid, from --avoid
3131 # - lgpl yes or a number if library's license shall be LGPL,
3133 # - makefile_name from --makefile-name
3134 # - libtool true if --libtool was given, false if --no-libtool was
3135 # given, blank otherwise
3136 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3137 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3138 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3139 # - vc_files true if --vc-files was given, false if --no-vc-files was
3140 # given, blank otherwise
3141 # - autoconf_minversion minimum supported autoconf version
3142 # - doit : if actions shall be executed, false if only to be printed
3143 # - symbolic true if files should be symlinked, copied otherwise
3144 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3146 # - do_copyrights true if copyright notices in files should be replaced,
3150 # Get the cached settings.
3151 cached_local_gnulib_dir=
3152 cached_specified_modules=
3163 cached_makefile_name=
3165 cached_macro_prefix=
3169 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3170 cached_libtool=false
3176 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3186 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3188 /gl_WITH_OBSOLETE/ {
3189 s,^.*$,cached_incobsolete=true,p
3192 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3195 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3198 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3201 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3204 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3207 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3210 s,^.*$,cached_inctests=true,p
3213 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3216 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3219 s,^.*$,cached_lgpl=yes,p
3221 /gl_MAKEFILE_NAME(/ {
3222 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3225 s,^.*$,cached_libtool=true,p
3227 /gl_MACRO_PREFIX(/ {
3228 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3231 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3234 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3236 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3237 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3242 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3243 s,^.*$,cached_files=",p
3256 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3260 # Merge the cached settings with the specified ones.
3261 # The m4base must be the same as expected from the pathname.
3262 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3263 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3265 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3266 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3267 if test -z "$local_gnulib_dir"; then
3268 if test -n "$cached_local_gnulib_dir"; then
3271 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3273 case "$cached_local_gnulib_dir" in
3275 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3277 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3278 local_gnulib_dir="$relconcat" ;;
3283 # Append the cached and the specified module names. So that
3284 # "gnulib-tool --import foo" means to add the module foo.
3285 specified_modules="$cached_specified_modules $1"
3286 # Included obsolete modules among the dependencies if specified either way.
3287 if test -z "$incobsolete"; then
3288 incobsolete="$cached_incobsolete"
3290 # Append the cached and the specified avoidlist. This is probably better
3291 # than dropping the cached one when --avoid is specified at least once.
3292 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3293 avoidlist=`echo $avoidlist`
3295 # The sourcebase defaults to the cached one.
3296 if test -z "$sourcebase"; then
3297 sourcebase="$cached_sourcebase"
3298 if test -z "$sourcebase"; then
3299 func_fatal_error "missing --source-base option"
3302 # The pobase defaults to the cached one.
3303 if test -z "$pobase"; then
3304 pobase="$cached_pobase"
3306 # The docbase defaults to the cached one.
3307 if test -z "$docbase"; then
3308 docbase="$cached_docbase"
3309 if test -z "$docbase"; then
3310 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."
3313 # The testsbase defaults to the cached one.
3314 if test -z "$testsbase"; then
3315 testsbase="$cached_testsbase"
3316 if test -z "$testsbase"; then
3317 func_fatal_error "missing --tests-base option"
3320 # Require the tests if specified either way.
3321 if test -z "$inctests"; then
3322 inctests="$cached_inctests"
3324 # The libname defaults to the cached one.
3325 if test -z "$supplied_libname"; then
3326 libname="$cached_libname"
3327 if test -z "$libname"; then
3328 func_fatal_error "missing --lib option"
3331 # Require LGPL if specified either way.
3332 if test -z "$lgpl"; then
3335 # The makefile_name defaults to the cached one.
3336 if test -z "$makefile_name"; then
3337 makefile_name="$cached_makefile_name"
3339 # Use libtool if specified either way, or if guessed.
3340 if test -z "$libtool"; then
3341 if test -n "$cached_m4base"; then
3342 libtool="$cached_libtool"
3344 libtool="$guessed_libtool"
3347 # The macro_prefix defaults to the cached one.
3348 if test -z "$macro_prefix"; then
3349 macro_prefix="$cached_macro_prefix"
3350 if test -z "$macro_prefix"; then
3351 func_fatal_error "missing --macro-prefix option"
3354 # The po_domain defaults to the cached one.
3355 if test -z "$po_domain"; then
3356 po_domain="$cached_po_domain"
3358 # The vc_files defaults to the cached one.
3359 if test -z "$vc_files"; then
3360 vc_files="$cached_vc_files"
3363 # Canonicalize the list of specified modules.
3364 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3366 # Determine final module list.
3367 modules="$specified_modules"
3368 func_modules_transitive_closure
3369 if test $verbose -ge 0; then
3370 echo "Module list with included dependencies:"
3371 echo "$modules" | sed -e 's/^/ /'
3373 final_modules="$modules"
3375 # Determine main module list and tests-related module list separately.
3376 # The main module list is the transitive closure of the specified modules,
3377 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3378 # is specified, it will consist only of LGPLed source.
3379 # The tests-related module list is the transitive closure of the specified
3380 # modules, including tests modules, minus the main module list excluding
3381 # modules of applicability 'all'. Its lib/* sources (brought in through
3382 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3383 # source, even if --lgpl is specified.
3384 # Determine main module list.
3385 saved_inctests="$inctests"
3387 modules="$specified_modules"
3388 func_modules_transitive_closure
3389 main_modules="$modules"
3390 inctests="$saved_inctests"
3391 if test $verbose -ge 1; then
3392 echo "Main module list:"
3393 echo "$main_modules" | sed -e 's/^/ /'
3395 # Determine tests-related module list.
3396 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3397 testsrelated_modules=`for module in $main_modules; do
3398 if test \`func_get_applicability $module\` = main; then
3402 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3403 if test $verbose -ge 1; then
3404 echo "Tests-related module list:"
3405 echo "$testsrelated_modules" | sed -e 's/^/ /'
3408 # Add the dummy module to the main module list if needed.
3409 modules="$main_modules"
3410 func_modules_add_dummy
3411 main_modules="$modules"
3413 # Determine whether a $testsbase/libtests.a is needed.
3415 for module in $testsrelated_modules; do
3416 func_verify_nontests_module
3417 if test -n "$module"; then
3418 all_files=`func_get_filelist $module`
3419 # Test whether some file in $all_files lies in lib/.
3420 for f in $all_files; do
3431 # Add the dummy module to the tests-related module list if needed.
3432 if $use_libtests; then
3433 modules="$testsrelated_modules"
3434 func_modules_add_dummy
3435 testsrelated_modules="$modules"
3438 # If --lgpl, verify that the licenses of modules are compatible.
3439 if test -n "$lgpl"; then
3440 license_incompatibilities=
3441 for module in $main_modules; do
3442 license=`func_get_license $module`
3444 'GPLed build tool') ;;
3445 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3450 LGPL | LGPLv2+ | LGPLv3+) ;;
3451 *) func_append license_incompatibilities "$module $license$nl" ;;
3457 *) func_append license_incompatibilities "$module $license$nl" ;;
3460 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3465 if test -n "$license_incompatibilities"; then
3466 # Format the license incompatibilities as a table.
3467 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3468 s,^\(.................................................[^ ]*\) *, \1 ,'
3469 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3470 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3474 # Show banner notice of every module.
3475 modules="$main_modules"
3478 # Determine script to apply to imported library files.
3479 sed_transform_lib_file=
3480 for module in $main_modules; do
3481 if test $module = config-h; then
3482 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3483 sed_transform_lib_file=$sed_transform_lib_file'
3484 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3489 sed_transform_main_lib_file="$sed_transform_lib_file"
3490 if test -n "$do_copyrights"; then
3491 if test -n "$lgpl"; then
3495 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3496 s/GNU General/GNU Lesser General/g
3500 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3501 s/GNU General/GNU Lesser General/g
3502 s/version [23]\([ ,]\)/version 2.1\1/g
3505 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3509 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3510 s/GNU Lesser General/GNU General/g
3511 s/GNU Library General/GNU General/g
3512 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3517 # Determine script to apply to auxiliary files that go into $auxdir/.
3518 sed_transform_build_aux_file=
3519 if test -n "$do_copyrights"; then
3521 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3522 s/GNU Lesser General/GNU General/g
3523 s/GNU Library General/GNU General/g
3524 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3528 # Determine script to apply to library files that go into $testsbase/.
3529 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3530 if test -n "$do_copyrights"; then
3532 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3533 s/GNU Lesser General/GNU General/g
3534 s/GNU Library General/GNU General/g
3535 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3539 # Determine the final file lists.
3540 # They must be computed separately, because files in lib/* go into
3541 # $sourcebase/ if they are in the main file list but into $testsbase/
3542 # if they are in the tests-related file list. Furthermore lib/dummy.c
3544 # Determine final main file list.
3545 modules="$main_modules"
3546 func_modules_to_filelist
3548 # Determine final tests-related file list.
3549 modules="$testsrelated_modules"
3550 func_modules_to_filelist
3551 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3552 # Merge both file lists.
3553 sed_remove_empty_lines='/^$/d'
3554 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3555 if test $verbose -ge 0; then
3557 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3558 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3562 || func_fatal_error "refusing to do nothing"
3564 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3565 new_files="$files m4/gnulib-tool.m4"
3566 old_files="$cached_files"
3567 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3568 func_append old_files " m4/gnulib-tool.m4"
3571 rewritten='%REWRITTEN%'
3572 sed_rewrite_old_files="\
3573 s,^build-aux/,$rewritten$auxdir/,
3574 s,^doc/,$rewritten$cached_docbase/,
3575 s,^lib/,$rewritten$cached_sourcebase/,
3576 s,^m4/,$rewritten$cached_m4base/,
3577 s,^tests/,$rewritten$cached_testsbase/,
3578 s,^tests=lib/,$rewritten$cached_testsbase/,
3581 sed_rewrite_new_files="\
3582 s,^build-aux/,$rewritten$auxdir/,
3583 s,^doc/,$rewritten$docbase/,
3584 s,^lib/,$rewritten$sourcebase/,
3585 s,^m4/,$rewritten$m4base/,
3586 s,^tests/,$rewritten$testsbase/,
3587 s,^tests=lib/,$rewritten$testsbase/,
3591 # Create directories.
3592 { echo "$sourcebase"
3594 if test -n "$pobase"; then
3597 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3598 if test -n "$docfiles"; then
3601 if test -n "$inctests"; then
3605 for f in $files; do echo $f; done \
3606 | sed -e "$sed_rewrite_new_files" \
3607 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3610 { # Rearrange file descriptors. Needed because "while ... done < ..."
3611 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3612 exec 5<&0 < "$tmp"/dirs
3614 if test ! -d "$destdir/$d"; then
3616 echo "Creating directory $destdir/$d"
3617 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3619 echo "Create directory $destdir/$d"
3626 # Copy files or make symbolic links. Remove obsolete files.
3630 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3631 # representing the files according to the last gnulib-tool invocation.
3632 for f in $old_files; do echo $f; done \
3633 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3636 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3637 # representing the files after this gnulib-tool invocation.
3638 for f in $new_files; do echo $f; done \
3639 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3642 # First the files that are in old-files, but not in new-files:
3643 sed_take_first_column='s,'"$delimiter"'.*,,'
3644 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3645 # Remove the file. Do nothing if the user already removed it.
3646 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3648 echo "Removing file $g (backup in ${g}~)"
3649 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3651 echo "Remove file $g (backup in ${g}~)"
3653 func_append removed_files "$g$nl"
3656 # func_add_or_update handles a file that ought to be present afterwards.
3658 # - f the original file name
3659 # - g the rewritten file name
3660 # - already_present nonempty if the file should already exist, empty
3662 func_add_or_update ()
3666 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3668 func_dest_tmpfilename "$g"
3669 func_lookup_file "$f"
3670 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3671 if test -n "$sed_transform_main_lib_file"; then
3674 sed -e "$sed_transform_main_lib_file" \
3675 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3679 if test -n "$sed_transform_build_aux_file"; then
3682 sed -e "$sed_transform_build_aux_file" \
3683 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3687 if test -n "$sed_transform_testsrelated_lib_file"; then
3690 sed -e "$sed_transform_testsrelated_lib_file" \
3691 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3695 if test -f "$destdir/$g"; then
3696 # The file already exists.
3700 # Don't protest if the file should be there but isn't: it happens
3701 # frequently that developers don't put autogenerated files into CVS.
3703 func_append added_files "$g$nl"
3707 # Then the files that are in new-files, but not in old-files:
3708 sed_take_last_column='s,^.*'"$delimiter"',,'
3710 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3711 | sed -e "$sed_take_last_column" \
3712 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3713 { # Rearrange file descriptors. Needed because "while ... done < ..."
3714 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3715 exec 5<&0 < "$tmp"/added-files
3721 # Then the files that are in new-files and in old-files:
3722 already_present=true
3723 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3724 | sed -e "$sed_take_last_column" \
3725 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3726 { # Rearrange file descriptors. Needed because "while ... done < ..."
3727 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3728 exec 5<&0 < "$tmp"/kept-files
3735 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3736 actioncmd="gnulib-tool --import"
3737 func_append actioncmd " --dir=$destdir"
3738 if test -n "$local_gnulib_dir"; then
3739 func_append actioncmd " --local-dir=$local_gnulib_dir"
3741 func_append actioncmd " --lib=$libname"
3742 func_append actioncmd " --source-base=$sourcebase"
3743 func_append actioncmd " --m4-base=$m4base"
3744 if test -n "$pobase"; then
3745 func_append actioncmd " --po-base=$pobase"
3747 func_append actioncmd " --doc-base=$docbase"
3748 func_append actioncmd " --tests-base=$testsbase"
3749 func_append actioncmd " --aux-dir=$auxdir"
3750 if test -n "$inctests"; then
3751 func_append actioncmd " --with-tests"
3753 if test -n "$incobsolete"; then
3754 func_append actioncmd " --with-obsolete"
3756 for module in $avoidlist; do
3757 func_append actioncmd " --avoid=$module"
3759 if test -n "$lgpl"; then
3760 if test "$lgpl" = yes; then
3761 func_append actioncmd " --lgpl"
3763 func_append actioncmd " --lgpl=$lgpl"
3766 if test -n "$makefile_name"; then
3767 func_append actioncmd " --makefile-name=$makefile_name"
3769 if test "$libtool" = true; then
3770 func_append actioncmd " --libtool"
3772 func_append actioncmd " --no-libtool"
3774 func_append actioncmd " --macro-prefix=$macro_prefix"
3775 if test -n "$po_domain"; then
3776 func_append actioncmd " --po-domain=$po_domain"
3778 if test -n "$vc_files"; then
3779 if test "$vc_files" = true; then
3780 func_append actioncmd " --vc-files"
3782 func_append actioncmd " --no-vc-files"
3785 func_append actioncmd " `echo $specified_modules`"
3787 # Default the makefile name to Makefile.am.
3788 if test -n "$makefile_name"; then
3789 makefile_am=$makefile_name
3791 makefile_am=Makefile.am
3794 # Create normal Makefile.ams.
3797 # Setup list of Makefile.am edits that are to be performed afterwards.
3798 # Some of these edits apply to files that we will generate; others are
3799 # under the responsibility of the developer.
3801 # func_note_Makefile_am_edit dir var value
3802 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3804 func_note_Makefile_am_edit ()
3806 makefile_am_edits=`expr $makefile_am_edits + 1`
3807 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3808 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3809 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3811 if test "$makefile_am" = Makefile.am; then
3812 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3813 sourcebase_base=`basename "$sourcebase"`
3814 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3816 if test -n "$pobase"; then
3817 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3818 pobase_base=`basename "$pobase"`
3819 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3821 if test -n "$inctests"; then
3822 if test "$makefile_am" = Makefile.am; then
3823 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3824 testsbase_base=`basename "$testsbase"`
3825 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3828 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3830 # Find the first parent directory of $m4base that contains or will contain
3832 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3834 sed_butlast='s,[^/][^/]*//*$,,'
3835 dir1="${m4base}/"; dir2=""
3836 while test -n "$dir1" \
3837 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3838 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3839 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3840 || { test -n "$inctests" \
3841 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3842 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3843 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3844 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3846 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3849 # Create library makefile.
3850 func_dest_tmpfilename $sourcebase/$makefile_am
3851 destfile="$sourcebase/$makefile_am"
3852 modules="$main_modules"
3853 func_emit_lib_Makefile_am > "$tmpfile"
3854 if test -f "$destdir"/$sourcebase/$makefile_am; then
3855 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3859 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3860 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3861 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3863 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3869 echo "Creating $sourcebase/$makefile_am"
3870 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3872 echo "Create $sourcebase/$makefile_am"
3875 func_append added_files "$sourcebase/$makefile_am$nl"
3878 # Create po/ directory.
3879 if test -n "$pobase"; then
3880 # Create po makefile and auxiliary files.
3881 for file in Makefile.in.in remove-potcdate.sin; do
3882 func_dest_tmpfilename $pobase/$file
3883 func_lookup_file build-aux/po/$file
3884 cat "$lookedup_file" > "$tmpfile"
3885 if test -f "$destdir"/$pobase/$file; then
3886 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3890 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3891 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3892 mv -f "$tmpfile" "$destdir"/$pobase/$file
3894 echo "Update $pobase/$file (backup in $pobase/$file~)"
3900 echo "Creating $pobase/$file"
3901 mv -f "$tmpfile" "$destdir"/$pobase/$file
3903 echo "Create $pobase/$file"
3906 func_append added_files "$pobase/$file$nl"
3909 # Create po makefile parameterization, part 1.
3910 func_dest_tmpfilename $pobase/Makevars
3911 func_emit_po_Makevars > "$tmpfile"
3912 if test -f "$destdir"/$pobase/Makevars; then
3913 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3917 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3918 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3919 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3921 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3927 echo "Creating $pobase/Makevars"
3928 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3930 echo "Create $pobase/Makevars"
3933 func_append added_files "$pobase/Makevars$nl"
3935 # Create po makefile parameterization, part 2.
3936 func_dest_tmpfilename $pobase/POTFILES.in
3937 func_emit_po_POTFILES_in > "$tmpfile"
3938 if test -f "$destdir"/$pobase/POTFILES.in; then
3939 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3943 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3944 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3945 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3947 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3953 echo "Creating $pobase/POTFILES.in"
3954 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3956 echo "Create $pobase/POTFILES.in"
3959 func_append added_files "$pobase/POTFILES.in$nl"
3962 TP_URL="http://translationproject.org/latest/"
3963 TP_RSYNC_URI="translationproject.org::tp/latest/"
3965 echo "Fetching gnulib PO files from $TP_URL"
3966 (cd "$destdir"/$pobase \
3967 && { # Prefer rsync over wget if it is available, since it consumes
3968 # less network bandwidth, due to compression.
3969 if type rsync 2>/dev/null | grep / > /dev/null; then
3970 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3972 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3977 echo "Fetch gnulib PO files from $TP_URL"
3979 # Create po/LINGUAS.
3981 func_dest_tmpfilename $pobase/LINGUAS
3982 (cd "$destdir"/$pobase \
3983 && { echo '# Set of available languages.'
3984 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3987 if test -f "$destdir"/$pobase/LINGUAS; then
3988 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3991 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3992 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3993 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3996 echo "Creating $pobase/LINGUAS"
3997 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3998 func_append added_files "$pobase/LINGUAS$nl"
4001 if test -f "$destdir"/$pobase/LINGUAS; then
4002 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4004 echo "Create $pobase/LINGUAS"
4009 # Create m4/gnulib-cache.m4.
4010 func_dest_tmpfilename $m4base/gnulib-cache.m4
4012 func_emit_copyright_notice
4014 echo "# This file represents the specification of how gnulib-tool is used."
4015 echo "# It acts as a cache: It is written and read by gnulib-tool."
4016 echo "# In projects using CVS, this file is meant to be stored in CVS,"
4017 echo "# like the configure.ac and various Makefile.am files."
4020 echo "# Specification in the form of a command-line invocation:"
4023 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4024 # Store the local_gnulib_dir relative to destdir.
4025 case "$local_gnulib_dir" in
4027 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4030 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4032 # destdir, local_gnulib_dir are both relative.
4033 func_relativize "$destdir" "$local_gnulib_dir"
4034 relative_local_gnulib_dir="$reldir" ;;
4037 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4039 echo "$specified_modules" | sed -e 's/^/ /g'
4041 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4042 echo "gl_AVOID([$avoidlist])"
4043 echo "gl_SOURCE_BASE([$sourcebase])"
4044 echo "gl_M4_BASE([$m4base])"
4045 echo "gl_PO_BASE([$pobase])"
4046 echo "gl_DOC_BASE([$docbase])"
4047 echo "gl_TESTS_BASE([$testsbase])"
4048 test -z "$inctests" || echo "gl_WITH_TESTS"
4049 echo "gl_LIB([$libname])"
4050 if test -n "$lgpl"; then
4051 if test "$lgpl" = yes; then
4054 echo "gl_LGPL([$lgpl])"
4057 echo "gl_MAKEFILE_NAME([$makefile_name])"
4058 if test "$libtool" = true; then
4061 echo "gl_MACRO_PREFIX([$macro_prefix])"
4062 echo "gl_PO_DOMAIN([$po_domain])"
4063 if test -n "$vc_files"; then
4064 echo "gl_VC_FILES([$vc_files])"
4067 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4068 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4072 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4073 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4074 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4076 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4080 echo "# gnulib-cache.m4 ends here"
4087 echo "Creating $m4base/gnulib-cache.m4"
4088 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4090 echo "Create $m4base/gnulib-cache.m4"
4096 # Create m4/gnulib-comp.m4.
4097 func_dest_tmpfilename $m4base/gnulib-comp.m4
4099 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4100 func_emit_copyright_notice
4102 echo "# This file represents the compiled summary of the specification in"
4103 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4104 echo "# to be invoked from configure.ac."
4105 echo "# In projects using CVS, this file can be treated like other built files."
4108 echo "# This macro should be invoked from $configure_ac, in the section"
4109 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4110 echo "# any checks for libraries, header files, types and library functions."
4111 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4113 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4114 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4115 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4116 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4117 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4118 if test -n "$uses_subdirs"; then
4119 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4121 for module in $final_modules; do
4123 if test -n "$module"; then
4124 echo "# Code from module $module:"
4125 func_get_autoconf_early_snippet "$module"
4128 | sed -e '/^$/d;' -e 's/^/ /'
4131 echo "# This macro should be invoked from $configure_ac, in the section"
4132 echo "# \"Check for header files, types and library functions\"."
4133 echo "AC_DEFUN([${macro_prefix}_INIT],"
4135 if test "$libtool" = true; then
4136 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4137 echo " gl_cond_libtool=true"
4139 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4140 echo " gl_cond_libtool=false"
4142 echo " gl_ltlibdeps="
4144 if test "$auxdir" != "build-aux"; then
4145 sed_replace_build_aux='
4147 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4148 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4152 sed_replace_build_aux="$sed_noop"
4154 func_emit_initmacro_start $macro_prefix
4155 echo " gl_source_base='$sourcebase'"
4156 for module in $main_modules; do
4158 if test -n "$module"; then
4159 echo " # Code from module $module:"
4160 func_get_autoconf_snippet "$module" \
4161 | sed -e '/^$/d;' -e 's/^/ /' \
4162 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4163 -e "$sed_replace_build_aux"
4164 if test "$module" = 'alloca' && test "$libtool" = true; then
4165 echo 'changequote(,)dnl'
4166 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4167 echo 'changequote([, ])dnl'
4168 echo 'AC_SUBST([LTALLOCA])'
4172 echo " # End of code from modules"
4173 func_emit_initmacro_end $macro_prefix
4174 echo " gltests_libdeps="
4175 echo " gltests_ltlibdeps="
4176 func_emit_initmacro_start ${macro_prefix}tests
4177 echo " gl_source_base='$testsbase'"
4178 # Define a tests witness macro that depends on the package.
4179 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4180 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4181 echo " ${macro_prefix}tests_WITNESS=IN_\`echo \"\${PACKAGE-\$PACKAGE_TARNAME}\" | LC_ALL=C tr 'a-z' 'A-Z' | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'\`_GNULIB_TESTS"
4182 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4183 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4184 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4185 for module in $testsrelated_modules; do
4187 if test -n "$module"; then
4188 func_get_autoconf_snippet "$module" \
4189 | sed -e '/^$/d;' -e 's/^/ /' \
4190 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4191 -e "$sed_replace_build_aux" \
4192 -e 's/\$gl_cond_libtool/false/g' \
4193 -e 's/gl_libdeps/gltests_libdeps/g' \
4194 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4197 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4198 func_emit_initmacro_end ${macro_prefix}tests
4199 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4200 # created using libtool, because libtool already handles the dependencies.
4201 if test "$libtool" != true; then
4202 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4203 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4204 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4205 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4206 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4208 if $use_libtests; then
4209 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4210 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4213 func_emit_initmacro_done $macro_prefix $sourcebase
4214 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4216 echo "# This macro records the list of files which have been installed by"
4217 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4218 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4219 echo "$files" | sed -e 's,^, ,'
4222 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4223 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4227 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4228 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4229 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4231 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4235 echo "# gnulib-comp.m4 ends here"
4242 echo "Creating $m4base/gnulib-comp.m4"
4243 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4245 echo "Create $m4base/gnulib-comp.m4"
4251 if test -n "$inctests"; then
4252 # Create tests makefile.
4253 func_dest_tmpfilename $testsbase/$makefile_am
4254 destfile="$testsbase/$makefile_am"
4255 modules="$testsrelated_modules"
4256 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4257 if test -f "$destdir"/$testsbase/$makefile_am; then
4258 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4262 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4263 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4264 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4266 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4272 echo "Creating $testsbase/$makefile_am"
4273 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4275 echo "Create $testsbase/$makefile_am"
4278 func_append added_files "$testsbase/$makefile_am$nl"
4282 if test "$vc_files" != false; then
4283 # Update the .cvsignore and .gitignore files.
4284 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4285 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4286 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4287 echo "$m4base/|A|gnulib-comp.m4"
4288 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4289 { # Rearrange file descriptors. Needed because "while ... done < ..."
4290 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4291 exec 5<&0 < "$tmp"/fileset-changes
4292 func_update_ignorelist ()
4295 if test "$ignore" = .gitignore; then
4296 # In a .gitignore file, "foo" applies to the current directory and all
4297 # subdirectories, whereas "/foo" applies to the current directory only.
4300 doubly_escaped_anchor='\\/'
4304 doubly_escaped_anchor=''
4306 if test -f "$destdir/$dir$ignore"; then
4307 if test -n "$dir_added" || test -n "$dir_removed"; then
4308 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4309 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4310 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4311 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4312 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4314 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4316 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4317 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4318 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4319 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4320 } > "$tmp"/sed-ignore-removed
4321 { cat "$destdir/$dir$ignore"~
4322 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4323 } | sed -f "$tmp"/sed-ignore-removed \
4324 > "$destdir/$dir$ignore"
4326 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4331 if test -n "$dir_added"; then
4333 echo "Creating $destdir/$dir$ignore"
4335 if test "$ignore" = .cvsignore; then
4337 # Automake generates Makefile rules that create .dirstamp files.
4340 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4341 } > "$destdir/$dir$ignore"
4343 echo "Create $destdir/$dir$ignore"
4353 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4354 func_update_ignorelist .cvsignore
4356 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4357 func_update_ignorelist .gitignore
4364 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4365 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4366 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4367 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4368 if test "$next_dir" != "$last_dir"; then
4369 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4370 last_dir="$next_dir"
4375 A) func_append last_dir_added "$file$nl";;
4376 R) func_append last_dir_removed "$file$nl";;
4379 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4386 echo "You may need to add #include directives for the following .h files."
4387 # Intersect $specified_modules and $main_modules
4388 # (since $specified_modules is not necessarily of subset of $main_modules
4389 # - some may have been skipped through --avoid, and since the elements of
4390 # $main_modules but not in $specified_modules can go away without explicit
4391 # notice - through changes in the module dependencies).
4392 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4393 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4394 # First the #include <...> directives without #ifs, sorted for convenience,
4395 # then the #include "..." directives without #ifs, sorted for convenience,
4396 # then the #include directives that are surrounded by #ifs. Not sorted.
4397 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4398 include_directive=`func_get_include_directive "$module"`
4399 case "$nl$include_directive" in
4401 echo "$include_directive" 1>&5
4404 echo "$include_directive" | grep -v 'include "' 1>&6
4405 echo "$include_directive" | grep 'include "' 1>&7
4408 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4410 LC_ALL=C sort -u "$tmp"/include-angles
4411 LC_ALL=C sort -u "$tmp"/include-quotes
4412 cat "$tmp"/include-if
4413 ) | sed -e '/^$/d' -e 's/^/ /'
4414 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4416 for module in $main_modules; do
4417 func_get_link_directive "$module"
4419 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4420 if test `wc -l < "$tmp"/link` != 0; then
4422 echo "You may need to use the following Makefile variables when linking."
4423 echo "Use them in <program>_LDADD when linking a program, or"
4424 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4430 echo "Don't forget to"
4431 if test "$makefile_am" = Makefile.am; then
4432 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4434 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4436 if test -n "$pobase"; then
4437 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4439 if test -n "$inctests"; then
4440 if test "$makefile_am" = Makefile.am; then
4441 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4443 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4447 while test $edit != $makefile_am_edits; do
4448 edit=`expr $edit + 1`
4449 eval dir=\"\$makefile_am_edit${edit}_dir\"
4450 eval var=\"\$makefile_am_edit${edit}_var\"
4451 eval val=\"\$makefile_am_edit${edit}_val\"
4452 if test -n "$var"; then
4453 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4456 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4457 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4460 # func_create_testdir testdir modules
4462 # - local_gnulib_dir from --local-dir
4463 # - modcache true or false, from --cache-modules/--no-cache-modules
4464 # - auxdir directory relative to destdir where to place build aux files
4465 # - inctests true if tests should be included, blank otherwise
4466 # - incobsolete true if obsolete modules among dependencies should be
4467 # included, blank otherwise
4468 # - avoidlist list of modules to avoid
4469 # - libtool true if --libtool was given, false if --no-libtool was
4470 # given, blank otherwise
4471 # - symbolic true if files should be symlinked, copied otherwise
4472 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4474 func_create_testdir ()
4478 if test -z "$modules"; then
4479 # All modules together.
4480 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4481 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4482 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4483 modules=`func_all_modules`
4484 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4486 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
4488 # Check that the license of every module is consistent with the license of
4490 saved_modules="$modules"
4491 saved_inctests="$inctests"
4492 # When computing transitive closures, don't consider $module to depend on
4493 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4494 # on GPL modules - therefore we don't want a warning in this case.
4496 for requested_module in $saved_modules; do
4497 requested_license=`func_get_license "$requested_module"`
4498 if test "$requested_license" != GPL; then
4499 # Here we use func_modules_transitive_closure, not just
4500 # func_get_dependencies, so that we also detect weird situations like
4501 # an LGPL module which depends on a GPLed build tool module which depends
4503 modules="$requested_module"
4504 func_modules_transitive_closure
4505 for module in $modules; do
4506 license=`func_get_license "$module"`
4508 'GPLed build tool') ;;
4509 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4511 case "$requested_license" in
4514 GPLv2+ | LGPLv2+) ;;
4515 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4521 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4527 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4536 modules="$saved_modules"
4537 inctests="$saved_inctests"
4539 # Subdirectory names.
4549 # Determine final module list.
4550 func_modules_transitive_closure
4551 if test $verbose -ge 0; then
4552 echo "Module list with included dependencies:"
4553 echo "$modules" | sed -e 's/^/ /'
4556 # Add the dummy module if needed.
4557 func_modules_add_dummy
4559 # Show banner notice of every module.
4562 # Determine final file list.
4563 func_modules_to_filelist
4564 if test $verbose -ge 0; then
4566 echo "$files" | sed -e 's/^/ /'
4569 rewritten='%REWRITTEN%'
4570 sed_rewrite_files="\
4571 s,^build-aux/,$rewritten$auxdir/,
4572 s,^doc/,$rewritten$docbase/,
4573 s,^lib/,$rewritten$sourcebase/,
4574 s,^m4/,$rewritten$m4base/,
4575 s,^tests/,$rewritten$testsbase/,
4579 # Create directories.
4580 for f in $files; do echo $f; done \
4581 | sed -e "$sed_rewrite_files" \
4582 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4583 | LC_ALL=C sort -u \
4585 { # Rearrange file descriptors. Needed because "while ... done < ..."
4586 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4587 exec 5<&0 < "$tmp"/dirs
4589 mkdir -p "$testdir/$d"
4594 # Copy files or make symbolic links.
4596 for f in $files; do echo $f; done \
4597 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4600 { # Rearrange file descriptors. Needed because "while ... done < ..."
4601 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4602 exec 5<&0 < "$tmp"/files
4604 func_lookup_file "$f"
4605 if test -n "$lookedup_tmp"; then
4606 cp -p "$lookedup_file" "$testdir/$g"
4608 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4609 if { test -n "$symbolic" \
4610 || { test -n "$lsymbolic" \
4611 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4612 func_ln "$lookedup_file" "$testdir/$g"
4614 cp -p "$lookedup_file" "$testdir/$g"
4621 # Create Makefile.ams that are for testing.
4624 # No special edits are needed.
4627 # Create $sourcebase/Makefile.am.
4628 mkdir -p "$testdir/$sourcebase"
4629 destfile="$sourcebase/Makefile.am"
4630 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4631 any_uses_subdirs="$uses_subdirs"
4633 # Create $m4base/Makefile.am.
4634 mkdir -p "$testdir/$m4base"
4635 (echo "## Process this file with automake to produce Makefile.in."
4641 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4644 ) > "$testdir/$m4base/Makefile.am"
4646 subdirs="$sourcebase $m4base"
4647 subdirs_with_configure_ac=""
4649 if false && test -f "$testdir"/$m4base/gettext.m4; then
4650 # Avoid stupid error message from automake:
4651 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4652 mkdir -p "$testdir/po"
4653 (echo "## Process this file with automake to produce Makefile.in."
4654 ) > "$testdir/po/Makefile.am"
4655 func_append subdirs " po"
4658 if test -n "$inctests"; then
4659 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4660 # Viewed from the $testsbase subdirectory, $auxdir is different.
4661 saved_auxdir="$auxdir"
4662 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4663 # Create $testsbase/Makefile.am.
4665 destfile="$testsbase/Makefile.am"
4666 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
4667 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4668 # Create $testsbase/configure.ac.
4669 (echo "# Process this file with autoconf to produce a configure script."
4670 echo "AC_INIT([dummy], [0])"
4671 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4672 echo "AM_INIT_AUTOMAKE"
4674 echo "AC_CONFIG_HEADERS([config.h])"
4677 echo "AC_PROG_INSTALL"
4678 echo "AC_PROG_MAKE_SET"
4679 echo "AC_PROG_RANLIB"
4681 if test -n "$uses_subdirs"; then
4682 echo "AM_PROG_CC_C_O"
4685 for module in $modules; do
4687 if test -n "$module"; then
4689 gnumakefile | maintainer-makefile)
4690 # These modules are meant to be used only in the top-level directory.
4693 func_get_autoconf_early_snippet "$module"
4698 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4699 if test "$libtool" = true; then
4700 echo "LT_INIT([win32-dll])"
4701 echo "LT_LANG([C++])"
4702 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4703 echo "gl_cond_libtool=true"
4705 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4706 echo "gl_cond_libtool=false"
4708 echo "gl_ltlibdeps="
4710 # Wrap the set of autoconf snippets into an autoconf macro that is then
4711 # invoked. This is needed because autoconf does not support AC_REQUIRE
4713 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4714 # but we want the AC_REQUIRE to have its normal meaning (provide one
4715 # expansion of the required macro before the current point, and only one
4717 echo "AC_DEFUN([gl_INIT], ["
4718 sed_replace_build_aux='
4720 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4721 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4724 func_emit_initmacro_start $macro_prefix
4725 # We don't have explicit ordering constraints between the various
4726 # autoconf snippets. It's cleanest to put those of the library before
4727 # those of the tests.
4728 echo "gl_source_base='../$sourcebase'"
4729 for module in $modules; do
4730 func_verify_nontests_module
4731 if test -n "$module"; then
4733 gnumakefile | maintainer-makefile)
4734 # These modules are meant to be used only in the top-level directory.
4737 func_get_autoconf_snippet "$module" \
4738 | sed -e "$sed_replace_build_aux"
4743 echo "gl_source_base='.'"
4744 for module in $modules; do
4745 func_verify_tests_module
4746 if test -n "$module"; then
4747 func_get_autoconf_snippet "$module" \
4748 | sed -e "$sed_replace_build_aux"
4751 func_emit_initmacro_end $macro_prefix
4752 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4753 # created using libtool, because libtool already handles the dependencies.
4754 if test "$libtool" != true; then
4755 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4756 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4757 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4758 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4759 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4762 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4766 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4767 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4768 echo "AH_TOP([#include \"../config.h\"])"
4770 echo "AC_CONFIG_FILES([Makefile])"
4772 ) > "$testdir/$testsbase/configure.ac"
4773 auxdir="$saved_auxdir"
4774 func_append subdirs " $testsbase"
4775 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4778 # Create Makefile.am.
4779 (echo "## Process this file with automake to produce Makefile.in."
4781 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4783 echo "SUBDIRS = $subdirs"
4785 echo "ACLOCAL_AMFLAGS = -I $m4base"
4786 ) > "$testdir/Makefile.am"
4788 # Create configure.ac.
4789 (echo "# Process this file with autoconf to produce a configure script."
4790 echo "AC_INIT([dummy], [0])"
4791 if test "$auxdir" != "."; then
4792 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4794 echo "AM_INIT_AUTOMAKE"
4796 echo "AC_CONFIG_HEADERS([config.h])"
4799 echo "AC_PROG_INSTALL"
4800 echo "AC_PROG_MAKE_SET"
4802 echo "# For autobuild."
4803 echo "AC_CANONICAL_BUILD"
4804 echo "AC_CANONICAL_HOST"
4806 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4807 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4808 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4809 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4811 echo "AC_PROG_RANLIB"
4813 if test -n "$any_uses_subdirs"; then
4814 echo "AM_PROG_CC_C_O"
4817 for module in $modules; do
4818 func_verify_nontests_module
4819 if test -n "$module"; then
4820 func_get_autoconf_early_snippet "$module"
4823 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4824 if test "$libtool" = true; then
4825 echo "LT_INIT([win32-dll])"
4826 echo "LT_LANG([C++])"
4827 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4828 echo "gl_cond_libtool=true"
4830 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4831 echo "gl_cond_libtool=false"
4833 echo "gl_ltlibdeps="
4835 # Wrap the set of autoconf snippets into an autoconf macro that is then
4836 # invoked. This is needed because autoconf does not support AC_REQUIRE
4838 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4839 # but we want the AC_REQUIRE to have its normal meaning (provide one
4840 # expansion of the required macro before the current point, and only one
4842 echo "AC_DEFUN([gl_INIT], ["
4843 if test "$auxdir" != "build-aux"; then
4844 sed_replace_build_aux='
4846 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4847 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4851 sed_replace_build_aux="$sed_noop"
4853 func_emit_initmacro_start $macro_prefix
4854 echo "gl_source_base='$sourcebase'"
4855 for module in $modules; do
4856 func_verify_nontests_module
4857 if test -n "$module"; then
4858 func_get_autoconf_snippet "$module" \
4859 | sed -e "$sed_replace_build_aux"
4862 func_emit_initmacro_end $macro_prefix
4863 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4864 # created using libtool, because libtool already handles the dependencies.
4865 if test "$libtool" != true; then
4866 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4867 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4868 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4869 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4870 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4873 func_emit_initmacro_done $macro_prefix $sourcebase
4877 if test -n "$subdirs_with_configure_ac"; then
4878 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4880 makefiles="Makefile"
4881 for d in $subdirs; do
4882 # For subdirs that have a configure.ac by their own, it's the subdir's
4883 # configure.ac which creates the subdir's Makefile.am, not this one.
4884 case " $subdirs_with_configure_ac " in
4886 *) func_append makefiles " $d/Makefile" ;;
4889 echo "AC_CONFIG_FILES([$makefiles])"
4891 ) > "$testdir/configure.ac"
4893 # Create autogenerated files.
4895 # Do not use "${AUTORECONF} --force --install", because it may invoke
4896 # autopoint, which brings in older versions of some of our .m4 files.
4897 if test -f $m4base/gettext.m4; then
4898 func_execute_command ${AUTOPOINT} --force || func_exit 1
4899 for f in $m4base/*.m4~; do
4901 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4905 if test "$libtool" = true; then
4906 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
4908 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4909 if ! test -d build-aux; then
4910 func_execute_command mkdir build-aux || func_exit 1
4912 func_execute_command ${AUTOCONF} || func_exit 1
4913 func_execute_command ${AUTOHEADER} || func_exit 1
4914 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4916 if test -n "$inctests"; then
4917 # Create autogenerated files.
4918 (cd "$testdir/$testsbase" || func_exit 1
4919 # Do not use "${AUTORECONF} --force --install", because it may invoke
4920 # autopoint, which brings in older versions of some of our .m4 files.
4921 if test -f ../$m4base/gettext.m4; then
4922 func_execute_command ${AUTOPOINT} --force || func_exit 1
4923 for f in ../$m4base/*.m4~; do
4925 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4929 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4930 if ! test -d ../build-aux; then
4931 func_execute_command mkdir ../build-aux
4933 func_execute_command ${AUTOCONF} || func_exit 1
4934 func_execute_command ${AUTOHEADER} || func_exit 1
4935 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4938 # Need to run configure and make once, to create built files that are to be
4939 # distributed (such as getdate.c).
4940 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4941 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4942 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4943 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4944 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4945 # such $(FOO_H) because they don't refer to distributed files.
4946 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4947 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4948 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4949 | sed -e "$sed_remove_make_variables"`
4950 distributed_built_sources=`for file in $built_sources; do
4951 case "$cleaned_files" in
4956 if test -n "$distributed_built_sources"; then
4958 ./configure || func_exit 1
4960 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4961 $MAKE built_sources || func_exit 1
4963 $MAKE distclean || func_exit 1
4968 # func_create_megatestdir megatestdir allmodules
4970 # - local_gnulib_dir from --local-dir
4971 # - modcache true or false, from --cache-modules/--no-cache-modules
4972 # - auxdir directory relative to destdir where to place build aux files
4973 func_create_megatestdir ()
4977 if test -z "$allmodules"; then
4978 allmodules=`func_all_modules`
4982 # First, all modules one by one.
4983 for onemodule in $allmodules; do
4984 func_create_testdir "$megatestdir/$onemodule" $onemodule
4985 func_append megasubdirs "$onemodule "
4987 # Then, all modules all together.
4988 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4989 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
4990 func_create_testdir "$megatestdir/ALL" "$allmodules"
4991 func_append megasubdirs "ALL"
4994 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4995 vc_witness="$gnulib_dir/CVS/Entries"; \
4997 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4999 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5000 | sed -e 's,January,01,' -e 's,Jan,01,' \
5001 -e 's,February,02,' -e 's,Feb,02,' \
5002 -e 's,March,03,' -e 's,Mar,03,' \
5003 -e 's,April,04,' -e 's,Apr,04,' \
5005 -e 's,June,06,' -e 's,Jun,06,' \
5006 -e 's,July,07,' -e 's,Jul,07,' \
5007 -e 's,August,08,' -e 's,Aug,08,' \
5008 -e 's,September,09,' -e 's,Sep,09,' \
5009 -e 's,October,10,' -e 's,Oct,10,' \
5010 -e 's,November,11,' -e 's,Nov,11,' \
5011 -e 's,December,12,' -e 's,Dec,12,' \
5012 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5013 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5015 echo "CVSDATE=$cvsdate"
5016 echo ": \${MAKE=make}"
5017 echo "test -d logs || mkdir logs"
5018 echo "for module in $megasubdirs; do"
5019 echo " echo \"Working on module \$module...\""
5020 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5021 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5024 echo " : autobuild project... \$module"
5025 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5026 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5027 echo " : autobuild hostname... \`hostname\`"
5028 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5030 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5032 ) > "$megatestdir/do-autobuild"
5033 chmod a+x "$megatestdir/do-autobuild"
5035 # Create Makefile.am.
5036 (echo "## Process this file with automake to produce Makefile.in."
5038 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5040 echo "SUBDIRS = $megasubdirs"
5042 echo "EXTRA_DIST = do-autobuild"
5043 ) > "$megatestdir/Makefile.am"
5045 # Create configure.ac.
5046 (echo "# Process this file with autoconf to produce a configure script."
5047 echo "AC_INIT([dummy], [0])"
5048 if test "$auxdir" != "."; then
5049 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5051 echo "AM_INIT_AUTOMAKE"
5053 echo "AC_PROG_MAKE_SET"
5055 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5056 echo "AC_CONFIG_FILES([Makefile])"
5058 ) > "$megatestdir/configure.ac"
5060 # Create autogenerated files.
5062 # Do not use "${AUTORECONF} --install", because autoreconf operates
5063 # recursively, but the subdirectories are already finished, therefore
5064 # calling autoreconf here would only waste lots of CPU time.
5065 func_execute_command ${ACLOCAL} || func_exit 1
5066 func_execute_command mkdir build-aux
5067 func_execute_command ${AUTOCONF} || func_exit 1
5068 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5074 func_fatal_error "no mode specified" ;;
5081 # sed expression that converts a literal to a basic regular expression.
5082 # Needs to handle . [ \ * ^ $.
5083 sed_literal_to_basic_regex='s/\\/\\\\/g
5089 if test -f "$gnulib_dir/$filename" \
5090 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5091 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5092 filename_line_regex='^'"$filename_anywhere_regex"'$'
5095 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5096 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5097 (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$,,')
5100 | func_sanitize_modulelist \
5103 for module in $module_candidates; do
5104 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5109 func_warning "file $filename does not exist"
5117 if test -z "$destdir"; then
5120 test -d "$destdir" \
5121 || func_fatal_error "destination directory does not exist: $destdir"
5123 # Prefer configure.ac to configure.in.
5124 if test -f "$destdir"/configure.ac; then
5125 configure_ac="$destdir/configure.ac"
5127 if test -f "$destdir"/configure.in; then
5128 configure_ac="$destdir/configure.in"
5130 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5134 # Analyze configure.ac.
5136 guessed_libtool=false
5141 /AC_CONFIG_AUX_DIR/ {
5142 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5144 /A[CM]_PROG_LIBTOOL/ {
5145 s,^.*$,guessed_libtool=true,p
5147 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5149 if test -z "$auxdir"; then
5150 auxdir="$guessed_auxdir"
5153 # Determine where to apply func_import.
5154 if test -n "$m4base"; then
5155 # Apply func_import to a particular gnulib directory.
5156 # Any number of additional modules can be given.
5157 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5158 # First use of gnulib in the given m4base.
5159 test -n "$supplied_libname" || supplied_libname=true
5160 test -n "$sourcebase" || sourcebase="lib"
5161 test -n "$docbase" || docbase="doc"
5162 test -n "$testsbase" || testsbase="tests"
5163 test -n "$macro_prefix" || macro_prefix="gl"
5167 # Apply func_import to all gnulib directories.
5168 # To get this list of directories, look at Makefile.am. (Not at
5169 # configure, because it may be omitted from CVS. Also, don't run
5170 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5173 if test -f "$destdir"/Makefile.am; then
5174 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5176 for arg in $aclocal_amflags; do
5177 if test -n "$m4dir_is_next"; then
5178 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5182 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5183 func_append m4dirs " $arg"
5184 m4dirs_count=`expr $m4dirs_count + 1`
5190 if test "X$arg" = "X-I"; then
5198 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5199 if test -f "$destdir"/aclocal.m4; then
5200 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5201 sedexpr2='s,^[^/]*$,.,'
5202 sedexpr3='s,/[^/]*$,,'
5203 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5204 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5207 if test $m4dirs_count = 0; then
5208 # First use of gnulib in a package.
5209 # Any number of additional modules can be given.
5210 test -n "$supplied_libname" || supplied_libname=true
5211 test -n "$sourcebase" || sourcebase="lib"
5213 test -n "$docbase" || docbase="doc"
5214 test -n "$testsbase" || testsbase="tests"
5215 test -n "$macro_prefix" || macro_prefix="gl"
5218 if test $m4dirs_count = 1; then
5219 # There's only one use of gnulib here. Assume the user means it.
5220 # Any number of additional modules can be given.
5221 for m4base in $m4dirs; do
5225 # Ambiguous - guess what the user meant.
5226 if test $# = 0; then
5227 # No further arguments. Guess the user wants to update all of them.
5228 for m4base in $m4dirs; do
5229 # Perform func_import in a subshell, so that variable values
5231 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
5232 # pobase, docbase, testsbase, inctests, libname, lgpl,
5233 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5234 # don't propagate from one directory to another.
5235 (func_import) || func_exit 1
5239 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5247 if test -z "$destdir"; then
5248 func_fatal_error "please specify --dir option"
5251 test -d "$destdir" \
5252 || func_fatal_error "could not create destination directory"
5253 test -n "$auxdir" || auxdir="build-aux"
5254 func_create_testdir "$destdir" "$*"
5257 create-megatestdir )
5258 if test -z "$destdir"; then
5259 func_fatal_error "please specify --dir option"
5261 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5262 test -n "$auxdir" || auxdir="build-aux"
5263 func_create_megatestdir "$destdir" "$*"
5267 test -n "$destdir" || destdir=testdir$$
5268 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5269 test -n "$auxdir" || auxdir="build-aux"
5270 func_create_testdir "$destdir" "$*"
5274 ../configure || func_exit 1
5275 $MAKE || func_exit 1
5276 $MAKE check || func_exit 1
5277 $MAKE distclean || func_exit 1
5278 remaining=`find . -type f -print`
5279 if test -n "$remaining"; then
5280 echo "Remaining files:" $remaining 1>&2
5281 echo "gnulib-tool: *** Stop." 1>&2
5290 test -n "$destdir" || destdir=testdir$$
5291 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5292 test -n "$auxdir" || auxdir="build-aux"
5293 func_create_megatestdir "$destdir" "$*"
5301 remaining=`find . -type f -print`
5302 if test -n "$remaining"; then
5303 echo "Remaining files:" $remaining 1>&2
5304 echo "gnulib-tool: *** Stop." 1>&2
5312 extract-description )
5316 if test -n "$module"; then
5317 func_get_description "$module"
5326 if test -n "$module"; then
5327 func_get_comment "$module"
5336 if test -n "$module"; then
5337 func_get_status "$module"
5346 if test -n "$module"; then
5347 func_get_notice "$module"
5352 extract-applicability )
5356 if test -n "$module"; then
5357 func_get_applicability "$module"
5366 if test -n "$module"; then
5367 func_get_filelist "$module"
5372 extract-dependencies )
5376 if test -n "$module"; then
5377 func_get_dependencies "$module"
5382 extract-autoconf-snippet )
5386 if test -n "$module"; then
5387 func_get_autoconf_snippet "$module"
5392 extract-automake-snippet )
5396 if test -n "$module"; then
5397 func_get_automake_snippet "$module"
5402 extract-include-directive )
5406 if test -n "$module"; then
5407 func_get_include_directive "$module"
5412 extract-link-directive )
5416 if test -n "$module"; then
5417 func_get_link_directive "$module"
5426 if test -n "$module"; then
5427 func_get_license "$module"
5432 extract-maintainer )
5436 if test -n "$module"; then
5437 func_get_maintainer "$module"
5442 extract-tests-module )
5446 if test -n "$module"; then
5447 func_get_tests_module "$module"
5453 # Verify the number of arguments.
5454 if test $# -lt 1 || test $# -gt 2; then
5455 func_fatal_error "invalid number of arguments for --$mode"
5458 # The first argument is the file to be copied.
5460 # Verify the file exists.
5461 func_lookup_file "$f"
5463 # The second argument is the destination; either a directory ot a file.
5464 # It defaults to the current directory.
5466 test -n "$dest" || dest='.'
5467 test -n "$sourcebase" || sourcebase="lib"
5468 test -n "$m4base" || m4base="m4"
5469 test -n "$docbase" || docbase="doc"
5470 test -n "$testsbase" || testsbase="tests"
5471 test -n "$auxdir" || auxdir="build-aux"
5472 rewritten='%REWRITTEN%'
5473 sed_rewrite_files="\
5474 s,^build-aux/,$rewritten$auxdir/,
5475 s,^doc/,$rewritten$docbase/,
5476 s,^lib/,$rewritten$sourcebase/,
5477 s,^m4/,$rewritten$m4base/,
5478 s,^tests/,$rewritten$testsbase/,
5481 if test -d "$dest"; then
5483 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5485 destdir=`dirname "$dest"`
5486 g=`basename "$dest"`
5489 # Create the directory for destfile.
5490 d=`dirname "$destdir/$g"`
5492 if test -n "$d" && test ! -d "$d"; then
5493 mkdir -p "$d" || func_fatal_error "failed"
5497 func_dest_tmpfilename "$g"
5498 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5499 already_present=true
5500 if test -f "$destdir/$g"; then
5501 # The file already exists.
5505 # Don't protest if the file should be there but isn't: it happens
5506 # frequently that developers don't put autogenerated files into CVS.
5513 func_fatal_error "unknown operation mode --$mode" ;;
5517 # Undo the effect of the previous 'trap' command. Some shellology:
5518 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5519 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5520 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5521 # 128 + signal number and is set before the trap-registered command is run.
5523 trap 'func_exit $?' 1 2 3 13 15
5528 # indent-tabs-mode: nil
5529 # whitespace-check-buffer-indent: nil