3 # Copyright (C) 2002-2008 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"
66 # When using GNU sed, turn off as many GNU extensions as possible,
67 # to minimize the risk of accidentally using non-portable features.
68 # However, do this only for gnulib-tool itself, not for the code that
69 # gnulib-tool generates, since we don't want "sed --posix" to leak
71 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
72 # Define sed as an alias.
73 # It is not always possible to use aliases. Aliases are guaranteed to work
74 # if the executing shell is bash and either it is invoked as /bin/sh or
75 # is a version >= 2.0, supporting shopt. This is the common case.
76 # Two other approaches (use of a variable $sed or of a function func_sed
77 # instead of an alias) require massive, fragile code changes.
78 # An other approach (use of function sed) requires `which sed` - but 'which'
79 # is hard to emulate, due to missing "test -x" on some platforms.
80 if test -n "$BASH_VERSION"; then
81 shopt -s expand_aliases >/dev/null 2>&1
83 alias sed='sed --posix'
87 # outputs to stdout the --help usage message.
91 Usage: gnulib-tool --list
92 gnulib-tool --import [module1 ... moduleN]
94 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
95 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
96 gnulib-tool --test --dir=directory module1 ... moduleN
97 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
98 gnulib-tool --extract-description module
99 gnulib-tool --extract-notice module
100 gnulib-tool --extract-filelist module
101 gnulib-tool --extract-dependencies module
102 gnulib-tool --extract-autoconf-snippet module
103 gnulib-tool --extract-automake-snippet module
104 gnulib-tool --extract-include-directive module
105 gnulib-tool --extract-link-directive module
106 gnulib-tool --extract-license module
107 gnulib-tool --extract-maintainer module
108 gnulib-tool --extract-tests-module module
111 --list print the available module names
112 --import import the given modules into the current package;
113 if no modules are specified, update the current
114 package from the current gnulib
115 --update update the current package, restore files omitted
117 --create-testdir create a scratch package with the given modules
118 --create-megatestdir create a mega scratch package with the given modules
119 one by one and all together
120 --test test the combination of the given modules
121 (recommended to use CC=\"gcc -Wall\" here)
122 --megatest test the given modules one by one and all together
123 (recommended to use CC=\"gcc -Wall\" here)
124 --extract-description extract the description
125 --extract-notice extract the notice or banner
126 --extract-filelist extract the list of files
127 --extract-dependencies extract the dependencies
128 --extract-autoconf-snippet extract the snippet for configure.ac
129 --extract-automake-snippet extract the snippet for library makefile
130 --extract-include-directive extract the #include directive
131 --extract-link-directive extract the linker directive
132 --extract-license report the license terms of the source files
134 --extract-maintainer report the maintainer(s) inside gnulib
135 --extract-tests-module report the unit test module, if it exists
138 --dir=DIRECTORY Specify the target directory.
139 For --import, this specifies where your
140 configure.ac can be found. Defaults to current
142 --local-dir=DIRECTORY Specify a local override directory where to look
143 up files before looking in gnulib's directory.
144 --verbose Increase verbosity. May be repeated.
145 --quiet Decrease verbosity. May be repeated.
147 Options for --import:
148 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
149 --source-base=DIRECTORY
150 Directory relative to --dir where source code is
151 placed (default \"lib\").
152 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
153 placed (default \"m4\").
154 --po-base=DIRECTORY Directory relative to --dir where *.po files are
155 placed (default \"po\").
156 --doc-base=DIRECTORY Directory relative to --dir where doc files are
157 placed (default \"doc\").
158 --tests-base=DIRECTORY
159 Directory relative to --dir where unit tests are
160 placed (default \"tests\").
161 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
162 tools are placed (default \"build-aux\").
163 --with-tests Include unit tests for the included modules.
164 --avoid=MODULE Avoid including the given MODULE. Useful if you
165 have code that provides equivalent functionality.
166 This option can be repeated.
167 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
168 Also modify license template from GPL to LGPL.
169 The version number of the LGPL can be specified;
170 the default is currently LGPLv3.
171 --makefile-name=NAME Name of makefile in automake syntax in the
172 source-base and tests-base directories
173 (default \"Makefile.am\").
174 --libtool Use libtool rules.
175 --no-libtool Don't use libtool rules.
176 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
177 'gl_INIT'. Default is 'gl'.
178 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
179 the package name. A suffix '-gnulib' is appended.
180 --vc-files Update version control related files.
181 --no-vc-files Don't update version control related files
182 (.gitignore and/or .cvsignore).
183 --no-changelog Don't update or create ChangeLog files.
185 Options for --import and --update:
186 --dry-run For --import, only print what would have been done.
187 -s, --symbolic, --symlink Make symbolic links instead of copying files.
188 --local-symlink Make symbolic links instead of copying files, only
189 for files from the local override directory.
190 -S, --more-symlinks Make symbolic links instead of copying files, and
191 don't replace copyright notices.
193 Report bugs to <bug-gnulib@gnu.org>."
197 # outputs to stdout the --version message.
201 if test -d "$gnulib_dir"/.git \
202 && (git --version) >/dev/null 2>/dev/null \
203 && (date --version) >/dev/null 2>/dev/null; then
204 # gnulib checked out from git.
205 sed_extract_first_date='/^Date/{
209 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
210 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
211 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
212 date=`echo "$date" | sed -e "$sed_year_before_time"`
213 # Use GNU date to compute the time in GMT.
214 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
215 version=' '`"$gnulib_dir"/build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
217 if test -d "$gnulib_dir"/CVS \
218 && (cvs --version) >/dev/null 2>/dev/null; then
219 # gnulib checked out from CVS.
220 sed_extract_first_date='/^date: /{
221 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
224 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
226 # gnulib copy without versioning information.
227 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
231 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
233 gnulib-tool (GNU $package $date)$version
234 Copyright (C) $year Free Software Foundation, Inc.
235 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
236 This is free software: you are free to change and redistribute it.
237 There is NO WARRANTY, to the extent permitted by law.
239 Written by" "Bruno Haible" "and" "Simon Josefsson"
242 # func_emit_copyright_notice
243 # outputs to stdout a header for a generated file.
244 func_emit_copyright_notice ()
246 sed -n '/Copyright/ {
249 }' < "$self_abspathname"
251 echo "# This file is free software, distributed under the terms of the GNU"
252 echo "# General Public License. As a special exception to the GNU General"
253 echo "# Public License, this file may be distributed as part of a program"
254 echo "# that contains a configuration script generated by Autoconf, under"
255 echo "# the same distribution terms as the rest of that program."
257 echo "# Generated by gnulib-tool."
268 # locates the directory where the gnulib repository lives
270 # - self_abspathname absolute pathname of gnulib-tool
271 # - gnulib_dir absolute pathname of gnulib repository
275 /*) self_abspathname="$0" ;;
276 */*) self_abspathname=`pwd`/"$0" ;;
279 # Iterate through the elements of $PATH.
280 # We use IFS=: instead of
281 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
282 # because the latter does not work when some PATH element contains spaces.
283 # We use a canonicalized $pathx instead of $PATH, because empty PATH
284 # elements are by definition equivalent to '.', however field splitting
285 # according to IFS=: loses empty fields in many shells:
286 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
287 # beginning, at the end, and in the middle),
288 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
289 # at the beginning and at the end,
290 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
291 # Solaris lose empty fields at the end.
292 # The 'case' statement is an optimization, to avoid evaluating the
293 # explicit canonicalization command when $PATH contains no empty fields.
295 if test "${PATH_SEPARATOR+set}" != set; then
297 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
298 chmod +x "$tmp"/conf.sh
299 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
306 if test "$PATH_SEPARATOR" = ";"; then
307 # On Windows, programs are searched in "." before $PATH.
310 # On Unix, we have to convert empty PATH elements to ".".
314 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
319 IFS="$PATH_SEPARATOR"
323 if test -x "$d/$0" && test ! -d "$d/$0"; then
324 self_abspathname="$d/$0"
329 if test -z "$self_abspathname"; then
330 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
334 while test -h "$self_abspathname"; do
335 # Resolve symbolic link.
336 linkval=`func_readlink "$self_abspathname"`
337 test -n "$linkval" || break
339 /* ) self_abspathname="$linkval" ;;
340 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
343 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
347 # creates a temporary directory.
349 # - tmp pathname of freshly created temporary directory
352 # Use the environment variable TMPDIR, falling back to /tmp. This allows
353 # users to specify a different temporary directory, for example, if their
354 # /tmp is filled up or too small.
357 # Use the mktemp program if available. If not available, hide the error
359 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
360 test -n "$tmp" && test -d "$tmp"
363 # Use a simple mkdir command. It is guaranteed to fail if the directory
364 # already exists. $RANDOM is bash specific and expands to empty in shells
365 # other than bash, ksh and zsh. Its use does not increase security;
366 # rather, it minimizes the probability of failure in a very cluttered /tmp
368 tmp=$TMPDIR/gl$$-$RANDOM
369 (umask 077 && mkdir "$tmp")
372 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
377 # func_append var value
378 # appends the given value to the shell variable var.
379 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
380 # Use bash's += operator. It reduces complexity of appending repeatedly to
381 # a single variable from O(n^2) to O(n).
389 eval "$1=\"\$$1\$2\""
393 # func_fatal_error message
394 # outputs to stderr a fatal error message, and terminates the program.
397 echo "gnulib-tool: *** $1" 1>&2
398 echo "gnulib-tool: *** Stop." 1>&2
402 # func_readlink SYMLINK
403 # outputs the target of the given symlink.
404 if (type -p readlink) > /dev/null 2>&1; then
407 # Use the readlink program from GNU coreutils.
413 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
414 # would do the wrong thing if the link target contains " -> ".
415 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
419 # func_relativize DIR1 DIR2
420 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
422 # - DIR1 relative pathname, relative to the current directory
423 # - DIR2 relative pathname, relative to the current directory
425 # - reldir relative pathname of DIR2, relative to DIR1
431 sed_first='s,^\([^/]*\)/.*$,\1,'
432 sed_rest='s,^[^/]*/*,,'
433 sed_last='s,^.*/\([^/]*\)$,\1,'
434 sed_butlast='s,/*[^/]*$,,'
435 while test -n "$dir1"; do
436 first=`echo "$dir1" | sed -e "$sed_first"`
437 if test "$first" != "."; then
438 if test "$first" = ".."; then
439 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
440 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
442 first2=`echo "$dir2" | sed -e "$sed_first"`
443 if test "$first2" = "$first"; then
444 dir2=`echo "$dir2" | sed -e "$sed_rest"`
448 dir0="$dir0"/"$first"
451 dir1=`echo "$dir1" | sed -e "$sed_rest"`
456 # func_relconcat DIR1 DIR2
457 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
459 # - DIR1 relative pathname, relative to the current directory
460 # - DIR2 relative pathname, relative to DIR1
462 # - relconcat DIR1/DIR2, relative to the current directory
467 sed_first='s,^\([^/]*\)/.*$,\1,'
468 sed_rest='s,^[^/]*/*,,'
469 sed_last='s,^.*/\([^/]*\)$,\1,'
470 sed_butlast='s,/*[^/]*$,,'
472 first=`echo "$dir2" | sed -e "$sed_first"`
473 if test "$first" = "."; then
474 dir2=`echo "$dir2" | sed -e "$sed_rest"`
475 if test -z "$dir2"; then
480 last=`echo "$dir1" | sed -e "$sed_last"`
481 while test "$last" = "."; do
482 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
483 last=`echo "$dir1" | sed -e "$sed_last"`
485 if test -z "$dir1"; then
489 if test "$first" = ".."; then
490 if test "$last" = ".."; then
491 relconcat="$dir1/$dir2"
494 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
495 dir2=`echo "$dir2" | sed -e "$sed_rest"`
496 if test -z "$dir1"; then
500 if test -z "$dir2"; then
505 relconcat="$dir1/$dir2"
513 # Like ln -s, except that SRC is given relative to the current directory (or
514 # absolute), not given relative to the directory of DEST.
520 *) # SRC is relative.
523 ln -s "`pwd`/$1" "$2" ;;
524 *) # DEST is relative too.
525 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
526 test -n "$ln_destdir" || ln_destdir="."
527 func_relativize "$ln_destdir" "$1"
535 # func_ln_if_changed SRC DEST
536 # Like func_ln, but avoids munging timestamps if the link is correct.
537 func_ln_if_changed ()
539 if test $# -ne 2; then
540 echo "usage: func_ln_if_changed SRC DEST" >&2
542 ln_target=`func_readlink "$2"`
543 if test -h "$2" && test "$1" = "$ln_target"; then
552 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
553 # writes into a pipe with no readers, i.e. a pipe where all readers have
554 # already closed their file descriptor that read from it or exited entirely.
555 # The default behaviour is to terminate the current process without an error
557 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
558 # terminate the current process with an error message.
559 # This function should be called at the beginning of a command that only
560 # produces output to stdout (i.e. no side effects!), when the command that
561 # will read from this pipe might prematurely exit or close its standard input
563 if test -n "$BASH_VERSION"; then
564 # The problem has only been reported with bash.
565 # Note that Solaris sh does not understand "trap - SIGPIPE".
566 func_reset_sigpipe ()
571 func_reset_sigpipe ()
577 # Ensure an 'echo' command that does not interpret backslashes.
579 # echo '\n' | wc -l prints 1 when OK, 2 when KO
580 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
581 # This problem is a weird heritage from SVR4. BSD got it right (except that
582 # BSD echo interprets '-n' as an option, which is also not desirable).
583 # Nowadays the problem occurs in 4 situations:
584 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
585 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
586 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
587 # - in zsh, when sh-emulation is not set,
588 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
589 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
590 # - in Solaris /bin/sh and OSF/1 /bin/sh.
591 # We try the following workarounds:
592 # - for all: respawn using $CONFIG_SHELL if that is set and works.
593 # - for bash >= 2.04: unset the shell option xpg_echo.
594 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
595 # - for bash < 2.0: define echo to a function that uses cat of a here document.
596 # - for zsh: turn sh-emulation on.
597 # - for ksh: alias echo to 'print -r'.
598 # - for ksh: alias echo to a function that uses cat of a here document.
599 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
600 # the ksh workaround.
601 # - otherwise: respawn using /bin/sh and rely on the workarounds.
602 # When respawning, we pass --no-reexec as first argument, so as to avoid
603 # turning this script into a fork bomb in unlucky situations.
605 if echo '\t' | grep t > /dev/null; then
606 have_echo=yes # Lucky!
608 # Try the workarounds.
609 # Respawn using $CONFIG_SHELL if that is set and works.
610 if test -z "$have_echo" \
611 && test "X$1" != "X--no-reexec" \
612 && test -n "$CONFIG_SHELL" \
613 && test -f "$CONFIG_SHELL" \
614 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
615 exec $CONFIG_SHELL "$0" --no-reexec "$@"
618 # For bash >= 2.04: unset the shell option xpg_echo.
619 if test -z "$have_echo" \
620 && test -n "$BASH_VERSION" \
621 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
625 # For bash >= 2.0: define echo to a function that uses the printf built-in.
626 # For bash < 2.0: define echo to a function that uses cat of a here document.
627 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
628 if test -z "$have_echo" \
629 && test -n "$BASH_VERSION"; then \
630 if type printf 2>/dev/null | grep / > /dev/null; then
631 # 'printf' is not a shell built-in.
639 # 'printf' is a shell built-in.
645 if echo '\t' | grep t > /dev/null; then
649 # For zsh: turn sh-emulation on.
650 if test -z "$have_echo" \
651 && test -n "$ZSH_VERSION" \
652 && (emulate sh) >/dev/null 2>&1; then
655 # For ksh: alias echo to 'print -r'.
656 if test -z "$have_echo" \
657 && (type print) >/dev/null 2>&1; then
658 # A 'print' command exists.
659 if type print 2>/dev/null | grep / > /dev/null; then
662 # 'print' is a shell built-in.
663 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
664 # 'print' is the ksh shell built-in.
665 alias echo='print -r'
669 if test -z "$have_echo" \
670 && echo '\t' | grep t > /dev/null; then
673 # For ksh: alias echo to a function that uses cat of a here document.
674 # The ksh manual page says:
675 # "Aliasing is performed when scripts are read, not while they are executed.
676 # Therefore, for an alias to take effect, the alias definition command has
677 # to be executed before the command which references the alias is read."
678 # Because of this, we have to play strange tricks with have_echo, to ensure
679 # that the top-level statement containing the test starts after the 'alias'
681 if test -z "$have_echo"; then
688 alias echo=bsd_echo 2>/dev/null
690 if test -z "$have_echo" \
691 && echo '\t' | grep t > /dev/null; then
694 if test -z "$have_echo"; then
695 unalias echo 2>/dev/null
697 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
698 if test -z "$have_echo" \
699 && test "X$1" != "X--no-reexec" \
700 && test -f /bin/ksh; then
701 exec /bin/ksh "$0" --no-reexec "$@"
704 # Otherwise: respawn using /bin/sh.
705 if test -z "$have_echo" \
706 && test "X$1" != "X--no-reexec" \
707 && test -f /bin/sh; then
708 exec /bin/sh "$0" --no-reexec "$@"
711 if test -z "$have_echo"; then
712 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
714 if echo '\t' | grep t > /dev/null; then
717 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
719 if test "X$1" = "X--no-reexec"; then
723 # Command-line option processing.
724 # Removes the OPTIONS from the arguments. Sets the variables:
725 # - mode list or import or create-testdir or create-megatestdir
726 # - destdir from --dir
727 # - local_gnulib_dir from --local-dir
728 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
729 # - libname, supplied_libname from --lib
730 # - sourcebase from --source-base
731 # - m4base from --m4-base
732 # - pobase from --po-base
733 # - docbase from --doc-base
734 # - testsbase from --tests-base
735 # - auxdir from --aux-dir
736 # - inctests true if --with-tests was given, blank otherwise
737 # - avoidlist list of modules to avoid, from --avoid
738 # - lgpl yes or a number if --lgpl was given, blank otherwise
739 # - makefile_name from --makefile-name
740 # - libtool true if --libtool was given, false if --no-libtool was
741 # given, blank otherwise
742 # - macro_prefix from --macro-prefix
743 # - po_domain from --po-domain
744 # - vc_files true if --vc-files was given, false if --no-vc-files was
745 # given, blank otherwise
746 # - autoconf_minversion minimum supported autoconf version
747 # - do_changelog false if --no-changelog was given, : otherwise
748 # - doit : if actions shall be executed, false if only to be printed
749 # - symbolic true if --symlink or --more-symlinks was given, blank
751 # - lsymbolic true if --local-symlink was given, blank otherwise
752 # - do_copyrights blank if --more-symlinks was given, true otherwise
782 while test $# -gt 0; do
787 --import | --impor | --impo | --imp | --im | --i )
790 --update | --updat | --upda | --upd | --up | --u )
793 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
796 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
797 mode=create-megatestdir
799 --test | --tes | --te | --t )
802 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
806 mode=`echo "X$1" | sed -e 's/^X--//'`
811 func_fatal_error "missing argument for --dir"
816 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
821 func_fatal_error "missing argument for --local-dir"
826 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
828 --verbose | --verbos | --verbo | --verb )
829 verbose=`expr $verbose + 1`
831 --quiet | --quie | --qui | --qu | --q )
832 verbose=`expr $verbose - 1`
837 func_fatal_error "missing argument for --lib"
840 supplied_libname=true
843 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
844 supplied_libname=true
849 func_fatal_error "missing argument for --source-base"
854 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
859 func_fatal_error "missing argument for --m4-base"
864 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
869 func_fatal_error "missing argument for --po-base"
874 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
879 func_fatal_error "missing argument for --doc-base"
884 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
889 func_fatal_error "missing argument for --tests-base"
894 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
899 func_fatal_error "missing argument for --aux-dir"
904 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
912 func_fatal_error "missing argument for --avoid"
914 func_append avoidlist " $1"
917 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
918 func_append avoidlist " $arg"
924 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
927 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
934 func_fatal_error "missing argument for --makefile-name"
939 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
950 func_fatal_error "missing argument for --macro-prefix"
955 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
960 func_fatal_error "missing argument for --po-domain"
965 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
973 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
979 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
982 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
985 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
989 --help | --hel | --he | --h )
992 --version | --versio | --versi | --vers )
996 # Stop option processing
1000 echo "gnulib-tool: unknown option $1" 1>&2
1001 echo "Try 'gnulib-tool --help' for more information." 1>&2
1008 if test "$mode" = update; then
1009 if test $# != 0; then
1010 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1011 echo "Try 'gnulib-tool --help' for more information." 1>&2
1012 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1013 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1016 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1017 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1018 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1019 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
1020 || test -n "$makefile_name" || test -n "$macro_prefix" \
1021 || test -n "$po_domain" || test -n "$vc_files"; then
1022 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1023 echo "Try 'gnulib-tool --help' for more information." 1>&2
1024 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1025 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1030 if test -n "$pobase" && test -z "$po_domain"; then
1031 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1032 echo "Try 'gnulib-tool --help' for more information." 1>&2
1035 if test -z "$pobase" && test -n "$po_domain"; then
1036 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1039 # Determine the minimum supported autoconf version from the project's
1041 DEFAULT_AUTOCONF_MINVERSION="2.59"
1042 autoconf_minversion=
1044 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1045 if test -f "$destdir"/configure.ac; then
1046 configure_ac="$destdir/configure.ac"
1048 if test -f "$destdir"/configure.in; then
1049 configure_ac="$destdir/configure.in"
1053 if test -f configure.ac; then
1054 configure_ac="configure.ac"
1056 if test -f configure.in; then
1057 configure_ac="configure.in"
1061 if test -n "$configure_ac"; then
1062 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1063 # because when some m4 files are omitted from a CVS repository,
1064 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1065 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1066 # autom4te: m4 failed with exit status: 1
1073 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1075 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1076 if test -n "$prereqs"; then
1077 autoconf_minversion=`
1078 for version in $prereqs; do echo $version; done |
1079 LC_ALL=C sort -nru | sed 1q
1083 if test -z "$autoconf_minversion"; then
1084 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1086 case "$autoconf_minversion" in
1087 1.* | 2.[0-4]* | 2.5[0-8]*)
1088 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1091 # Remove trailing slashes from the directory names. This is necessary for
1092 # m4base (to avoid an error in func_import) and optional for the others.
1093 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1094 case "$local_gnulib_dir" in
1095 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1097 case "$sourcebase" in
1098 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1101 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1104 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1107 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1109 case "$testsbase" in
1110 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1113 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1119 trap 'exit_status=$?
1120 if test "$signal" != 0; then
1121 echo "caught signal $signal" >&2
1124 exit $exit_status' 0
1125 for signal in 1 2 3 13 15; do
1126 trap '{ signal='$signal'; func_exit 1; }' $signal
1130 # func_lookup_file file
1131 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1134 # - local_gnulib_dir from --local-dir
1136 # - lookedup_file name of the merged (combined) file
1137 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1141 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1142 lookedup_file="$local_gnulib_dir/$lkfile"
1145 if test -f "$gnulib_dir/$lkfile"; then
1146 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1147 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1148 rm -f "$tmp/$lkbase"
1149 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1150 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1151 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1152 lookedup_file="$tmp/$lkbase"
1155 lookedup_file="$gnulib_dir/$lkfile"
1159 func_fatal_error "file $gnulib_dir/$lkfile not found"
1166 # - local_gnulib_dir from --local-dir
1169 # Filter out metainformation files like README, which are not modules.
1170 # Filter out unit test modules; they can be retrieved through
1171 # --extract-tests-module if desired.
1173 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1174 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1175 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1178 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1179 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1180 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1181 -e '/^README$/d' -e '/\/README$/d' \
1182 -e '/^TEMPLATE$/d' \
1183 -e '/^TEMPLATE-EXTENDED$/d' \
1184 -e '/^TEMPLATE-TESTS$/d' \
1187 | sed -e '/-tests$/d' \
1191 # func_verify_module
1192 # verifies a module name
1194 # - local_gnulib_dir from --local-dir
1195 # - module module name argument
1196 func_verify_module ()
1198 if { test -f "$gnulib_dir/modules/$module" \
1199 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1200 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1201 && test "CVS" != "$module" \
1202 && test "ChangeLog" != "$module" \
1203 && test "COPYING" != "$module" \
1204 && test "README" != "$module" \
1205 && test "TEMPLATE" != "$module" \
1206 && test "TEMPLATE-EXTENDED" != "$module" \
1207 && test "TEMPLATE-TESTS" != "$module"; then
1208 # OK, $module is a correct module name.
1209 # Verify that building the module description with 'patch' succeeds.
1210 func_lookup_file "modules/$module"
1212 echo "gnulib-tool: module $module doesn't exist" 1>&2
1217 # func_verify_nontests_module
1218 # verifies a module name, excluding tests modules
1220 # - local_gnulib_dir from --local-dir
1221 # - module module name argument
1222 func_verify_nontests_module ()
1225 *-tests ) module= ;;
1226 * ) func_verify_module ;;
1230 # func_verify_tests_module
1231 # verifies a module name, considering only tests modules
1233 # - local_gnulib_dir from --local-dir
1234 # - module module name argument
1235 func_verify_tests_module ()
1238 *-tests ) func_verify_module ;;
1243 sed_extract_prog=':[ ]*$/ {
1246 s/^Description:[ ]*$//
1249 s/^Depends-on:[ ]*$//
1250 s/^configure\.ac-early:[ ]*$//
1251 s/^configure\.ac:[ ]*$//
1252 s/^Makefile\.am:[ ]*$//
1256 s/^Maintainer:[ ]*$//
1263 # func_get_description module
1265 # - local_gnulib_dir from --local-dir
1266 func_get_description ()
1268 func_lookup_file "modules/$1"
1269 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1272 # func_get_notice module
1274 # - local_gnulib_dir from --local-dir
1277 func_lookup_file "modules/$1"
1278 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1281 # func_get_filelist module
1283 # - local_gnulib_dir from --local-dir
1284 func_get_filelist ()
1286 func_lookup_file "modules/$1"
1287 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1288 echo m4/gnulib-common.m4
1289 case "$autoconf_minversion" in
1296 # func_get_dependencies module
1298 # - local_gnulib_dir from --local-dir
1299 func_get_dependencies ()
1301 # ${module}-tests always implicitly depends on ${module}.
1302 echo "$1" | sed -n -e 's/-tests$//p'
1303 # Then the explicit dependencies listed in the module description.
1304 func_lookup_file "modules/$1"
1305 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1308 # func_get_autoconf_early_snippet module
1310 # - local_gnulib_dir from --local-dir
1311 func_get_autoconf_early_snippet ()
1313 func_lookup_file "modules/$1"
1314 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1317 # func_get_autoconf_snippet module
1319 # - local_gnulib_dir from --local-dir
1320 func_get_autoconf_snippet ()
1322 func_lookup_file "modules/$1"
1323 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1326 # func_get_automake_snippet module
1328 # - local_gnulib_dir from --local-dir
1329 func_get_automake_snippet ()
1331 func_lookup_file "modules/$1"
1332 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1335 # *-tests module live in tests/, not lib/.
1336 # Synthesize an EXTRA_DIST augmentation.
1337 all_files=`func_get_filelist $1`
1338 tests_files=`for f in $all_files; do \
1340 tests/*) echo $f ;; \
1342 done | sed -e 's,^tests/,,'`
1343 extra_files="$tests_files"
1344 if test -n "$extra_files"; then
1345 echo "EXTRA_DIST +=" $extra_files
1350 # Synthesize an EXTRA_DIST augmentation.
1351 sed_combine_lines='/\\$/{
1358 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1359 already_mentioned_files=` \
1360 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1361 | sed -e "$sed_combine_lines" \
1362 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1363 all_files=`func_get_filelist $1`
1364 lib_files=`for f in $all_files; do \
1368 done | sed -e 's,^lib/,,'`
1369 # Remove $already_mentioned_files from $lib_files.
1370 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1371 extra_files=`func_reset_sigpipe; \
1372 for f in $already_mentioned_files; do echo $f; done \
1373 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1374 if test -n "$extra_files"; then
1375 echo "EXTRA_DIST +=" $extra_files
1378 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1379 # This is necessary so that automake can generate the right list of
1381 # A possible approach would be to use autom4te --trace of the redefined
1382 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1383 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1384 # inside autoconf's built-in macros are not missed).
1385 # But it's simpler and more robust to do it here, based on the file list.
1386 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1387 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1388 # automake will generate a useless dependency; this is harmless.
1390 relocatable-prog-wrapper) ;;
1392 sed_extract_c_files='/\.c$/p'
1393 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1394 if test -n "$extra_files"; then
1395 echo "EXTRA_lib_SOURCES +=" $extra_files
1400 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1401 buildaux_files=`for f in $all_files; do \
1403 build-aux/*) echo $f ;; \
1405 done | sed -e 's,^build-aux/,,'`
1406 if test -n "$buildaux_files"; then
1407 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1408 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1411 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1412 top_files=`for f in $all_files; do \
1416 done | sed -e 's,^top/,,'`
1417 if test -n "$top_files"; then
1418 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1419 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1426 # func_get_include_directive module
1428 # - local_gnulib_dir from --local-dir
1429 func_get_include_directive ()
1431 func_lookup_file "modules/$1"
1432 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1433 sed -e 's/^\(["<]\)/#include \1/'
1436 # func_get_link_directive module
1438 # - local_gnulib_dir from --local-dir
1439 func_get_link_directive ()
1441 func_lookup_file "modules/$1"
1442 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1445 # func_get_license module
1447 # - local_gnulib_dir from --local-dir
1450 func_lookup_file "modules/$1"
1451 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1452 # The default is GPL.
1454 } | sed -e 's,^ *$,,' | sed -e 1q
1457 # func_get_maintainer module
1459 # - local_gnulib_dir from --local-dir
1460 func_get_maintainer ()
1462 func_lookup_file "modules/$1"
1463 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1466 # func_get_tests_module module
1468 # - local_gnulib_dir from --local-dir
1469 func_get_tests_module ()
1471 # The naming convention for tests modules is hardwired: ${module}-tests.
1472 if test -f "$gnulib_dir/modules/$1"-tests \
1473 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1474 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1479 # func_acceptable module
1480 # tests whether a module is acceptable.
1482 # - avoidlist list of modules to avoid
1485 for avoid in $avoidlist; do
1486 if test "$avoid" = "$1"; then
1493 # func_modules_transitive_closure
1495 # - local_gnulib_dir from --local-dir
1496 # - modules list of specified modules
1497 # - inctests true if tests should be included, blank otherwise
1498 # - avoidlist list of modules to avoid
1499 # - tmp pathname of a temporary directory
1501 # - modules list of modules, including dependencies
1502 func_modules_transitive_closure ()
1504 # In order to process every module only once (for speed), process an "input
1505 # list" of modules, producing an "output list" of modules. During each round,
1506 # more modules can be queued in the input list. Once a module on the input
1507 # list has been processed, it is added to the "handled list", so we can avoid
1508 # to process it again.
1510 inmodules="$modules"
1512 while test -n "$inmodules"; do
1513 inmodules_this_round="$inmodules"
1514 inmodules= # Accumulator, queue for next round
1515 for module in $inmodules_this_round; do
1517 if test -n "$module"; then
1518 if func_acceptable $module; then
1519 func_append outmodules " $module"
1520 deps=`func_get_dependencies $module`
1521 # Duplicate dependencies are harmless, but Jim wants a warning.
1522 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1523 if test -n "$duplicated_deps"; then
1524 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1526 func_append inmodules " $deps"
1527 if test -n "$inctests"; then
1528 testsmodule=`func_get_tests_module $module`
1529 if test -n "$testsmodule"; then
1530 func_append inmodules " $testsmodule"
1536 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1537 # Remove $handledmodules from $inmodules.
1538 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1539 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1541 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1542 rm -f "$tmp"/queued-modules
1545 # func_modules_add_dummy
1547 # - local_gnulib_dir from --local-dir
1548 # - modules list of modules, including dependencies
1550 # - modules list of modules, including 'dummy' if needed
1551 func_modules_add_dummy ()
1554 sed_remove_backslash_newline=':a
1561 for module in $modules; do
1562 func_verify_nontests_module
1563 if test -n "$module"; then
1564 # Extract the value of "lib_SOURCES += ...".
1565 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1566 # Ignore .h files since they are not compiled.
1569 *) have_lib_SOURCES=yes ;;
1574 # Add the dummy module, to make sure the library will be non-empty.
1575 if test -z "$have_lib_SOURCES"; then
1576 if func_acceptable "dummy"; then
1577 func_append modules " dummy"
1582 # func_modules_notice
1584 # - local_gnulib_dir from --local-dir
1585 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1586 # - modules list of modules, including dependencies
1587 func_modules_notice ()
1589 if test $verbose -ge -1; then
1590 for module in $modules; do
1592 if test -n "$module"; then
1593 msg=`func_get_notice $module`
1594 if test -n "$msg"; then
1595 echo "Notice from module $module:"
1596 echo "$msg" | sed -e 's/^/ /'
1603 # func_modules_to_filelist
1605 # - local_gnulib_dir from --local-dir
1606 # - modules list of modules, including dependencies
1608 # - files list of files
1609 func_modules_to_filelist ()
1612 for module in $modules; do
1614 if test -n "$module"; then
1615 fs=`func_get_filelist $module`
1616 func_append files " $fs"
1619 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1622 # func_execute_command command [args...]
1623 # Executes a command.
1624 # Uses also the variables
1625 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1626 func_execute_command ()
1628 if test $verbose -ge 0; then
1632 # Commands like automake produce output to stderr even when they succeed.
1633 # Turn this output off if the command succeeds.
1634 "$@" > "$tmp"/cmdout 2>&1
1636 if test $cmdret = 0; then
1640 cat "$tmp"/cmdout 1>&2
1647 # func_emit_lib_Makefile_am
1648 # emits the contents of library makefile to standard output.
1650 # - local_gnulib_dir from --local-dir
1651 # - modules list of modules, including dependencies
1652 # - libname library name
1653 # - pobase directory relative to destdir where to place *.po files
1654 # - auxdir directory relative to destdir where to place build aux files
1655 # - makefile_name from --makefile-name
1656 # - libtool true if libtool will be used, false or blank otherwise
1657 # - macro_prefix prefix of gl_LIBOBJS macros to use
1658 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1659 # - actioncmd (optional) command that will reproduce this invocation
1660 # - for_test true if creating a package for testing, false otherwise
1662 # - uses_subdirs nonempty if object files in subdirs exist
1663 func_emit_lib_Makefile_am ()
1665 # When creating an includable Makefile.am snippet, augment variables with
1666 # += instead of assigning them.
1667 if test -n "$makefile_name"; then
1672 if test "$libtool" = true; then
1675 sed_eliminate_LDFLAGS=
1679 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1682 # When creating a package for testing: Attempt to provoke failures,
1683 # especially link errors, already during "make" rather than during
1684 # "make check", because "make check" is not possible in a cross-compiling
1685 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1686 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1688 sed_transform_check_PROGRAMS=
1690 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1691 echo "## Process this file with automake to produce Makefile.in."
1692 func_emit_copyright_notice
1693 if test -n "$actioncmd"; then
1694 echo "# Reproduce by: $actioncmd"
1699 for module in $modules; do
1700 func_verify_nontests_module
1701 if test -n "$module"; then
1703 func_get_automake_snippet "$module" |
1704 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1705 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1706 -e "$sed_eliminate_LDFLAGS" \
1707 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1708 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1709 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1710 -e "$sed_transform_check_PROGRAMS"
1711 if test "$module" = 'alloca'; then
1712 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1713 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1716 # Skip the contents if it's entirely empty.
1717 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1718 echo "## begin gnulib module $module"
1721 echo "## end gnulib module $module"
1725 # Test whether there are some source files in subdirectories.
1726 for f in `func_get_filelist "$module"`; do
1728 lib/*/*.c) uses_subdirs=yes ;;
1734 if test -z "$makefile_name"; then
1735 # If there are source files in subdirectories, prevent collision of the
1736 # object files (example: hash.c and libxml/hash.c).
1738 if test -n "$uses_subdirs"; then
1739 subdir_options=' subdir-objects'
1741 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1744 if test -z "$makefile_name"; then
1745 echo "noinst_HEADERS ="
1746 echo "noinst_LIBRARIES ="
1747 echo "noinst_LTLIBRARIES ="
1748 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1749 # if you specify pkgdata_DATA to empty. This is a workaround.
1750 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1751 echo "pkgdata_DATA ="
1754 echo "BUILT_SOURCES ="
1757 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1758 if test -z "$makefile_name"; then
1759 echo "MOSTLYCLEANDIRS ="
1761 echo "DISTCLEANFILES ="
1762 echo "MAINTAINERCLEANFILES ="
1764 echo "AM_CPPFLAGS ="
1767 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1768 # One of the snippets already specifies an installation location for the
1769 # library. Don't confuse automake by saying it should not be installed.
1772 # By default, the generated library should not be installed.
1773 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1776 echo "${libname}_${libext}_SOURCES ="
1777 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1778 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
1779 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1780 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1781 echo "EXTRA_${libname}_${libext}_SOURCES ="
1782 if test "$libtool" = true; then
1783 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1786 if test -n "$pobase"; then
1787 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1790 cat allsnippets.tmp \
1791 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1793 echo "mostlyclean-local: mostlyclean-generic"
1794 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1795 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1796 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1800 rm -f allsnippets.tmp
1803 # func_emit_po_Makevars
1804 # emits the contents of po/ makefile parameterization to standard output.
1806 # - local_gnulib_dir from --local-dir
1807 # - sourcebase directory relative to destdir where to place source code
1808 # - pobase directory relative to destdir where to place *.po files
1809 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1810 func_emit_po_Makevars ()
1812 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1813 func_emit_copyright_notice
1815 echo "# Usually the message domain is the same as the package name."
1816 echo "# But here it has a '-gnulib' suffix."
1817 echo "DOMAIN = ${po_domain}-gnulib"
1819 echo "# These two variables depend on the location of this directory."
1820 echo "subdir = ${pobase}"
1821 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1824 # These options get passed to xgettext.
1825 XGETTEXT_OPTIONS = \
1826 --keyword=_ --flag=_:1:pass-c-format \
1827 --keyword=N_ --flag=N_:1:pass-c-format \
1828 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1829 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1830 --flag=error:3:c-format --flag=error_at_line:5:c-format
1832 # This is the copyright holder that gets inserted into the header of the
1833 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1834 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1836 # This is the email address or URL to which the translators shall report
1837 # bugs in the untranslated strings:
1838 # - Strings which are not entire sentences, see the maintainer guidelines
1839 # in the GNU gettext documentation, section 'Preparing Strings'.
1840 # - Strings which use unclear terms or require additional context to be
1842 # - Strings which make invalid assumptions about notation of date, time or
1844 # - Pluralisation problems.
1845 # - Incorrect English spelling.
1846 # - Incorrect formatting.
1847 # It can be your email address, or a mailing list address where translators
1848 # can write to without being subscribed, or the URL of a web page through
1849 # which the translators can contact you.
1850 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1852 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1853 # message catalogs shall be used. It is usually empty.
1854 EXTRA_LOCALE_CATEGORIES =
1856 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1857 # context. Possible values are "yes" and "no". Set this to yes if the
1858 # package uses functions taking also a message context, like pgettext(), or
1859 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1864 # func_emit_po_POTFILES_in
1865 # emits the file list to be passed to xgettext to standard output.
1867 # - local_gnulib_dir from --local-dir
1868 # - sourcebase directory relative to destdir where to place source code
1869 # - files list of new files
1870 func_emit_po_POTFILES_in ()
1872 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1873 func_emit_copyright_notice
1875 echo "# List of files which contain translatable strings."
1876 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1879 # func_emit_tests_Makefile_am
1880 # emits the contents of tests makefile to standard output.
1882 # - local_gnulib_dir from --local-dir
1883 # - modules list of modules, including dependencies
1884 # - libname library name
1885 # - auxdir directory relative to destdir where to place build aux files
1886 # - makefile_name from --makefile-name
1887 # - libtool true if libtool will be used, false or blank otherwise
1888 # - sourcebase relative directory containing lib source code
1889 # - m4base relative directory containing autoconf macros
1890 # - testsbase relative directory containing unit test code
1891 # - macro_prefix prefix of gl_LIBOBJS macros to use
1892 # - for_test true if creating a package for testing, false otherwise
1893 # - use_libtests true if a libtests.a should be built, false otherwise
1895 # - uses_subdirs nonempty if object files in subdirs exist
1896 func_emit_tests_Makefile_am ()
1898 if test "$libtool" = true; then
1900 sed_eliminate_LDFLAGS=
1903 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1906 # When creating a package for testing: Attempt to provoke failures,
1907 # especially link errors, already during "make" rather than during
1908 # "make check", because "make check" is not possible in a cross-compiling
1909 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1910 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1912 sed_transform_check_PROGRAMS=
1914 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1915 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1916 echo "## Process this file with automake to produce Makefile.in."
1917 func_emit_copyright_notice
1921 for module in $modules; do
1923 func_verify_tests_module
1927 if test -n "$module"; then
1929 func_get_automake_snippet "$module" |
1930 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1931 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1932 -e "$sed_eliminate_LDFLAGS" \
1933 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
1934 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1935 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1936 -e "$sed_transform_check_PROGRAMS"
1937 if $use_libtests && test "$module" = 'alloca'; then
1938 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
1939 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1942 # Skip the contents if it's entirely empty.
1943 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1944 echo "## begin gnulib module $module"
1947 echo "## end gnulib module $module"
1951 # Test whether there are some source files in subdirectories.
1952 for f in `func_get_filelist "$module"`; do
1954 lib/*/*.c | tests/*/*.c) uses_subdirs=yes ;;
1960 # Generate dependencies here, since it eases the debugging of test failures.
1961 # If there are source files in subdirectories, prevent collision of the
1962 # object files (example: hash.c and libxml/hash.c).
1964 if test -n "$uses_subdirs"; then
1965 subdir_options=' subdir-objects'
1967 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
1970 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1973 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1974 # variable is needed to avoid an error from automake:
1975 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1978 echo "TESTS_ENVIRONMENT ="
1979 echo "noinst_PROGRAMS ="
1980 if ! $for_test; then
1981 echo "check_PROGRAMS ="
1983 echo "noinst_HEADERS ="
1984 echo "noinst_LIBRARIES ="
1985 if $use_libtests; then
1987 echo "noinst_LIBRARIES += libtests.a"
1989 echo "check_LIBRARIES = libtests.a"
1992 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1993 # if you specify pkgdata_DATA to empty. This is a workaround.
1994 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1995 echo "pkgdata_DATA ="
1998 echo "BUILT_SOURCES ="
2000 echo "MOSTLYCLEANFILES = core *.stackdump"
2001 echo "MOSTLYCLEANDIRS ="
2003 echo "DISTCLEANFILES ="
2004 echo "MAINTAINERCLEANFILES ="
2006 echo "AM_CPPFLAGS = \\"
2007 echo " -I. -I\$(srcdir) \\"
2008 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2009 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2011 local_ldadd_before=''
2012 local_ldadd_after=''
2013 if $use_libtests; then
2014 # All test programs need to be linked with libtests.a.
2015 # It needs to be passed to the linker before ${libname}.${libext}, since
2016 # the tests-related modules depend on the main modules.
2017 # It also needs to be passed to the linker after ${libname}.${libext}
2018 # because the latter might contain incomplete modules (such as the 'error'
2019 # module whose dependency to 'progname' is voluntarily omitted).
2020 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2022 local_ldadd_before=' libtests.a'
2023 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2025 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2027 if $use_libtests; then
2028 echo "libtests_a_SOURCES ="
2029 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2030 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2031 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2032 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2033 echo "EXTRA_libtests_a_SOURCES ="
2034 # The circular dependency in LDADD requires this.
2035 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2038 cat allsnippets.tmp \
2039 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2040 echo "# Clean up after Solaris cc."
2042 echo " rm -rf SunWS_cache"
2044 echo "mostlyclean-local: mostlyclean-generic"
2045 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2046 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2047 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2051 rm -f allsnippets.tmp
2054 # func_emit_initmacro_start macro_prefix
2055 # emits the first few statements of the gl_INIT macro to standard output.
2056 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2057 func_emit_initmacro_start ()
2059 macro_prefix_arg="$1"
2060 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2061 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2062 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2063 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2065 # Furthermore it avoids an automake error like this when a Makefile.am
2066 # that uses pieces of gnulib also uses $(LIBOBJ):
2067 # automatically discovered file `error.c' should not be explicitly mentioned
2068 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2069 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2070 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2071 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2072 # automatically discovered file `error.c' should not be explicitly mentioned
2073 # We let automake know about the files to be distributed through the
2074 # EXTRA_lib_SOURCES variable.
2075 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2076 # Create data variables for checking the presence of files that are mentioned
2077 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2078 # because we want the check to happen when the configure file is created,
2079 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2080 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2081 # in which to expect them.
2082 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2083 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2087 # func_emit_initmacro_end macro_prefix
2088 # emits the last few statements of the gl_INIT macro to standard output.
2089 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2090 func_emit_initmacro_end ()
2092 macro_prefix_arg="$1"
2093 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2094 # The check is performed only when autoconf is run from the directory where
2095 # the configure.ac resides; if it is run from a different directory, the
2097 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2098 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2099 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2100 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2101 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2105 echo " m4_if(m4_sysval, [0], [],"
2106 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2108 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2109 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2110 echo " m4_popdef([AC_LIBSOURCES])"
2111 echo " m4_popdef([AC_REPLACE_FUNCS])"
2112 echo " m4_popdef([AC_LIBOBJ])"
2113 echo " AC_CONFIG_COMMANDS_PRE(["
2114 echo " ${macro_prefix_arg}_libobjs="
2115 echo " ${macro_prefix_arg}_ltlibobjs="
2116 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2117 echo " # Remove the extension."
2118 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2119 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2120 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2121 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2124 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2125 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2129 # func_emit_initmacro_done macro_prefix sourcebase
2130 # emits a few statements after the gl_INIT macro to standard output.
2131 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2132 # - sourcebase directory relative to destdir where to place source code
2133 func_emit_initmacro_done ()
2135 macro_prefix_arg="$1"
2138 echo "# Like AC_LIBOBJ, except that the module name goes"
2139 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2140 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2141 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2142 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2145 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2146 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2147 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2148 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2149 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2152 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2153 echo "# expected is derived from the gnulib-tool parameterization,"
2154 echo "# and alloca is special cased (for the alloca-opt module)."
2155 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2156 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2157 echo " m4_foreach([_gl_NAME], [\$1], ["
2158 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2159 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2160 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2166 # func_import modules
2167 # Uses also the variables
2168 # - destdir target directory
2169 # - local_gnulib_dir from --local-dir
2170 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2171 # - libname library name
2172 # - sourcebase directory relative to destdir where to place source code
2173 # - m4base directory relative to destdir where to place *.m4 macros
2174 # - pobase directory relative to destdir where to place *.po files
2175 # - docbase directory relative to destdir where to place doc files
2176 # - testsbase directory relative to destdir where to place unit test code
2177 # - auxdir directory relative to destdir where to place build aux files
2178 # - inctests true if --with-tests was given, blank otherwise
2179 # - avoidlist list of modules to avoid, from --avoid
2180 # - lgpl yes or a number if library's license shall be LGPL,
2182 # - makefile_name from --makefile-name
2183 # - libtool true if --libtool was given, false if --no-libtool was
2184 # given, blank otherwise
2185 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2186 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2187 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2188 # - vc_files true if --vc-files was given, false if --no-vc-files was
2189 # given, blank otherwise
2190 # - autoconf_minversion minimum supported autoconf version
2191 # - doit : if actions shall be executed, false if only to be printed
2192 # - symbolic true if files should be symlinked, copied otherwise
2193 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2195 # - do_copyrights true if copyright notices in files should be replaced,
2199 # Get the cached settings.
2200 cached_local_gnulib_dir=
2201 cached_specified_modules=
2211 cached_makefile_name=
2213 cached_macro_prefix=
2217 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2218 cached_libtool=false
2224 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2234 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2237 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2240 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2243 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2246 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2249 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2252 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2255 s,^.*$,cached_inctests=true,p
2258 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2261 s,^.*gl_LGPL([[ ]*\([^])]*\).*$,cached_lgpl="\1",p
2264 s,^.*$,cached_lgpl=yes,p
2266 /gl_MAKEFILE_NAME(/ {
2267 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2270 s,^.*$,cached_libtool=true,p
2272 /gl_MACRO_PREFIX(/ {
2273 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2276 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2279 s,^.*gl_VC_FILES([[ ]*\([^])]*\).*$,cached_vc_files="\1",p
2281 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2282 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2287 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2288 s,^.*$,cached_files=",p
2300 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2304 # Merge the cached settings with the specified ones.
2305 # The m4base must be the same as expected from the pathname.
2306 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2307 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2309 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2310 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2311 if test -z "$local_gnulib_dir"; then
2312 if test -n "$cached_local_gnulib_dir"; then
2315 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2317 case "$cached_local_gnulib_dir" in
2319 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2321 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2322 local_gnulib_dir="$relconcat" ;;
2327 # Append the cached and the specified module names. So that
2328 # "gnulib-tool --import foo" means to add the module foo.
2329 specified_modules="$cached_specified_modules $1"
2330 # Append the cached and the specified avoidlist. This is probably better
2331 # than dropping the cached one when --avoid is specified at least once.
2332 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2333 avoidlist=`echo $avoidlist`
2335 # The sourcebase defaults to the cached one.
2336 if test -z "$sourcebase"; then
2337 sourcebase="$cached_sourcebase"
2338 if test -z "$sourcebase"; then
2339 func_fatal_error "missing --source-base option"
2342 # The pobase defaults to the cached one.
2343 if test -z "$pobase"; then
2344 pobase="$cached_pobase"
2346 # The docbase defaults to the cached one.
2347 if test -z "$docbase"; then
2348 docbase="$cached_docbase"
2349 if test -z "$docbase"; then
2350 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."
2353 # The testsbase defaults to the cached one.
2354 if test -z "$testsbase"; then
2355 testsbase="$cached_testsbase"
2356 if test -z "$testsbase"; then
2357 func_fatal_error "missing --tests-base option"
2360 # Require the tests if specified either way.
2361 if test -z "$inctests"; then
2362 inctests="$cached_inctests"
2364 # The libname defaults to the cached one.
2365 if test -z "$supplied_libname"; then
2366 libname="$cached_libname"
2367 if test -z "$libname"; then
2368 func_fatal_error "missing --lib option"
2371 # Require LGPL if specified either way.
2372 if test -z "$lgpl"; then
2375 # The makefile_name defaults to the cached one.
2376 if test -z "$makefile_name"; then
2377 makefile_name="$cached_makefile_name"
2379 # Use libtool if specified either way, or if guessed.
2380 if test -z "$libtool"; then
2381 if test -n "$cached_m4base"; then
2382 libtool="$cached_libtool"
2384 libtool="$guessed_libtool"
2387 # The macro_prefix defaults to the cached one.
2388 if test -z "$macro_prefix"; then
2389 macro_prefix="$cached_macro_prefix"
2390 if test -z "$macro_prefix"; then
2391 func_fatal_error "missing --macro-prefix option"
2394 # The po_domain defaults to the cached one.
2395 if test -z "$po_domain"; then
2396 po_domain="$cached_po_domain"
2398 # The vc_files defaults to the cached one.
2399 if test -z "$vc_files"; then
2400 vc_files="$cached_vc_files"
2403 # Canonicalize the list of specified modules.
2404 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2406 # Determine final module list.
2407 modules="$specified_modules"
2408 func_modules_transitive_closure
2409 if test $verbose -ge 0; then
2410 echo "Module list with included dependencies:"
2411 echo "$modules" | sed -e 's/^/ /'
2413 final_modules="$modules"
2415 # Determine main module list and tests-related module list separately.
2416 # The main module list is the transitive closure of the specified modules,
2417 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2418 # is specified, it will consist only of LGPLed source.
2419 # The tests-related module list is the transitive closure of the specified
2420 # modules, including tests modules, minus the main module list. Its lib/*
2421 # sources (brought in through dependencies of *-tests modules) go into
2422 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2423 # Determine main module list.
2424 saved_inctests="$inctests"
2426 modules="$specified_modules"
2427 func_modules_transitive_closure
2428 main_modules="$modules"
2429 inctests="$saved_inctests"
2430 if test $verbose -ge 1; then
2431 echo "Main module list:"
2432 echo "$main_modules" | sed -e 's/^/ /'
2434 # Determine tests-related module list.
2435 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2436 testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2437 if test $verbose -ge 1; then
2438 echo "Tests-related module list:"
2439 echo "$testsrelated_modules" | sed -e 's/^/ /'
2442 # Add the dummy module to the main module list if needed.
2443 modules="$main_modules"
2444 func_modules_add_dummy
2445 main_modules="$modules"
2447 # Determine whether a $testsbase/libtests.a is needed.
2449 for module in $testsrelated_modules; do
2450 func_verify_nontests_module
2451 if test -n "$module"; then
2452 all_files=`func_get_filelist $module`
2453 lib_files=`for f in $all_files; do \
2457 done | sed -e 's,^lib/,,'`
2458 if test -n "$lib_files"; then
2465 # Add the dummy module to the tests-related module list if needed.
2466 if $use_libtests; then
2467 modules="$testsrelated_modules"
2468 func_modules_add_dummy
2469 testsrelated_modules="$modules"
2472 # If --lgpl, verify that the licenses of modules are compatible.
2473 if test -n "$lgpl"; then
2474 for module in $main_modules; do
2475 license=`func_get_license $module`
2477 'GPLed build tool') ;;
2478 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2484 *) func_fatal_error "incompatible license on module $module: $license" ;;
2490 *) func_fatal_error "incompatible license on module $module: $license" ;;
2493 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2500 # Show banner notice of every module.
2501 modules="$main_modules"
2504 # Determine script to apply to imported library files.
2505 sed_transform_lib_file=
2506 for module in $main_modules; do
2507 if test $module = config-h; then
2508 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2509 sed_transform_lib_file=$sed_transform_lib_file'
2510 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2515 sed_transform_main_lib_file="$sed_transform_lib_file"
2516 if test -n "$do_copyrights"; then
2517 if test -n "$lgpl"; then
2521 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2522 s/GNU General/GNU Lesser General/g
2526 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2527 s/GNU General/GNU Lesser General/g
2528 s/version [23]\([ ,]\)/version 2.1\1/g
2531 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2535 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2536 s/GNU Lesser General/GNU General/g
2537 s/GNU Library General/GNU General/g
2538 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2543 # Determine script to apply to library files that go into $testsbase/.
2544 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2545 if test -n "$do_copyrights"; then
2547 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2548 s/GNU Lesser General/GNU General/g
2549 s/GNU Library General/GNU General/g
2550 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2554 # Determine the final file lists.
2555 # They must be computed separately, because files in lib/* go into
2556 # $sourcebase/ if they are in the main file list but into $testsbase/
2557 # if they are in the tests-related file list. Furthermore lib/dummy.c
2559 # Determine final main file list.
2560 modules="$main_modules"
2561 func_modules_to_filelist
2563 # Determine final tests-related file list.
2564 modules="$testsrelated_modules"
2565 func_modules_to_filelist
2566 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2567 # Merge both file lists.
2568 sed_remove_empty_lines='/^$/d'
2569 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2570 if test $verbose -ge 0; then
2572 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2573 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2577 || func_fatal_error "refusing to do nothing"
2579 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2580 new_files="$files m4/gnulib-tool.m4"
2581 old_files="$cached_files"
2582 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2583 func_append old_files " m4/gnulib-tool.m4"
2586 sed_rewrite_old_files="\
2587 s,^build-aux/,$auxdir/,
2588 s,^doc/,$cached_docbase/,
2589 s,^lib/,$cached_sourcebase/,
2590 s,^m4/,$cached_m4base/,
2591 s,^tests/,$cached_testsbase/,
2592 s,^tests=lib/,$cached_testsbase/,
2594 sed_rewrite_new_files="\
2595 s,^build-aux/,$auxdir/,
2597 s,^lib/,$sourcebase/,
2599 s,^tests/,$testsbase/,
2600 s,^tests=lib/,$testsbase/,
2603 # Create directories.
2604 { echo "$sourcebase"
2606 if test -n "$pobase"; then
2609 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2610 if test -n "$docfiles"; then
2613 if test -n "$inctests"; then
2617 for f in $files; do echo $f; done \
2618 | sed -e "$sed_rewrite_new_files" \
2619 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2622 { # Rearrange file descriptors. Needed because "while ... done < ..."
2623 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2624 exec 5<&0 < "$tmp"/dirs
2626 if test ! -d "$destdir/$d"; then
2628 echo "Creating directory $destdir/$d"
2629 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2631 echo "Create directory $destdir/$d"
2638 # func_dest_tmpfilename file
2639 # determines the name of a temporary file (file is relative to destdir).
2641 # - tmpfile absolute filename of the temporary file
2642 func_dest_tmpfilename ()
2645 # Put the new contents of $file in a file in the same directory (needed
2646 # to guarantee that an 'mv' to "$destdir/$file" works).
2647 tmpfile="$destdir/$1.tmp"
2649 # Put the new contents of $file in a file in a temporary directory
2650 # (because the directory of "$file" might not exist).
2651 tmpfile="$tmp"/`basename "$1"`.tmp
2655 # Copy files or make symbolic links. Remove obsolete files.
2659 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2660 # representing the files according to the last gnulib-tool invocation.
2661 for f in $old_files; do echo $f; done \
2662 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2665 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2666 # representing the files after this gnulib-tool invocation.
2667 for f in $new_files; do echo $f; done \
2668 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2671 # First the files that are in old-files, but not in new-files:
2672 sed_take_first_column='s,'"$delimiter"'.*,,'
2673 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2674 # Remove the file. Do nothing if the user already removed it.
2675 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2677 echo "Removing file $g (backup in ${g}~)"
2678 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2680 echo "Remove file $g (backup in ${g}~)"
2682 func_append removed_files "$g$nl"
2685 # func_add_or_update handles a file that ought to be present afterwards.
2687 # - f the original file name
2688 # - g the rewritten file name
2689 # - already_present nonempty if the file already exists, empty otherwise
2690 func_add_or_update ()
2694 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2696 func_dest_tmpfilename "$g"
2697 func_lookup_file "$f"
2698 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2699 if test -n "$sed_transform_main_lib_file"; then
2702 sed -e "$sed_transform_main_lib_file" \
2703 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2707 if test -n "$sed_transform_testsrelated_lib_file"; then
2710 sed -e "$sed_transform_testsrelated_lib_file" \
2711 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2715 if test -f "$destdir/$g"; then
2716 # The file already exists.
2717 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2718 : # The file has not changed.
2722 if test -n "$already_present"; then
2723 echo "Updating file $g (backup in ${g}~)"
2725 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2727 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2728 if { test -n "$symbolic" \
2729 || { test -n "$lsymbolic" \
2730 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2731 && test -z "$lookedup_tmp" \
2732 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2733 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2735 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2738 if test -n "$already_present"; then
2739 echo "Update file $g (backup in ${g}~)"
2741 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2747 # Don't protest if the file should be there but isn't: it happens
2748 # frequently that developers don't put autogenerated files into CVS.
2750 echo "Copying file $g"
2751 if { test -n "$symbolic" \
2752 || { test -n "$lsymbolic" \
2753 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2754 && test -z "$lookedup_tmp" \
2755 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2756 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2758 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2763 func_append added_files "$g$nl"
2767 # Then the files that are in new-files, but not in old-files:
2768 sed_take_last_column='s,^.*'"$delimiter"',,'
2770 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2771 | sed -e "$sed_take_last_column" \
2772 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2773 { # Rearrange file descriptors. Needed because "while ... done < ..."
2774 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2775 exec 5<&0 < "$tmp"/added-files
2781 # Then the files that are in new-files and in old-files:
2782 already_present=true
2783 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2784 | sed -e "$sed_take_last_column" \
2785 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2786 { # Rearrange file descriptors. Needed because "while ... done < ..."
2787 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2788 exec 5<&0 < "$tmp"/kept-files
2795 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2796 actioncmd="gnulib-tool --import"
2797 func_append actioncmd " --dir=$destdir"
2798 if test -n "$local_gnulib_dir"; then
2799 func_append actioncmd " --local-dir=$local_gnulib_dir"
2801 func_append actioncmd " --lib=$libname"
2802 func_append actioncmd " --source-base=$sourcebase"
2803 func_append actioncmd " --m4-base=$m4base"
2804 if test -n "$pobase"; then
2805 func_append actioncmd " --po-base=$pobase"
2807 func_append actioncmd " --doc-base=$docbase"
2808 func_append actioncmd " --aux-dir=$auxdir"
2809 if test -n "$inctests"; then
2810 func_append actioncmd " --with-tests"
2812 for module in $avoidlist; do
2813 func_append actioncmd " --avoid=$module"
2815 if test -n "$lgpl"; then
2816 if test "$lgpl" = yes; then
2817 func_append actioncmd " --lgpl"
2819 func_append actioncmd " --lgpl=$lgpl"
2822 if test -n "$makefile_name"; then
2823 func_append actioncmd " --makefile-name=$makefile_name"
2825 if test "$libtool" = true; then
2826 func_append actioncmd " --libtool"
2828 func_append actioncmd " --no-libtool"
2830 func_append actioncmd " --macro-prefix=$macro_prefix"
2831 if test -n "$po_domain"; then
2832 func_append actioncmd " --po-domain=$po_domain"
2834 if test -n "$vc_files"; then
2835 if test "$vc_files" = true; then
2836 func_append actioncmd " --vc-files"
2838 func_append actioncmd " --no-vc-files"
2841 func_append actioncmd " `echo $specified_modules`"
2843 # Default the makefile name to Makefile.am.
2844 if test -n "$makefile_name"; then
2845 makefile_am=$makefile_name
2847 makefile_am=Makefile.am
2850 # Create normal Makefile.ams.
2853 # Create library makefile.
2854 func_dest_tmpfilename $sourcebase/$makefile_am
2855 modules="$main_modules"
2856 func_emit_lib_Makefile_am > "$tmpfile"
2857 if test -f "$destdir"/$sourcebase/$makefile_am; then
2858 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2862 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2863 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2864 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2866 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2872 echo "Creating $sourcebase/$makefile_am"
2873 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2875 echo "Create $sourcebase/$makefile_am"
2878 func_append added_files "$sourcebase/$makefile_am$nl"
2881 # Create po/ directory.
2882 if test -n "$pobase"; then
2883 # Create po makefile and auxiliary files.
2884 for file in Makefile.in.in remove-potcdate.sin; do
2885 func_dest_tmpfilename $pobase/$file
2886 func_lookup_file build-aux/po/$file
2887 cat "$lookedup_file" > "$tmpfile"
2888 if test -f "$destdir"/$pobase/$file; then
2889 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2893 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2894 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2895 mv -f "$tmpfile" "$destdir"/$pobase/$file
2897 echo "Update $pobase/$file (backup in $pobase/$file~)"
2903 echo "Creating $pobase/$file"
2904 mv -f "$tmpfile" "$destdir"/$pobase/$file
2906 echo "Create $pobase/$file"
2909 func_append added_files "$pobase/$file$nl"
2912 # Create po makefile parameterization, part 1.
2913 func_dest_tmpfilename $pobase/Makevars
2914 func_emit_po_Makevars > "$tmpfile"
2915 if test -f "$destdir"/$pobase/Makevars; then
2916 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2920 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2921 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2922 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2924 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2930 echo "Creating $pobase/Makevars"
2931 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2933 echo "Create $pobase/Makevars"
2936 func_append added_files "$pobase/Makevars$nl"
2938 # Create po makefile parameterization, part 2.
2939 func_dest_tmpfilename $pobase/POTFILES.in
2940 func_emit_po_POTFILES_in > "$tmpfile"
2941 if test -f "$destdir"/$pobase/POTFILES.in; then
2942 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2946 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2947 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2948 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2950 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2956 echo "Creating $pobase/POTFILES.in"
2957 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2959 echo "Create $pobase/POTFILES.in"
2962 func_append added_files "$pobase/POTFILES.in$nl"
2965 TP_URL="http://translationproject.org/latest/"
2966 TP_RSYNC_URI="translationproject.org::tp/latest/"
2968 echo "Fetching gnulib PO files from $TP_URL"
2969 (cd "$destdir"/$pobase \
2970 && { # Prefer rsync over wget if it is available, since it consumes
2971 # less network bandwidth, due to compression.
2972 if type rsync 2>/dev/null | grep / > /dev/null; then
2973 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2975 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2980 echo "Fetch gnulib PO files from $TP_URL"
2982 # Create po/LINGUAS.
2984 func_dest_tmpfilename $pobase/LINGUAS
2985 (cd "$destdir"/$pobase \
2986 && { echo '# Set of available languages.'
2987 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2990 if test -f "$destdir"/$pobase/LINGUAS; then
2991 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2994 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2995 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2996 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2999 echo "Creating $pobase/LINGUAS"
3000 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3001 func_append added_files "$pobase/LINGUAS$nl"
3004 if test -f "$destdir"/$pobase/LINGUAS; then
3005 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3007 echo "Create $pobase/LINGUAS"
3012 # Create m4/gnulib-cache.m4.
3013 func_dest_tmpfilename $m4base/gnulib-cache.m4
3015 func_emit_copyright_notice
3017 echo "# This file represents the specification of how gnulib-tool is used."
3018 echo "# It acts as a cache: It is written and read by gnulib-tool."
3019 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3020 echo "# like the configure.ac and various Makefile.am files."
3023 echo "# Specification in the form of a command-line invocation:"
3026 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3027 # Store the local_gnulib_dir relative to destdir.
3028 case "$local_gnulib_dir" in
3030 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3033 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3035 # destdir, local_gnulib_dir are both relative.
3036 func_relativize "$destdir" "$local_gnulib_dir"
3037 relative_local_gnulib_dir="$reldir" ;;
3040 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3042 echo "$specified_modules" | sed 's/^/ /g'
3044 echo "gl_AVOID([$avoidlist])"
3045 echo "gl_SOURCE_BASE([$sourcebase])"
3046 echo "gl_M4_BASE([$m4base])"
3047 echo "gl_PO_BASE([$pobase])"
3048 echo "gl_DOC_BASE([$docbase])"
3049 echo "gl_TESTS_BASE([$testsbase])"
3050 test -z "$inctests" || echo "gl_WITH_TESTS"
3051 echo "gl_LIB([$libname])"
3052 if test -n "$lgpl"; then
3053 if test "$lgpl" = yes; then
3056 echo "gl_LGPL([$lgpl])"
3059 echo "gl_MAKEFILE_NAME([$makefile_name])"
3060 if test "$libtool" = true; then
3063 echo "gl_MACRO_PREFIX([$macro_prefix])"
3064 echo "gl_PO_DOMAIN([$po_domain])"
3065 if test -n "$vc_files"; then
3066 echo "gl_VC_FILES([$vc_files])"
3069 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3070 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3074 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3075 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3076 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3078 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3082 echo "# gnulib-cache.m4 ends here"
3089 echo "Creating $m4base/gnulib-cache.m4"
3090 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3092 echo "Create $m4base/gnulib-cache.m4"
3098 # Create m4/gnulib-comp.m4.
3099 func_dest_tmpfilename $m4base/gnulib-comp.m4
3101 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3102 func_emit_copyright_notice
3104 echo "# This file represents the compiled summary of the specification in"
3105 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3106 echo "# to be invoked from configure.ac."
3107 echo "# In projects using CVS, this file can be treated like other built files."
3110 echo "# This macro should be invoked from $configure_ac, in the section"
3111 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3112 echo "# any checks for libraries, header files, types and library functions."
3113 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3115 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3116 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3117 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3118 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3119 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3120 if test -n "$uses_subdirs"; then
3121 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3123 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
3124 echo " AC_REQUIRE([AC_GNU_SOURCE])"
3126 for module in $final_modules; do
3128 if test -n "$module"; then
3129 func_get_autoconf_early_snippet "$module"
3132 | sed -e '/^$/d;' -e 's/^/ /'
3135 echo "# This macro should be invoked from $configure_ac, in the section"
3136 echo "# \"Check for header files, types and library functions\"."
3137 echo "AC_DEFUN([${macro_prefix}_INIT],"
3139 if test "$libtool" = true; then
3140 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3141 echo " gl_cond_libtool=true"
3143 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3144 echo " gl_cond_libtool=false"
3146 echo " gl_ltlibdeps="
3148 if test "$auxdir" != "build-aux"; then
3149 sed_replace_build_aux='
3151 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3152 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3156 sed_replace_build_aux=
3158 func_emit_initmacro_start $macro_prefix
3159 echo " gl_source_base='$sourcebase'"
3160 for module in $main_modules; do
3162 if test -n "$module"; then
3163 func_get_autoconf_snippet "$module" \
3164 | sed -e '/^$/d;' -e 's/^/ /' \
3165 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3166 -e "$sed_replace_build_aux"
3167 if test "$module" = 'alloca' && test "$libtool" = true; then
3168 echo 'changequote(,)dnl'
3169 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3170 echo 'changequote([, ])dnl'
3171 echo 'AC_SUBST([LTALLOCA])'
3175 func_emit_initmacro_end $macro_prefix
3176 echo " gltests_libdeps="
3177 echo " gltests_ltlibdeps="
3178 func_emit_initmacro_start ${macro_prefix}tests
3179 echo " gl_source_base='$testsbase'"
3180 for module in $testsrelated_modules; do
3182 if test -n "$module"; then
3183 func_get_autoconf_snippet "$module" \
3184 | sed -e '/^$/d;' -e 's/^/ /' \
3185 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3186 -e "$sed_replace_build_aux" \
3187 -e 's/\$gl_cond_libtool/false/g' \
3188 -e 's/gl_libdeps/gltests_libdeps/g' \
3189 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3192 func_emit_initmacro_end ${macro_prefix}tests
3193 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3194 # created using libtool, because libtool already handles the dependencies.
3195 if test "$libtool" != true; then
3196 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3197 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3198 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3199 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3200 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3202 if $use_libtests; then
3203 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3204 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3207 func_emit_initmacro_done $macro_prefix $sourcebase
3208 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3210 echo "# This macro records the list of files which have been installed by"
3211 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3212 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3213 echo "$files" | sed -e 's,^, ,'
3216 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3217 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3221 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3222 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3223 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3225 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3229 echo "# gnulib-comp.m4 ends here"
3236 echo "Creating $m4base/gnulib-comp.m4"
3237 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3239 echo "Create $m4base/gnulib-comp.m4"
3245 if test -n "$inctests"; then
3246 # Create tests makefile.
3247 func_dest_tmpfilename $testsbase/$makefile_am
3248 modules="$testsrelated_modules"
3249 func_emit_tests_Makefile_am > "$tmpfile"
3250 if test -f "$destdir"/$testsbase/$makefile_am; then
3251 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3255 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3256 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3257 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3259 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3265 echo "Creating $testsbase/$makefile_am"
3266 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3268 echo "Create $testsbase/$makefile_am"
3271 func_append added_files "$testsbase/$makefile_am$nl"
3275 if test "$vc_files" != false; then
3276 # Update the .cvsignore and .gitignore files.
3277 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3278 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3279 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3280 echo "$m4base/|A|gnulib-comp.m4"
3281 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3282 { # Rearrange file descriptors. Needed because "while ... done < ..."
3283 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3284 exec 5<&0 < "$tmp"/fileset-changes
3285 func_update_ignorelist ()
3288 if test "$ignore" = .gitignore; then
3289 # In a .gitignore file, "foo" applies to the current directory and all
3290 # subdirectories, whereas "/foo" applies to the current directory only.
3293 doubly_escaped_anchor='\\/'
3297 doubly_escaped_anchor=''
3299 if test -f "$destdir/$dir$ignore"; then
3300 if test -n "$dir_added" || test -n "$dir_removed"; then
3301 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3303 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3304 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
3305 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3306 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
3308 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3310 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3311 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3312 { sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3313 if test -n "$anchor"; then sed -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,\$/d,' < "$tmp"/ignore-removed; fi
3314 } > "$tmp"/sed-ignore-removed
3315 { cat "$destdir/$dir$ignore"~
3316 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3317 } | sed -f "$tmp"/sed-ignore-removed \
3318 > "$destdir/$dir$ignore"
3320 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3325 if test -n "$dir_added"; then
3327 echo "Creating $destdir/$dir$ignore"
3329 if test "$ignore" = .cvsignore; then
3331 # Automake generates Makefile rules that create .dirstamp files.
3334 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3335 } > "$destdir/$dir$ignore"
3337 echo "Create $destdir/$dir$ignore"
3347 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3348 func_update_ignorelist .cvsignore
3350 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3351 func_update_ignorelist .gitignore
3358 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3359 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3360 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3361 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3362 if test "$next_dir" != "$last_dir"; then
3363 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3364 last_dir="$next_dir"
3369 A) func_append last_dir_added "$file$nl";;
3370 R) func_append last_dir_removed "$file$nl";;
3373 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3380 echo "You may need to add #include directives for the following .h files."
3381 # Intersect $specified_modules and $main_modules
3382 # (since $specified_modules is not necessarily of subset of $main_modules
3383 # - some may have been skipped through --avoid, and since the elements of
3384 # $main_modules but not in $specified_modules can go away without explicit
3385 # notice - through changes in the module dependencies).
3386 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3387 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3388 # First the #include <...> directives without #ifs, sorted for convenience,
3389 # then the #include "..." directives without #ifs, sorted for convenience,
3390 # then the #include directives that are surrounded by #ifs. Not sorted.
3391 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3392 include_directive=`func_get_include_directive "$module"`
3393 case "$nl$include_directive" in
3395 echo "$include_directive" 1>&5
3398 echo "$include_directive" | grep -v 'include "' 1>&6
3399 echo "$include_directive" | grep 'include "' 1>&7
3402 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3404 LC_ALL=C sort -u "$tmp"/include-angles
3405 LC_ALL=C sort -u "$tmp"/include-quotes
3406 cat "$tmp"/include-if
3407 ) | sed -e '/^$/d' -e 's/^/ /'
3408 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3410 for module in $main_modules; do
3411 func_get_link_directive "$module"
3413 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3414 if test `wc -l < "$tmp"/link` != 0; then
3416 echo "You may need to use the following Makefile variables when linking."
3417 echo "Use them in <program>_LDADD when linking a program, or"
3418 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3424 echo "Don't forget to"
3425 if test "$makefile_am" = Makefile.am; then
3426 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3428 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3430 if test -n "$pobase"; then
3431 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3433 if test -n "$inctests"; then
3434 if test "$makefile_am" = Makefile.am; then
3435 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3437 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3440 if test "$makefile_am" = Makefile.am; then
3441 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3442 sourcebase_base=`basename "$sourcebase"`
3443 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
3445 if test -n "$pobase"; then
3446 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3447 pobase_base=`basename "$pobase"`
3448 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
3450 if test -n "$inctests"; then
3451 if test "$makefile_am" = Makefile.am; then
3452 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3453 testsbase_base=`basename "$testsbase"`
3454 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
3457 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
3459 # Find the first parent directory of $m4base that contains a Makefile.am.
3460 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3462 sed_butlast='s,[^/][^/]*//*$,,'
3463 dir1="${m4base}/"; dir2=""
3464 while test -n "$dir1" && test ! -f "${destdir}/${dir1}Makefile.am"; do
3465 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3466 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3468 echo " - mention ${dir2}gnulib-cache.m4 in EXTRA_DIST in ${dir1}Makefile.am."
3470 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3471 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3474 # func_create_testdir testdir modules
3476 # - local_gnulib_dir from --local-dir
3477 # - auxdir directory relative to destdir where to place build aux files
3478 func_create_testdir ()
3482 if test -z "$modules"; then
3483 # All modules together.
3484 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3485 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3486 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3487 modules=`func_all_modules`
3488 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3490 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3492 # Check that the license of every module is consistent with the license of
3494 saved_modules="$modules"
3495 saved_inctests="$inctests"
3496 # When computing transitive closures, don't consider $module to depend on
3497 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3498 # on GPL modules - therefore we don't want a warning in this case.
3500 for requested_module in $saved_modules; do
3501 requested_license=`func_get_license "$requested_module"`
3502 if test "$requested_license" != GPL; then
3503 # Here we use func_modules_transitive_closure, not just
3504 # func_get_dependencies, so that we also detect weird situations like
3505 # an LGPL module which depends on a GPLed build tool module which depends
3507 modules="$requested_module"
3508 func_modules_transitive_closure
3509 for module in $modules; do
3510 license=`func_get_license "$module"`
3512 'GPLed build tool') ;;
3513 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3515 case "$requested_license" in
3518 GPLv2+ | LGPLv2+) ;;
3519 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3525 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3531 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3540 modules="$saved_modules"
3541 inctests="$saved_inctests"
3543 # Subdirectory names.
3553 # Determine final module list.
3554 func_modules_transitive_closure
3555 if test $verbose -ge 0; then
3556 echo "Module list with included dependencies:"
3557 echo "$modules" | sed -e 's/^/ /'
3560 # Add the dummy module if needed.
3561 func_modules_add_dummy
3563 # Show banner notice of every module.
3566 # Determine final file list.
3567 func_modules_to_filelist
3568 if test $verbose -ge 0; then
3570 echo "$files" | sed -e 's/^/ /'
3573 sed_rewrite_files="\
3574 s,^build-aux/,$auxdir/,
3576 s,^lib/,$sourcebase/,
3578 s,^tests/,$testsbase/,
3581 # Create directories.
3582 for f in $files; do echo $f; done \
3583 | sed -e "$sed_rewrite_files" \
3584 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3585 | LC_ALL=C sort -u \
3587 { # Rearrange file descriptors. Needed because "while ... done < ..."
3588 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3589 exec 5<&0 < "$tmp"/dirs
3591 mkdir -p "$testdir/$d"
3596 # Copy files or make symbolic links.
3598 for f in $files; do echo $f; done \
3599 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3602 { # Rearrange file descriptors. Needed because "while ... done < ..."
3603 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3604 exec 5<&0 < "$tmp"/files
3606 func_lookup_file "$f"
3607 if test -n "$lookedup_tmp"; then
3608 cp -p "$lookedup_file" "$testdir/$g"
3610 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3611 if { test -n "$symbolic" \
3612 || { test -n "$lsymbolic" \
3613 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3614 func_ln "$lookedup_file" "$testdir/$g"
3616 cp -p "$lookedup_file" "$testdir/$g"
3623 # Create Makefile.ams that are for testing.
3626 # Create $sourcebase/Makefile.am.
3627 mkdir -p "$testdir/$sourcebase"
3628 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3629 any_uses_subdirs="$uses_subdirs"
3631 # Create $m4base/Makefile.am.
3632 mkdir -p "$testdir/$m4base"
3633 (echo "## Process this file with automake to produce Makefile.in."
3639 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3642 ) > "$testdir/$m4base/Makefile.am"
3644 subdirs="$sourcebase $m4base"
3645 subdirs_with_configure_ac=""
3647 if false && test -f "$testdir"/$m4base/gettext.m4; then
3648 # Avoid stupid error message from automake:
3649 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3650 mkdir -p "$testdir/po"
3651 (echo "## Process this file with automake to produce Makefile.in."
3652 ) > "$testdir/po/Makefile.am"
3653 func_append subdirs " po"
3656 if test -n "$inctests"; then
3657 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3658 # Viewed from the $testsbase subdirectory, $auxdir is different.
3659 saved_auxdir="$auxdir"
3660 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3661 # Create $testsbase/Makefile.am.
3663 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3664 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3665 # Create $testsbase/configure.ac.
3666 (echo "# Process this file with autoconf to produce a configure script."
3667 echo "AC_INIT([dummy], [0])"
3668 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3669 echo "AM_INIT_AUTOMAKE"
3671 echo "AM_CONFIG_HEADER([config.h])"
3674 echo "AC_PROG_INSTALL"
3675 echo "AC_PROG_MAKE_SET"
3676 echo "AC_PROG_RANLIB"
3678 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3679 echo "AC_GNU_SOURCE"
3682 for module in $modules; do
3684 if test -n "$module"; then
3685 func_get_autoconf_early_snippet "$module"
3688 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3689 if test "$libtool" = true; then
3690 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3691 echo "gl_cond_libtool=true"
3693 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3694 echo "gl_cond_libtool=false"
3696 echo "gl_ltlibdeps="
3698 # Wrap the set of autoconf snippets into an autoconf macro that is then
3699 # invoked. This is needed because autoconf does not support AC_REQUIRE
3701 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3702 # but we want the AC_REQUIRE to have its normal meaning (provide one
3703 # expansion of the required macro before the current point, and only one
3705 echo "AC_DEFUN([gl_INIT], ["
3706 sed_replace_build_aux='
3708 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3709 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3712 func_emit_initmacro_start $macro_prefix
3713 # We don't have explicit ordering constraints between the various
3714 # autoconf snippets. It's cleanest to put those of the library before
3715 # those of the tests.
3716 echo "gl_source_base='../$sourcebase'"
3717 for module in $modules; do
3718 func_verify_nontests_module
3719 if test -n "$module"; then
3720 func_get_autoconf_snippet "$module" \
3721 | sed -e "$sed_replace_build_aux"
3724 echo "gl_source_base='.'"
3725 for module in $modules; do
3726 func_verify_tests_module
3727 if test -n "$module"; then
3728 func_get_autoconf_snippet "$module" \
3729 | sed -e "$sed_replace_build_aux"
3732 func_emit_initmacro_end $macro_prefix
3733 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3734 # created using libtool, because libtool already handles the dependencies.
3735 if test "$libtool" != true; then
3736 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3737 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3738 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3739 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3740 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3743 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3747 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3748 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3749 echo "AH_TOP([#include \"../config.h\"])"
3751 echo "AC_OUTPUT([Makefile])"
3752 ) > "$testdir/$testsbase/configure.ac"
3753 auxdir="$saved_auxdir"
3754 func_append subdirs " $testsbase"
3755 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3758 # Create Makefile.am.
3759 (echo "## Process this file with automake to produce Makefile.in."
3761 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3763 echo "SUBDIRS = $subdirs"
3765 echo "ACLOCAL_AMFLAGS = -I $m4base"
3766 ) > "$testdir/Makefile.am"
3768 # Create configure.ac.
3769 (echo "# Process this file with autoconf to produce a configure script."
3770 echo "AC_INIT([dummy], [0])"
3771 if test "$auxdir" != "."; then
3772 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3774 echo "AM_INIT_AUTOMAKE"
3776 echo "AM_CONFIG_HEADER([config.h])"
3779 echo "AC_PROG_INSTALL"
3780 echo "AC_PROG_MAKE_SET"
3782 echo "# For autobuild."
3783 echo "AC_CANONICAL_BUILD"
3784 echo "AC_CANONICAL_HOST"
3786 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3787 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3788 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3789 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3791 echo "AC_PROG_RANLIB"
3793 if test -n "$any_uses_subdirs"; then
3794 echo "AM_PROG_CC_C_O"
3797 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3798 echo "AC_GNU_SOURCE"
3801 for module in $modules; do
3802 func_verify_nontests_module
3803 if test -n "$module"; then
3804 func_get_autoconf_early_snippet "$module"
3807 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3808 if test "$libtool" = true; then
3809 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3810 echo "gl_cond_libtool=true"
3812 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3813 echo "gl_cond_libtool=false"
3815 echo "gl_ltlibdeps="
3817 # Wrap the set of autoconf snippets into an autoconf macro that is then
3818 # invoked. This is needed because autoconf does not support AC_REQUIRE
3820 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3821 # but we want the AC_REQUIRE to have its normal meaning (provide one
3822 # expansion of the required macro before the current point, and only one
3824 echo "AC_DEFUN([gl_INIT], ["
3825 if test "$auxdir" != "build-aux"; then
3826 sed_replace_build_aux='
3828 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3829 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3833 sed_replace_build_aux=
3835 func_emit_initmacro_start $macro_prefix
3836 echo "gl_source_base='$sourcebase'"
3837 for module in $modules; do
3838 func_verify_nontests_module
3839 if test -n "$module"; then
3840 func_get_autoconf_snippet "$module" \
3841 | sed -e "$sed_replace_build_aux"
3844 func_emit_initmacro_end $macro_prefix
3845 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3846 # created using libtool, because libtool already handles the dependencies.
3847 if test "$libtool" != true; then
3848 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3849 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3850 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3851 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3852 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3855 func_emit_initmacro_done $macro_prefix $sourcebase
3859 if test -n "$subdirs_with_configure_ac"; then
3860 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3862 makefiles="Makefile"
3863 for d in $subdirs; do
3864 # For subdirs that have a configure.ac by their own, it's the subdir's
3865 # configure.ac which creates the subdir's Makefile.am, not this one.
3866 case " $subdirs_with_configure_ac " in
3868 *) func_append makefiles " $d/Makefile" ;;
3871 echo "AC_OUTPUT([$makefiles])"
3872 ) > "$testdir/configure.ac"
3874 # Create autogenerated files.
3876 # Do not use "${AUTORECONF} --force --install", because it may invoke
3877 # autopoint, which brings in older versions of some of our .m4 files.
3878 if test -f $m4base/gettext.m4; then
3879 func_execute_command ${AUTOPOINT} --force || func_exit 1
3880 for f in $m4base/*.m4~; do
3881 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3884 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3885 if ! test -d build-aux; then
3886 func_execute_command mkdir build-aux || func_exit 1
3888 func_execute_command ${AUTOCONF} || func_exit 1
3889 func_execute_command ${AUTOHEADER} || func_exit 1
3890 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3892 if test -n "$inctests"; then
3893 # Create autogenerated files.
3894 (cd "$testdir/$testsbase" || func_exit 1
3895 # Do not use "${AUTORECONF} --force --install", because it may invoke
3896 # autopoint, which brings in older versions of some of our .m4 files.
3897 if test -f ../$m4base/gettext.m4; then
3898 func_execute_command ${AUTOPOINT} --force || func_exit 1
3899 for f in ../$m4base/*.m4~; do
3900 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3903 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3904 if ! test -d ../build-aux; then
3905 func_execute_command mkdir ../build-aux
3907 func_execute_command ${AUTOCONF} || func_exit 1
3908 func_execute_command ${AUTOHEADER} || func_exit 1
3909 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3912 # Need to run configure and make once, to create built files that are to be
3913 # distributed (such as getdate.c).
3914 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3915 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3916 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3917 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3918 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3919 # such $(FOO_H) because they don't refer to distributed files.
3920 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3921 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3922 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3923 | sed -e "$sed_remove_make_variables"`
3924 distributed_built_sources=`for file in $built_sources; do
3925 case "$cleaned_files" in
3930 if test -n "$distributed_built_sources"; then
3932 ./configure || func_exit 1
3934 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3935 make built_sources || func_exit 1
3937 make distclean || func_exit 1
3942 # func_create_megatestdir megatestdir allmodules
3944 # - local_gnulib_dir from --local-dir
3945 # - auxdir directory relative to destdir where to place build aux files
3946 func_create_megatestdir ()
3950 if test -z "$allmodules"; then
3951 allmodules=`func_all_modules`
3955 # First, all modules one by one.
3956 for onemodule in $allmodules; do
3957 func_create_testdir "$megatestdir/$onemodule" $onemodule
3958 func_append megasubdirs "$onemodule "
3960 # Then, all modules all together.
3961 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3962 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3963 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3964 func_create_testdir "$megatestdir/ALL" "$allmodules"
3965 func_append megasubdirs "ALL"
3968 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
3969 vc_witness="$gnulib_dir/CVS/Entries"; \
3971 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
3973 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
3974 | sed -e 's,January,01,' -e 's,Jan,01,' \
3975 -e 's,February,02,' -e 's,Feb,02,' \
3976 -e 's,March,03,' -e 's,Mar,03,' \
3977 -e 's,April,04,' -e 's,Apr,04,' \
3979 -e 's,June,06,' -e 's,Jun,06,' \
3980 -e 's,July,07,' -e 's,Jul,07,' \
3981 -e 's,August,08,' -e 's,Aug,08,' \
3982 -e 's,September,09,' -e 's,Sep,09,' \
3983 -e 's,October,10,' -e 's,Oct,10,' \
3984 -e 's,November,11,' -e 's,Nov,11,' \
3985 -e 's,December,12,' -e 's,Dec,12,' \
3986 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3987 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3989 echo "CVSDATE=$cvsdate"
3990 echo "test -d logs || mkdir logs"
3991 echo "for module in $megasubdirs; do"
3992 echo " echo \"Working on module \$module...\""
3993 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3994 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3997 echo " : autobuild project... \$module"
3998 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3999 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4000 echo " : autobuild hostname... \`hostname\`"
4001 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
4003 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4005 ) > "$megatestdir/do-autobuild"
4006 chmod a+x "$megatestdir/do-autobuild"
4008 # Create Makefile.am.
4009 (echo "## Process this file with automake to produce Makefile.in."
4011 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4013 echo "SUBDIRS = $megasubdirs"
4015 echo "EXTRA_DIST = do-autobuild"
4016 ) > "$megatestdir/Makefile.am"
4018 # Create configure.ac.
4019 (echo "# Process this file with autoconf to produce a configure script."
4020 echo "AC_INIT([dummy], [0])"
4021 if test "$auxdir" != "."; then
4022 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4024 echo "AM_INIT_AUTOMAKE"
4026 echo "AC_PROG_MAKE_SET"
4028 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4029 echo "AC_OUTPUT([Makefile])"
4030 ) > "$megatestdir/configure.ac"
4032 # Create autogenerated files.
4034 # Do not use "${AUTORECONF} --install", because autoreconf operates
4035 # recursively, but the subdirectories are already finished, therefore
4036 # calling autoreconf here would only waste lots of CPU time.
4037 func_execute_command ${ACLOCAL} || func_exit 1
4038 func_execute_command mkdir build-aux
4039 func_execute_command ${AUTOCONF} || func_exit 1
4040 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4046 func_fatal_error "no mode specified" ;;
4055 if test -z "$destdir"; then
4058 test -d "$destdir" \
4059 || func_fatal_error "destination directory does not exist: $destdir"
4061 # Prefer configure.ac to configure.in.
4062 if test -f "$destdir"/configure.ac; then
4063 configure_ac="$destdir/configure.ac"
4065 if test -f "$destdir"/configure.in; then
4066 configure_ac="$destdir/configure.in"
4068 func_fatal_error "cannot find $destdir/configure.ac"
4072 # Analyze configure.ac.
4074 guessed_libtool=false
4079 /AC_CONFIG_AUX_DIR/ {
4080 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
4082 /A[CM]_PROG_LIBTOOL/ {
4083 s,^.*$,guessed_libtool=true,p
4085 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4087 if test -z "$auxdir"; then
4088 auxdir="$guessed_auxdir"
4091 # Determine where to apply func_import.
4092 if test -n "$m4base"; then
4093 # Apply func_import to a particular gnulib directory.
4094 # Any number of additional modules can be given.
4095 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4096 # First use of gnulib in the given m4base.
4097 test -n "$supplied_libname" || supplied_libname=true
4098 test -n "$sourcebase" || sourcebase="lib"
4099 test -n "$docbase" || docbase="doc"
4100 test -n "$testsbase" || testsbase="tests"
4101 test -n "$macro_prefix" || macro_prefix="gl"
4105 # Apply func_import to all gnulib directories.
4106 # To get this list of directories, look at Makefile.am. (Not at
4107 # configure, because it may be omitted from CVS. Also, don't run
4108 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4111 if test -f "$destdir"/Makefile.am; then
4112 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4114 for arg in $aclocal_amflags; do
4115 if test -n "$m4dir_is_next"; then
4116 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4120 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4121 func_append m4dirs " $arg"
4122 m4dirs_count=`expr $m4dirs_count + 1`
4128 if test "X$arg" = "X-I"; then
4136 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4137 if test -f "$destdir"/aclocal.m4; then
4138 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4139 sedexpr2='s,^[^/]*$,.,'
4140 sedexpr3='s,/[^/]*$,,'
4141 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4142 m4dirs_count=`echo "$m4dirs" | wc -l`
4145 if test $m4dirs_count = 0; then
4146 # First use of gnulib in a package.
4147 # Any number of additional modules can be given.
4148 test -n "$supplied_libname" || supplied_libname=true
4149 test -n "$sourcebase" || sourcebase="lib"
4151 test -n "$docbase" || docbase="doc"
4152 test -n "$testsbase" || testsbase="tests"
4153 test -n "$macro_prefix" || macro_prefix="gl"
4156 if test $m4dirs_count = 1; then
4157 # There's only one use of gnulib here. Assume the user means it.
4158 # Any number of additional modules can be given.
4159 for m4base in $m4dirs; do
4163 # Ambiguous - guess what the user meant.
4164 if test $# = 0; then
4165 # No further arguments. Guess the user wants to update all of them.
4166 for m4base in $m4dirs; do
4167 # Perform func_import in a subshell, so that variable values
4169 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
4170 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
4171 # libtool, macro_prefix, po_domain, vc_files
4172 # don't propagate from one directory to another.
4173 (func_import) || func_exit 1
4177 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4185 if test -z "$destdir"; then
4186 func_fatal_error "please specify --dir option"
4189 test -d "$destdir" \
4190 || func_fatal_error "could not create destination directory"
4191 test -n "$auxdir" || auxdir="build-aux"
4192 func_create_testdir "$destdir" "$*"
4195 create-megatestdir )
4196 if test -z "$destdir"; then
4197 func_fatal_error "please specify --dir option"
4199 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4200 test -n "$auxdir" || auxdir="build-aux"
4201 func_create_megatestdir "$destdir" "$*"
4205 test -n "$destdir" || destdir=testdir$$
4206 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4207 test -n "$auxdir" || auxdir="build-aux"
4208 func_create_testdir "$destdir" "$*"
4212 ../configure || func_exit 1
4214 make check || func_exit 1
4215 make distclean || func_exit 1
4216 remaining=`find . -type f -print`
4217 if test -n "$remaining"; then
4218 echo "Remaining files:" $remaining 1>&2
4219 echo "gnulib-tool: *** Stop." 1>&2
4228 test -n "$destdir" || destdir=testdir$$
4229 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4230 test -n "$auxdir" || auxdir="build-aux"
4231 func_create_megatestdir "$destdir" "$*"
4239 remaining=`find . -type f -print`
4240 if test -n "$remaining"; then
4241 echo "Remaining files:" $remaining 1>&2
4242 echo "gnulib-tool: *** Stop." 1>&2
4250 extract-description )
4254 if test -n "$module"; then
4255 func_get_description "$module"
4264 if test -n "$module"; then
4265 func_get_notice "$module"
4274 if test -n "$module"; then
4275 func_get_filelist "$module"
4280 extract-dependencies )
4284 if test -n "$module"; then
4285 func_get_dependencies "$module"
4290 extract-autoconf-snippet )
4294 if test -n "$module"; then
4295 func_get_autoconf_snippet "$module"
4300 extract-automake-snippet )
4304 if test -n "$module"; then
4305 func_get_automake_snippet "$module"
4310 extract-include-directive )
4314 if test -n "$module"; then
4315 func_get_include_directive "$module"
4320 extract-link-directive )
4324 if test -n "$module"; then
4325 func_get_link_directive "$module"
4334 if test -n "$module"; then
4335 func_get_license "$module"
4340 extract-maintainer )
4344 if test -n "$module"; then
4345 func_get_maintainer "$module"
4350 extract-tests-module )
4354 if test -n "$module"; then
4355 func_get_tests_module "$module"
4361 func_fatal_error "unknown operation mode --$mode" ;;
4365 # Undo the effect of the previous 'trap' command. Some shellology:
4366 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4367 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4368 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4369 # 128 + signal number and is set before the trap-registered command is run.
4371 trap 'func_exit $?' 1 2 3 13 15
4376 # indent-tabs-mode: nil
4377 # whitespace-check-buffer-indent: nil