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 ()
576 # Ensure an 'echo' command that does not interpret backslashes.
578 # echo '\n' | wc -l prints 1 when OK, 2 when KO
579 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
580 # This problem is a weird heritage from SVR4. BSD got it right (except that
581 # BSD echo interprets '-n' as an option, which is also not desirable).
582 # Nowadays the problem occurs in 4 situations:
583 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
584 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
585 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
586 # - in zsh, when sh-emulation is not set,
587 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
588 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
589 # - in Solaris /bin/sh and OSF/1 /bin/sh.
590 # We try the following workarounds:
591 # - for all: respawn using $CONFIG_SHELL if that is set and works.
592 # - for bash >= 2.04: unset the shell option xpg_echo.
593 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
594 # - for bash < 2.0: define echo to a function that uses cat of a here document.
595 # - for zsh: turn sh-emulation on.
596 # - for ksh: alias echo to 'print -r'.
597 # - for ksh: alias echo to a function that uses cat of a here document.
598 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
599 # the ksh workaround.
600 # - otherwise: respawn using /bin/sh and rely on the workarounds.
601 # When respawning, we pass --no-reexec as first argument, so as to avoid
602 # turning this script into a fork bomb in unlucky situations.
604 if echo '\t' | grep t > /dev/null; then
605 have_echo=yes # Lucky!
607 # Try the workarounds.
608 # Respawn using $CONFIG_SHELL if that is set and works.
609 if test -z "$have_echo" \
610 && test "X$1" != "X--no-reexec" \
611 && test -n "$CONFIG_SHELL" \
612 && test -f "$CONFIG_SHELL" \
613 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
614 exec $CONFIG_SHELL "$0" --no-reexec "$@"
617 # For bash >= 2.04: unset the shell option xpg_echo.
618 if test -z "$have_echo" \
619 && test -n "$BASH_VERSION" \
620 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
624 # For bash >= 2.0: define echo to a function that uses the printf built-in.
625 # For bash < 2.0: define echo to a function that uses cat of a here document.
626 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
627 if test -z "$have_echo" \
628 && test -n "$BASH_VERSION"; then \
629 if type printf 2>/dev/null | grep / > /dev/null; then
630 # 'printf' is not a shell built-in.
638 # 'printf' is a shell built-in.
644 if echo '\t' | grep t > /dev/null; then
648 # For zsh: turn sh-emulation on.
649 if test -z "$have_echo" \
650 && test -n "$ZSH_VERSION" \
651 && (emulate sh) >/dev/null 2>&1; then
654 # For ksh: alias echo to 'print -r'.
655 if test -z "$have_echo" \
656 && (type print) >/dev/null 2>&1; then
657 # A 'print' command exists.
658 if type print 2>/dev/null | grep / > /dev/null; then
661 # 'print' is a shell built-in.
662 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
663 # 'print' is the ksh shell built-in.
664 alias echo='print -r'
668 if test -z "$have_echo" \
669 && echo '\t' | grep t > /dev/null; then
672 # For ksh: alias echo to a function that uses cat of a here document.
673 # The ksh manual page says:
674 # "Aliasing is performed when scripts are read, not while they are executed.
675 # Therefore, for an alias to take effect, the alias definition command has
676 # to be executed before the command which references the alias is read."
677 # Because of this, we have to play strange tricks with have_echo, to ensure
678 # that the top-level statement containing the test starts after the 'alias'
680 if test -z "$have_echo"; then
687 alias echo=bsd_echo 2>/dev/null
689 if test -z "$have_echo" \
690 && echo '\t' | grep t > /dev/null; then
693 if test -z "$have_echo"; then
694 unalias echo 2>/dev/null
696 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
697 if test -z "$have_echo" \
698 && test "X$1" != "X--no-reexec" \
699 && test -f /bin/ksh; then
700 exec /bin/ksh "$0" --no-reexec "$@"
703 # Otherwise: respawn using /bin/sh.
704 if test -z "$have_echo" \
705 && test "X$1" != "X--no-reexec" \
706 && test -f /bin/sh; then
707 exec /bin/sh "$0" --no-reexec "$@"
710 if test -z "$have_echo"; then
711 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
713 if echo '\t' | grep t > /dev/null; then
716 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
718 if test "X$1" = "X--no-reexec"; then
722 # Command-line option processing.
723 # Removes the OPTIONS from the arguments. Sets the variables:
724 # - mode list or import or create-testdir or create-megatestdir
725 # - destdir from --dir
726 # - local_gnulib_dir from --local-dir
727 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
728 # - libname, supplied_libname from --lib
729 # - sourcebase from --source-base
730 # - m4base from --m4-base
731 # - pobase from --po-base
732 # - docbase from --doc-base
733 # - testsbase from --tests-base
734 # - auxdir from --aux-dir
735 # - inctests true if --with-tests was given, blank otherwise
736 # - avoidlist list of modules to avoid, from --avoid
737 # - lgpl yes or a number if --lgpl was given, blank otherwise
738 # - makefile_name from --makefile-name
739 # - libtool true if --libtool was given, false if --no-libtool was
740 # given, blank otherwise
741 # - macro_prefix from --macro-prefix
742 # - po_domain from --po-domain
743 # - vc_files true if --vc-files was given, false if --no-vc-files was
744 # given, blank otherwise
745 # - autoconf_minversion minimum supported autoconf version
746 # - do_changelog false if --no-changelog was given, : otherwise
747 # - doit : if actions shall be executed, false if only to be printed
748 # - symbolic true if --symlink or --more-symlinks was given, blank
750 # - lsymbolic true if --local-symlink was given, blank otherwise
751 # - do_copyrights blank if --more-symlinks was given, true otherwise
781 while test $# -gt 0; do
786 --import | --impor | --impo | --imp | --im | --i )
789 --update | --updat | --upda | --upd | --up | --u )
792 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
795 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
796 mode=create-megatestdir
798 --test | --tes | --te | --t )
801 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
805 mode=`echo "X$1" | sed -e 's/^X--//'`
810 func_fatal_error "missing argument for --dir"
815 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
820 func_fatal_error "missing argument for --local-dir"
825 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
827 --verbose | --verbos | --verbo | --verb )
828 verbose=`expr $verbose + 1`
830 --quiet | --quie | --qui | --qu | --q )
831 verbose=`expr $verbose - 1`
836 func_fatal_error "missing argument for --lib"
839 supplied_libname=true
842 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
843 supplied_libname=true
848 func_fatal_error "missing argument for --source-base"
853 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
858 func_fatal_error "missing argument for --m4-base"
863 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
868 func_fatal_error "missing argument for --po-base"
873 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
878 func_fatal_error "missing argument for --doc-base"
883 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
888 func_fatal_error "missing argument for --tests-base"
893 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
898 func_fatal_error "missing argument for --aux-dir"
903 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
911 func_fatal_error "missing argument for --avoid"
913 func_append avoidlist " $1"
916 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
917 func_append avoidlist " $arg"
923 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
926 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
933 func_fatal_error "missing argument for --makefile-name"
938 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
949 func_fatal_error "missing argument for --macro-prefix"
954 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
959 func_fatal_error "missing argument for --po-domain"
964 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
972 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
978 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
981 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
984 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
988 --help | --hel | --he | --h )
991 --version | --versio | --versi | --vers )
995 # Stop option processing
999 echo "gnulib-tool: unknown option $1" 1>&2
1000 echo "Try 'gnulib-tool --help' for more information." 1>&2
1007 if test "$mode" = update; then
1008 if test $# != 0; then
1009 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1010 echo "Try 'gnulib-tool --help' for more information." 1>&2
1011 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1012 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1015 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1016 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1017 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1018 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
1019 || test -n "$makefile_name" || test -n "$macro_prefix" \
1020 || test -n "$po_domain" || test -n "$vc_files"; then
1021 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1022 echo "Try 'gnulib-tool --help' for more information." 1>&2
1023 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1024 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1029 if test -n "$pobase" && test -z "$po_domain"; then
1030 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1031 echo "Try 'gnulib-tool --help' for more information." 1>&2
1034 if test -z "$pobase" && test -n "$po_domain"; then
1035 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1038 # Determine the minimum supported autoconf version from the project's
1040 DEFAULT_AUTOCONF_MINVERSION="2.59"
1041 autoconf_minversion=
1043 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1044 if test -f "$destdir"/configure.ac; then
1045 configure_ac="$destdir/configure.ac"
1047 if test -f "$destdir"/configure.in; then
1048 configure_ac="$destdir/configure.in"
1052 if test -f configure.ac; then
1053 configure_ac="configure.ac"
1055 if test -f configure.in; then
1056 configure_ac="configure.in"
1060 if test -n "$configure_ac"; then
1061 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1062 # because when some m4 files are omitted from a CVS repository,
1063 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1064 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1065 # autom4te: m4 failed with exit status: 1
1072 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1074 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1075 if test -n "$prereqs"; then
1076 autoconf_minversion=`
1077 for version in $prereqs; do echo $version; done |
1078 LC_ALL=C sort -nru | sed 1q
1082 if test -z "$autoconf_minversion"; then
1083 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1085 case "$autoconf_minversion" in
1086 1.* | 2.[0-4]* | 2.5[0-8]*)
1087 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1090 # Remove trailing slashes from the directory names. This is necessary for
1091 # m4base (to avoid an error in func_import) and optional for the others.
1092 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1093 case "$local_gnulib_dir" in
1094 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1096 case "$sourcebase" in
1097 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1100 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1103 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1106 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1108 case "$testsbase" in
1109 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1112 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1118 trap 'exit_status=$?
1119 if test "$signal" != 0; then
1120 echo "caught signal $signal" >&2
1123 exit $exit_status' 0
1124 for signal in 1 2 3 13 15; do
1125 trap '{ signal='$signal'; func_exit 1; }' $signal
1129 # func_lookup_file file
1130 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1133 # - local_gnulib_dir from --local-dir
1135 # - lookedup_file name of the merged (combined) file
1136 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1140 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1141 lookedup_file="$local_gnulib_dir/$lkfile"
1144 if test -f "$gnulib_dir/$lkfile"; then
1145 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1146 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1147 rm -f "$tmp/$lkbase"
1148 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1149 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1150 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1151 lookedup_file="$tmp/$lkbase"
1154 lookedup_file="$gnulib_dir/$lkfile"
1158 func_fatal_error "file $gnulib_dir/$lkfile not found"
1165 # - local_gnulib_dir from --local-dir
1168 # Filter out metainformation files like README, which are not modules.
1169 # Filter out unit test modules; they can be retrieved through
1170 # --extract-tests-module if desired.
1172 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1173 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1174 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1177 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1178 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1179 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1180 -e '/^README$/d' -e '/\/README$/d' \
1181 -e '/^TEMPLATE$/d' \
1182 -e '/^TEMPLATE-EXTENDED$/d' \
1183 -e '/^TEMPLATE-TESTS$/d' \
1186 | sed -e '/-tests$/d' \
1190 # func_verify_module
1191 # verifies a module name
1193 # - local_gnulib_dir from --local-dir
1194 # - module module name argument
1195 func_verify_module ()
1197 if { test -f "$gnulib_dir/modules/$module" \
1198 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1199 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1200 && test "CVS" != "$module" \
1201 && test "ChangeLog" != "$module" \
1202 && test "COPYING" != "$module" \
1203 && test "README" != "$module" \
1204 && test "TEMPLATE" != "$module" \
1205 && test "TEMPLATE-EXTENDED" != "$module" \
1206 && test "TEMPLATE-TESTS" != "$module"; then
1207 # OK, $module is a correct module name.
1208 # Verify that building the module description with 'patch' succeeds.
1209 func_lookup_file "modules/$module"
1211 echo "gnulib-tool: module $module doesn't exist" 1>&2
1216 # func_verify_nontests_module
1217 # verifies a module name, excluding tests modules
1219 # - local_gnulib_dir from --local-dir
1220 # - module module name argument
1221 func_verify_nontests_module ()
1224 *-tests ) module= ;;
1225 * ) func_verify_module ;;
1229 # func_verify_tests_module
1230 # verifies a module name, considering only tests modules
1232 # - local_gnulib_dir from --local-dir
1233 # - module module name argument
1234 func_verify_tests_module ()
1237 *-tests ) func_verify_module ;;
1242 sed_extract_prog=':[ ]*$/ {
1245 s/^Description:[ ]*$//
1248 s/^Depends-on:[ ]*$//
1249 s/^configure\.ac-early:[ ]*$//
1250 s/^configure\.ac:[ ]*$//
1251 s/^Makefile\.am:[ ]*$//
1255 s/^Maintainer:[ ]*$//
1262 # func_get_description module
1264 # - local_gnulib_dir from --local-dir
1265 func_get_description ()
1267 func_lookup_file "modules/$1"
1268 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1271 # func_get_notice module
1273 # - local_gnulib_dir from --local-dir
1276 func_lookup_file "modules/$1"
1277 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1280 # func_get_filelist module
1282 # - local_gnulib_dir from --local-dir
1283 func_get_filelist ()
1285 func_lookup_file "modules/$1"
1286 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1287 echo m4/gnulib-common.m4
1288 case "$autoconf_minversion" in
1295 # func_get_dependencies module
1297 # - local_gnulib_dir from --local-dir
1298 func_get_dependencies ()
1300 # ${module}-tests always implicitly depends on ${module}.
1301 echo "$1" | sed -n -e 's/-tests$//p'
1302 # Then the explicit dependencies listed in the module description.
1303 func_lookup_file "modules/$1"
1304 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1307 # func_get_autoconf_early_snippet module
1309 # - local_gnulib_dir from --local-dir
1310 func_get_autoconf_early_snippet ()
1312 func_lookup_file "modules/$1"
1313 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1316 # func_get_autoconf_snippet module
1318 # - local_gnulib_dir from --local-dir
1319 func_get_autoconf_snippet ()
1321 func_lookup_file "modules/$1"
1322 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1325 # func_get_automake_snippet module
1327 # - local_gnulib_dir from --local-dir
1328 func_get_automake_snippet ()
1330 func_lookup_file "modules/$1"
1331 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1334 # *-tests module live in tests/, not lib/.
1335 # Synthesize an EXTRA_DIST augmentation.
1336 all_files=`func_get_filelist $1`
1337 tests_files=`for f in $all_files; do \
1339 tests/*) echo $f ;; \
1341 done | sed -e 's,^tests/,,'`
1342 extra_files="$tests_files"
1343 if test -n "$extra_files"; then
1344 echo "EXTRA_DIST +=" $extra_files
1349 # Synthesize an EXTRA_DIST augmentation.
1350 sed_combine_lines='/\\$/{
1357 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1358 already_mentioned_files=` \
1359 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1360 | sed -e "$sed_combine_lines" \
1361 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1362 all_files=`func_get_filelist $1`
1363 lib_files=`for f in $all_files; do \
1367 done | sed -e 's,^lib/,,'`
1368 # Remove $already_mentioned_files from $lib_files.
1369 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1370 extra_files=`func_reset_sigpipe; \
1371 for f in $already_mentioned_files; do echo $f; done \
1372 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1373 if test -n "$extra_files"; then
1374 echo "EXTRA_DIST +=" $extra_files
1377 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1378 # This is necessary so that automake can generate the right list of
1380 # A possible approach would be to use autom4te --trace of the redefined
1381 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1382 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1383 # inside autoconf's built-in macros are not missed).
1384 # But it's simpler and more robust to do it here, based on the file list.
1385 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1386 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1387 # automake will generate a useless dependency; this is harmless.
1389 relocatable-prog-wrapper) ;;
1391 sed_extract_c_files='/\.c$/p'
1392 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1393 if test -n "$extra_files"; then
1394 echo "EXTRA_lib_SOURCES +=" $extra_files
1399 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1400 buildaux_files=`for f in $all_files; do \
1402 build-aux/*) echo $f ;; \
1404 done | sed -e 's,^build-aux/,,'`
1405 if test -n "$buildaux_files"; then
1406 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1407 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1410 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1411 top_files=`for f in $all_files; do \
1415 done | sed -e 's,^top/,,'`
1416 if test -n "$top_files"; then
1417 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1418 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1425 # func_get_include_directive module
1427 # - local_gnulib_dir from --local-dir
1428 func_get_include_directive ()
1430 func_lookup_file "modules/$1"
1431 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1432 sed -e 's/^\(["<]\)/#include \1/'
1435 # func_get_link_directive module
1437 # - local_gnulib_dir from --local-dir
1438 func_get_link_directive ()
1440 func_lookup_file "modules/$1"
1441 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1444 # func_get_license module
1446 # - local_gnulib_dir from --local-dir
1449 func_lookup_file "modules/$1"
1450 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1451 # The default is GPL.
1453 } | sed -e 's,^ *$,,' | sed -e 1q
1456 # func_get_maintainer module
1458 # - local_gnulib_dir from --local-dir
1459 func_get_maintainer ()
1461 func_lookup_file "modules/$1"
1462 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1465 # func_get_tests_module module
1467 # - local_gnulib_dir from --local-dir
1468 func_get_tests_module ()
1470 # The naming convention for tests modules is hardwired: ${module}-tests.
1471 if test -f "$gnulib_dir/modules/$1"-tests \
1472 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1473 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1478 # func_acceptable module
1479 # tests whether a module is acceptable.
1481 # - avoidlist list of modules to avoid
1484 for avoid in $avoidlist; do
1485 if test "$avoid" = "$1"; then
1492 # func_modules_transitive_closure
1494 # - local_gnulib_dir from --local-dir
1495 # - modules list of specified modules
1496 # - inctests true if tests should be included, blank otherwise
1497 # - avoidlist list of modules to avoid
1498 # - tmp pathname of a temporary directory
1500 # - modules list of modules, including dependencies
1501 func_modules_transitive_closure ()
1503 # In order to process every module only once (for speed), process an "input
1504 # list" of modules, producing an "output list" of modules. During each round,
1505 # more modules can be queued in the input list. Once a module on the input
1506 # list has been processed, it is added to the "handled list", so we can avoid
1507 # to process it again.
1509 inmodules="$modules"
1511 while test -n "$inmodules"; do
1512 inmodules_this_round="$inmodules"
1513 inmodules= # Accumulator, queue for next round
1514 for module in $inmodules_this_round; do
1516 if test -n "$module"; then
1517 if func_acceptable $module; then
1518 func_append outmodules " $module"
1519 deps=`func_get_dependencies $module`
1520 # Duplicate dependencies are harmless, but Jim wants a warning.
1521 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1522 if test -n "$duplicated_deps"; then
1523 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1525 func_append inmodules " $deps"
1526 if test -n "$inctests"; then
1527 testsmodule=`func_get_tests_module $module`
1528 if test -n "$testsmodule"; then
1529 func_append inmodules " $testsmodule"
1535 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1536 # Remove $handledmodules from $inmodules.
1537 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1538 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1540 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1541 rm -f "$tmp"/queued-modules
1544 # func_modules_add_dummy
1546 # - local_gnulib_dir from --local-dir
1547 # - modules list of modules, including dependencies
1549 # - modules list of modules, including 'dummy' if needed
1550 func_modules_add_dummy ()
1553 sed_remove_backslash_newline=':a
1560 for module in $modules; do
1561 func_verify_nontests_module
1562 if test -n "$module"; then
1563 # Extract the value of "lib_SOURCES += ...".
1564 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1565 # Ignore .h files since they are not compiled.
1568 *) have_lib_SOURCES=yes ;;
1573 # Add the dummy module, to make sure the library will be non-empty.
1574 if test -z "$have_lib_SOURCES"; then
1575 if func_acceptable "dummy"; then
1576 func_append modules " dummy"
1581 # func_modules_notice
1583 # - local_gnulib_dir from --local-dir
1584 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1585 # - modules list of modules, including dependencies
1586 func_modules_notice ()
1588 if test $verbose -ge -1; then
1589 for module in $modules; do
1591 if test -n "$module"; then
1592 msg=`func_get_notice $module`
1593 if test -n "$msg"; then
1594 echo "Notice from module $module:"
1595 echo "$msg" | sed -e 's/^/ /'
1602 # func_modules_to_filelist
1604 # - local_gnulib_dir from --local-dir
1605 # - modules list of modules, including dependencies
1607 # - files list of files
1608 func_modules_to_filelist ()
1611 for module in $modules; do
1613 if test -n "$module"; then
1614 fs=`func_get_filelist $module`
1615 func_append files " $fs"
1618 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1621 # func_execute_command command [args...]
1622 # Executes a command.
1623 # Uses also the variables
1624 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1625 func_execute_command ()
1627 if test $verbose -ge 0; then
1631 # Commands like automake produce output to stderr even when they succeed.
1632 # Turn this output off if the command succeeds.
1633 "$@" > "$tmp"/cmdout 2>&1
1635 if test $cmdret = 0; then
1639 cat "$tmp"/cmdout 1>&2
1646 # func_emit_lib_Makefile_am
1647 # emits the contents of library makefile to standard output.
1649 # - local_gnulib_dir from --local-dir
1650 # - modules list of modules, including dependencies
1651 # - libname library name
1652 # - pobase directory relative to destdir where to place *.po files
1653 # - auxdir directory relative to destdir where to place build aux files
1654 # - makefile_name from --makefile-name
1655 # - libtool true if libtool will be used, false or blank otherwise
1656 # - macro_prefix prefix of gl_LIBOBJS macros to use
1657 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1658 # - actioncmd (optional) command that will reproduce this invocation
1659 # - for_test true if creating a package for testing, false otherwise
1661 # - uses_subdirs nonempty if object files in subdirs exist
1662 func_emit_lib_Makefile_am ()
1664 # When creating an includable Makefile.am snippet, augment variables with
1665 # += instead of assigning them.
1666 if test -n "$makefile_name"; then
1671 if test "$libtool" = true; then
1674 sed_eliminate_LDFLAGS=
1678 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1681 # When creating a package for testing: Attempt to provoke failures,
1682 # especially link errors, already during "make" rather than during
1683 # "make check", because "make check" is not possible in a cross-compiling
1684 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1685 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1687 sed_transform_check_PROGRAMS=
1689 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1690 echo "## Process this file with automake to produce Makefile.in."
1691 func_emit_copyright_notice
1692 if test -n "$actioncmd"; then
1693 echo "# Reproduce by: $actioncmd"
1698 for module in $modules; do
1699 func_verify_nontests_module
1700 if test -n "$module"; then
1702 func_get_automake_snippet "$module" |
1703 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1704 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1705 -e "$sed_eliminate_LDFLAGS" \
1706 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1707 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1708 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1709 -e "$sed_transform_check_PROGRAMS"
1710 if test "$module" = 'alloca'; then
1711 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1712 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1715 # Skip the contents if it's entirely empty.
1716 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1717 echo "## begin gnulib module $module"
1720 echo "## end gnulib module $module"
1724 # Test whether there are some source files in subdirectories.
1725 for f in `func_get_filelist "$module"`; do
1727 lib/*/*.c) uses_subdirs=yes ;;
1733 if test -z "$makefile_name"; then
1734 # If there are source files in subdirectories, prevent collision of the
1735 # object files (example: hash.c and libxml/hash.c).
1737 if test -n "$uses_subdirs"; then
1738 subdir_options=' subdir-objects'
1740 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1743 if test -z "$makefile_name"; then
1744 echo "noinst_HEADERS ="
1745 echo "noinst_LIBRARIES ="
1746 echo "noinst_LTLIBRARIES ="
1747 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1748 # if you specify pkgdata_DATA to empty. This is a workaround.
1749 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1750 echo "pkgdata_DATA ="
1753 echo "BUILT_SOURCES ="
1756 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1757 if test -z "$makefile_name"; then
1758 echo "MOSTLYCLEANDIRS ="
1760 echo "DISTCLEANFILES ="
1761 echo "MAINTAINERCLEANFILES ="
1763 echo "AM_CPPFLAGS ="
1766 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1767 # One of the snippets already specifies an installation location for the
1768 # library. Don't confuse automake by saying it should not be installed.
1771 # By default, the generated library should not be installed.
1772 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1775 echo "${libname}_${libext}_SOURCES ="
1776 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1777 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
1778 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1779 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1780 echo "EXTRA_${libname}_${libext}_SOURCES ="
1781 if test "$libtool" = true; then
1782 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1785 if test -n "$pobase"; then
1786 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1789 cat allsnippets.tmp \
1790 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1792 echo "mostlyclean-local: mostlyclean-generic"
1793 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1794 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1795 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1799 rm -f allsnippets.tmp
1802 # func_emit_po_Makevars
1803 # emits the contents of po/ makefile parameterization to standard output.
1805 # - local_gnulib_dir from --local-dir
1806 # - sourcebase directory relative to destdir where to place source code
1807 # - pobase directory relative to destdir where to place *.po files
1808 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1809 func_emit_po_Makevars ()
1811 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1812 func_emit_copyright_notice
1814 echo "# Usually the message domain is the same as the package name."
1815 echo "# But here it has a '-gnulib' suffix."
1816 echo "DOMAIN = ${po_domain}-gnulib"
1818 echo "# These two variables depend on the location of this directory."
1819 echo "subdir = ${pobase}"
1820 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1823 # These options get passed to xgettext.
1824 XGETTEXT_OPTIONS = \
1825 --keyword=_ --flag=_:1:pass-c-format \
1826 --keyword=N_ --flag=N_:1:pass-c-format \
1827 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1828 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1829 --flag=error:3:c-format --flag=error_at_line:5:c-format
1831 # This is the copyright holder that gets inserted into the header of the
1832 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1833 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1835 # This is the email address or URL to which the translators shall report
1836 # bugs in the untranslated strings:
1837 # - Strings which are not entire sentences, see the maintainer guidelines
1838 # in the GNU gettext documentation, section 'Preparing Strings'.
1839 # - Strings which use unclear terms or require additional context to be
1841 # - Strings which make invalid assumptions about notation of date, time or
1843 # - Pluralisation problems.
1844 # - Incorrect English spelling.
1845 # - Incorrect formatting.
1846 # It can be your email address, or a mailing list address where translators
1847 # can write to without being subscribed, or the URL of a web page through
1848 # which the translators can contact you.
1849 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1851 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1852 # message catalogs shall be used. It is usually empty.
1853 EXTRA_LOCALE_CATEGORIES =
1855 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1856 # context. Possible values are "yes" and "no". Set this to yes if the
1857 # package uses functions taking also a message context, like pgettext(), or
1858 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1863 # func_emit_po_POTFILES_in
1864 # emits the file list to be passed to xgettext to standard output.
1866 # - local_gnulib_dir from --local-dir
1867 # - sourcebase directory relative to destdir where to place source code
1868 # - files list of new files
1869 func_emit_po_POTFILES_in ()
1871 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1872 func_emit_copyright_notice
1874 echo "# List of files which contain translatable strings."
1875 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1878 # func_emit_tests_Makefile_am
1879 # emits the contents of tests makefile to standard output.
1881 # - local_gnulib_dir from --local-dir
1882 # - modules list of modules, including dependencies
1883 # - libname library name
1884 # - auxdir directory relative to destdir where to place build aux files
1885 # - makefile_name from --makefile-name
1886 # - libtool true if libtool will be used, false or blank otherwise
1887 # - sourcebase relative directory containing lib source code
1888 # - m4base relative directory containing autoconf macros
1889 # - testsbase relative directory containing unit test code
1890 # - macro_prefix prefix of gl_LIBOBJS macros to use
1891 # - for_test true if creating a package for testing, false otherwise
1892 # - use_libtests true if a libtests.a should be built, false otherwise
1894 # - uses_subdirs nonempty if object files in subdirs exist
1895 func_emit_tests_Makefile_am ()
1897 if test "$libtool" = true; then
1899 sed_eliminate_LDFLAGS=
1902 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1905 # When creating a package for testing: Attempt to provoke failures,
1906 # especially link errors, already during "make" rather than during
1907 # "make check", because "make check" is not possible in a cross-compiling
1908 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1909 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1911 sed_transform_check_PROGRAMS=
1913 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1914 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1915 echo "## Process this file with automake to produce Makefile.in."
1916 func_emit_copyright_notice
1920 for module in $modules; do
1922 func_verify_tests_module
1926 if test -n "$module"; then
1928 func_get_automake_snippet "$module" |
1929 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1930 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1931 -e "$sed_eliminate_LDFLAGS" \
1932 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
1933 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1934 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1935 -e "$sed_transform_check_PROGRAMS"
1936 if $use_libtests && test "$module" = 'alloca'; then
1937 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
1938 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1941 # Skip the contents if it's entirely empty.
1942 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1943 echo "## begin gnulib module $module"
1946 echo "## end gnulib module $module"
1950 # Test whether there are some source files in subdirectories.
1951 for f in `func_get_filelist "$module"`; do
1953 lib/*/*.c | tests/*/*.c) uses_subdirs=yes ;;
1959 # Generate dependencies here, since it eases the debugging of test failures.
1960 # If there are source files in subdirectories, prevent collision of the
1961 # object files (example: hash.c and libxml/hash.c).
1963 if test -n "$uses_subdirs"; then
1964 subdir_options=' subdir-objects'
1966 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
1969 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1972 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1973 # variable is needed to avoid an error from automake:
1974 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1977 echo "TESTS_ENVIRONMENT ="
1978 echo "noinst_PROGRAMS ="
1979 if ! $for_test; then
1980 echo "check_PROGRAMS ="
1982 echo "noinst_HEADERS ="
1983 echo "noinst_LIBRARIES ="
1984 if $use_libtests; then
1986 echo "noinst_LIBRARIES += libtests.a"
1988 echo "check_LIBRARIES = libtests.a"
1991 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1992 # if you specify pkgdata_DATA to empty. This is a workaround.
1993 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1994 echo "pkgdata_DATA ="
1997 echo "BUILT_SOURCES ="
1999 echo "MOSTLYCLEANFILES = core *.stackdump"
2000 echo "MOSTLYCLEANDIRS ="
2002 echo "DISTCLEANFILES ="
2003 echo "MAINTAINERCLEANFILES ="
2005 echo "AM_CPPFLAGS = \\"
2006 echo " -I. -I\$(srcdir) \\"
2007 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2008 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2010 local_ldadd_before=''
2011 local_ldadd_after=''
2012 if $use_libtests; then
2013 # All test programs need to be linked with libtests.a.
2014 # It needs to be passed to the linker before ${libname}.${libext}, since
2015 # the tests-related modules depend on the main modules.
2016 # It also needs to be passed to the linker after ${libname}.${libext}
2017 # because the latter might contain incomplete modules (such as the 'error'
2018 # module whose dependency to 'progname' is voluntarily omitted).
2019 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2021 local_ldadd_before=' libtests.a'
2022 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2024 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2026 if $use_libtests; then
2027 echo "libtests_a_SOURCES ="
2028 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2029 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2030 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2031 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2032 echo "EXTRA_libtests_a_SOURCES ="
2033 # The circular dependency in LDADD requires this.
2034 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2037 cat allsnippets.tmp \
2038 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2039 echo "# Clean up after Solaris cc."
2041 echo " rm -rf SunWS_cache"
2043 echo "mostlyclean-local: mostlyclean-generic"
2044 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2045 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2046 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2050 rm -f allsnippets.tmp
2053 # func_emit_initmacro_start macro_prefix
2054 # emits the first few statements of the gl_INIT macro to standard output.
2055 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2056 func_emit_initmacro_start ()
2058 macro_prefix_arg="$1"
2059 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2060 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2061 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2062 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2064 # Furthermore it avoids an automake error like this when a Makefile.am
2065 # that uses pieces of gnulib also uses $(LIBOBJ):
2066 # automatically discovered file `error.c' should not be explicitly mentioned
2067 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2068 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2069 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2070 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2071 # automatically discovered file `error.c' should not be explicitly mentioned
2072 # We let automake know about the files to be distributed through the
2073 # EXTRA_lib_SOURCES variable.
2074 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2075 # Create data variables for checking the presence of files that are mentioned
2076 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2077 # because we want the check to happen when the configure file is created,
2078 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2079 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2080 # in which to expect them.
2081 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2082 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2086 # func_emit_initmacro_end macro_prefix
2087 # emits the last few statements of the gl_INIT macro to standard output.
2088 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2089 func_emit_initmacro_end ()
2091 macro_prefix_arg="$1"
2092 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2093 # The check is performed only when autoconf is run from the directory where
2094 # the configure.ac resides; if it is run from a different directory, the
2096 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2097 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2098 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2099 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2100 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2104 echo " m4_if(m4_sysval, [0], [],"
2105 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2107 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2108 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2109 echo " m4_popdef([AC_LIBSOURCES])"
2110 echo " m4_popdef([AC_REPLACE_FUNCS])"
2111 echo " m4_popdef([AC_LIBOBJ])"
2112 echo " AC_CONFIG_COMMANDS_PRE(["
2113 echo " ${macro_prefix_arg}_libobjs="
2114 echo " ${macro_prefix_arg}_ltlibobjs="
2115 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2116 echo " # Remove the extension."
2117 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2118 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2119 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2120 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2123 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2124 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2128 # func_emit_initmacro_done macro_prefix sourcebase
2129 # emits a few statements after the gl_INIT macro to standard output.
2130 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2131 # - sourcebase directory relative to destdir where to place source code
2132 func_emit_initmacro_done ()
2134 macro_prefix_arg="$1"
2137 echo "# Like AC_LIBOBJ, except that the module name goes"
2138 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2139 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2140 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2141 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2144 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2145 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2146 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2147 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2148 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2151 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2152 echo "# expected is derived from the gnulib-tool parameterization,"
2153 echo "# and alloca is special cased (for the alloca-opt module)."
2154 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2155 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2156 echo " m4_foreach([_gl_NAME], [\$1], ["
2157 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2158 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2159 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2165 # func_import modules
2166 # Uses also the variables
2167 # - destdir target directory
2168 # - local_gnulib_dir from --local-dir
2169 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2170 # - libname library name
2171 # - sourcebase directory relative to destdir where to place source code
2172 # - m4base directory relative to destdir where to place *.m4 macros
2173 # - pobase directory relative to destdir where to place *.po files
2174 # - docbase directory relative to destdir where to place doc files
2175 # - testsbase directory relative to destdir where to place unit test code
2176 # - auxdir directory relative to destdir where to place build aux files
2177 # - inctests true if --with-tests was given, blank otherwise
2178 # - avoidlist list of modules to avoid, from --avoid
2179 # - lgpl yes or a number if library's license shall be LGPL,
2181 # - makefile_name from --makefile-name
2182 # - libtool true if --libtool was given, false if --no-libtool was
2183 # given, blank otherwise
2184 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2185 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2186 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2187 # - vc_files true if --vc-files was given, false if --no-vc-files was
2188 # given, blank otherwise
2189 # - autoconf_minversion minimum supported autoconf version
2190 # - doit : if actions shall be executed, false if only to be printed
2191 # - symbolic true if files should be symlinked, copied otherwise
2192 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2194 # - do_copyrights true if copyright notices in files should be replaced,
2198 # Get the cached settings.
2199 cached_local_gnulib_dir=
2200 cached_specified_modules=
2210 cached_makefile_name=
2212 cached_macro_prefix=
2216 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2217 cached_libtool=false
2223 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2233 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2236 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2239 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2242 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2245 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2248 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2251 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2254 s,^.*$,cached_inctests=true,p
2257 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2260 s,^.*gl_LGPL([[ ]*\([^])]*\).*$,cached_lgpl="\1",p
2263 s,^.*$,cached_lgpl=yes,p
2265 /gl_MAKEFILE_NAME(/ {
2266 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2269 s,^.*$,cached_libtool=true,p
2271 /gl_MACRO_PREFIX(/ {
2272 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2275 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2278 s,^.*gl_VC_FILES([[ ]*\([^])]*\).*$,cached_vc_files="\1",p
2280 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2281 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2286 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2287 s,^.*$,cached_files=",p
2299 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2303 # Merge the cached settings with the specified ones.
2304 # The m4base must be the same as expected from the pathname.
2305 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2306 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2308 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2309 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2310 if test -z "$local_gnulib_dir"; then
2311 if test -n "$cached_local_gnulib_dir"; then
2314 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2316 case "$cached_local_gnulib_dir" in
2318 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2320 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2321 local_gnulib_dir="$relconcat" ;;
2326 # Append the cached and the specified module names. So that
2327 # "gnulib-tool --import foo" means to add the module foo.
2328 specified_modules="$cached_specified_modules $1"
2329 # Append the cached and the specified avoidlist. This is probably better
2330 # than dropping the cached one when --avoid is specified at least once.
2331 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2332 avoidlist=`echo $avoidlist`
2334 # The sourcebase defaults to the cached one.
2335 if test -z "$sourcebase"; then
2336 sourcebase="$cached_sourcebase"
2337 if test -z "$sourcebase"; then
2338 func_fatal_error "missing --source-base option"
2341 # The pobase defaults to the cached one.
2342 if test -z "$pobase"; then
2343 pobase="$cached_pobase"
2345 # The docbase defaults to the cached one.
2346 if test -z "$docbase"; then
2347 docbase="$cached_docbase"
2348 if test -z "$docbase"; then
2349 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."
2352 # The testsbase defaults to the cached one.
2353 if test -z "$testsbase"; then
2354 testsbase="$cached_testsbase"
2355 if test -z "$testsbase"; then
2356 func_fatal_error "missing --tests-base option"
2359 # Require the tests if specified either way.
2360 if test -z "$inctests"; then
2361 inctests="$cached_inctests"
2363 # The libname defaults to the cached one.
2364 if test -z "$supplied_libname"; then
2365 libname="$cached_libname"
2366 if test -z "$libname"; then
2367 func_fatal_error "missing --lib option"
2370 # Require LGPL if specified either way.
2371 if test -z "$lgpl"; then
2374 # The makefile_name defaults to the cached one.
2375 if test -z "$makefile_name"; then
2376 makefile_name="$cached_makefile_name"
2378 # Use libtool if specified either way, or if guessed.
2379 if test -z "$libtool"; then
2380 if test -n "$cached_m4base"; then
2381 libtool="$cached_libtool"
2383 libtool="$guessed_libtool"
2386 # The macro_prefix defaults to the cached one.
2387 if test -z "$macro_prefix"; then
2388 macro_prefix="$cached_macro_prefix"
2389 if test -z "$macro_prefix"; then
2390 func_fatal_error "missing --macro-prefix option"
2393 # The po_domain defaults to the cached one.
2394 if test -z "$po_domain"; then
2395 po_domain="$cached_po_domain"
2397 # The vc_files defaults to the cached one.
2398 if test -z "$vc_files"; then
2399 vc_files="$cached_vc_files"
2402 # Canonicalize the list of specified modules.
2403 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2405 # Determine final module list.
2406 modules="$specified_modules"
2407 func_modules_transitive_closure
2408 if test $verbose -ge 0; then
2409 echo "Module list with included dependencies:"
2410 echo "$modules" | sed -e 's/^/ /'
2412 final_modules="$modules"
2414 # Determine main module list and tests-related module list separately.
2415 # The main module list is the transitive closure of the specified modules,
2416 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2417 # is specified, it will consist only of LGPLed source.
2418 # The tests-related module list is the transitive closure of the specified
2419 # modules, including tests modules, minus the main module list. Its lib/*
2420 # sources (brought in through dependencies of *-tests modules) go into
2421 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2422 # Determine main module list.
2423 saved_inctests="$inctests"
2425 modules="$specified_modules"
2426 func_modules_transitive_closure
2427 main_modules="$modules"
2428 inctests="$saved_inctests"
2429 if test $verbose -ge 1; then
2430 echo "Main module list:"
2431 echo "$main_modules" | sed -e 's/^/ /'
2433 # Determine tests-related module list.
2434 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2435 testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2436 if test $verbose -ge 1; then
2437 echo "Tests-related module list:"
2438 echo "$testsrelated_modules" | sed -e 's/^/ /'
2441 # Add the dummy module to the main module list if needed.
2442 modules="$main_modules"
2443 func_modules_add_dummy
2444 main_modules="$modules"
2446 # Determine whether a $testsbase/libtests.a is needed.
2448 for module in $testsrelated_modules; do
2449 func_verify_nontests_module
2450 if test -n "$module"; then
2451 all_files=`func_get_filelist $module`
2452 lib_files=`for f in $all_files; do \
2456 done | sed -e 's,^lib/,,'`
2457 if test -n "$lib_files"; then
2464 # Add the dummy module to the tests-related module list if needed.
2465 if $use_libtests; then
2466 modules="$testsrelated_modules"
2467 func_modules_add_dummy
2468 testsrelated_modules="$modules"
2471 # If --lgpl, verify that the licenses of modules are compatible.
2472 if test -n "$lgpl"; then
2473 for module in $main_modules; do
2474 license=`func_get_license $module`
2476 'GPLed build tool') ;;
2477 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2483 *) func_fatal_error "incompatible license on module $module: $license" ;;
2489 *) func_fatal_error "incompatible license on module $module: $license" ;;
2492 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2499 # Show banner notice of every module.
2500 modules="$main_modules"
2503 # Determine script to apply to imported library files.
2504 sed_transform_lib_file=
2505 for module in $main_modules; do
2506 if test $module = config-h; then
2507 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2508 sed_transform_lib_file=$sed_transform_lib_file'
2509 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2514 sed_transform_main_lib_file="$sed_transform_lib_file"
2515 if test -n "$do_copyrights"; then
2516 if test -n "$lgpl"; then
2520 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2521 s/GNU General/GNU Lesser General/g
2525 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2526 s/GNU General/GNU Lesser General/g
2527 s/version [23]\([ ,]\)/version 2.1\1/g
2530 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2534 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2535 s/GNU Lesser General/GNU General/g
2536 s/GNU Library General/GNU General/g
2537 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2542 # Determine script to apply to library files that go into $testsbase/.
2543 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2544 if test -n "$do_copyrights"; then
2546 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2547 s/GNU Lesser General/GNU General/g
2548 s/GNU Library General/GNU General/g
2549 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2553 # Determine the final file lists.
2554 # They must be computed separately, because files in lib/* go into
2555 # $sourcebase/ if they are in the main file list but into $testsbase/
2556 # if they are in the tests-related file list. Furthermore lib/dummy.c
2558 # Determine final main file list.
2559 modules="$main_modules"
2560 func_modules_to_filelist
2562 # Determine final tests-related file list.
2563 modules="$testsrelated_modules"
2564 func_modules_to_filelist
2565 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2566 # Merge both file lists.
2567 sed_remove_empty_lines='/^$/d'
2568 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2569 if test $verbose -ge 0; then
2571 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2572 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2576 || func_fatal_error "refusing to do nothing"
2578 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2579 new_files="$files m4/gnulib-tool.m4"
2580 old_files="$cached_files"
2581 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2582 func_append old_files " m4/gnulib-tool.m4"
2585 sed_rewrite_old_files="\
2586 s,^build-aux/,$auxdir/,
2587 s,^doc/,$cached_docbase/,
2588 s,^lib/,$cached_sourcebase/,
2589 s,^m4/,$cached_m4base/,
2590 s,^tests/,$cached_testsbase/,
2591 s,^tests=lib/,$cached_testsbase/,
2593 sed_rewrite_new_files="\
2594 s,^build-aux/,$auxdir/,
2596 s,^lib/,$sourcebase/,
2598 s,^tests/,$testsbase/,
2599 s,^tests=lib/,$testsbase/,
2602 # Create directories.
2603 { echo "$sourcebase"
2605 if test -n "$pobase"; then
2608 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2609 if test -n "$docfiles"; then
2612 if test -n "$inctests"; then
2616 for f in $files; do echo $f; done \
2617 | sed -e "$sed_rewrite_new_files" \
2618 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2621 { # Rearrange file descriptors. Needed because "while ... done < ..."
2622 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2623 exec 5<&0 < "$tmp"/dirs
2625 if test ! -d "$destdir/$d"; then
2627 echo "Creating directory $destdir/$d"
2628 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2630 echo "Create directory $destdir/$d"
2637 # func_dest_tmpfilename file
2638 # determines the name of a temporary file (file is relative to destdir).
2640 # - tmpfile absolute filename of the temporary file
2641 func_dest_tmpfilename ()
2644 # Put the new contents of $file in a file in the same directory (needed
2645 # to guarantee that an 'mv' to "$destdir/$file" works).
2646 tmpfile="$destdir/$1.tmp"
2648 # Put the new contents of $file in a file in a temporary directory
2649 # (because the directory of "$file" might not exist).
2650 tmpfile="$tmp"/`basename "$1"`.tmp
2654 # Copy files or make symbolic links. Remove obsolete files.
2658 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2659 # representing the files according to the last gnulib-tool invocation.
2660 for f in $old_files; do echo $f; done \
2661 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2664 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2665 # representing the files after this gnulib-tool invocation.
2666 for f in $new_files; do echo $f; done \
2667 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2670 # First the files that are in old-files, but not in new-files:
2671 sed_take_first_column='s,'"$delimiter"'.*,,'
2672 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2673 # Remove the file. Do nothing if the user already removed it.
2674 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2676 echo "Removing file $g (backup in ${g}~)"
2677 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2679 echo "Remove file $g (backup in ${g}~)"
2681 func_append removed_files "$g$nl"
2684 # func_add_or_update handles a file that ought to be present afterwards.
2686 # - f the original file name
2687 # - g the rewritten file name
2688 # - already_present nonempty if the file already exists, empty otherwise
2689 func_add_or_update ()
2693 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2695 func_dest_tmpfilename "$g"
2696 func_lookup_file "$f"
2697 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2698 if test -n "$sed_transform_main_lib_file"; then
2701 sed -e "$sed_transform_main_lib_file" \
2702 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2706 if test -n "$sed_transform_testsrelated_lib_file"; then
2709 sed -e "$sed_transform_testsrelated_lib_file" \
2710 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2714 if test -f "$destdir/$g"; then
2715 # The file already exists.
2716 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2717 : # The file has not changed.
2721 if test -n "$already_present"; then
2722 echo "Updating file $g (backup in ${g}~)"
2724 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2726 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2727 if { test -n "$symbolic" \
2728 || { test -n "$lsymbolic" \
2729 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2730 && test -z "$lookedup_tmp" \
2731 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2732 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2734 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2737 if test -n "$already_present"; then
2738 echo "Update file $g (backup in ${g}~)"
2740 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2746 # Don't protest if the file should be there but isn't: it happens
2747 # frequently that developers don't put autogenerated files into CVS.
2749 echo "Copying file $g"
2750 if { test -n "$symbolic" \
2751 || { test -n "$lsymbolic" \
2752 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2753 && test -z "$lookedup_tmp" \
2754 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2755 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2757 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2762 func_append added_files "$g$nl"
2766 # Then the files that are in new-files, but not in old-files:
2767 sed_take_last_column='s,^.*'"$delimiter"',,'
2769 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2770 | sed -e "$sed_take_last_column" \
2771 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2772 { # Rearrange file descriptors. Needed because "while ... done < ..."
2773 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2774 exec 5<&0 < "$tmp"/added-files
2780 # Then the files that are in new-files and in old-files:
2781 already_present=true
2782 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2783 | sed -e "$sed_take_last_column" \
2784 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2785 { # Rearrange file descriptors. Needed because "while ... done < ..."
2786 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2787 exec 5<&0 < "$tmp"/kept-files
2794 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2795 actioncmd="gnulib-tool --import"
2796 func_append actioncmd " --dir=$destdir"
2797 if test -n "$local_gnulib_dir"; then
2798 func_append actioncmd " --local-dir=$local_gnulib_dir"
2800 func_append actioncmd " --lib=$libname"
2801 func_append actioncmd " --source-base=$sourcebase"
2802 func_append actioncmd " --m4-base=$m4base"
2803 if test -n "$pobase"; then
2804 func_append actioncmd " --po-base=$pobase"
2806 func_append actioncmd " --doc-base=$docbase"
2807 func_append actioncmd " --aux-dir=$auxdir"
2808 if test -n "$inctests"; then
2809 func_append actioncmd " --with-tests"
2811 for module in $avoidlist; do
2812 func_append actioncmd " --avoid=$module"
2814 if test -n "$lgpl"; then
2815 if test "$lgpl" = yes; then
2816 func_append actioncmd " --lgpl"
2818 func_append actioncmd " --lgpl=$lgpl"
2821 if test -n "$makefile_name"; then
2822 func_append actioncmd " --makefile-name=$makefile_name"
2824 if test "$libtool" = true; then
2825 func_append actioncmd " --libtool"
2827 func_append actioncmd " --no-libtool"
2829 func_append actioncmd " --macro-prefix=$macro_prefix"
2830 if test -n "$po_domain"; then
2831 func_append actioncmd " --po-domain=$po_domain"
2833 if test -n "$vc_files"; then
2834 if test "$vc_files" = true; then
2835 func_append actioncmd " --vc-files"
2837 func_append actioncmd " --no-vc-files"
2840 func_append actioncmd " `echo $specified_modules`"
2842 # Default the makefile name to Makefile.am.
2843 if test -n "$makefile_name"; then
2844 makefile_am=$makefile_name
2846 makefile_am=Makefile.am
2849 # Create normal Makefile.ams.
2852 # Create library makefile.
2853 func_dest_tmpfilename $sourcebase/$makefile_am
2854 modules="$main_modules"
2855 func_emit_lib_Makefile_am > "$tmpfile"
2856 if test -f "$destdir"/$sourcebase/$makefile_am; then
2857 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2861 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2862 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2863 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2865 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2871 echo "Creating $sourcebase/$makefile_am"
2872 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2874 echo "Create $sourcebase/$makefile_am"
2877 func_append added_files "$sourcebase/$makefile_am$nl"
2880 # Create po/ directory.
2881 if test -n "$pobase"; then
2882 # Create po makefile and auxiliary files.
2883 for file in Makefile.in.in remove-potcdate.sin; do
2884 func_dest_tmpfilename $pobase/$file
2885 func_lookup_file build-aux/po/$file
2886 cat "$lookedup_file" > "$tmpfile"
2887 if test -f "$destdir"/$pobase/$file; then
2888 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2892 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2893 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2894 mv -f "$tmpfile" "$destdir"/$pobase/$file
2896 echo "Update $pobase/$file (backup in $pobase/$file~)"
2902 echo "Creating $pobase/$file"
2903 mv -f "$tmpfile" "$destdir"/$pobase/$file
2905 echo "Create $pobase/$file"
2908 func_append added_files "$pobase/$file$nl"
2911 # Create po makefile parameterization, part 1.
2912 func_dest_tmpfilename $pobase/Makevars
2913 func_emit_po_Makevars > "$tmpfile"
2914 if test -f "$destdir"/$pobase/Makevars; then
2915 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2919 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2920 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2921 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2923 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2929 echo "Creating $pobase/Makevars"
2930 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2932 echo "Create $pobase/Makevars"
2935 func_append added_files "$pobase/Makevars$nl"
2937 # Create po makefile parameterization, part 2.
2938 func_dest_tmpfilename $pobase/POTFILES.in
2939 func_emit_po_POTFILES_in > "$tmpfile"
2940 if test -f "$destdir"/$pobase/POTFILES.in; then
2941 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2945 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2946 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2947 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2949 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2955 echo "Creating $pobase/POTFILES.in"
2956 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2958 echo "Create $pobase/POTFILES.in"
2961 func_append added_files "$pobase/POTFILES.in$nl"
2964 TP_URL="http://translationproject.org/latest/"
2965 TP_RSYNC_URI="translationproject.org::tp/latest/"
2967 echo "Fetching gnulib PO files from $TP_URL"
2968 (cd "$destdir"/$pobase \
2969 && { # Prefer rsync over wget if it is available, since it consumes
2970 # less network bandwidth, due to compression.
2971 if type rsync 2>/dev/null | grep / > /dev/null; then
2972 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2974 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2979 echo "Fetch gnulib PO files from $TP_URL"
2981 # Create po/LINGUAS.
2983 func_dest_tmpfilename $pobase/LINGUAS
2984 (cd "$destdir"/$pobase \
2985 && { echo '# Set of available languages.'
2986 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2989 if test -f "$destdir"/$pobase/LINGUAS; then
2990 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2993 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2994 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2995 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2998 echo "Creating $pobase/LINGUAS"
2999 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3000 func_append added_files "$pobase/LINGUAS$nl"
3003 if test -f "$destdir"/$pobase/LINGUAS; then
3004 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3006 echo "Create $pobase/LINGUAS"
3011 # Create m4/gnulib-cache.m4.
3012 func_dest_tmpfilename $m4base/gnulib-cache.m4
3014 func_emit_copyright_notice
3016 echo "# This file represents the specification of how gnulib-tool is used."
3017 echo "# It acts as a cache: It is written and read by gnulib-tool."
3018 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3019 echo "# like the configure.ac and various Makefile.am files."
3022 echo "# Specification in the form of a command-line invocation:"
3025 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3026 # Store the local_gnulib_dir relative to destdir.
3027 case "$local_gnulib_dir" in
3029 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3032 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3034 # destdir, local_gnulib_dir are both relative.
3035 func_relativize "$destdir" "$local_gnulib_dir"
3036 relative_local_gnulib_dir="$reldir" ;;
3039 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3041 echo "$specified_modules" | sed 's/^/ /g'
3043 echo "gl_AVOID([$avoidlist])"
3044 echo "gl_SOURCE_BASE([$sourcebase])"
3045 echo "gl_M4_BASE([$m4base])"
3046 echo "gl_PO_BASE([$pobase])"
3047 echo "gl_DOC_BASE([$docbase])"
3048 echo "gl_TESTS_BASE([$testsbase])"
3049 test -z "$inctests" || echo "gl_WITH_TESTS"
3050 echo "gl_LIB([$libname])"
3051 if test -n "$lgpl"; then
3052 if test "$lgpl" = yes; then
3055 echo "gl_LGPL([$lgpl])"
3058 echo "gl_MAKEFILE_NAME([$makefile_name])"
3059 if test "$libtool" = true; then
3062 echo "gl_MACRO_PREFIX([$macro_prefix])"
3063 echo "gl_PO_DOMAIN([$po_domain])"
3064 if test -n "$vc_files"; then
3065 echo "gl_VC_FILES([$vc_files])"
3068 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3069 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3073 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3074 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3075 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3077 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3081 echo "# gnulib-cache.m4 ends here"
3088 echo "Creating $m4base/gnulib-cache.m4"
3089 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3091 echo "Create $m4base/gnulib-cache.m4"
3097 # Create m4/gnulib-comp.m4.
3098 func_dest_tmpfilename $m4base/gnulib-comp.m4
3100 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3101 func_emit_copyright_notice
3103 echo "# This file represents the compiled summary of the specification in"
3104 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3105 echo "# to be invoked from configure.ac."
3106 echo "# In projects using CVS, this file can be treated like other built files."
3109 echo "# This macro should be invoked from $configure_ac, in the section"
3110 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3111 echo "# any checks for libraries, header files, types and library functions."
3112 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3114 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3115 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3116 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3117 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3118 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3119 if test -n "$uses_subdirs"; then
3120 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3122 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
3123 echo " AC_REQUIRE([AC_GNU_SOURCE])"
3125 for module in $final_modules; do
3127 if test -n "$module"; then
3128 func_get_autoconf_early_snippet "$module"
3131 | sed -e '/^$/d;' -e 's/^/ /'
3134 echo "# This macro should be invoked from $configure_ac, in the section"
3135 echo "# \"Check for header files, types and library functions\"."
3136 echo "AC_DEFUN([${macro_prefix}_INIT],"
3138 if test "$libtool" = true; then
3139 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3140 echo " gl_cond_libtool=true"
3142 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3143 echo " gl_cond_libtool=false"
3145 echo " gl_ltlibdeps="
3147 if test "$auxdir" != "build-aux"; then
3148 sed_replace_build_aux='
3150 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3151 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3155 sed_replace_build_aux=
3157 func_emit_initmacro_start $macro_prefix
3158 echo " gl_source_base='$sourcebase'"
3159 for module in $main_modules; do
3161 if test -n "$module"; then
3162 func_get_autoconf_snippet "$module" \
3163 | sed -e '/^$/d;' -e 's/^/ /' \
3164 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3165 -e "$sed_replace_build_aux"
3166 if test "$module" = 'alloca' && test "$libtool" = true; then
3167 echo 'changequote(,)dnl'
3168 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3169 echo 'changequote([, ])dnl'
3170 echo 'AC_SUBST([LTALLOCA])'
3174 func_emit_initmacro_end $macro_prefix
3175 echo " gltests_libdeps="
3176 echo " gltests_ltlibdeps="
3177 func_emit_initmacro_start ${macro_prefix}tests
3178 echo " gl_source_base='$testsbase'"
3179 for module in $testsrelated_modules; do
3181 if test -n "$module"; then
3182 func_get_autoconf_snippet "$module" \
3183 | sed -e '/^$/d;' -e 's/^/ /' \
3184 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3185 -e "$sed_replace_build_aux" \
3186 -e 's/\$gl_cond_libtool/false/g' \
3187 -e 's/gl_libdeps/gltests_libdeps/g' \
3188 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3191 func_emit_initmacro_end ${macro_prefix}tests
3192 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3193 # created using libtool, because libtool already handles the dependencies.
3194 if test "$libtool" != true; then
3195 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3196 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3197 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3198 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3199 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3201 if $use_libtests; then
3202 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3203 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3206 func_emit_initmacro_done $macro_prefix $sourcebase
3207 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3209 echo "# This macro records the list of files which have been installed by"
3210 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3211 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3212 echo "$files" | sed -e 's,^, ,'
3215 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3216 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3220 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3221 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3222 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3224 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3228 echo "# gnulib-comp.m4 ends here"
3235 echo "Creating $m4base/gnulib-comp.m4"
3236 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3238 echo "Create $m4base/gnulib-comp.m4"
3244 if test -n "$inctests"; then
3245 # Create tests makefile.
3246 func_dest_tmpfilename $testsbase/$makefile_am
3247 modules="$testsrelated_modules"
3248 func_emit_tests_Makefile_am > "$tmpfile"
3249 if test -f "$destdir"/$testsbase/$makefile_am; then
3250 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3254 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3255 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3256 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3258 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3264 echo "Creating $testsbase/$makefile_am"
3265 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3267 echo "Create $testsbase/$makefile_am"
3270 func_append added_files "$testsbase/$makefile_am$nl"
3274 if test "$vc_files" != false; then
3275 # Update the .cvsignore and .gitignore files.
3276 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3277 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3278 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3279 echo "$m4base/|A|gnulib-comp.m4"
3280 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3281 { # Rearrange file descriptors. Needed because "while ... done < ..."
3282 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3283 exec 5<&0 < "$tmp"/fileset-changes
3284 func_update_ignorelist ()
3287 if test "$ignore" = .gitignore; then
3288 # In a .gitignore file, "foo" applies to the current directory and all
3289 # subdirectories, whereas "/foo" applies to the current directory only.
3292 doubly_escaped_anchor='\\/'
3296 doubly_escaped_anchor=''
3298 if test -f "$destdir/$dir$ignore"; then
3299 if test -n "$dir_added" || test -n "$dir_removed"; then
3300 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3302 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3303 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
3304 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3305 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
3307 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3309 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3310 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3311 { sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3312 if test -n "$anchor"; then sed -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,\$/d,' < "$tmp"/ignore-removed; fi
3313 } > "$tmp"/sed-ignore-removed
3314 { cat "$destdir/$dir$ignore"~
3315 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3316 } | sed -f "$tmp"/sed-ignore-removed \
3317 > "$destdir/$dir$ignore"
3319 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3324 if test -n "$dir_added"; then
3326 echo "Creating $destdir/$dir$ignore"
3328 if test "$ignore" = .cvsignore; then
3330 # Automake generates Makefile rules that create .dirstamp files.
3333 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3334 } > "$destdir/$dir$ignore"
3336 echo "Create $destdir/$dir$ignore"
3346 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3347 func_update_ignorelist .cvsignore
3349 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3350 func_update_ignorelist .gitignore
3357 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3358 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3359 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3360 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3361 if test "$next_dir" != "$last_dir"; then
3362 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3363 last_dir="$next_dir"
3368 A) func_append last_dir_added "$file$nl";;
3369 R) func_append last_dir_removed "$file$nl";;
3372 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3379 echo "You may need to add #include directives for the following .h files."
3380 # Intersect $specified_modules and $main_modules
3381 # (since $specified_modules is not necessarily of subset of $main_modules
3382 # - some may have been skipped through --avoid, and since the elements of
3383 # $main_modules but not in $specified_modules can go away without explicit
3384 # notice - through changes in the module dependencies).
3385 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3386 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3387 # First the #include <...> directives without #ifs, sorted for convenience,
3388 # then the #include "..." directives without #ifs, sorted for convenience,
3389 # then the #include directives that are surrounded by #ifs. Not sorted.
3390 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3391 include_directive=`func_get_include_directive "$module"`
3392 case "$nl$include_directive" in
3394 echo "$include_directive" 1>&5
3397 echo "$include_directive" | grep -v 'include "' 1>&6
3398 echo "$include_directive" | grep 'include "' 1>&7
3401 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3403 LC_ALL=C sort -u "$tmp"/include-angles
3404 LC_ALL=C sort -u "$tmp"/include-quotes
3405 cat "$tmp"/include-if
3406 ) | sed -e '/^$/d' -e 's/^/ /'
3407 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3409 for module in $main_modules; do
3410 func_get_link_directive "$module"
3412 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3413 if test `wc -l < "$tmp"/link` != 0; then
3415 echo "You may need to use the following Makefile variables when linking."
3416 echo "Use them in <program>_LDADD when linking a program, or"
3417 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3423 echo "Don't forget to"
3424 if test "$makefile_am" = Makefile.am; then
3425 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3427 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3429 if test -n "$pobase"; then
3430 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3432 if test -n "$inctests"; then
3433 if test "$makefile_am" = Makefile.am; then
3434 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3436 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3439 if test "$makefile_am" = Makefile.am; then
3440 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3441 sourcebase_base=`basename "$sourcebase"`
3442 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
3444 if test -n "$pobase"; then
3445 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3446 pobase_base=`basename "$pobase"`
3447 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
3449 if test -n "$inctests"; then
3450 if test "$makefile_am" = Makefile.am; then
3451 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3452 testsbase_base=`basename "$testsbase"`
3453 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
3456 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
3458 # Find the first parent directory of $m4base that contains a Makefile.am.
3459 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3461 sed_butlast='s,[^/][^/]*//*$,,'
3462 dir1="${m4base}/"; dir2=""
3463 while test -n "$dir1" && test ! -f "${destdir}/${dir1}Makefile.am"; do
3464 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3465 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3467 echo " - mention ${dir2}gnulib-cache.m4 in EXTRA_DIST in ${dir1}Makefile.am."
3469 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3470 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3473 # func_create_testdir testdir modules
3475 # - local_gnulib_dir from --local-dir
3476 # - auxdir directory relative to destdir where to place build aux files
3477 func_create_testdir ()
3481 if test -z "$modules"; then
3482 # All modules together.
3483 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3484 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3485 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3486 modules=`func_all_modules`
3487 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3489 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3491 # Check that the license of every module is consistent with the license of
3493 saved_modules="$modules"
3494 saved_inctests="$inctests"
3495 # When computing transitive closures, don't consider $module to depend on
3496 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3497 # on GPL modules - therefore we don't want a warning in this case.
3499 for requested_module in $saved_modules; do
3500 requested_license=`func_get_license "$requested_module"`
3501 if test "$requested_license" != GPL; then
3502 # Here we use func_modules_transitive_closure, not just
3503 # func_get_dependencies, so that we also detect weird situations like
3504 # an LGPL module which depends on a GPLed build tool module which depends
3506 modules="$requested_module"
3507 func_modules_transitive_closure
3508 for module in $modules; do
3509 license=`func_get_license "$module"`
3511 'GPLed build tool') ;;
3512 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3514 case "$requested_license" in
3517 GPLv2+ | LGPLv2+) ;;
3518 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3524 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3530 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3539 modules="$saved_modules"
3540 inctests="$saved_inctests"
3542 # Subdirectory names.
3552 # Determine final module list.
3553 func_modules_transitive_closure
3554 if test $verbose -ge 0; then
3555 echo "Module list with included dependencies:"
3556 echo "$modules" | sed -e 's/^/ /'
3559 # Add the dummy module if needed.
3560 func_modules_add_dummy
3562 # Show banner notice of every module.
3565 # Determine final file list.
3566 func_modules_to_filelist
3567 if test $verbose -ge 0; then
3569 echo "$files" | sed -e 's/^/ /'
3572 sed_rewrite_files="\
3573 s,^build-aux/,$auxdir/,
3575 s,^lib/,$sourcebase/,
3577 s,^tests/,$testsbase/,
3580 # Create directories.
3581 for f in $files; do echo $f; done \
3582 | sed -e "$sed_rewrite_files" \
3583 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3584 | LC_ALL=C sort -u \
3586 { # Rearrange file descriptors. Needed because "while ... done < ..."
3587 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3588 exec 5<&0 < "$tmp"/dirs
3590 mkdir -p "$testdir/$d"
3595 # Copy files or make symbolic links.
3597 for f in $files; do echo $f; done \
3598 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3601 { # Rearrange file descriptors. Needed because "while ... done < ..."
3602 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3603 exec 5<&0 < "$tmp"/files
3605 func_lookup_file "$f"
3606 if test -n "$lookedup_tmp"; then
3607 cp -p "$lookedup_file" "$testdir/$g"
3609 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3610 if { test -n "$symbolic" \
3611 || { test -n "$lsymbolic" \
3612 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3613 func_ln "$lookedup_file" "$testdir/$g"
3615 cp -p "$lookedup_file" "$testdir/$g"
3622 # Create Makefile.ams that are for testing.
3625 # Create $sourcebase/Makefile.am.
3626 mkdir -p "$testdir/$sourcebase"
3627 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3628 any_uses_subdirs="$uses_subdirs"
3630 # Create $m4base/Makefile.am.
3631 mkdir -p "$testdir/$m4base"
3632 (echo "## Process this file with automake to produce Makefile.in."
3638 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3641 ) > "$testdir/$m4base/Makefile.am"
3643 subdirs="$sourcebase $m4base"
3644 subdirs_with_configure_ac=""
3646 if false && test -f "$testdir"/$m4base/gettext.m4; then
3647 # Avoid stupid error message from automake:
3648 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3649 mkdir -p "$testdir/po"
3650 (echo "## Process this file with automake to produce Makefile.in."
3651 ) > "$testdir/po/Makefile.am"
3652 func_append subdirs " po"
3655 if test -n "$inctests"; then
3656 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3657 # Viewed from the $testsbase subdirectory, $auxdir is different.
3658 saved_auxdir="$auxdir"
3659 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3660 # Create $testsbase/Makefile.am.
3662 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3663 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3664 # Create $testsbase/configure.ac.
3665 (echo "# Process this file with autoconf to produce a configure script."
3666 echo "AC_INIT([dummy], [0])"
3667 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3668 echo "AM_INIT_AUTOMAKE"
3670 echo "AM_CONFIG_HEADER([config.h])"
3673 echo "AC_PROG_INSTALL"
3674 echo "AC_PROG_MAKE_SET"
3675 echo "AC_PROG_RANLIB"
3677 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3678 echo "AC_GNU_SOURCE"
3681 for module in $modules; do
3683 if test -n "$module"; then
3684 func_get_autoconf_early_snippet "$module"
3687 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3688 if test "$libtool" = true; then
3689 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3690 echo "gl_cond_libtool=true"
3692 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3693 echo "gl_cond_libtool=false"
3695 echo "gl_ltlibdeps="
3697 # Wrap the set of autoconf snippets into an autoconf macro that is then
3698 # invoked. This is needed because autoconf does not support AC_REQUIRE
3700 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3701 # but we want the AC_REQUIRE to have its normal meaning (provide one
3702 # expansion of the required macro before the current point, and only one
3704 echo "AC_DEFUN([gl_INIT], ["
3705 sed_replace_build_aux='
3707 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3708 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3711 func_emit_initmacro_start $macro_prefix
3712 # We don't have explicit ordering constraints between the various
3713 # autoconf snippets. It's cleanest to put those of the library before
3714 # those of the tests.
3715 echo "gl_source_base='../$sourcebase'"
3716 for module in $modules; do
3717 func_verify_nontests_module
3718 if test -n "$module"; then
3719 func_get_autoconf_snippet "$module" \
3720 | sed -e "$sed_replace_build_aux"
3723 echo "gl_source_base='.'"
3724 for module in $modules; do
3725 func_verify_tests_module
3726 if test -n "$module"; then
3727 func_get_autoconf_snippet "$module" \
3728 | sed -e "$sed_replace_build_aux"
3731 func_emit_initmacro_end $macro_prefix
3732 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3733 # created using libtool, because libtool already handles the dependencies.
3734 if test "$libtool" != true; then
3735 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3736 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3737 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3738 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3739 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3742 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3746 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3747 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3748 echo "AH_TOP([#include \"../config.h\"])"
3750 echo "AC_OUTPUT([Makefile])"
3751 ) > "$testdir/$testsbase/configure.ac"
3752 auxdir="$saved_auxdir"
3753 func_append subdirs " $testsbase"
3754 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3757 # Create Makefile.am.
3758 (echo "## Process this file with automake to produce Makefile.in."
3760 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3762 echo "SUBDIRS = $subdirs"
3764 echo "ACLOCAL_AMFLAGS = -I $m4base"
3765 ) > "$testdir/Makefile.am"
3767 # Create configure.ac.
3768 (echo "# Process this file with autoconf to produce a configure script."
3769 echo "AC_INIT([dummy], [0])"
3770 if test "$auxdir" != "."; then
3771 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3773 echo "AM_INIT_AUTOMAKE"
3775 echo "AM_CONFIG_HEADER([config.h])"
3778 echo "AC_PROG_INSTALL"
3779 echo "AC_PROG_MAKE_SET"
3781 echo "# For autobuild."
3782 echo "AC_CANONICAL_BUILD"
3783 echo "AC_CANONICAL_HOST"
3785 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3786 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3787 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3788 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3790 echo "AC_PROG_RANLIB"
3792 if test -n "$any_uses_subdirs"; then
3793 echo "AM_PROG_CC_C_O"
3796 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3797 echo "AC_GNU_SOURCE"
3800 for module in $modules; do
3801 func_verify_nontests_module
3802 if test -n "$module"; then
3803 func_get_autoconf_early_snippet "$module"
3806 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3807 if test "$libtool" = true; then
3808 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3809 echo "gl_cond_libtool=true"
3811 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3812 echo "gl_cond_libtool=false"
3814 echo "gl_ltlibdeps="
3816 # Wrap the set of autoconf snippets into an autoconf macro that is then
3817 # invoked. This is needed because autoconf does not support AC_REQUIRE
3819 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3820 # but we want the AC_REQUIRE to have its normal meaning (provide one
3821 # expansion of the required macro before the current point, and only one
3823 echo "AC_DEFUN([gl_INIT], ["
3824 if test "$auxdir" != "build-aux"; then
3825 sed_replace_build_aux='
3827 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3828 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3832 sed_replace_build_aux=
3834 func_emit_initmacro_start $macro_prefix
3835 echo "gl_source_base='$sourcebase'"
3836 for module in $modules; do
3837 func_verify_nontests_module
3838 if test -n "$module"; then
3839 func_get_autoconf_snippet "$module" \
3840 | sed -e "$sed_replace_build_aux"
3843 func_emit_initmacro_end $macro_prefix
3844 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3845 # created using libtool, because libtool already handles the dependencies.
3846 if test "$libtool" != true; then
3847 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3848 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3849 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3850 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3851 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3854 func_emit_initmacro_done $macro_prefix $sourcebase
3858 if test -n "$subdirs_with_configure_ac"; then
3859 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3861 makefiles="Makefile"
3862 for d in $subdirs; do
3863 # For subdirs that have a configure.ac by their own, it's the subdir's
3864 # configure.ac which creates the subdir's Makefile.am, not this one.
3865 case " $subdirs_with_configure_ac " in
3867 *) func_append makefiles " $d/Makefile" ;;
3870 echo "AC_OUTPUT([$makefiles])"
3871 ) > "$testdir/configure.ac"
3873 # Create autogenerated files.
3875 # Do not use "${AUTORECONF} --force --install", because it may invoke
3876 # autopoint, which brings in older versions of some of our .m4 files.
3877 if test -f $m4base/gettext.m4; then
3878 func_execute_command ${AUTOPOINT} --force || func_exit 1
3879 for f in $m4base/*.m4~; do
3880 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3883 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3884 if ! test -d build-aux; then
3885 func_execute_command mkdir build-aux || func_exit 1
3887 func_execute_command ${AUTOCONF} || func_exit 1
3888 func_execute_command ${AUTOHEADER} || func_exit 1
3889 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3891 if test -n "$inctests"; then
3892 # Create autogenerated files.
3893 (cd "$testdir/$testsbase" || func_exit 1
3894 # Do not use "${AUTORECONF} --force --install", because it may invoke
3895 # autopoint, which brings in older versions of some of our .m4 files.
3896 if test -f ../$m4base/gettext.m4; then
3897 func_execute_command ${AUTOPOINT} --force || func_exit 1
3898 for f in ../$m4base/*.m4~; do
3899 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3902 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3903 if ! test -d ../build-aux; then
3904 func_execute_command mkdir ../build-aux
3906 func_execute_command ${AUTOCONF} || func_exit 1
3907 func_execute_command ${AUTOHEADER} || func_exit 1
3908 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3911 # Need to run configure and make once, to create built files that are to be
3912 # distributed (such as getdate.c).
3913 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3914 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3915 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3916 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3917 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3918 # such $(FOO_H) because they don't refer to distributed files.
3919 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3920 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3921 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3922 | sed -e "$sed_remove_make_variables"`
3923 distributed_built_sources=`for file in $built_sources; do
3924 case "$cleaned_files" in
3929 if test -n "$distributed_built_sources"; then
3931 ./configure || func_exit 1
3933 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3934 make built_sources || func_exit 1
3936 make distclean || func_exit 1
3941 # func_create_megatestdir megatestdir allmodules
3943 # - local_gnulib_dir from --local-dir
3944 # - auxdir directory relative to destdir where to place build aux files
3945 func_create_megatestdir ()
3949 if test -z "$allmodules"; then
3950 allmodules=`func_all_modules`
3954 # First, all modules one by one.
3955 for onemodule in $allmodules; do
3956 func_create_testdir "$megatestdir/$onemodule" $onemodule
3957 func_append megasubdirs "$onemodule "
3959 # Then, all modules all together.
3960 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3961 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3962 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3963 func_create_testdir "$megatestdir/ALL" "$allmodules"
3964 func_append megasubdirs "ALL"
3967 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
3968 vc_witness="$gnulib_dir/CVS/Entries"; \
3970 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
3972 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
3973 | sed -e 's,January,01,' -e 's,Jan,01,' \
3974 -e 's,February,02,' -e 's,Feb,02,' \
3975 -e 's,March,03,' -e 's,Mar,03,' \
3976 -e 's,April,04,' -e 's,Apr,04,' \
3978 -e 's,June,06,' -e 's,Jun,06,' \
3979 -e 's,July,07,' -e 's,Jul,07,' \
3980 -e 's,August,08,' -e 's,Aug,08,' \
3981 -e 's,September,09,' -e 's,Sep,09,' \
3982 -e 's,October,10,' -e 's,Oct,10,' \
3983 -e 's,November,11,' -e 's,Nov,11,' \
3984 -e 's,December,12,' -e 's,Dec,12,' \
3985 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3986 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3988 echo "CVSDATE=$cvsdate"
3989 echo "test -d logs || mkdir logs"
3990 echo "for module in $megasubdirs; do"
3991 echo " echo \"Working on module \$module...\""
3992 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3993 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3996 echo " : autobuild project... \$module"
3997 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3998 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3999 echo " : autobuild hostname... \`hostname\`"
4000 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
4002 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4004 ) > "$megatestdir/do-autobuild"
4005 chmod a+x "$megatestdir/do-autobuild"
4007 # Create Makefile.am.
4008 (echo "## Process this file with automake to produce Makefile.in."
4010 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4012 echo "SUBDIRS = $megasubdirs"
4014 echo "EXTRA_DIST = do-autobuild"
4015 ) > "$megatestdir/Makefile.am"
4017 # Create configure.ac.
4018 (echo "# Process this file with autoconf to produce a configure script."
4019 echo "AC_INIT([dummy], [0])"
4020 if test "$auxdir" != "."; then
4021 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4023 echo "AM_INIT_AUTOMAKE"
4025 echo "AC_PROG_MAKE_SET"
4027 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4028 echo "AC_OUTPUT([Makefile])"
4029 ) > "$megatestdir/configure.ac"
4031 # Create autogenerated files.
4033 # Do not use "${AUTORECONF} --install", because autoreconf operates
4034 # recursively, but the subdirectories are already finished, therefore
4035 # calling autoreconf here would only waste lots of CPU time.
4036 func_execute_command ${ACLOCAL} || func_exit 1
4037 func_execute_command mkdir build-aux
4038 func_execute_command ${AUTOCONF} || func_exit 1
4039 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4045 func_fatal_error "no mode specified" ;;
4054 if test -z "$destdir"; then
4057 test -d "$destdir" \
4058 || func_fatal_error "destination directory does not exist: $destdir"
4060 # Prefer configure.ac to configure.in.
4061 if test -f "$destdir"/configure.ac; then
4062 configure_ac="$destdir/configure.ac"
4064 if test -f "$destdir"/configure.in; then
4065 configure_ac="$destdir/configure.in"
4067 func_fatal_error "cannot find $destdir/configure.ac"
4071 # Analyze configure.ac.
4073 guessed_libtool=false
4078 /AC_CONFIG_AUX_DIR/ {
4079 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
4081 /A[CM]_PROG_LIBTOOL/ {
4082 s,^.*$,guessed_libtool=true,p
4084 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4086 if test -z "$auxdir"; then
4087 auxdir="$guessed_auxdir"
4090 # Determine where to apply func_import.
4091 if test -n "$m4base"; then
4092 # Apply func_import to a particular gnulib directory.
4093 # Any number of additional modules can be given.
4094 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4095 # First use of gnulib in the given m4base.
4096 test -n "$supplied_libname" || supplied_libname=true
4097 test -n "$sourcebase" || sourcebase="lib"
4098 test -n "$docbase" || docbase="doc"
4099 test -n "$testsbase" || testsbase="tests"
4100 test -n "$macro_prefix" || macro_prefix="gl"
4104 # Apply func_import to all gnulib directories.
4105 # To get this list of directories, look at Makefile.am. (Not at
4106 # configure, because it may be omitted from CVS. Also, don't run
4107 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4110 if test -f "$destdir"/Makefile.am; then
4111 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4113 for arg in $aclocal_amflags; do
4114 if test -n "$m4dir_is_next"; then
4115 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4119 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4120 func_append m4dirs " $arg"
4121 m4dirs_count=`expr $m4dirs_count + 1`
4127 if test "X$arg" = "X-I"; then
4135 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4136 if test -f "$destdir"/aclocal.m4; then
4137 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4138 sedexpr2='s,^[^/]*$,.,'
4139 sedexpr3='s,/[^/]*$,,'
4140 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4141 m4dirs_count=`echo "$m4dirs" | wc -l`
4144 if test $m4dirs_count = 0; then
4145 # First use of gnulib in a package.
4146 # Any number of additional modules can be given.
4147 test -n "$supplied_libname" || supplied_libname=true
4148 test -n "$sourcebase" || sourcebase="lib"
4150 test -n "$docbase" || docbase="doc"
4151 test -n "$testsbase" || testsbase="tests"
4152 test -n "$macro_prefix" || macro_prefix="gl"
4155 if test $m4dirs_count = 1; then
4156 # There's only one use of gnulib here. Assume the user means it.
4157 # Any number of additional modules can be given.
4158 for m4base in $m4dirs; do
4162 # Ambiguous - guess what the user meant.
4163 if test $# = 0; then
4164 # No further arguments. Guess the user wants to update all of them.
4165 for m4base in $m4dirs; do
4166 # Perform func_import in a subshell, so that variable values
4168 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
4169 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
4170 # libtool, macro_prefix, po_domain, vc_files
4171 # don't propagate from one directory to another.
4172 (func_import) || func_exit 1
4176 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4184 if test -z "$destdir"; then
4185 func_fatal_error "please specify --dir option"
4188 test -d "$destdir" \
4189 || func_fatal_error "could not create destination directory"
4190 test -n "$auxdir" || auxdir="build-aux"
4191 func_create_testdir "$destdir" "$*"
4194 create-megatestdir )
4195 if test -z "$destdir"; then
4196 func_fatal_error "please specify --dir option"
4198 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4199 test -n "$auxdir" || auxdir="build-aux"
4200 func_create_megatestdir "$destdir" "$*"
4204 test -n "$destdir" || destdir=testdir$$
4205 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4206 test -n "$auxdir" || auxdir="build-aux"
4207 func_create_testdir "$destdir" "$*"
4211 ../configure || func_exit 1
4213 make check || func_exit 1
4214 make distclean || func_exit 1
4215 remaining=`find . -type f -print`
4216 if test -n "$remaining"; then
4217 echo "Remaining files:" $remaining 1>&2
4218 echo "gnulib-tool: *** Stop." 1>&2
4227 test -n "$destdir" || destdir=testdir$$
4228 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4229 test -n "$auxdir" || auxdir="build-aux"
4230 func_create_megatestdir "$destdir" "$*"
4238 remaining=`find . -type f -print`
4239 if test -n "$remaining"; then
4240 echo "Remaining files:" $remaining 1>&2
4241 echo "gnulib-tool: *** Stop." 1>&2
4249 extract-description )
4253 if test -n "$module"; then
4254 func_get_description "$module"
4263 if test -n "$module"; then
4264 func_get_notice "$module"
4273 if test -n "$module"; then
4274 func_get_filelist "$module"
4279 extract-dependencies )
4283 if test -n "$module"; then
4284 func_get_dependencies "$module"
4289 extract-autoconf-snippet )
4293 if test -n "$module"; then
4294 func_get_autoconf_snippet "$module"
4299 extract-automake-snippet )
4303 if test -n "$module"; then
4304 func_get_automake_snippet "$module"
4309 extract-include-directive )
4313 if test -n "$module"; then
4314 func_get_include_directive "$module"
4319 extract-link-directive )
4323 if test -n "$module"; then
4324 func_get_link_directive "$module"
4333 if test -n "$module"; then
4334 func_get_license "$module"
4339 extract-maintainer )
4343 if test -n "$module"; then
4344 func_get_maintainer "$module"
4349 extract-tests-module )
4353 if test -n "$module"; then
4354 func_get_tests_module "$module"
4360 func_fatal_error "unknown operation mode --$mode" ;;
4364 # Undo the effect of the previous 'trap' command. Some shellology:
4365 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4366 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4367 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4368 # 128 + signal number and is set before the trap-registered command is run.
4370 trap 'func_exit $?' 1 2 3 13 15
4375 # indent-tabs-mode: nil
4376 # whitespace-check-buffer-indent: nil