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 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
44 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
45 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
46 AUTOCONF="${AUTOCONFPATH}autoconf"
48 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
49 AUTOHEADER="${AUTOCONFPATH}autoheader"
51 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
52 ACLOCAL="${AUTOMAKEPATH}aclocal"
54 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
55 AUTOMAKE="${AUTOMAKEPATH}automake"
57 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
58 AUTORECONF="${AUTOCONFPATH}autoreconf"
61 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
62 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
63 AUTOPOINT="${GETTEXTPATH}autopoint"
67 if test -z "${MAKE}"; then
71 # When using GNU sed, turn off as many GNU extensions as possible,
72 # to minimize the risk of accidentally using non-portable features.
73 # However, do this only for gnulib-tool itself, not for the code that
74 # gnulib-tool generates, since we don't want "sed --posix" to leak
75 # into makefiles. And do it only for sed versions 4.2 or newer,
76 # because "sed --posix" is buggy in GNU sed 4.1.5, see
77 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
78 if (alias) > /dev/null 2>&1 \
79 && echo | sed --posix -e d >/dev/null 2>&1 \
80 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
81 [1-3]* | 4.[01]*) false;; \
85 # Define sed as an alias.
86 # It is not always possible to use aliases. Aliases are guaranteed to work
87 # if the executing shell is bash and either it is invoked as /bin/sh or
88 # is a version >= 2.0, supporting shopt. This is the common case.
89 # Two other approaches (use of a variable $sed or of a function func_sed
90 # instead of an alias) require massive, fragile code changes.
91 # An other approach (use of function sed) requires `which sed` - but
92 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
93 if test -n "$BASH_VERSION"; then
94 shopt -s expand_aliases >/dev/null 2>&1
96 alias sed='sed --posix'
99 # sed_noop is a sed expression that does nothing.
100 # An empty expression does not work with the native 'sed' on AIX 6.1.
104 # outputs to stdout the --help usage message.
108 Usage: gnulib-tool --list
109 gnulib-tool --import [module1 ... moduleN]
111 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
112 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
113 gnulib-tool --test --dir=directory module1 ... moduleN
114 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
115 gnulib-tool --extract-description module
116 gnulib-tool --extract-status module
117 gnulib-tool --extract-notice module
118 gnulib-tool --extract-applicability module
119 gnulib-tool --extract-filelist module
120 gnulib-tool --extract-dependencies module
121 gnulib-tool --extract-autoconf-snippet module
122 gnulib-tool --extract-automake-snippet module
123 gnulib-tool --extract-include-directive module
124 gnulib-tool --extract-link-directive module
125 gnulib-tool --extract-license module
126 gnulib-tool --extract-maintainer module
127 gnulib-tool --extract-tests-module module
128 gnulib-tool --copy-file file [destination]
131 --list print the available module names
132 --import import the given modules into the current package;
133 if no modules are specified, update the current
134 package from the current gnulib
135 --update update the current package, restore files omitted
137 --create-testdir create a scratch package with the given modules
138 --create-megatestdir create a mega scratch package with the given modules
139 one by one and all together
140 --test test the combination of the given modules
141 (recommended to use CC=\"gcc -Wall\" here)
142 --megatest test the given modules one by one and all together
143 (recommended to use CC=\"gcc -Wall\" here)
144 --extract-description extract the description
145 --extract-status extract the status (obsolete or not)
146 --extract-notice extract the notice or banner
147 --extract-filelist extract the list of files
148 --extract-dependencies extract the dependencies
149 --extract-autoconf-snippet extract the snippet for configure.ac
150 --extract-automake-snippet extract the snippet for library makefile
151 --extract-include-directive extract the #include directive
152 --extract-link-directive extract the linker directive
153 --extract-license report the license terms of the source files
155 --extract-maintainer report the maintainer(s) inside gnulib
156 --extract-tests-module report the unit test module, if it exists
157 --copy-file copy a file that is not part of any module
160 --dir=DIRECTORY Specify the target directory.
161 For --import, this specifies where your
162 configure.ac can be found. Defaults to current
164 --local-dir=DIRECTORY Specify a local override directory where to look
165 up files before looking in gnulib's directory.
166 --verbose Increase verbosity. May be repeated.
167 --quiet Decrease verbosity. May be repeated.
169 Options for --import:
170 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
171 --source-base=DIRECTORY
172 Directory relative to --dir where source code is
173 placed (default \"lib\").
174 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
175 placed (default \"m4\").
176 --po-base=DIRECTORY Directory relative to --dir where *.po files are
177 placed (default \"po\").
178 --doc-base=DIRECTORY Directory relative to --dir where doc files are
179 placed (default \"doc\").
180 --tests-base=DIRECTORY
181 Directory relative to --dir where unit tests are
182 placed (default \"tests\").
183 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
184 tools are placed (default \"build-aux\").
185 --with-tests Include unit tests for the included modules.
186 --with-obsolete Include obsolete modules when they occur among the
187 dependencies. By default, dependencies to obsolete
189 --avoid=MODULE Avoid including the given MODULE. Useful if you
190 have code that provides equivalent functionality.
191 This option can be repeated.
192 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
193 Also modify license template from GPL to LGPL.
194 The version number of the LGPL can be specified;
195 the default is currently LGPLv3.
196 --makefile-name=NAME Name of makefile in automake syntax in the
197 source-base and tests-base directories
198 (default \"Makefile.am\").
199 --libtool Use libtool rules.
200 --no-libtool Don't use libtool rules.
201 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
202 'gl_INIT'. Default is 'gl'.
203 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
204 the package name. A suffix '-gnulib' is appended.
205 --vc-files Update version control related files.
206 --no-vc-files Don't update version control related files
207 (.gitignore and/or .cvsignore).
208 --no-changelog Don't update or create ChangeLog files.
210 Options for --import and --update:
211 --dry-run For --import, only print what would have been done.
212 -s, --symbolic, --symlink Make symbolic links instead of copying files.
213 --local-symlink Make symbolic links instead of copying files, only
214 for files from the local override directory.
215 -S, --more-symlinks Make symbolic links instead of copying files, and
216 don't replace copyright notices.
218 Report bugs to <bug-gnulib@gnu.org>."
222 # outputs to stdout the --version message.
226 if test -d "$gnulib_dir"/.git \
227 && (git --version) >/dev/null 2>/dev/null \
228 && (date --version) >/dev/null 2>/dev/null; then
229 # gnulib checked out from git.
230 sed_extract_first_date='/^Date/{
234 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
235 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
236 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
237 date=`echo "$date" | sed -e "$sed_year_before_time"`
238 # Use GNU date to compute the time in GMT.
239 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
240 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
242 if test -d "$gnulib_dir"/CVS \
243 && (cvs --version) >/dev/null 2>/dev/null; then
244 # gnulib checked out from CVS.
245 sed_extract_first_date='/^date: /{
246 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
249 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
251 # gnulib copy without versioning information.
252 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
256 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
258 gnulib-tool (GNU $package $date)$version
259 Copyright (C) $year Free Software Foundation, Inc.
260 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
261 This is free software: you are free to change and redistribute it.
262 There is NO WARRANTY, to the extent permitted by law.
264 Written by" "Bruno Haible" "and" "Simon Josefsson"
267 # func_emit_copyright_notice
268 # outputs to stdout a header for a generated file.
269 func_emit_copyright_notice ()
271 sed -n -e '/Copyright/ {
274 }' < "$self_abspathname"
276 echo "# This file is free software, distributed under the terms of the GNU"
277 echo "# General Public License. As a special exception to the GNU General"
278 echo "# Public License, this file may be distributed as part of a program"
279 echo "# that contains a configuration script generated by Autoconf, under"
280 echo "# the same distribution terms as the rest of that program."
282 echo "# Generated by gnulib-tool."
286 # exits with a given status.
287 # This function needs to be used, rather than 'exit', when a 'trap' handler is
288 # in effect that refers to $?.
295 # locates the directory where the gnulib repository lives
297 # - progname name of this program
299 # - self_abspathname absolute pathname of gnulib-tool
300 # - gnulib_dir absolute pathname of gnulib repository
304 /*) self_abspathname="$progname" ;;
305 */*) self_abspathname=`pwd`/"$progname" ;;
308 # Iterate through the elements of $PATH.
309 # We use IFS=: instead of
310 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
311 # because the latter does not work when some PATH element contains spaces.
312 # We use a canonicalized $pathx instead of $PATH, because empty PATH
313 # elements are by definition equivalent to '.', however field splitting
314 # according to IFS=: loses empty fields in many shells:
315 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
316 # beginning, at the end, and in the middle),
317 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
318 # at the beginning and at the end,
319 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
320 # Solaris lose empty fields at the end.
321 # The 'case' statement is an optimization, to avoid evaluating the
322 # explicit canonicalization command when $PATH contains no empty fields.
324 if test "${PATH_SEPARATOR+set}" != set; then
326 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
327 chmod +x "$tmp"/conf.sh
328 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
335 if test "$PATH_SEPARATOR" = ";"; then
336 # On Windows, programs are searched in "." before $PATH.
339 # On Unix, we have to convert empty PATH elements to ".".
343 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
348 IFS="$PATH_SEPARATOR"
352 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
353 self_abspathname="$d/$progname"
358 if test -z "$self_abspathname"; then
359 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
363 while test -h "$self_abspathname"; do
364 # Resolve symbolic link.
365 linkval=`func_readlink "$self_abspathname"`
366 test -n "$linkval" || break
368 /* ) self_abspathname="$linkval" ;;
369 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
372 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
376 # creates a temporary directory.
378 # - progname name of this program
380 # - tmp pathname of freshly created temporary directory
383 # Use the environment variable TMPDIR, falling back to /tmp. This allows
384 # users to specify a different temporary directory, for example, if their
385 # /tmp is filled up or too small.
388 # Use the mktemp program if available. If not available, hide the error
390 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
391 test -n "$tmp" && test -d "$tmp"
394 # Use a simple mkdir command. It is guaranteed to fail if the directory
395 # already exists. $RANDOM is bash specific and expands to empty in shells
396 # other than bash, ksh and zsh. Its use does not increase security;
397 # rather, it minimizes the probability of failure in a very cluttered /tmp
399 tmp=$TMPDIR/gl$$-$RANDOM
400 (umask 077 && mkdir "$tmp")
403 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
408 # func_append var value
409 # appends the given value to the shell variable var.
410 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
411 # Use bash's += operator. It reduces complexity of appending repeatedly to
412 # a single variable from O(n^2) to O(n).
417 fast_func_append=true
421 eval "$1=\"\$$1\$2\""
423 fast_func_append=false
426 # func_remove_prefix var prefix
427 # removes the given prefix from the value of the shell variable var.
428 # var should be the name of a shell variable.
429 # Its value should not contain a newline and not start or end with whitespace.
430 # prefix should not contain the characters "$`\{}[]^|.
431 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
432 func_remove_prefix ()
436 fast_func_remove_prefix=true
438 func_remove_prefix ()
440 eval "value=\"\$$1\""
444 sed_escape_dots='s/\([.]\)/\\\1/g'
445 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
448 value=`echo "$value" | sed -e "s|^${prefix}||"`
449 eval "$1=\"\$value\""
451 fast_func_remove_prefix=false
454 # func_remove_suffix var suffix
455 # removes the given suffix from the value of the shell variable var.
456 # var should be the name of a shell variable.
457 # Its value should not contain a newline and not start or end with whitespace.
458 # suffix should not contain the characters "$`\{}[]^|.
459 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
460 func_remove_suffix ()
464 fast_func_remove_suffix=true
466 func_remove_suffix ()
468 eval "value=\"\$$1\""
472 sed_escape_dots='s/\([.]\)/\\\1/g'
473 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
476 value=`echo "$value" | sed -e "s|${suffix}\$||"`
477 eval "$1=\"\$value\""
479 fast_func_remove_suffix=false
482 # func_fatal_error message
483 # outputs to stderr a fatal error message, and terminates the program.
485 # - progname name of this program
488 echo "$progname: *** $1" 1>&2
489 echo "$progname: *** Stop." 1>&2
493 # func_warning message
494 # Outputs to stderr a warning message,
497 echo "gnulib-tool: warning: $1" 1>&2
500 # func_readlink SYMLINK
501 # outputs the target of the given symlink.
502 if (type -p readlink) > /dev/null 2>&1; then
505 # Use the readlink program from GNU coreutils.
511 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
512 # would do the wrong thing if the link target contains " -> ".
513 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
517 # func_relativize DIR1 DIR2
518 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
520 # - DIR1 relative pathname, relative to the current directory
521 # - DIR2 relative pathname, relative to the current directory
523 # - reldir relative pathname of DIR2, relative to DIR1
529 sed_first='s,^\([^/]*\)/.*$,\1,'
530 sed_rest='s,^[^/]*/*,,'
531 sed_last='s,^.*/\([^/]*\)$,\1,'
532 sed_butlast='s,/*[^/]*$,,'
533 while test -n "$dir1"; do
534 first=`echo "$dir1" | sed -e "$sed_first"`
535 if test "$first" != "."; then
536 if test "$first" = ".."; then
537 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
538 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
540 first2=`echo "$dir2" | sed -e "$sed_first"`
541 if test "$first2" = "$first"; then
542 dir2=`echo "$dir2" | sed -e "$sed_rest"`
546 dir0="$dir0"/"$first"
549 dir1=`echo "$dir1" | sed -e "$sed_rest"`
554 # func_relconcat DIR1 DIR2
555 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
557 # - DIR1 relative pathname, relative to the current directory
558 # - DIR2 relative pathname, relative to DIR1
560 # - relconcat DIR1/DIR2, relative to the current directory
565 sed_first='s,^\([^/]*\)/.*$,\1,'
566 sed_rest='s,^[^/]*/*,,'
567 sed_last='s,^.*/\([^/]*\)$,\1,'
568 sed_butlast='s,/*[^/]*$,,'
570 first=`echo "$dir2" | sed -e "$sed_first"`
571 if test "$first" = "."; then
572 dir2=`echo "$dir2" | sed -e "$sed_rest"`
573 if test -z "$dir2"; then
578 last=`echo "$dir1" | sed -e "$sed_last"`
579 while test "$last" = "."; do
580 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
581 last=`echo "$dir1" | sed -e "$sed_last"`
583 if test -z "$dir1"; then
587 if test "$first" = ".."; then
588 if test "$last" = ".."; then
589 relconcat="$dir1/$dir2"
592 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
593 dir2=`echo "$dir2" | sed -e "$sed_rest"`
594 if test -z "$dir1"; then
598 if test -z "$dir2"; then
603 relconcat="$dir1/$dir2"
611 # Like ln -s, except that SRC is given relative to the current directory (or
612 # absolute), not given relative to the directory of DEST.
618 *) # SRC is relative.
621 ln -s "`pwd`/$1" "$2" ;;
622 *) # DEST is relative too.
623 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
624 test -n "$ln_destdir" || ln_destdir="."
625 func_relativize "$ln_destdir" "$1"
633 # func_ln_if_changed SRC DEST
634 # Like func_ln, but avoids munging timestamps if the link is correct.
635 func_ln_if_changed ()
637 if test $# -ne 2; then
638 echo "usage: func_ln_if_changed SRC DEST" >&2
640 ln_target=`func_readlink "$2"`
641 if test -h "$2" && test "$1" = "$ln_target"; then
650 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
651 # writes into a pipe with no readers, i.e. a pipe where all readers have
652 # already closed their file descriptor that read from it or exited entirely.
653 # The default behaviour is to terminate the current process without an error
655 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
656 # terminate the current process with an error message.
657 # This function should be called at the beginning of a command that only
658 # produces output to stdout (i.e. no side effects!), when the command that
659 # will read from this pipe might prematurely exit or close its standard input
661 if test -n "$BASH_VERSION"; then
662 # The problem has only been reported with bash. Probably it occurs only with
663 # bash-3.2. For the reasons, see
664 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
665 # Note that Solaris sh does not understand "trap - SIGPIPE".
666 func_reset_sigpipe ()
671 func_reset_sigpipe ()
677 # Ensure an 'echo' command that does not interpret backslashes.
679 # echo '\n' | wc -l prints 1 when OK, 2 when KO
680 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
681 # This problem is a weird heritage from SVR4. BSD got it right (except that
682 # BSD echo interprets '-n' as an option, which is also not desirable).
683 # Nowadays the problem occurs in 4 situations:
684 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
685 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
686 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
687 # - in zsh, when sh-emulation is not set,
688 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
689 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
690 # - in Solaris /bin/sh and OSF/1 /bin/sh.
691 # We try the following workarounds:
692 # - for all: respawn using $CONFIG_SHELL if that is set and works.
693 # - for bash >= 2.04: unset the shell option xpg_echo.
694 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
695 # - for bash < 2.0: define echo to a function that uses cat of a here document.
696 # - for zsh: turn sh-emulation on.
697 # - for ksh: alias echo to 'print -r'.
698 # - for ksh: alias echo to a function that uses cat of a here document.
699 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
700 # the ksh workaround.
701 # - otherwise: respawn using /bin/sh and rely on the workarounds.
702 # When respawning, we pass --no-reexec as first argument, so as to avoid
703 # turning this script into a fork bomb in unlucky situations.
705 if echo '\t' | grep t > /dev/null; then
706 have_echo=yes # Lucky!
708 # Try the workarounds.
709 # Respawn using $CONFIG_SHELL if that is set and works.
710 if test -z "$have_echo" \
711 && test "X$1" != "X--no-reexec" \
712 && test -n "$CONFIG_SHELL" \
713 && test -f "$CONFIG_SHELL" \
714 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
715 exec $CONFIG_SHELL "$0" --no-reexec "$@"
718 # For bash >= 2.04: unset the shell option xpg_echo.
719 if test -z "$have_echo" \
720 && test -n "$BASH_VERSION" \
721 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
725 # For bash >= 2.0: define echo to a function that uses the printf built-in.
726 # For bash < 2.0: define echo to a function that uses cat of a here document.
727 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
728 if test -z "$have_echo" \
729 && test -n "$BASH_VERSION"; then \
730 if type printf 2>/dev/null | grep / > /dev/null; then
731 # 'printf' is not a shell built-in.
739 # 'printf' is a shell built-in.
745 if echo '\t' | grep t > /dev/null; then
749 # For zsh: turn sh-emulation on.
750 if test -z "$have_echo" \
751 && test -n "$ZSH_VERSION" \
752 && (emulate sh) >/dev/null 2>&1; then
755 # For ksh: alias echo to 'print -r'.
756 if test -z "$have_echo" \
757 && (type print) >/dev/null 2>&1; then
758 # A 'print' command exists.
759 if type print 2>/dev/null | grep / > /dev/null; then
762 # 'print' is a shell built-in.
763 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
764 # 'print' is the ksh shell built-in.
765 alias echo='print -r'
769 if test -z "$have_echo" \
770 && echo '\t' | grep t > /dev/null; then
773 # For ksh: alias echo to a function that uses cat of a here document.
774 # The ksh manual page says:
775 # "Aliasing is performed when scripts are read, not while they are executed.
776 # Therefore, for an alias to take effect, the alias definition command has
777 # to be executed before the command which references the alias is read."
778 # Because of this, we have to play strange tricks with have_echo, to ensure
779 # that the top-level statement containing the test starts after the 'alias'
781 if test -z "$have_echo"; then
788 alias echo=bsd_echo 2>/dev/null
790 if test -z "$have_echo" \
791 && echo '\t' | grep t > /dev/null; then
794 if test -z "$have_echo"; then
795 unalias echo 2>/dev/null
797 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
798 if test -z "$have_echo" \
799 && test "X$1" != "X--no-reexec" \
800 && test -f /bin/ksh; then
801 exec /bin/ksh "$0" --no-reexec "$@"
804 # Otherwise: respawn using /bin/sh.
805 if test -z "$have_echo" \
806 && test "X$1" != "X--no-reexec" \
807 && test -f /bin/sh; then
808 exec /bin/sh "$0" --no-reexec "$@"
811 if test -z "$have_echo"; then
812 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
814 if echo '\t' | grep t > /dev/null; then
817 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
819 if test "X$1" = "X--no-reexec"; then
823 # Command-line option processing.
824 # Removes the OPTIONS from the arguments. Sets the variables:
825 # - mode list or import or create-testdir or create-megatestdir
826 # - destdir from --dir
827 # - local_gnulib_dir from --local-dir
828 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
829 # - libname, supplied_libname from --lib
830 # - sourcebase from --source-base
831 # - m4base from --m4-base
832 # - pobase from --po-base
833 # - docbase from --doc-base
834 # - testsbase from --tests-base
835 # - auxdir from --aux-dir
836 # - inctests true if --with-tests was given, blank otherwise
837 # - incobsolete true if --with-obsolete was given, blank otherwise
838 # - avoidlist list of modules to avoid, from --avoid
839 # - lgpl yes or a number if --lgpl was given, blank otherwise
840 # - makefile_name from --makefile-name
841 # - libtool true if --libtool was given, false if --no-libtool was
842 # given, blank otherwise
843 # - macro_prefix from --macro-prefix
844 # - po_domain from --po-domain
845 # - vc_files true if --vc-files was given, false if --no-vc-files was
846 # given, blank otherwise
847 # - autoconf_minversion minimum supported autoconf version
848 # - do_changelog false if --no-changelog was given, : otherwise
849 # - doit : if actions shall be executed, false if only to be printed
850 # - symbolic true if --symlink or --more-symlinks was given, blank
852 # - lsymbolic true if --local-symlink was given, blank otherwise
853 # - do_copyrights blank if --more-symlinks was given, true otherwise
884 while test $# -gt 0; do
889 --import | --impor | --impo | --imp | --im | --i )
892 --update | --updat | --upda | --upd | --up | --u )
895 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
898 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
899 mode=create-megatestdir
901 --test | --tes | --te | --t )
904 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
908 mode=`echo "X$1" | sed -e 's/^X--//'`
910 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
916 func_fatal_error "missing argument for --dir"
921 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
926 func_fatal_error "missing argument for --local-dir"
931 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
933 --verbose | --verbos | --verbo | --verb )
934 verbose=`expr $verbose + 1`
936 --quiet | --quie | --qui | --qu | --q )
937 verbose=`expr $verbose - 1`
942 func_fatal_error "missing argument for --lib"
945 supplied_libname=true
948 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
949 supplied_libname=true
954 func_fatal_error "missing argument for --source-base"
959 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
964 func_fatal_error "missing argument for --m4-base"
969 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
974 func_fatal_error "missing argument for --po-base"
979 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
984 func_fatal_error "missing argument for --doc-base"
989 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
994 func_fatal_error "missing argument for --tests-base"
999 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1003 if test $# = 0; then
1004 func_fatal_error "missing argument for --aux-dir"
1009 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1019 if test $# = 0; then
1020 func_fatal_error "missing argument for --avoid"
1022 func_append avoidlist " $1"
1025 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1026 func_append avoidlist " $arg"
1032 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1035 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1041 if test $# = 0; then
1042 func_fatal_error "missing argument for --makefile-name"
1047 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1057 if test $# = 0; then
1058 func_fatal_error "missing argument for --macro-prefix"
1063 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1067 if test $# = 0; then
1068 func_fatal_error "missing argument for --po-domain"
1073 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1081 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
1087 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1090 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1093 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1097 --help | --hel | --he | --h )
1100 --version | --versio | --versi | --vers )
1104 # Stop option processing
1108 echo "gnulib-tool: unknown option $1" 1>&2
1109 echo "Try 'gnulib-tool --help' for more information." 1>&2
1116 if test "$mode" = update; then
1117 if test $# != 0; then
1118 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1119 echo "Try 'gnulib-tool --help' for more information." 1>&2
1120 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1121 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1124 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1125 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1126 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1127 || test -n "$inctests" || test -n "$incobsolete" \
1128 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1129 || test -n "$macro_prefix" || test -n "$po_domain" \
1130 || test -n "$vc_files"; then
1131 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1132 echo "Try 'gnulib-tool --help' for more information." 1>&2
1133 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1134 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1139 if test -n "$pobase" && test -z "$po_domain"; then
1140 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1141 echo "Try 'gnulib-tool --help' for more information." 1>&2
1144 if test -z "$pobase" && test -n "$po_domain"; then
1145 func_warning "--po-domain has no effect without a --po-base option"
1148 # Determine the minimum supported autoconf version from the project's
1150 DEFAULT_AUTOCONF_MINVERSION="2.59"
1151 autoconf_minversion=
1153 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1154 if test -f "$destdir"/configure.ac; then
1155 configure_ac="$destdir/configure.ac"
1157 if test -f "$destdir"/configure.in; then
1158 configure_ac="$destdir/configure.in"
1162 if test -f configure.ac; then
1163 configure_ac="configure.ac"
1165 if test -f configure.in; then
1166 configure_ac="configure.in"
1170 if test -n "$configure_ac"; then
1171 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1172 # because when some m4 files are omitted from a CVS repository,
1173 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1174 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1175 # autom4te: m4 failed with exit status: 1
1182 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1184 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1185 if test -n "$prereqs"; then
1186 autoconf_minversion=`
1187 for version in $prereqs; do echo $version; done |
1188 LC_ALL=C sort -nru | sed -e 1q
1192 if test -z "$autoconf_minversion"; then
1193 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1195 case "$autoconf_minversion" in
1196 1.* | 2.[0-4]* | 2.5[0-8]*)
1197 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1200 # Remove trailing slashes from the directory names. This is necessary for
1201 # m4base (to avoid an error in func_import) and optional for the others.
1202 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1203 case "$local_gnulib_dir" in
1204 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1206 case "$sourcebase" in
1207 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1210 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1213 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1216 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1218 case "$testsbase" in
1219 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1222 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1228 trap 'exit_status=$?
1229 if test "$signal" != 0; then
1230 echo "caught signal $signal" >&2
1233 exit $exit_status' 0
1234 for signal in 1 2 3 13 15; do
1235 trap '{ signal='$signal'; func_exit 1; }' $signal
1239 # func_lookup_file file
1240 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1243 # - local_gnulib_dir from --local-dir
1245 # - lookedup_file name of the merged (combined) file
1246 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1250 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1251 lookedup_file="$local_gnulib_dir/$lkfile"
1254 if test -f "$gnulib_dir/$lkfile"; then
1255 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1256 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1257 rm -f "$tmp/$lkbase"
1258 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1259 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1260 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1261 lookedup_file="$tmp/$lkbase"
1264 lookedup_file="$gnulib_dir/$lkfile"
1268 func_fatal_error "file $gnulib_dir/$lkfile not found"
1275 # - local_gnulib_dir from --local-dir
1278 # Filter out metainformation files like README, which are not modules.
1279 # Filter out unit test modules; they can be retrieved through
1280 # --extract-tests-module if desired.
1282 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1283 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1284 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1287 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1288 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1289 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1290 -e '/^README$/d' -e '/\/README$/d' \
1291 -e '/^TEMPLATE$/d' \
1292 -e '/^TEMPLATE-EXTENDED$/d' \
1293 -e '/^TEMPLATE-TESTS$/d' \
1296 | sed -e '/-tests$/d' \
1300 # func_verify_module
1301 # verifies a module name
1303 # - local_gnulib_dir from --local-dir
1304 # - module module name argument
1305 func_verify_module ()
1307 if { test -f "$gnulib_dir/modules/$module" \
1308 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1309 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1310 && test "CVS" != "$module" \
1311 && test "ChangeLog" != "$module" \
1312 && test "COPYING" != "$module" \
1313 && test "README" != "$module" \
1314 && test "TEMPLATE" != "$module" \
1315 && test "TEMPLATE-EXTENDED" != "$module" \
1316 && test "TEMPLATE-TESTS" != "$module"; then
1317 # OK, $module is a correct module name.
1318 # Verify that building the module description with 'patch' succeeds.
1319 func_lookup_file "modules/$module"
1321 func_warning "module $module doesn't exist"
1326 # func_verify_nontests_module
1327 # verifies a module name, excluding tests modules
1329 # - local_gnulib_dir from --local-dir
1330 # - module module name argument
1331 func_verify_nontests_module ()
1334 *-tests ) module= ;;
1335 * ) func_verify_module ;;
1339 # func_verify_tests_module
1340 # verifies a module name, considering only tests modules
1342 # - local_gnulib_dir from --local-dir
1343 # - module module name argument
1344 func_verify_tests_module ()
1347 *-tests ) func_verify_module ;;
1352 sed_extract_prog=':[ ]*$/ {
1355 s/^Description:[ ]*$//
1358 s/^Applicability:[ ]*$//
1360 s/^Depends-on:[ ]*$//
1361 s/^configure\.ac-early:[ ]*$//
1362 s/^configure\.ac:[ ]*$//
1363 s/^Makefile\.am:[ ]*$//
1367 s/^Maintainer:[ ]*$//
1374 # func_get_description module
1376 # - local_gnulib_dir from --local-dir
1377 func_get_description ()
1379 func_lookup_file "modules/$1"
1380 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1383 # func_get_status module
1385 # - local_gnulib_dir from --local-dir
1388 func_lookup_file "modules/$1"
1389 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1392 # func_get_notice module
1394 # - local_gnulib_dir from --local-dir
1397 func_lookup_file "modules/$1"
1398 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1401 # func_get_applicability module
1403 # - local_gnulib_dir from --local-dir
1404 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1405 func_get_applicability ()
1407 func_lookup_file "modules/$1"
1408 { sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"
1409 # The default is 'main' or 'tests', depending on the module's name.
1411 *-tests) echo "tests";;
1414 } | sed -e 's,^ *$,,' | sed -e 1q
1417 # func_get_filelist module
1419 # - local_gnulib_dir from --local-dir
1420 func_get_filelist ()
1422 func_lookup_file "modules/$1"
1423 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1425 echo m4/gnulib-common.m4
1426 case "$autoconf_minversion" in
1433 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1434 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1435 # elements starting with prefix and ending with suffix are considered.
1436 # Processing: removed_prefix and removed_suffix are removed from each element,
1437 # added_prefix and added_suffix are added to each element.
1438 # prefix, suffix should not contain shell-special characters.
1439 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1440 # added_prefix, added_suffix should not contain the characters \|&.
1441 func_filter_filelist ()
1443 if test "$2" != "$nl" \
1444 || { $fast_func_append \
1445 && { test -z "$6" || $fast_func_remove_prefix; } \
1446 && { test -z "$7" || $fast_func_remove_suffix; }; \
1450 # Do not quote possibly-empty parameters in case patterns,
1451 # AIX and HP-UX ksh won't match them if they are empty.
1454 if test -n "$6"; then
1455 func_remove_prefix fff "$6"
1457 if test -n "$7"; then
1458 func_remove_suffix fff "$7"
1461 if test -z "$ffflist"; then
1464 func_append ffflist "$2${fff}"
1470 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1471 ffflist=`for fff in $3; do
1473 $4*$5) echo "$fff" ;;
1475 done | sed -e "$sed_fff_filter"`
1477 eval "$1=\"\$ffflist\""
1480 # func_get_dependencies module
1482 # - local_gnulib_dir from --local-dir
1483 func_get_dependencies ()
1485 # ${module}-tests always implicitly depends on ${module}.
1489 func_remove_suffix fgd1 '-tests'
1493 # Then the explicit dependencies listed in the module description.
1494 func_lookup_file "modules/$1"
1495 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1498 # func_get_autoconf_early_snippet module
1500 # - local_gnulib_dir from --local-dir
1501 func_get_autoconf_early_snippet ()
1503 func_lookup_file "modules/$1"
1504 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1507 # func_get_autoconf_snippet module
1509 # - local_gnulib_dir from --local-dir
1510 func_get_autoconf_snippet ()
1512 func_lookup_file "modules/$1"
1513 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1516 # func_get_automake_snippet module
1518 # - local_gnulib_dir from --local-dir
1519 func_get_automake_snippet ()
1521 func_lookup_file "modules/$1"
1522 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1525 # *-tests module live in tests/, not lib/.
1526 # Synthesize an EXTRA_DIST augmentation.
1527 all_files=`func_get_filelist $1`
1528 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1529 extra_files="$tests_files"
1530 if test -n "$extra_files"; then
1531 echo "EXTRA_DIST +=" $extra_files
1536 # Synthesize an EXTRA_DIST augmentation.
1537 sed_combine_lines='/\\$/{
1544 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1545 already_mentioned_files=` \
1546 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1547 | sed -e "$sed_combine_lines" \
1548 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1549 all_files=`func_get_filelist $1`
1550 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
1551 # Remove $already_mentioned_files from $lib_files.
1552 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1553 extra_files=`func_reset_sigpipe; \
1554 for f in $already_mentioned_files; do echo $f; done \
1555 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1556 if test -n "$extra_files"; then
1557 echo "EXTRA_DIST +=" $extra_files
1560 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1561 # This is necessary so that automake can generate the right list of
1563 # A possible approach would be to use autom4te --trace of the redefined
1564 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1565 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1566 # inside autoconf's built-in macros are not missed).
1567 # But it's simpler and more robust to do it here, based on the file list.
1568 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1569 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1570 # automake will generate a useless dependency; this is harmless.
1572 relocatable-prog-wrapper) ;;
1574 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
1575 if test -n "$extra_files"; then
1576 echo "EXTRA_lib_SOURCES +=" $extra_files
1581 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1582 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
1583 if test -n "$buildaux_files"; then
1584 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1585 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1588 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1589 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
1590 if test -n "$top_files"; then
1591 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1592 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1599 # func_get_include_directive module
1601 # - local_gnulib_dir from --local-dir
1602 func_get_include_directive ()
1604 func_lookup_file "modules/$1"
1605 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1606 sed -e 's/^\(["<]\)/#include \1/'
1609 # func_get_link_directive module
1611 # - local_gnulib_dir from --local-dir
1612 func_get_link_directive ()
1614 func_lookup_file "modules/$1"
1615 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1618 # func_get_license module
1620 # - local_gnulib_dir from --local-dir
1623 func_lookup_file "modules/$1"
1624 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1625 # The default is GPL.
1627 } | sed -e 's,^ *$,,' | sed -e 1q
1630 # func_get_maintainer module
1632 # - local_gnulib_dir from --local-dir
1633 func_get_maintainer ()
1635 func_lookup_file "modules/$1"
1636 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1639 # func_get_tests_module module
1641 # - local_gnulib_dir from --local-dir
1642 func_get_tests_module ()
1644 # The naming convention for tests modules is hardwired: ${module}-tests.
1645 if test -f "$gnulib_dir/modules/$1"-tests \
1646 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1647 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1652 # func_acceptable module
1653 # tests whether a module is acceptable.
1655 # - avoidlist list of modules to avoid
1658 for avoid in $avoidlist; do
1659 if test "$avoid" = "$1"; then
1666 # func_modules_transitive_closure
1668 # - local_gnulib_dir from --local-dir
1669 # - modules list of specified modules
1670 # - inctests true if tests should be included, blank otherwise
1671 # - incobsolete true if obsolete modules among dependencies should be
1672 # included, blank otherwise
1673 # - avoidlist list of modules to avoid
1674 # - tmp pathname of a temporary directory
1676 # - modules list of modules, including dependencies
1677 func_modules_transitive_closure ()
1679 # In order to process every module only once (for speed), process an "input
1680 # list" of modules, producing an "output list" of modules. During each round,
1681 # more modules can be queued in the input list. Once a module on the input
1682 # list has been processed, it is added to the "handled list", so we can avoid
1683 # to process it again.
1685 inmodules="$modules"
1687 while test -n "$inmodules"; do
1688 inmodules_this_round="$inmodules"
1689 inmodules= # Accumulator, queue for next round
1690 for module in $inmodules_this_round; do
1692 if test -n "$module"; then
1693 if func_acceptable $module; then
1694 func_append outmodules " $module"
1695 deps=`func_get_dependencies $module`
1696 # Duplicate dependencies are harmless, but Jim wants a warning.
1697 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1698 if test -n "$duplicated_deps"; then
1699 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
1701 for dep in $deps; do
1702 if test -n "$incobsolete" \
1703 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
1704 func_append inmodules " $dep"
1707 if test -n "$inctests"; then
1708 testsmodule=`func_get_tests_module $module`
1709 if test -n "$testsmodule"; then
1710 func_append inmodules " $testsmodule"
1716 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1717 # Remove $handledmodules from $inmodules.
1718 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1719 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1721 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1722 rm -f "$tmp"/queued-modules
1725 # func_modules_add_dummy
1727 # - local_gnulib_dir from --local-dir
1728 # - modules list of modules, including dependencies
1730 # - modules list of modules, including 'dummy' if needed
1731 func_modules_add_dummy ()
1733 # Determine whether any module provides a lib_SOURCES augmentation.
1735 sed_remove_backslash_newline=':a
1742 for module in $modules; do
1743 func_verify_nontests_module
1744 if test -n "$module"; then
1745 # Extract the value of "lib_SOURCES += ...".
1746 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1747 # Ignore .h files since they are not compiled.
1751 have_lib_SOURCES=yes
1758 # Add the dummy module, to make sure the library will be non-empty.
1759 if test -z "$have_lib_SOURCES"; then
1760 if func_acceptable "dummy"; then
1761 func_append modules " dummy"
1766 # func_modules_notice
1768 # - local_gnulib_dir from --local-dir
1769 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1770 # - modules list of modules, including dependencies
1771 func_modules_notice ()
1773 if test $verbose -ge -1; then
1774 for module in $modules; do
1776 if test -n "$module"; then
1777 msg=`func_get_notice $module`
1778 if test -n "$msg"; then
1779 echo "Notice from module $module:"
1780 echo "$msg" | sed -e 's/^/ /'
1787 # func_modules_to_filelist
1789 # - local_gnulib_dir from --local-dir
1790 # - modules list of modules, including dependencies
1792 # - files list of files
1793 func_modules_to_filelist ()
1796 for module in $modules; do
1798 if test -n "$module"; then
1799 fs=`func_get_filelist $module`
1800 func_append files " $fs"
1803 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1806 # func_execute_command command [args...]
1807 # Executes a command.
1808 # Uses also the variables
1809 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1810 func_execute_command ()
1812 if test $verbose -ge 0; then
1816 # Commands like automake produce output to stderr even when they succeed.
1817 # Turn this output off if the command succeeds.
1818 "$@" > "$tmp"/cmdout 2>&1
1820 if test $cmdret = 0; then
1824 cat "$tmp"/cmdout 1>&2
1831 # func_dest_tmpfilename file
1832 # determines the name of a temporary file (file is relative to destdir).
1834 # - destdir target directory
1835 # - doit : if actions shall be executed, false if only to be printed
1836 # - tmp pathname of a temporary directory
1838 # - tmpfile absolute filename of the temporary file
1839 func_dest_tmpfilename ()
1842 # Put the new contents of $file in a file in the same directory (needed
1843 # to guarantee that an 'mv' to "$destdir/$file" works).
1844 tmpfile="$destdir/$1.tmp"
1846 # Put the new contents of $file in a file in a temporary directory
1847 # (because the directory of "$file" might not exist).
1848 tmpfile="$tmp"/`basename "$1"`.tmp
1853 # copies a file from gnulib into the destination directory. The destination
1854 # is known to not exist.
1856 # - destdir target directory
1857 # - local_gnulib_dir from --local-dir
1858 # - f the original file name
1859 # - lookedup_file name of the merged (combined) file
1860 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1861 # - g the rewritten file name
1862 # - tmpfile absolute filename of the temporary file
1863 # - doit : if actions shall be executed, false if only to be printed
1864 # - symbolic true if files should be symlinked, copied otherwise
1865 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1870 echo "Copying file $g"
1871 if { test -n "$symbolic" \
1872 || { test -n "$lsymbolic" \
1873 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1874 && test -z "$lookedup_tmp" \
1875 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1876 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1878 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1886 # copies a file from gnulib into the destination directory. The destination
1887 # is known to exist.
1889 # - destdir target directory
1890 # - local_gnulib_dir from --local-dir
1891 # - f the original file name
1892 # - lookedup_file name of the merged (combined) file
1893 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1894 # - g the rewritten file name
1895 # - tmpfile absolute filename of the temporary file
1896 # - doit : if actions shall be executed, false if only to be printed
1897 # - symbolic true if files should be symlinked, copied otherwise
1898 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1900 # - already_present nonempty if the file should already exist, empty otherwise
1903 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1904 : # The file has not changed.
1908 if test -n "$already_present"; then
1909 echo "Updating file $g (backup in ${g}~)"
1911 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
1913 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1914 if { test -n "$symbolic" \
1915 || { test -n "$lsymbolic" \
1916 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1917 && test -z "$lookedup_tmp" \
1918 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1919 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1921 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1924 if test -n "$already_present"; then
1925 echo "Update file $g (backup in ${g}~)"
1927 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
1933 # func_emit_lib_Makefile_am
1934 # emits the contents of library makefile to standard output.
1936 # - local_gnulib_dir from --local-dir
1937 # - modules list of modules, including dependencies
1938 # - libname library name
1939 # - pobase directory relative to destdir where to place *.po files
1940 # - auxdir directory relative to destdir where to place build aux files
1941 # - makefile_name from --makefile-name
1942 # - libtool true if libtool will be used, false or blank otherwise
1943 # - macro_prefix prefix of gl_LIBOBJS macros to use
1944 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1945 # - actioncmd (optional) command that will reproduce this invocation
1946 # - for_test true if creating a package for testing, false otherwise
1947 # - destfile filename relative to destdir of makefile being generated
1949 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1950 # list of edits to be done to Makefile.am variables
1952 # - uses_subdirs nonempty if object files in subdirs exist
1953 func_emit_lib_Makefile_am ()
1955 # When creating an includable Makefile.am snippet, augment variables with
1956 # += instead of assigning them.
1957 if test -n "$makefile_name"; then
1962 if test "$libtool" = true; then
1965 sed_eliminate_LDFLAGS="$sed_noop"
1969 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1972 # When creating a package for testing: Attempt to provoke failures,
1973 # especially link errors, already during "make" rather than during
1974 # "make check", because "make check" is not possible in a cross-compiling
1975 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1976 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1978 sed_transform_check_PROGRAMS="$sed_noop"
1980 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1981 echo "## Process this file with automake to produce Makefile.in."
1982 func_emit_copyright_notice
1983 if test -n "$actioncmd"; then
1984 # The maximum line length (excluding the terminating newline) of any file
1985 # that is to be preprocessed by config.status is 3070. config.status uses
1986 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
1987 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
1988 len=`echo "$actioncmd" | wc -c`
1989 if test -n "$len" && test "$len" -le 3000; then
1990 echo "# Reproduce by: $actioncmd"
1996 for module in $modules; do
1997 func_verify_nontests_module
1998 if test -n "$module"; then
2000 func_get_automake_snippet "$module" |
2001 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2002 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2003 -e "$sed_eliminate_LDFLAGS" \
2004 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2005 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2006 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2007 -e "$sed_transform_check_PROGRAMS"
2008 if test "$module" = 'alloca'; then
2009 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2010 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2012 } > "$tmp"/amsnippet
2013 # Skip the contents if it's entirely empty.
2014 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2015 echo "## begin gnulib module $module"
2017 cat "$tmp"/amsnippet
2018 echo "## end gnulib module $module"
2021 rm -f "$tmp"/amsnippet
2022 # Test whether there are some source files in subdirectories.
2023 for f in `func_get_filelist "$module"`; do
2033 } > "$tmp"/allsnippets
2034 if test -z "$makefile_name"; then
2035 # If there are source files in subdirectories, prevent collision of the
2036 # object files (example: hash.c and libxml/hash.c).
2038 if test -n "$uses_subdirs"; then
2039 subdir_options=' subdir-objects'
2041 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2044 if test -z "$makefile_name"; then
2046 echo "noinst_HEADERS ="
2047 echo "noinst_LIBRARIES ="
2048 echo "noinst_LTLIBRARIES ="
2049 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2050 # if you specify pkgdata_DATA to empty. This is a workaround.
2051 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2052 echo "pkgdata_DATA ="
2055 echo "BUILT_SOURCES ="
2058 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2059 if test -z "$makefile_name"; then
2060 echo "MOSTLYCLEANDIRS ="
2062 echo "DISTCLEANFILES ="
2063 echo "MAINTAINERCLEANFILES ="
2065 # Execute edits that apply to the Makefile.am being generated.
2067 while test $edit != $makefile_am_edits; do
2068 edit=`expr $edit + 1`
2069 eval dir=\"\$makefile_am_edit${edit}_dir\"
2070 eval var=\"\$makefile_am_edit${edit}_var\"
2071 eval val=\"\$makefile_am_edit${edit}_val\"
2072 if test -n "$var"; then
2073 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2074 echo "${var} += ${val}"
2075 eval "makefile_am_edit${edit}_var="
2079 if test -z "$makefile_name"; then
2081 echo "AM_CPPFLAGS ="
2085 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2086 || { test -n "$makefile_name" \
2087 && test -f "$sourcebase/Makefile.am" \
2088 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2090 # One of the snippets or the user's Makefile.am already specifies an
2091 # installation location for the library. Don't confuse automake by saying
2092 # it should not be installed.
2095 # By default, the generated library should not be installed.
2096 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2099 echo "${libname}_${libext}_SOURCES ="
2100 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2101 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2102 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2103 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2104 echo "EXTRA_${libname}_${libext}_SOURCES ="
2105 if test "$libtool" = true; then
2106 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2109 if test -n "$pobase"; then
2110 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2113 cat "$tmp"/allsnippets \
2114 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2116 echo "mostlyclean-local: mostlyclean-generic"
2117 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2118 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2119 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2123 rm -f "$tmp"/allsnippets
2126 # func_emit_po_Makevars
2127 # emits the contents of po/ makefile parameterization to standard output.
2129 # - local_gnulib_dir from --local-dir
2130 # - sourcebase directory relative to destdir where to place source code
2131 # - pobase directory relative to destdir where to place *.po files
2132 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2133 func_emit_po_Makevars ()
2135 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2136 func_emit_copyright_notice
2138 echo "# Usually the message domain is the same as the package name."
2139 echo "# But here it has a '-gnulib' suffix."
2140 echo "DOMAIN = ${po_domain}-gnulib"
2142 echo "# These two variables depend on the location of this directory."
2143 echo "subdir = ${pobase}"
2144 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2147 # These options get passed to xgettext.
2148 XGETTEXT_OPTIONS = \
2149 --keyword=_ --flag=_:1:pass-c-format \
2150 --keyword=N_ --flag=N_:1:pass-c-format \
2151 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2152 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2153 --flag=error:3:c-format --flag=error_at_line:5:c-format
2155 # This is the copyright holder that gets inserted into the header of the
2156 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2157 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2159 # This is the email address or URL to which the translators shall report
2160 # bugs in the untranslated strings:
2161 # - Strings which are not entire sentences, see the maintainer guidelines
2162 # in the GNU gettext documentation, section 'Preparing Strings'.
2163 # - Strings which use unclear terms or require additional context to be
2165 # - Strings which make invalid assumptions about notation of date, time or
2167 # - Pluralisation problems.
2168 # - Incorrect English spelling.
2169 # - Incorrect formatting.
2170 # It can be your email address, or a mailing list address where translators
2171 # can write to without being subscribed, or the URL of a web page through
2172 # which the translators can contact you.
2173 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2175 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2176 # message catalogs shall be used. It is usually empty.
2177 EXTRA_LOCALE_CATEGORIES =
2179 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2180 # context. Possible values are "yes" and "no". Set this to yes if the
2181 # package uses functions taking also a message context, like pgettext(), or
2182 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2187 # func_emit_po_POTFILES_in
2188 # emits the file list to be passed to xgettext to standard output.
2190 # - local_gnulib_dir from --local-dir
2191 # - sourcebase directory relative to destdir where to place source code
2192 # - files list of new files
2193 func_emit_po_POTFILES_in ()
2195 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2196 func_emit_copyright_notice
2198 echo "# List of files which contain translatable strings."
2199 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2202 # func_emit_tests_Makefile_am
2203 # emits the contents of tests makefile to standard output.
2205 # - local_gnulib_dir from --local-dir
2206 # - modules list of modules, including dependencies
2207 # - libname library name
2208 # - auxdir directory relative to destdir where to place build aux files
2209 # - makefile_name from --makefile-name
2210 # - libtool true if libtool will be used, false or blank otherwise
2211 # - sourcebase relative directory containing lib source code
2212 # - m4base relative directory containing autoconf macros
2213 # - testsbase relative directory containing unit test code
2214 # - macro_prefix prefix of gl_LIBOBJS macros to use
2215 # - for_test true if creating a package for testing, false otherwise
2216 # - use_libtests true if a libtests.a should be built, false otherwise
2217 # - destfile filename relative to destdir of makefile being generated
2219 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2220 # list of edits to be done to Makefile.am variables
2222 # - uses_subdirs nonempty if object files in subdirs exist
2223 func_emit_tests_Makefile_am ()
2225 if test "$libtool" = true; then
2227 sed_eliminate_LDFLAGS="$sed_noop"
2230 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2233 # When creating a package for testing: Attempt to provoke failures,
2234 # especially link errors, already during "make" rather than during
2235 # "make check", because "make check" is not possible in a cross-compiling
2236 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2237 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2239 sed_transform_check_PROGRAMS="$sed_noop"
2241 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2242 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2243 echo "## Process this file with automake to produce Makefile.in."
2244 func_emit_copyright_notice
2248 for module in $modules; do
2250 func_verify_tests_module
2254 if test -n "$module"; then
2256 func_get_automake_snippet "$module" |
2257 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2258 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2259 -e "$sed_eliminate_LDFLAGS" \
2260 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2261 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2262 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2263 -e "$sed_transform_check_PROGRAMS"
2264 if $use_libtests && test "$module" = 'alloca'; then
2265 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2266 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2268 } > "$tmp"/amsnippet
2269 # Skip the contents if it's entirely empty.
2270 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2271 echo "## begin gnulib module $module"
2273 cat "$tmp"/amsnippet
2274 echo "## end gnulib module $module"
2277 rm -f "$tmp"/amsnippet
2278 # Test whether there are some source files in subdirectories.
2279 for f in `func_get_filelist "$module"`; do
2281 lib/*/*.c | tests/*/*.c)
2289 } > "$tmp"/allsnippets
2290 # Generate dependencies here, since it eases the debugging of test failures.
2291 # If there are source files in subdirectories, prevent collision of the
2292 # object files (example: hash.c and libxml/hash.c).
2294 if test -n "$uses_subdirs"; then
2295 subdir_options=' subdir-objects'
2297 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2300 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2303 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2304 # variable is needed to avoid an error from automake:
2305 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2308 echo "XFAIL_TESTS ="
2309 echo "TESTS_ENVIRONMENT ="
2310 echo "noinst_PROGRAMS ="
2311 if ! $for_test; then
2312 echo "check_PROGRAMS ="
2314 echo "noinst_HEADERS ="
2315 echo "noinst_LIBRARIES ="
2316 if $use_libtests; then
2318 echo "noinst_LIBRARIES += libtests.a"
2320 echo "check_LIBRARIES = libtests.a"
2323 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2324 # if you specify pkgdata_DATA to empty. This is a workaround.
2325 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2326 echo "pkgdata_DATA ="
2329 echo "BUILT_SOURCES ="
2331 echo "MOSTLYCLEANFILES = core *.stackdump"
2332 echo "MOSTLYCLEANDIRS ="
2334 echo "DISTCLEANFILES ="
2335 echo "MAINTAINERCLEANFILES ="
2336 # Execute edits that apply to the Makefile.am being generated.
2338 while test $edit != $makefile_am_edits; do
2339 edit=`expr $edit + 1`
2340 eval dir=\"\$makefile_am_edit${edit}_dir\"
2341 eval var=\"\$makefile_am_edit${edit}_var\"
2342 eval val=\"\$makefile_am_edit${edit}_val\"
2343 if test -n "$var"; then
2344 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2345 echo "${var} += ${val}"
2346 eval "makefile_am_edit${edit}_var="
2351 echo "AM_CPPFLAGS = \\"
2352 echo " -I. -I\$(srcdir) \\"
2353 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2354 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2356 local_ldadd_before=''
2357 local_ldadd_after=''
2358 if $use_libtests; then
2359 # All test programs need to be linked with libtests.a.
2360 # It needs to be passed to the linker before ${libname}.${libext}, since
2361 # the tests-related modules depend on the main modules.
2362 # It also needs to be passed to the linker after ${libname}.${libext}
2363 # because the latter might contain incomplete modules (such as the 'error'
2364 # module whose dependency to 'progname' is voluntarily omitted).
2365 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2367 local_ldadd_before=' libtests.a'
2368 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2370 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2372 if $use_libtests; then
2373 echo "libtests_a_SOURCES ="
2374 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2375 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2376 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2377 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2378 echo "EXTRA_libtests_a_SOURCES ="
2379 # The circular dependency in LDADD requires this.
2380 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2383 # Many test scripts use ${EXEEXT} or ${srcdir}.
2384 # EXEEXT is defined by AC_PROG_CC through autoconf.
2385 # srcdir is defined by autoconf and automake.
2386 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
2388 cat "$tmp"/allsnippets \
2389 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2390 echo "# Clean up after Solaris cc."
2392 echo " rm -rf SunWS_cache"
2394 echo "mostlyclean-local: mostlyclean-generic"
2395 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2396 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2397 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2401 rm -f "$tmp"/allsnippets
2404 # func_emit_initmacro_start macro_prefix
2405 # emits the first few statements of the gl_INIT macro to standard output.
2406 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2407 func_emit_initmacro_start ()
2409 macro_prefix_arg="$1"
2410 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2411 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2412 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2413 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2415 # Furthermore it avoids an automake error like this when a Makefile.am
2416 # that uses pieces of gnulib also uses $(LIBOBJ):
2417 # automatically discovered file `error.c' should not be explicitly mentioned
2418 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2419 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2420 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2421 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2422 # automatically discovered file `error.c' should not be explicitly mentioned
2423 # We let automake know about the files to be distributed through the
2424 # EXTRA_lib_SOURCES variable.
2425 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2426 # Create data variables for checking the presence of files that are mentioned
2427 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2428 # because we want the check to happen when the configure file is created,
2429 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2430 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2431 # in which to expect them.
2432 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2433 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2437 # func_emit_initmacro_end macro_prefix
2438 # emits the last few statements of the gl_INIT macro to standard output.
2439 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2440 func_emit_initmacro_end ()
2442 macro_prefix_arg="$1"
2443 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2444 # The check is performed only when autoconf is run from the directory where
2445 # the configure.ac resides; if it is run from a different directory, the
2447 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2448 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2449 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2450 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2451 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2455 echo " m4_if(m4_sysval, [0], [],"
2456 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2458 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2459 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2460 echo " m4_popdef([AC_LIBSOURCES])"
2461 echo " m4_popdef([AC_REPLACE_FUNCS])"
2462 echo " m4_popdef([AC_LIBOBJ])"
2463 echo " AC_CONFIG_COMMANDS_PRE(["
2464 echo " ${macro_prefix_arg}_libobjs="
2465 echo " ${macro_prefix_arg}_ltlibobjs="
2466 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2467 echo " # Remove the extension."
2468 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2469 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
2470 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2471 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2474 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2475 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2479 # func_emit_initmacro_done macro_prefix sourcebase
2480 # emits a few statements after the gl_INIT macro to standard output.
2481 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2482 # - sourcebase directory relative to destdir where to place source code
2483 func_emit_initmacro_done ()
2485 macro_prefix_arg="$1"
2488 echo "# Like AC_LIBOBJ, except that the module name goes"
2489 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2490 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2491 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2492 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2495 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2496 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2497 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2498 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2499 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2502 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2503 echo "# expected is derived from the gnulib-tool parameterization,"
2504 echo "# and alloca is special cased (for the alloca-opt module)."
2505 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2506 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2507 echo " m4_foreach([_gl_NAME], [\$1], ["
2508 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2509 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2510 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2516 # func_import modules
2517 # Uses also the variables
2518 # - destdir target directory
2519 # - local_gnulib_dir from --local-dir
2520 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2521 # - libname library name
2522 # - sourcebase directory relative to destdir where to place source code
2523 # - m4base directory relative to destdir where to place *.m4 macros
2524 # - pobase directory relative to destdir where to place *.po files
2525 # - docbase directory relative to destdir where to place doc files
2526 # - testsbase directory relative to destdir where to place unit test code
2527 # - auxdir directory relative to destdir where to place build aux files
2528 # - inctests true if --with-tests was given, blank otherwise
2529 # - incobsolete true if --with-obsolete was given, blank otherwise
2530 # - avoidlist list of modules to avoid, from --avoid
2531 # - lgpl yes or a number if library's license shall be LGPL,
2533 # - makefile_name from --makefile-name
2534 # - libtool true if --libtool was given, false if --no-libtool was
2535 # given, blank otherwise
2536 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2537 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2538 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2539 # - vc_files true if --vc-files was given, false if --no-vc-files was
2540 # given, blank otherwise
2541 # - autoconf_minversion minimum supported autoconf version
2542 # - doit : if actions shall be executed, false if only to be printed
2543 # - symbolic true if files should be symlinked, copied otherwise
2544 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2546 # - do_copyrights true if copyright notices in files should be replaced,
2550 # Get the cached settings.
2551 cached_local_gnulib_dir=
2552 cached_specified_modules=
2563 cached_makefile_name=
2565 cached_macro_prefix=
2569 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2570 cached_libtool=false
2576 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
2586 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
2588 /gl_WITH_OBSOLETE/ {
2589 s,^.*$,cached_incobsolete=true,p
2592 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
2595 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
2598 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
2601 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
2604 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
2607 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
2610 s,^.*$,cached_inctests=true,p
2613 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
2616 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
2619 s,^.*$,cached_lgpl=yes,p
2621 /gl_MAKEFILE_NAME(/ {
2622 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
2625 s,^.*$,cached_libtool=true,p
2627 /gl_MACRO_PREFIX(/ {
2628 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
2631 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
2634 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
2636 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2637 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2642 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2643 s,^.*$,cached_files=",p
2656 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2660 # Merge the cached settings with the specified ones.
2661 # The m4base must be the same as expected from the pathname.
2662 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2663 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2665 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2666 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2667 if test -z "$local_gnulib_dir"; then
2668 if test -n "$cached_local_gnulib_dir"; then
2671 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2673 case "$cached_local_gnulib_dir" in
2675 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2677 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2678 local_gnulib_dir="$relconcat" ;;
2683 # Append the cached and the specified module names. So that
2684 # "gnulib-tool --import foo" means to add the module foo.
2685 specified_modules="$cached_specified_modules $1"
2686 # Included obsolete modules among the dependencies if specified either way.
2687 if test -z "$incobsolete"; then
2688 incobsolete="$cached_incobsolete"
2690 # Append the cached and the specified avoidlist. This is probably better
2691 # than dropping the cached one when --avoid is specified at least once.
2692 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2693 avoidlist=`echo $avoidlist`
2695 # The sourcebase defaults to the cached one.
2696 if test -z "$sourcebase"; then
2697 sourcebase="$cached_sourcebase"
2698 if test -z "$sourcebase"; then
2699 func_fatal_error "missing --source-base option"
2702 # The pobase defaults to the cached one.
2703 if test -z "$pobase"; then
2704 pobase="$cached_pobase"
2706 # The docbase defaults to the cached one.
2707 if test -z "$docbase"; then
2708 docbase="$cached_docbase"
2709 if test -z "$docbase"; then
2710 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."
2713 # The testsbase defaults to the cached one.
2714 if test -z "$testsbase"; then
2715 testsbase="$cached_testsbase"
2716 if test -z "$testsbase"; then
2717 func_fatal_error "missing --tests-base option"
2720 # Require the tests if specified either way.
2721 if test -z "$inctests"; then
2722 inctests="$cached_inctests"
2724 # The libname defaults to the cached one.
2725 if test -z "$supplied_libname"; then
2726 libname="$cached_libname"
2727 if test -z "$libname"; then
2728 func_fatal_error "missing --lib option"
2731 # Require LGPL if specified either way.
2732 if test -z "$lgpl"; then
2735 # The makefile_name defaults to the cached one.
2736 if test -z "$makefile_name"; then
2737 makefile_name="$cached_makefile_name"
2739 # Use libtool if specified either way, or if guessed.
2740 if test -z "$libtool"; then
2741 if test -n "$cached_m4base"; then
2742 libtool="$cached_libtool"
2744 libtool="$guessed_libtool"
2747 # The macro_prefix defaults to the cached one.
2748 if test -z "$macro_prefix"; then
2749 macro_prefix="$cached_macro_prefix"
2750 if test -z "$macro_prefix"; then
2751 func_fatal_error "missing --macro-prefix option"
2754 # The po_domain defaults to the cached one.
2755 if test -z "$po_domain"; then
2756 po_domain="$cached_po_domain"
2758 # The vc_files defaults to the cached one.
2759 if test -z "$vc_files"; then
2760 vc_files="$cached_vc_files"
2763 # Canonicalize the list of specified modules.
2764 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2766 # Determine final module list.
2767 modules="$specified_modules"
2768 func_modules_transitive_closure
2769 if test $verbose -ge 0; then
2770 echo "Module list with included dependencies:"
2771 echo "$modules" | sed -e 's/^/ /'
2773 final_modules="$modules"
2775 # Determine main module list and tests-related module list separately.
2776 # The main module list is the transitive closure of the specified modules,
2777 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2778 # is specified, it will consist only of LGPLed source.
2779 # The tests-related module list is the transitive closure of the specified
2780 # modules, including tests modules, minus the main module list excluding
2781 # modules of applicability 'all'. Its lib/* sources (brought in through
2782 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2783 # source, even if --lgpl is specified.
2784 # Determine main module list.
2785 saved_inctests="$inctests"
2787 modules="$specified_modules"
2788 func_modules_transitive_closure
2789 main_modules="$modules"
2790 inctests="$saved_inctests"
2791 if test $verbose -ge 1; then
2792 echo "Main module list:"
2793 echo "$main_modules" | sed -e 's/^/ /'
2795 # Determine tests-related module list.
2796 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2797 testsrelated_modules=`func_reset_sigpipe
2798 for module in $main_modules; do
2799 if test \`func_get_applicability $module\` = main; then
2803 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2804 if test $verbose -ge 1; then
2805 echo "Tests-related module list:"
2806 echo "$testsrelated_modules" | sed -e 's/^/ /'
2809 # Add the dummy module to the main module list if needed.
2810 modules="$main_modules"
2811 func_modules_add_dummy
2812 main_modules="$modules"
2814 # Determine whether a $testsbase/libtests.a is needed.
2816 for module in $testsrelated_modules; do
2817 func_verify_nontests_module
2818 if test -n "$module"; then
2819 all_files=`func_get_filelist $module`
2820 # Test whether some file in $all_files lies in lib/.
2821 for f in $all_files; do
2832 # Add the dummy module to the tests-related module list if needed.
2833 if $use_libtests; then
2834 modules="$testsrelated_modules"
2835 func_modules_add_dummy
2836 testsrelated_modules="$modules"
2839 # If --lgpl, verify that the licenses of modules are compatible.
2840 if test -n "$lgpl"; then
2841 license_incompatibilities=
2842 for module in $main_modules; do
2843 license=`func_get_license $module`
2845 'GPLed build tool') ;;
2846 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2851 LGPL | LGPLv2+ | LGPLv3+) ;;
2852 *) func_append license_incompatibilities "$module $license$nl" ;;
2858 *) func_append license_incompatibilities "$module $license$nl" ;;
2861 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2866 if test -n "$license_incompatibilities"; then
2867 # Format the license incompatibilities as a table.
2868 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
2869 s,^\(.................................................[^ ]*\) *, \1 ,'
2870 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
2871 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
2875 # Show banner notice of every module.
2876 modules="$main_modules"
2879 # Determine script to apply to imported library files.
2880 sed_transform_lib_file=
2881 for module in $main_modules; do
2882 if test $module = config-h; then
2883 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2884 sed_transform_lib_file=$sed_transform_lib_file'
2885 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2890 sed_transform_main_lib_file="$sed_transform_lib_file"
2891 if test -n "$do_copyrights"; then
2892 if test -n "$lgpl"; then
2896 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2897 s/GNU General/GNU Lesser General/g
2901 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2902 s/GNU General/GNU Lesser General/g
2903 s/version [23]\([ ,]\)/version 2.1\1/g
2906 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2910 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2911 s/GNU Lesser General/GNU General/g
2912 s/GNU Library General/GNU General/g
2913 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
2918 # Determine script to apply to auxiliary files that go into $auxdir/.
2919 sed_transform_build_aux_file=
2920 if test -n "$do_copyrights"; then
2922 sed_transform_build_aux_file=$sed_transform_build_aux_file'
2923 s/GNU Lesser General/GNU General/g
2924 s/GNU Library General/GNU General/g
2925 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
2929 # Determine script to apply to library files that go into $testsbase/.
2930 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2931 if test -n "$do_copyrights"; then
2933 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2934 s/GNU Lesser General/GNU General/g
2935 s/GNU Library General/GNU General/g
2936 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
2940 # Determine the final file lists.
2941 # They must be computed separately, because files in lib/* go into
2942 # $sourcebase/ if they are in the main file list but into $testsbase/
2943 # if they are in the tests-related file list. Furthermore lib/dummy.c
2945 # Determine final main file list.
2946 modules="$main_modules"
2947 func_modules_to_filelist
2949 # Determine final tests-related file list.
2950 modules="$testsrelated_modules"
2951 func_modules_to_filelist
2952 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2953 # Merge both file lists.
2954 sed_remove_empty_lines='/^$/d'
2955 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2956 if test $verbose -ge 0; then
2958 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2959 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2963 || func_fatal_error "refusing to do nothing"
2965 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2966 new_files="$files m4/gnulib-tool.m4"
2967 old_files="$cached_files"
2968 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2969 func_append old_files " m4/gnulib-tool.m4"
2972 rewritten='%REWRITTEN%'
2973 sed_rewrite_old_files="\
2974 s,^build-aux/,$rewritten$auxdir/,
2975 s,^doc/,$rewritten$cached_docbase/,
2976 s,^lib/,$rewritten$cached_sourcebase/,
2977 s,^m4/,$rewritten$cached_m4base/,
2978 s,^tests/,$rewritten$cached_testsbase/,
2979 s,^tests=lib/,$rewritten$cached_testsbase/,
2982 sed_rewrite_new_files="\
2983 s,^build-aux/,$rewritten$auxdir/,
2984 s,^doc/,$rewritten$docbase/,
2985 s,^lib/,$rewritten$sourcebase/,
2986 s,^m4/,$rewritten$m4base/,
2987 s,^tests/,$rewritten$testsbase/,
2988 s,^tests=lib/,$rewritten$testsbase/,
2992 # Create directories.
2993 { echo "$sourcebase"
2995 if test -n "$pobase"; then
2998 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2999 if test -n "$docfiles"; then
3002 if test -n "$inctests"; then
3006 for f in $files; do echo $f; done \
3007 | sed -e "$sed_rewrite_new_files" \
3008 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3011 { # Rearrange file descriptors. Needed because "while ... done < ..."
3012 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3013 exec 5<&0 < "$tmp"/dirs
3015 if test ! -d "$destdir/$d"; then
3017 echo "Creating directory $destdir/$d"
3018 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3020 echo "Create directory $destdir/$d"
3027 # Copy files or make symbolic links. Remove obsolete files.
3031 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3032 # representing the files according to the last gnulib-tool invocation.
3033 for f in $old_files; do echo $f; done \
3034 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3037 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3038 # representing the files after this gnulib-tool invocation.
3039 for f in $new_files; do echo $f; done \
3040 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3043 # First the files that are in old-files, but not in new-files:
3044 sed_take_first_column='s,'"$delimiter"'.*,,'
3045 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3046 # Remove the file. Do nothing if the user already removed it.
3047 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3049 echo "Removing file $g (backup in ${g}~)"
3050 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3052 echo "Remove file $g (backup in ${g}~)"
3054 func_append removed_files "$g$nl"
3057 # func_add_or_update handles a file that ought to be present afterwards.
3059 # - f the original file name
3060 # - g the rewritten file name
3061 # - already_present nonempty if the file should already exist, empty
3063 func_add_or_update ()
3067 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3069 func_dest_tmpfilename "$g"
3070 func_lookup_file "$f"
3071 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3072 if test -n "$sed_transform_main_lib_file"; then
3075 sed -e "$sed_transform_main_lib_file" \
3076 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3080 if test -n "$sed_transform_build_aux_file"; then
3083 sed -e "$sed_transform_build_aux_file" \
3084 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3088 if test -n "$sed_transform_testsrelated_lib_file"; then
3091 sed -e "$sed_transform_testsrelated_lib_file" \
3092 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3096 if test -f "$destdir/$g"; then
3097 # The file already exists.
3101 # Don't protest if the file should be there but isn't: it happens
3102 # frequently that developers don't put autogenerated files into CVS.
3104 func_append added_files "$g$nl"
3108 # Then the files that are in new-files, but not in old-files:
3109 sed_take_last_column='s,^.*'"$delimiter"',,'
3111 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3112 | sed -e "$sed_take_last_column" \
3113 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3114 { # Rearrange file descriptors. Needed because "while ... done < ..."
3115 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3116 exec 5<&0 < "$tmp"/added-files
3122 # Then the files that are in new-files and in old-files:
3123 already_present=true
3124 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3125 | sed -e "$sed_take_last_column" \
3126 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3127 { # Rearrange file descriptors. Needed because "while ... done < ..."
3128 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3129 exec 5<&0 < "$tmp"/kept-files
3136 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3137 actioncmd="gnulib-tool --import"
3138 func_append actioncmd " --dir=$destdir"
3139 if test -n "$local_gnulib_dir"; then
3140 func_append actioncmd " --local-dir=$local_gnulib_dir"
3142 func_append actioncmd " --lib=$libname"
3143 func_append actioncmd " --source-base=$sourcebase"
3144 func_append actioncmd " --m4-base=$m4base"
3145 if test -n "$pobase"; then
3146 func_append actioncmd " --po-base=$pobase"
3148 func_append actioncmd " --doc-base=$docbase"
3149 func_append actioncmd " --tests-base=$testsbase"
3150 func_append actioncmd " --aux-dir=$auxdir"
3151 if test -n "$inctests"; then
3152 func_append actioncmd " --with-tests"
3154 if test -n "$incobsolete"; then
3155 func_append actioncmd " --with-obsolete"
3157 for module in $avoidlist; do
3158 func_append actioncmd " --avoid=$module"
3160 if test -n "$lgpl"; then
3161 if test "$lgpl" = yes; then
3162 func_append actioncmd " --lgpl"
3164 func_append actioncmd " --lgpl=$lgpl"
3167 if test -n "$makefile_name"; then
3168 func_append actioncmd " --makefile-name=$makefile_name"
3170 if test "$libtool" = true; then
3171 func_append actioncmd " --libtool"
3173 func_append actioncmd " --no-libtool"
3175 func_append actioncmd " --macro-prefix=$macro_prefix"
3176 if test -n "$po_domain"; then
3177 func_append actioncmd " --po-domain=$po_domain"
3179 if test -n "$vc_files"; then
3180 if test "$vc_files" = true; then
3181 func_append actioncmd " --vc-files"
3183 func_append actioncmd " --no-vc-files"
3186 func_append actioncmd " `echo $specified_modules`"
3188 # Default the makefile name to Makefile.am.
3189 if test -n "$makefile_name"; then
3190 makefile_am=$makefile_name
3192 makefile_am=Makefile.am
3195 # Create normal Makefile.ams.
3198 # Setup list of Makefile.am edits that are to be performed afterwards.
3199 # Some of these edits apply to files that we will generate; others are
3200 # under the responsibility of the developer.
3202 # func_note_Makefile_am_edit dir var value
3203 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3205 func_note_Makefile_am_edit ()
3207 makefile_am_edits=`expr $makefile_am_edits + 1`
3208 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3209 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3210 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3212 if test "$makefile_am" = Makefile.am; then
3213 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3214 sourcebase_base=`basename "$sourcebase"`
3215 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3217 if test -n "$pobase"; then
3218 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3219 pobase_base=`basename "$pobase"`
3220 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3222 if test -n "$inctests"; then
3223 if test "$makefile_am" = Makefile.am; then
3224 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3225 testsbase_base=`basename "$testsbase"`
3226 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3229 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3231 # Find the first parent directory of $m4base that contains or will contain
3233 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3235 sed_butlast='s,[^/][^/]*//*$,,'
3236 dir1="${m4base}/"; dir2=""
3237 while test -n "$dir1" \
3238 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3239 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3240 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3241 || { test -n "$inctests" \
3242 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3243 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3244 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3245 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3247 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3250 # Create library makefile.
3251 func_dest_tmpfilename $sourcebase/$makefile_am
3252 destfile="$sourcebase/$makefile_am"
3253 modules="$main_modules"
3254 func_emit_lib_Makefile_am > "$tmpfile"
3255 if test -f "$destdir"/$sourcebase/$makefile_am; then
3256 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3260 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3261 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3262 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3264 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3270 echo "Creating $sourcebase/$makefile_am"
3271 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3273 echo "Create $sourcebase/$makefile_am"
3276 func_append added_files "$sourcebase/$makefile_am$nl"
3279 # Create po/ directory.
3280 if test -n "$pobase"; then
3281 # Create po makefile and auxiliary files.
3282 for file in Makefile.in.in remove-potcdate.sin; do
3283 func_dest_tmpfilename $pobase/$file
3284 func_lookup_file build-aux/po/$file
3285 cat "$lookedup_file" > "$tmpfile"
3286 if test -f "$destdir"/$pobase/$file; then
3287 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3291 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3292 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3293 mv -f "$tmpfile" "$destdir"/$pobase/$file
3295 echo "Update $pobase/$file (backup in $pobase/$file~)"
3301 echo "Creating $pobase/$file"
3302 mv -f "$tmpfile" "$destdir"/$pobase/$file
3304 echo "Create $pobase/$file"
3307 func_append added_files "$pobase/$file$nl"
3310 # Create po makefile parameterization, part 1.
3311 func_dest_tmpfilename $pobase/Makevars
3312 func_emit_po_Makevars > "$tmpfile"
3313 if test -f "$destdir"/$pobase/Makevars; then
3314 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3318 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3319 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3320 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3322 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3328 echo "Creating $pobase/Makevars"
3329 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3331 echo "Create $pobase/Makevars"
3334 func_append added_files "$pobase/Makevars$nl"
3336 # Create po makefile parameterization, part 2.
3337 func_dest_tmpfilename $pobase/POTFILES.in
3338 func_emit_po_POTFILES_in > "$tmpfile"
3339 if test -f "$destdir"/$pobase/POTFILES.in; then
3340 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3344 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3345 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3346 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3348 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3354 echo "Creating $pobase/POTFILES.in"
3355 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3357 echo "Create $pobase/POTFILES.in"
3360 func_append added_files "$pobase/POTFILES.in$nl"
3363 TP_URL="http://translationproject.org/latest/"
3364 TP_RSYNC_URI="translationproject.org::tp/latest/"
3366 echo "Fetching gnulib PO files from $TP_URL"
3367 (cd "$destdir"/$pobase \
3368 && { # Prefer rsync over wget if it is available, since it consumes
3369 # less network bandwidth, due to compression.
3370 if type rsync 2>/dev/null | grep / > /dev/null; then
3371 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3373 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3378 echo "Fetch gnulib PO files from $TP_URL"
3380 # Create po/LINGUAS.
3382 func_dest_tmpfilename $pobase/LINGUAS
3383 (cd "$destdir"/$pobase \
3384 && { echo '# Set of available languages.'
3385 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3388 if test -f "$destdir"/$pobase/LINGUAS; then
3389 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3392 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3393 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3394 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3397 echo "Creating $pobase/LINGUAS"
3398 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3399 func_append added_files "$pobase/LINGUAS$nl"
3402 if test -f "$destdir"/$pobase/LINGUAS; then
3403 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3405 echo "Create $pobase/LINGUAS"
3410 # Create m4/gnulib-cache.m4.
3411 func_dest_tmpfilename $m4base/gnulib-cache.m4
3413 func_emit_copyright_notice
3415 echo "# This file represents the specification of how gnulib-tool is used."
3416 echo "# It acts as a cache: It is written and read by gnulib-tool."
3417 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3418 echo "# like the configure.ac and various Makefile.am files."
3421 echo "# Specification in the form of a command-line invocation:"
3424 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3425 # Store the local_gnulib_dir relative to destdir.
3426 case "$local_gnulib_dir" in
3428 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3431 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3433 # destdir, local_gnulib_dir are both relative.
3434 func_relativize "$destdir" "$local_gnulib_dir"
3435 relative_local_gnulib_dir="$reldir" ;;
3438 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3440 echo "$specified_modules" | sed -e 's/^/ /g'
3442 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3443 echo "gl_AVOID([$avoidlist])"
3444 echo "gl_SOURCE_BASE([$sourcebase])"
3445 echo "gl_M4_BASE([$m4base])"
3446 echo "gl_PO_BASE([$pobase])"
3447 echo "gl_DOC_BASE([$docbase])"
3448 echo "gl_TESTS_BASE([$testsbase])"
3449 test -z "$inctests" || echo "gl_WITH_TESTS"
3450 echo "gl_LIB([$libname])"
3451 if test -n "$lgpl"; then
3452 if test "$lgpl" = yes; then
3455 echo "gl_LGPL([$lgpl])"
3458 echo "gl_MAKEFILE_NAME([$makefile_name])"
3459 if test "$libtool" = true; then
3462 echo "gl_MACRO_PREFIX([$macro_prefix])"
3463 echo "gl_PO_DOMAIN([$po_domain])"
3464 if test -n "$vc_files"; then
3465 echo "gl_VC_FILES([$vc_files])"
3468 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3469 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3473 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3474 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3475 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3477 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3481 echo "# gnulib-cache.m4 ends here"
3488 echo "Creating $m4base/gnulib-cache.m4"
3489 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3491 echo "Create $m4base/gnulib-cache.m4"
3497 # Create m4/gnulib-comp.m4.
3498 func_dest_tmpfilename $m4base/gnulib-comp.m4
3500 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3501 func_emit_copyright_notice
3503 echo "# This file represents the compiled summary of the specification in"
3504 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3505 echo "# to be invoked from configure.ac."
3506 echo "# In projects using CVS, this file can be treated like other built files."
3509 echo "# This macro should be invoked from $configure_ac, in the section"
3510 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3511 echo "# any checks for libraries, header files, types and library functions."
3512 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3514 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3515 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3516 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3517 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3518 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3519 if test -n "$uses_subdirs"; then
3520 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3522 for module in $final_modules; do
3524 if test -n "$module"; then
3525 func_get_autoconf_early_snippet "$module"
3528 | sed -e '/^$/d;' -e 's/^/ /'
3531 echo "# This macro should be invoked from $configure_ac, in the section"
3532 echo "# \"Check for header files, types and library functions\"."
3533 echo "AC_DEFUN([${macro_prefix}_INIT],"
3535 if test "$libtool" = true; then
3536 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3537 echo " gl_cond_libtool=true"
3539 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3540 echo " gl_cond_libtool=false"
3542 echo " gl_ltlibdeps="
3544 if test "$auxdir" != "build-aux"; then
3545 sed_replace_build_aux='
3547 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3548 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3552 sed_replace_build_aux="$sed_noop"
3554 func_emit_initmacro_start $macro_prefix
3555 echo " gl_source_base='$sourcebase'"
3556 for module in $main_modules; do
3558 if test -n "$module"; then
3559 func_get_autoconf_snippet "$module" \
3560 | sed -e '/^$/d;' -e 's/^/ /' \
3561 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3562 -e "$sed_replace_build_aux"
3563 if test "$module" = 'alloca' && test "$libtool" = true; then
3564 echo 'changequote(,)dnl'
3565 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3566 echo 'changequote([, ])dnl'
3567 echo 'AC_SUBST([LTALLOCA])'
3571 func_emit_initmacro_end $macro_prefix
3572 echo " gltests_libdeps="
3573 echo " gltests_ltlibdeps="
3574 func_emit_initmacro_start ${macro_prefix}tests
3575 echo " gl_source_base='$testsbase'"
3576 for module in $testsrelated_modules; do
3578 if test -n "$module"; then
3579 func_get_autoconf_snippet "$module" \
3580 | sed -e '/^$/d;' -e 's/^/ /' \
3581 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3582 -e "$sed_replace_build_aux" \
3583 -e 's/\$gl_cond_libtool/false/g' \
3584 -e 's/gl_libdeps/gltests_libdeps/g' \
3585 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3588 func_emit_initmacro_end ${macro_prefix}tests
3589 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3590 # created using libtool, because libtool already handles the dependencies.
3591 if test "$libtool" != true; then
3592 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3593 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3594 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3595 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3596 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3598 if $use_libtests; then
3599 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3600 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3603 func_emit_initmacro_done $macro_prefix $sourcebase
3604 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3606 echo "# This macro records the list of files which have been installed by"
3607 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3608 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3609 echo "$files" | sed -e 's,^, ,'
3612 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3613 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3617 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3618 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3619 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3621 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3625 echo "# gnulib-comp.m4 ends here"
3632 echo "Creating $m4base/gnulib-comp.m4"
3633 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3635 echo "Create $m4base/gnulib-comp.m4"
3641 if test -n "$inctests"; then
3642 # Create tests makefile.
3643 func_dest_tmpfilename $testsbase/$makefile_am
3644 destfile="$testsbase/$makefile_am"
3645 modules="$testsrelated_modules"
3646 func_emit_tests_Makefile_am > "$tmpfile"
3647 if test -f "$destdir"/$testsbase/$makefile_am; then
3648 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3652 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3653 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3654 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3656 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3662 echo "Creating $testsbase/$makefile_am"
3663 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3665 echo "Create $testsbase/$makefile_am"
3668 func_append added_files "$testsbase/$makefile_am$nl"
3672 if test "$vc_files" != false; then
3673 # Update the .cvsignore and .gitignore files.
3674 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3675 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3676 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3677 echo "$m4base/|A|gnulib-comp.m4"
3678 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3679 { # Rearrange file descriptors. Needed because "while ... done < ..."
3680 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3681 exec 5<&0 < "$tmp"/fileset-changes
3682 func_update_ignorelist ()
3685 if test "$ignore" = .gitignore; then
3686 # In a .gitignore file, "foo" applies to the current directory and all
3687 # subdirectories, whereas "/foo" applies to the current directory only.
3690 doubly_escaped_anchor='\\/'
3694 doubly_escaped_anchor=''
3696 if test -f "$destdir/$dir$ignore"; then
3697 if test -n "$dir_added" || test -n "$dir_removed"; then
3698 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3700 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3701 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
3702 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3703 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
3705 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3707 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3708 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3709 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3710 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
3711 } > "$tmp"/sed-ignore-removed
3712 { cat "$destdir/$dir$ignore"~
3713 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3714 } | sed -f "$tmp"/sed-ignore-removed \
3715 > "$destdir/$dir$ignore"
3717 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3722 if test -n "$dir_added"; then
3724 echo "Creating $destdir/$dir$ignore"
3726 if test "$ignore" = .cvsignore; then
3728 # Automake generates Makefile rules that create .dirstamp files.
3731 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3732 } > "$destdir/$dir$ignore"
3734 echo "Create $destdir/$dir$ignore"
3744 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3745 func_update_ignorelist .cvsignore
3747 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3748 func_update_ignorelist .gitignore
3755 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3756 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3757 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3758 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3759 if test "$next_dir" != "$last_dir"; then
3760 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3761 last_dir="$next_dir"
3766 A) func_append last_dir_added "$file$nl";;
3767 R) func_append last_dir_removed "$file$nl";;
3770 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3777 echo "You may need to add #include directives for the following .h files."
3778 # Intersect $specified_modules and $main_modules
3779 # (since $specified_modules is not necessarily of subset of $main_modules
3780 # - some may have been skipped through --avoid, and since the elements of
3781 # $main_modules but not in $specified_modules can go away without explicit
3782 # notice - through changes in the module dependencies).
3783 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3784 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3785 # First the #include <...> directives without #ifs, sorted for convenience,
3786 # then the #include "..." directives without #ifs, sorted for convenience,
3787 # then the #include directives that are surrounded by #ifs. Not sorted.
3788 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3789 include_directive=`func_get_include_directive "$module"`
3790 case "$nl$include_directive" in
3792 echo "$include_directive" 1>&5
3795 echo "$include_directive" | grep -v 'include "' 1>&6
3796 echo "$include_directive" | grep 'include "' 1>&7
3799 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3801 LC_ALL=C sort -u "$tmp"/include-angles
3802 LC_ALL=C sort -u "$tmp"/include-quotes
3803 cat "$tmp"/include-if
3804 ) | sed -e '/^$/d' -e 's/^/ /'
3805 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3807 for module in $main_modules; do
3808 func_get_link_directive "$module"
3810 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3811 if test `wc -l < "$tmp"/link` != 0; then
3813 echo "You may need to use the following Makefile variables when linking."
3814 echo "Use them in <program>_LDADD when linking a program, or"
3815 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3821 echo "Don't forget to"
3822 if test "$makefile_am" = Makefile.am; then
3823 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3825 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3827 if test -n "$pobase"; then
3828 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3830 if test -n "$inctests"; then
3831 if test "$makefile_am" = Makefile.am; then
3832 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3834 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3838 while test $edit != $makefile_am_edits; do
3839 edit=`expr $edit + 1`
3840 eval dir=\"\$makefile_am_edit${edit}_dir\"
3841 eval var=\"\$makefile_am_edit${edit}_var\"
3842 eval val=\"\$makefile_am_edit${edit}_val\"
3843 if test -n "$var"; then
3844 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
3847 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3848 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3851 # func_create_testdir testdir modules
3853 # - local_gnulib_dir from --local-dir
3854 # - auxdir directory relative to destdir where to place build aux files
3855 func_create_testdir ()
3859 if test -z "$modules"; then
3860 # All modules together.
3861 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3862 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3863 modules=`func_all_modules`
3864 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3866 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3868 # Check that the license of every module is consistent with the license of
3870 saved_modules="$modules"
3871 saved_inctests="$inctests"
3872 # When computing transitive closures, don't consider $module to depend on
3873 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3874 # on GPL modules - therefore we don't want a warning in this case.
3876 for requested_module in $saved_modules; do
3877 requested_license=`func_get_license "$requested_module"`
3878 if test "$requested_license" != GPL; then
3879 # Here we use func_modules_transitive_closure, not just
3880 # func_get_dependencies, so that we also detect weird situations like
3881 # an LGPL module which depends on a GPLed build tool module which depends
3883 modules="$requested_module"
3884 func_modules_transitive_closure
3885 for module in $modules; do
3886 license=`func_get_license "$module"`
3888 'GPLed build tool') ;;
3889 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3891 case "$requested_license" in
3894 GPLv2+ | LGPLv2+) ;;
3895 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
3901 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
3907 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
3916 modules="$saved_modules"
3917 inctests="$saved_inctests"
3919 # Subdirectory names.
3929 # Determine final module list.
3930 func_modules_transitive_closure
3931 if test $verbose -ge 0; then
3932 echo "Module list with included dependencies:"
3933 echo "$modules" | sed -e 's/^/ /'
3936 # Add the dummy module if needed.
3937 func_modules_add_dummy
3939 # Show banner notice of every module.
3942 # Determine final file list.
3943 func_modules_to_filelist
3944 if test $verbose -ge 0; then
3946 echo "$files" | sed -e 's/^/ /'
3949 rewritten='%REWRITTEN%'
3950 sed_rewrite_files="\
3951 s,^build-aux/,$rewritten$auxdir/,
3952 s,^doc/,$rewritten$docbase/,
3953 s,^lib/,$rewritten$sourcebase/,
3954 s,^m4/,$rewritten$m4base/,
3955 s,^tests/,$rewritten$testsbase/,
3959 # Create directories.
3960 for f in $files; do echo $f; done \
3961 | sed -e "$sed_rewrite_files" \
3962 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3963 | LC_ALL=C sort -u \
3965 { # Rearrange file descriptors. Needed because "while ... done < ..."
3966 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3967 exec 5<&0 < "$tmp"/dirs
3969 mkdir -p "$testdir/$d"
3974 # Copy files or make symbolic links.
3976 for f in $files; do echo $f; done \
3977 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3980 { # Rearrange file descriptors. Needed because "while ... done < ..."
3981 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3982 exec 5<&0 < "$tmp"/files
3984 func_lookup_file "$f"
3985 if test -n "$lookedup_tmp"; then
3986 cp -p "$lookedup_file" "$testdir/$g"
3988 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3989 if { test -n "$symbolic" \
3990 || { test -n "$lsymbolic" \
3991 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3992 func_ln "$lookedup_file" "$testdir/$g"
3994 cp -p "$lookedup_file" "$testdir/$g"
4001 # Create Makefile.ams that are for testing.
4004 # No special edits are needed.
4007 # Create $sourcebase/Makefile.am.
4008 mkdir -p "$testdir/$sourcebase"
4009 destfile="$sourcebase/Makefile.am"
4010 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4011 any_uses_subdirs="$uses_subdirs"
4013 # Create $m4base/Makefile.am.
4014 mkdir -p "$testdir/$m4base"
4015 (echo "## Process this file with automake to produce Makefile.in."
4021 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4024 ) > "$testdir/$m4base/Makefile.am"
4026 subdirs="$sourcebase $m4base"
4027 subdirs_with_configure_ac=""
4029 if false && test -f "$testdir"/$m4base/gettext.m4; then
4030 # Avoid stupid error message from automake:
4031 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4032 mkdir -p "$testdir/po"
4033 (echo "## Process this file with automake to produce Makefile.in."
4034 ) > "$testdir/po/Makefile.am"
4035 func_append subdirs " po"
4038 if test -n "$inctests"; then
4039 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4040 # Viewed from the $testsbase subdirectory, $auxdir is different.
4041 saved_auxdir="$auxdir"
4042 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4043 # Create $testsbase/Makefile.am.
4045 destfile="$testsbase/Makefile.am"
4046 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
4047 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4048 # Create $testsbase/configure.ac.
4049 (echo "# Process this file with autoconf to produce a configure script."
4050 echo "AC_INIT([dummy], [0])"
4051 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4052 echo "AM_INIT_AUTOMAKE"
4054 echo "AC_CONFIG_HEADERS([config.h])"
4057 echo "AC_PROG_INSTALL"
4058 echo "AC_PROG_MAKE_SET"
4059 echo "AC_PROG_RANLIB"
4061 if test -n "$uses_subdirs"; then
4062 echo "AM_PROG_CC_C_O"
4065 for module in $modules; do
4067 if test -n "$module"; then
4069 gnumakefile | maintainer-makefile)
4070 # These modules are meant to be used only in the top-level directory.
4073 func_get_autoconf_early_snippet "$module"
4078 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4079 if test "$libtool" = true; then
4080 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4081 echo "gl_cond_libtool=true"
4083 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4084 echo "gl_cond_libtool=false"
4086 echo "gl_ltlibdeps="
4088 # Wrap the set of autoconf snippets into an autoconf macro that is then
4089 # invoked. This is needed because autoconf does not support AC_REQUIRE
4091 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4092 # but we want the AC_REQUIRE to have its normal meaning (provide one
4093 # expansion of the required macro before the current point, and only one
4095 echo "AC_DEFUN([gl_INIT], ["
4096 sed_replace_build_aux='
4098 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4099 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4102 func_emit_initmacro_start $macro_prefix
4103 # We don't have explicit ordering constraints between the various
4104 # autoconf snippets. It's cleanest to put those of the library before
4105 # those of the tests.
4106 echo "gl_source_base='../$sourcebase'"
4107 for module in $modules; do
4108 func_verify_nontests_module
4109 if test -n "$module"; then
4111 gnumakefile | maintainer-makefile)
4112 # These modules are meant to be used only in the top-level directory.
4115 func_get_autoconf_snippet "$module" \
4116 | sed -e "$sed_replace_build_aux"
4121 echo "gl_source_base='.'"
4122 for module in $modules; do
4123 func_verify_tests_module
4124 if test -n "$module"; then
4125 func_get_autoconf_snippet "$module" \
4126 | sed -e "$sed_replace_build_aux"
4129 func_emit_initmacro_end $macro_prefix
4130 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4131 # created using libtool, because libtool already handles the dependencies.
4132 if test "$libtool" != true; then
4133 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4134 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4135 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4136 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4137 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4140 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4144 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4145 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4146 echo "AH_TOP([#include \"../config.h\"])"
4148 echo "AC_CONFIG_FILES([Makefile])"
4150 ) > "$testdir/$testsbase/configure.ac"
4151 auxdir="$saved_auxdir"
4152 func_append subdirs " $testsbase"
4153 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4156 # Create Makefile.am.
4157 (echo "## Process this file with automake to produce Makefile.in."
4159 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4161 echo "SUBDIRS = $subdirs"
4163 echo "ACLOCAL_AMFLAGS = -I $m4base"
4164 ) > "$testdir/Makefile.am"
4166 # Create configure.ac.
4167 (echo "# Process this file with autoconf to produce a configure script."
4168 echo "AC_INIT([dummy], [0])"
4169 if test "$auxdir" != "."; then
4170 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4172 echo "AM_INIT_AUTOMAKE"
4174 echo "AC_CONFIG_HEADERS([config.h])"
4177 echo "AC_PROG_INSTALL"
4178 echo "AC_PROG_MAKE_SET"
4180 echo "# For autobuild."
4181 echo "AC_CANONICAL_BUILD"
4182 echo "AC_CANONICAL_HOST"
4184 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4185 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4186 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4187 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4189 echo "AC_PROG_RANLIB"
4191 if test -n "$any_uses_subdirs"; then
4192 echo "AM_PROG_CC_C_O"
4195 for module in $modules; do
4196 func_verify_nontests_module
4197 if test -n "$module"; then
4198 func_get_autoconf_early_snippet "$module"
4201 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4202 if test "$libtool" = true; then
4203 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4204 echo "gl_cond_libtool=true"
4206 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4207 echo "gl_cond_libtool=false"
4209 echo "gl_ltlibdeps="
4211 # Wrap the set of autoconf snippets into an autoconf macro that is then
4212 # invoked. This is needed because autoconf does not support AC_REQUIRE
4214 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4215 # but we want the AC_REQUIRE to have its normal meaning (provide one
4216 # expansion of the required macro before the current point, and only one
4218 echo "AC_DEFUN([gl_INIT], ["
4219 if test "$auxdir" != "build-aux"; then
4220 sed_replace_build_aux='
4222 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4223 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4227 sed_replace_build_aux="$sed_noop"
4229 func_emit_initmacro_start $macro_prefix
4230 echo "gl_source_base='$sourcebase'"
4231 for module in $modules; do
4232 func_verify_nontests_module
4233 if test -n "$module"; then
4234 func_get_autoconf_snippet "$module" \
4235 | sed -e "$sed_replace_build_aux"
4238 func_emit_initmacro_end $macro_prefix
4239 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4240 # created using libtool, because libtool already handles the dependencies.
4241 if test "$libtool" != true; then
4242 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4243 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4244 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4245 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4246 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4249 func_emit_initmacro_done $macro_prefix $sourcebase
4253 if test -n "$subdirs_with_configure_ac"; then
4254 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4256 makefiles="Makefile"
4257 for d in $subdirs; do
4258 # For subdirs that have a configure.ac by their own, it's the subdir's
4259 # configure.ac which creates the subdir's Makefile.am, not this one.
4260 case " $subdirs_with_configure_ac " in
4262 *) func_append makefiles " $d/Makefile" ;;
4265 echo "AC_CONFIG_FILES([$makefiles])"
4267 ) > "$testdir/configure.ac"
4269 # Create autogenerated files.
4271 # Do not use "${AUTORECONF} --force --install", because it may invoke
4272 # autopoint, which brings in older versions of some of our .m4 files.
4273 if test -f $m4base/gettext.m4; then
4274 func_execute_command ${AUTOPOINT} --force || func_exit 1
4275 for f in $m4base/*.m4~; do
4277 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4281 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4282 if ! test -d build-aux; then
4283 func_execute_command mkdir build-aux || func_exit 1
4285 func_execute_command ${AUTOCONF} || func_exit 1
4286 func_execute_command ${AUTOHEADER} || func_exit 1
4287 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4289 if test -n "$inctests"; then
4290 # Create autogenerated files.
4291 (cd "$testdir/$testsbase" || func_exit 1
4292 # Do not use "${AUTORECONF} --force --install", because it may invoke
4293 # autopoint, which brings in older versions of some of our .m4 files.
4294 if test -f ../$m4base/gettext.m4; then
4295 func_execute_command ${AUTOPOINT} --force || func_exit 1
4296 for f in ../$m4base/*.m4~; do
4298 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4302 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4303 if ! test -d ../build-aux; then
4304 func_execute_command mkdir ../build-aux
4306 func_execute_command ${AUTOCONF} || func_exit 1
4307 func_execute_command ${AUTOHEADER} || func_exit 1
4308 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4311 # Need to run configure and make once, to create built files that are to be
4312 # distributed (such as getdate.c).
4313 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4314 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4315 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4316 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4317 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4318 # such $(FOO_H) because they don't refer to distributed files.
4319 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4320 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4321 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4322 | sed -e "$sed_remove_make_variables"`
4323 distributed_built_sources=`for file in $built_sources; do
4324 case "$cleaned_files" in
4329 if test -n "$distributed_built_sources"; then
4331 ./configure || func_exit 1
4333 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4334 $MAKE built_sources || func_exit 1
4336 $MAKE distclean || func_exit 1
4341 # func_create_megatestdir megatestdir allmodules
4343 # - local_gnulib_dir from --local-dir
4344 # - auxdir directory relative to destdir where to place build aux files
4345 func_create_megatestdir ()
4349 if test -z "$allmodules"; then
4350 allmodules=`func_all_modules`
4354 # First, all modules one by one.
4355 for onemodule in $allmodules; do
4356 func_create_testdir "$megatestdir/$onemodule" $onemodule
4357 func_append megasubdirs "$onemodule "
4359 # Then, all modules all together.
4360 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4361 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
4362 func_create_testdir "$megatestdir/ALL" "$allmodules"
4363 func_append megasubdirs "ALL"
4366 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4367 vc_witness="$gnulib_dir/CVS/Entries"; \
4369 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4371 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4372 | sed -e 's,January,01,' -e 's,Jan,01,' \
4373 -e 's,February,02,' -e 's,Feb,02,' \
4374 -e 's,March,03,' -e 's,Mar,03,' \
4375 -e 's,April,04,' -e 's,Apr,04,' \
4377 -e 's,June,06,' -e 's,Jun,06,' \
4378 -e 's,July,07,' -e 's,Jul,07,' \
4379 -e 's,August,08,' -e 's,Aug,08,' \
4380 -e 's,September,09,' -e 's,Sep,09,' \
4381 -e 's,October,10,' -e 's,Oct,10,' \
4382 -e 's,November,11,' -e 's,Nov,11,' \
4383 -e 's,December,12,' -e 's,Dec,12,' \
4384 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4385 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4387 echo "CVSDATE=$cvsdate"
4388 echo ": \${MAKE=make}"
4389 echo "test -d logs || mkdir logs"
4390 echo "for module in $megasubdirs; do"
4391 echo " echo \"Working on module \$module...\""
4392 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4393 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4396 echo " : autobuild project... \$module"
4397 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4398 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4399 echo " : autobuild hostname... \`hostname\`"
4400 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
4402 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4404 ) > "$megatestdir/do-autobuild"
4405 chmod a+x "$megatestdir/do-autobuild"
4407 # Create Makefile.am.
4408 (echo "## Process this file with automake to produce Makefile.in."
4410 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4412 echo "SUBDIRS = $megasubdirs"
4414 echo "EXTRA_DIST = do-autobuild"
4415 ) > "$megatestdir/Makefile.am"
4417 # Create configure.ac.
4418 (echo "# Process this file with autoconf to produce a configure script."
4419 echo "AC_INIT([dummy], [0])"
4420 if test "$auxdir" != "."; then
4421 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4423 echo "AM_INIT_AUTOMAKE"
4425 echo "AC_PROG_MAKE_SET"
4427 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4428 echo "AC_CONFIG_FILES([Makefile])"
4430 ) > "$megatestdir/configure.ac"
4432 # Create autogenerated files.
4434 # Do not use "${AUTORECONF} --install", because autoreconf operates
4435 # recursively, but the subdirectories are already finished, therefore
4436 # calling autoreconf here would only waste lots of CPU time.
4437 func_execute_command ${ACLOCAL} || func_exit 1
4438 func_execute_command mkdir build-aux
4439 func_execute_command ${AUTOCONF} || func_exit 1
4440 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4446 func_fatal_error "no mode specified" ;;
4455 if test -z "$destdir"; then
4458 test -d "$destdir" \
4459 || func_fatal_error "destination directory does not exist: $destdir"
4461 # Prefer configure.ac to configure.in.
4462 if test -f "$destdir"/configure.ac; then
4463 configure_ac="$destdir/configure.ac"
4465 if test -f "$destdir"/configure.in; then
4466 configure_ac="$destdir/configure.in"
4468 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
4472 # Analyze configure.ac.
4474 guessed_libtool=false
4479 /AC_CONFIG_AUX_DIR/ {
4480 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
4482 /A[CM]_PROG_LIBTOOL/ {
4483 s,^.*$,guessed_libtool=true,p
4485 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4487 if test -z "$auxdir"; then
4488 auxdir="$guessed_auxdir"
4491 # Determine where to apply func_import.
4492 if test -n "$m4base"; then
4493 # Apply func_import to a particular gnulib directory.
4494 # Any number of additional modules can be given.
4495 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4496 # First use of gnulib in the given m4base.
4497 test -n "$supplied_libname" || supplied_libname=true
4498 test -n "$sourcebase" || sourcebase="lib"
4499 test -n "$docbase" || docbase="doc"
4500 test -n "$testsbase" || testsbase="tests"
4501 test -n "$macro_prefix" || macro_prefix="gl"
4505 # Apply func_import to all gnulib directories.
4506 # To get this list of directories, look at Makefile.am. (Not at
4507 # configure, because it may be omitted from CVS. Also, don't run
4508 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4511 if test -f "$destdir"/Makefile.am; then
4512 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4514 for arg in $aclocal_amflags; do
4515 if test -n "$m4dir_is_next"; then
4516 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4520 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4521 func_append m4dirs " $arg"
4522 m4dirs_count=`expr $m4dirs_count + 1`
4528 if test "X$arg" = "X-I"; then
4536 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4537 if test -f "$destdir"/aclocal.m4; then
4538 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4539 sedexpr2='s,^[^/]*$,.,'
4540 sedexpr3='s,/[^/]*$,,'
4541 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4542 m4dirs_count=`printf %s "$m4dirs" | wc -l`
4545 if test $m4dirs_count = 0; then
4546 # First use of gnulib in a package.
4547 # Any number of additional modules can be given.
4548 test -n "$supplied_libname" || supplied_libname=true
4549 test -n "$sourcebase" || sourcebase="lib"
4551 test -n "$docbase" || docbase="doc"
4552 test -n "$testsbase" || testsbase="tests"
4553 test -n "$macro_prefix" || macro_prefix="gl"
4556 if test $m4dirs_count = 1; then
4557 # There's only one use of gnulib here. Assume the user means it.
4558 # Any number of additional modules can be given.
4559 for m4base in $m4dirs; do
4563 # Ambiguous - guess what the user meant.
4564 if test $# = 0; then
4565 # No further arguments. Guess the user wants to update all of them.
4566 for m4base in $m4dirs; do
4567 # Perform func_import in a subshell, so that variable values
4569 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
4570 # pobase, docbase, testsbase, inctests, libname, lgpl,
4571 # makefile_name, libtool, macro_prefix, po_domain, vc_files
4572 # don't propagate from one directory to another.
4573 (func_import) || func_exit 1
4577 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4585 if test -z "$destdir"; then
4586 func_fatal_error "please specify --dir option"
4589 test -d "$destdir" \
4590 || func_fatal_error "could not create destination directory"
4591 test -n "$auxdir" || auxdir="build-aux"
4592 func_create_testdir "$destdir" "$*"
4595 create-megatestdir )
4596 if test -z "$destdir"; then
4597 func_fatal_error "please specify --dir option"
4599 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4600 test -n "$auxdir" || auxdir="build-aux"
4601 func_create_megatestdir "$destdir" "$*"
4605 test -n "$destdir" || destdir=testdir$$
4606 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4607 test -n "$auxdir" || auxdir="build-aux"
4608 func_create_testdir "$destdir" "$*"
4612 ../configure || func_exit 1
4613 $MAKE || func_exit 1
4614 $MAKE check || func_exit 1
4615 $MAKE distclean || func_exit 1
4616 remaining=`find . -type f -print`
4617 if test -n "$remaining"; then
4618 echo "Remaining files:" $remaining 1>&2
4619 echo "gnulib-tool: *** Stop." 1>&2
4628 test -n "$destdir" || destdir=testdir$$
4629 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4630 test -n "$auxdir" || auxdir="build-aux"
4631 func_create_megatestdir "$destdir" "$*"
4639 remaining=`find . -type f -print`
4640 if test -n "$remaining"; then
4641 echo "Remaining files:" $remaining 1>&2
4642 echo "gnulib-tool: *** Stop." 1>&2
4650 extract-description )
4654 if test -n "$module"; then
4655 func_get_description "$module"
4664 if test -n "$module"; then
4665 func_get_status "$module"
4674 if test -n "$module"; then
4675 func_get_notice "$module"
4680 extract-applicability )
4684 if test -n "$module"; then
4685 func_get_applicability "$module"
4694 if test -n "$module"; then
4695 func_get_filelist "$module"
4700 extract-dependencies )
4704 if test -n "$module"; then
4705 func_get_dependencies "$module"
4710 extract-autoconf-snippet )
4714 if test -n "$module"; then
4715 func_get_autoconf_snippet "$module"
4720 extract-automake-snippet )
4724 if test -n "$module"; then
4725 func_get_automake_snippet "$module"
4730 extract-include-directive )
4734 if test -n "$module"; then
4735 func_get_include_directive "$module"
4740 extract-link-directive )
4744 if test -n "$module"; then
4745 func_get_link_directive "$module"
4754 if test -n "$module"; then
4755 func_get_license "$module"
4760 extract-maintainer )
4764 if test -n "$module"; then
4765 func_get_maintainer "$module"
4770 extract-tests-module )
4774 if test -n "$module"; then
4775 func_get_tests_module "$module"
4781 # Verify the number of arguments.
4782 if test $# -lt 1 || test $# -gt 2; then
4783 func_fatal_error "invalid number of arguments for --$mode"
4786 # The first argument is the file to be copied.
4788 # Verify the file exists.
4789 func_lookup_file "$f"
4791 # The second argument is the destination; either a directory ot a file.
4792 # It defaults to the current directory.
4794 test -n "$dest" || dest='.'
4795 test -n "$sourcebase" || sourcebase="lib"
4796 test -n "$m4base" || m4base="m4"
4797 test -n "$docbase" || docbase="doc"
4798 test -n "$testsbase" || testsbase="tests"
4799 test -n "$auxdir" || auxdir="build-aux"
4800 rewritten='%REWRITTEN%'
4801 sed_rewrite_files="\
4802 s,^build-aux/,$rewritten$auxdir/,
4803 s,^doc/,$rewritten$docbase/,
4804 s,^lib/,$rewritten$sourcebase/,
4805 s,^m4/,$rewritten$m4base/,
4806 s,^tests/,$rewritten$testsbase/,
4809 if test -d "$dest"; then
4811 g=`echo "$f" | sed -e "$sed_rewrite_files"`
4813 destdir=`dirname "$dest"`
4814 g=`basename "$dest"`
4817 # Create the directory for destfile.
4818 d=`dirname "$destdir/$g"`
4820 if test -n "$d" && test ! -d "$d"; then
4821 mkdir -p "$d" || func_fatal_error "failed"
4825 func_dest_tmpfilename "$g"
4826 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4827 already_present=true
4828 if test -f "$destdir/$g"; then
4829 # The file already exists.
4833 # Don't protest if the file should be there but isn't: it happens
4834 # frequently that developers don't put autogenerated files into CVS.
4841 func_fatal_error "unknown operation mode --$mode" ;;
4845 # Undo the effect of the previous 'trap' command. Some shellology:
4846 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4847 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4848 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4849 # 128 + signal number and is set before the trap-registered command is run.
4851 trap 'func_exit $?' 1 2 3 13 15
4856 # indent-tabs-mode: nil
4857 # whitespace-check-buffer-indent: nil