3 # Copyright (C) 2002-2009 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'
86 # sed_noop is a sed expression that does nothing.
87 # An empty expression does not work with the native 'sed' on AIX 6.1.
91 # outputs to stdout the --help usage message.
95 Usage: gnulib-tool --list
96 gnulib-tool --import [module1 ... moduleN]
98 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
99 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
100 gnulib-tool --test --dir=directory module1 ... moduleN
101 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
102 gnulib-tool --extract-description module
103 gnulib-tool --extract-status module
104 gnulib-tool --extract-notice module
105 gnulib-tool --extract-filelist module
106 gnulib-tool --extract-dependencies module
107 gnulib-tool --extract-autoconf-snippet module
108 gnulib-tool --extract-automake-snippet module
109 gnulib-tool --extract-include-directive module
110 gnulib-tool --extract-link-directive module
111 gnulib-tool --extract-license module
112 gnulib-tool --extract-maintainer module
113 gnulib-tool --extract-tests-module module
116 --list print the available module names
117 --import import the given modules into the current package;
118 if no modules are specified, update the current
119 package from the current gnulib
120 --update update the current package, restore files omitted
122 --create-testdir create a scratch package with the given modules
123 --create-megatestdir create a mega scratch package with the given modules
124 one by one and all together
125 --test test the combination of the given modules
126 (recommended to use CC=\"gcc -Wall\" here)
127 --megatest test the given modules one by one and all together
128 (recommended to use CC=\"gcc -Wall\" here)
129 --extract-description extract the description
130 --extract-status extract the status (obsolete or not)
131 --extract-notice extract the notice or banner
132 --extract-filelist extract the list of files
133 --extract-dependencies extract the dependencies
134 --extract-autoconf-snippet extract the snippet for configure.ac
135 --extract-automake-snippet extract the snippet for library makefile
136 --extract-include-directive extract the #include directive
137 --extract-link-directive extract the linker directive
138 --extract-license report the license terms of the source files
140 --extract-maintainer report the maintainer(s) inside gnulib
141 --extract-tests-module report the unit test module, if it exists
144 --dir=DIRECTORY Specify the target directory.
145 For --import, this specifies where your
146 configure.ac can be found. Defaults to current
148 --local-dir=DIRECTORY Specify a local override directory where to look
149 up files before looking in gnulib's directory.
150 --verbose Increase verbosity. May be repeated.
151 --quiet Decrease verbosity. May be repeated.
153 Options for --import:
154 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
155 --source-base=DIRECTORY
156 Directory relative to --dir where source code is
157 placed (default \"lib\").
158 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
159 placed (default \"m4\").
160 --po-base=DIRECTORY Directory relative to --dir where *.po files are
161 placed (default \"po\").
162 --doc-base=DIRECTORY Directory relative to --dir where doc files are
163 placed (default \"doc\").
164 --tests-base=DIRECTORY
165 Directory relative to --dir where unit tests are
166 placed (default \"tests\").
167 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
168 tools are placed (default \"build-aux\").
169 --with-tests Include unit tests for the included modules.
170 --with-obsolete Include obsolete modules when they occur among the
171 dependencies. By default, dependencies to obsolete
173 --avoid=MODULE Avoid including the given MODULE. Useful if you
174 have code that provides equivalent functionality.
175 This option can be repeated.
176 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
177 Also modify license template from GPL to LGPL.
178 The version number of the LGPL can be specified;
179 the default is currently LGPLv3.
180 --makefile-name=NAME Name of makefile in automake syntax in the
181 source-base and tests-base directories
182 (default \"Makefile.am\").
183 --libtool Use libtool rules.
184 --no-libtool Don't use libtool rules.
185 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
186 'gl_INIT'. Default is 'gl'.
187 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
188 the package name. A suffix '-gnulib' is appended.
189 --vc-files Update version control related files.
190 --no-vc-files Don't update version control related files
191 (.gitignore and/or .cvsignore).
192 --no-changelog Don't update or create ChangeLog files.
194 Options for --import and --update:
195 --dry-run For --import, only print what would have been done.
196 -s, --symbolic, --symlink Make symbolic links instead of copying files.
197 --local-symlink Make symbolic links instead of copying files, only
198 for files from the local override directory.
199 -S, --more-symlinks Make symbolic links instead of copying files, and
200 don't replace copyright notices.
202 Report bugs to <bug-gnulib@gnu.org>."
206 # outputs to stdout the --version message.
210 if test -d "$gnulib_dir"/.git \
211 && (git --version) >/dev/null 2>/dev/null \
212 && (date --version) >/dev/null 2>/dev/null; then
213 # gnulib checked out from git.
214 sed_extract_first_date='/^Date/{
218 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
219 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
220 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
221 date=`echo "$date" | sed -e "$sed_year_before_time"`
222 # Use GNU date to compute the time in GMT.
223 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
224 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
226 if test -d "$gnulib_dir"/CVS \
227 && (cvs --version) >/dev/null 2>/dev/null; then
228 # gnulib checked out from CVS.
229 sed_extract_first_date='/^date: /{
230 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
233 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
235 # gnulib copy without versioning information.
236 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
240 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
242 gnulib-tool (GNU $package $date)$version
243 Copyright (C) $year Free Software Foundation, Inc.
244 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
245 This is free software: you are free to change and redistribute it.
246 There is NO WARRANTY, to the extent permitted by law.
248 Written by" "Bruno Haible" "and" "Simon Josefsson"
251 # func_emit_copyright_notice
252 # outputs to stdout a header for a generated file.
253 func_emit_copyright_notice ()
255 sed -n '/Copyright/ {
258 }' < "$self_abspathname"
260 echo "# This file is free software, distributed under the terms of the GNU"
261 echo "# General Public License. As a special exception to the GNU General"
262 echo "# Public License, this file may be distributed as part of a program"
263 echo "# that contains a configuration script generated by Autoconf, under"
264 echo "# the same distribution terms as the rest of that program."
266 echo "# Generated by gnulib-tool."
270 # exits with a given status.
271 # This function needs to be used, rather than 'exit', when a 'trap' handler is
272 # in effect that refers to $?.
279 # locates the directory where the gnulib repository lives
281 # - progname name of this program
283 # - self_abspathname absolute pathname of gnulib-tool
284 # - gnulib_dir absolute pathname of gnulib repository
288 /*) self_abspathname="$progname" ;;
289 */*) self_abspathname=`pwd`/"$progname" ;;
292 # Iterate through the elements of $PATH.
293 # We use IFS=: instead of
294 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
295 # because the latter does not work when some PATH element contains spaces.
296 # We use a canonicalized $pathx instead of $PATH, because empty PATH
297 # elements are by definition equivalent to '.', however field splitting
298 # according to IFS=: loses empty fields in many shells:
299 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
300 # beginning, at the end, and in the middle),
301 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
302 # at the beginning and at the end,
303 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
304 # Solaris lose empty fields at the end.
305 # The 'case' statement is an optimization, to avoid evaluating the
306 # explicit canonicalization command when $PATH contains no empty fields.
308 if test "${PATH_SEPARATOR+set}" != set; then
310 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
311 chmod +x "$tmp"/conf.sh
312 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
319 if test "$PATH_SEPARATOR" = ";"; then
320 # On Windows, programs are searched in "." before $PATH.
323 # On Unix, we have to convert empty PATH elements to ".".
327 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
332 IFS="$PATH_SEPARATOR"
336 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
337 self_abspathname="$d/$progname"
342 if test -z "$self_abspathname"; then
343 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
347 while test -h "$self_abspathname"; do
348 # Resolve symbolic link.
349 linkval=`func_readlink "$self_abspathname"`
350 test -n "$linkval" || break
352 /* ) self_abspathname="$linkval" ;;
353 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
356 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
360 # creates a temporary directory.
362 # - progname name of this program
364 # - tmp pathname of freshly created temporary directory
367 # Use the environment variable TMPDIR, falling back to /tmp. This allows
368 # users to specify a different temporary directory, for example, if their
369 # /tmp is filled up or too small.
372 # Use the mktemp program if available. If not available, hide the error
374 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
375 test -n "$tmp" && test -d "$tmp"
378 # Use a simple mkdir command. It is guaranteed to fail if the directory
379 # already exists. $RANDOM is bash specific and expands to empty in shells
380 # other than bash, ksh and zsh. Its use does not increase security;
381 # rather, it minimizes the probability of failure in a very cluttered /tmp
383 tmp=$TMPDIR/gl$$-$RANDOM
384 (umask 077 && mkdir "$tmp")
387 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
392 # func_append var value
393 # appends the given value to the shell variable var.
394 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
395 # Use bash's += operator. It reduces complexity of appending repeatedly to
396 # a single variable from O(n^2) to O(n).
404 eval "$1=\"\$$1\$2\""
408 # func_fatal_error message
409 # outputs to stderr a fatal error message, and terminates the program.
411 # - progname name of this program
414 echo "$progname: *** $1" 1>&2
415 echo "$progname: *** Stop." 1>&2
419 # func_readlink SYMLINK
420 # outputs the target of the given symlink.
421 if (type -p readlink) > /dev/null 2>&1; then
424 # Use the readlink program from GNU coreutils.
430 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
431 # would do the wrong thing if the link target contains " -> ".
432 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
436 # func_relativize DIR1 DIR2
437 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
439 # - DIR1 relative pathname, relative to the current directory
440 # - DIR2 relative pathname, relative to the current directory
442 # - reldir relative pathname of DIR2, relative to DIR1
448 sed_first='s,^\([^/]*\)/.*$,\1,'
449 sed_rest='s,^[^/]*/*,,'
450 sed_last='s,^.*/\([^/]*\)$,\1,'
451 sed_butlast='s,/*[^/]*$,,'
452 while test -n "$dir1"; do
453 first=`echo "$dir1" | sed -e "$sed_first"`
454 if test "$first" != "."; then
455 if test "$first" = ".."; then
456 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
457 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
459 first2=`echo "$dir2" | sed -e "$sed_first"`
460 if test "$first2" = "$first"; then
461 dir2=`echo "$dir2" | sed -e "$sed_rest"`
465 dir0="$dir0"/"$first"
468 dir1=`echo "$dir1" | sed -e "$sed_rest"`
473 # func_relconcat DIR1 DIR2
474 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
476 # - DIR1 relative pathname, relative to the current directory
477 # - DIR2 relative pathname, relative to DIR1
479 # - relconcat DIR1/DIR2, relative to the current directory
484 sed_first='s,^\([^/]*\)/.*$,\1,'
485 sed_rest='s,^[^/]*/*,,'
486 sed_last='s,^.*/\([^/]*\)$,\1,'
487 sed_butlast='s,/*[^/]*$,,'
489 first=`echo "$dir2" | sed -e "$sed_first"`
490 if test "$first" = "."; then
491 dir2=`echo "$dir2" | sed -e "$sed_rest"`
492 if test -z "$dir2"; then
497 last=`echo "$dir1" | sed -e "$sed_last"`
498 while test "$last" = "."; do
499 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
500 last=`echo "$dir1" | sed -e "$sed_last"`
502 if test -z "$dir1"; then
506 if test "$first" = ".."; then
507 if test "$last" = ".."; then
508 relconcat="$dir1/$dir2"
511 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
512 dir2=`echo "$dir2" | sed -e "$sed_rest"`
513 if test -z "$dir1"; then
517 if test -z "$dir2"; then
522 relconcat="$dir1/$dir2"
530 # Like ln -s, except that SRC is given relative to the current directory (or
531 # absolute), not given relative to the directory of DEST.
537 *) # SRC is relative.
540 ln -s "`pwd`/$1" "$2" ;;
541 *) # DEST is relative too.
542 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
543 test -n "$ln_destdir" || ln_destdir="."
544 func_relativize "$ln_destdir" "$1"
552 # func_ln_if_changed SRC DEST
553 # Like func_ln, but avoids munging timestamps if the link is correct.
554 func_ln_if_changed ()
556 if test $# -ne 2; then
557 echo "usage: func_ln_if_changed SRC DEST" >&2
559 ln_target=`func_readlink "$2"`
560 if test -h "$2" && test "$1" = "$ln_target"; then
569 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
570 # writes into a pipe with no readers, i.e. a pipe where all readers have
571 # already closed their file descriptor that read from it or exited entirely.
572 # The default behaviour is to terminate the current process without an error
574 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
575 # terminate the current process with an error message.
576 # This function should be called at the beginning of a command that only
577 # produces output to stdout (i.e. no side effects!), when the command that
578 # will read from this pipe might prematurely exit or close its standard input
580 if test -n "$BASH_VERSION"; then
581 # The problem has only been reported with bash. Probably it occurs only with
582 # bash-3.2. For the reasons, see
583 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
584 # Note that Solaris sh does not understand "trap - SIGPIPE".
585 func_reset_sigpipe ()
590 func_reset_sigpipe ()
596 # Ensure an 'echo' command that does not interpret backslashes.
598 # echo '\n' | wc -l prints 1 when OK, 2 when KO
599 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
600 # This problem is a weird heritage from SVR4. BSD got it right (except that
601 # BSD echo interprets '-n' as an option, which is also not desirable).
602 # Nowadays the problem occurs in 4 situations:
603 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
604 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
605 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
606 # - in zsh, when sh-emulation is not set,
607 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
608 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
609 # - in Solaris /bin/sh and OSF/1 /bin/sh.
610 # We try the following workarounds:
611 # - for all: respawn using $CONFIG_SHELL if that is set and works.
612 # - for bash >= 2.04: unset the shell option xpg_echo.
613 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
614 # - for bash < 2.0: define echo to a function that uses cat of a here document.
615 # - for zsh: turn sh-emulation on.
616 # - for ksh: alias echo to 'print -r'.
617 # - for ksh: alias echo to a function that uses cat of a here document.
618 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
619 # the ksh workaround.
620 # - otherwise: respawn using /bin/sh and rely on the workarounds.
621 # When respawning, we pass --no-reexec as first argument, so as to avoid
622 # turning this script into a fork bomb in unlucky situations.
624 if echo '\t' | grep t > /dev/null; then
625 have_echo=yes # Lucky!
627 # Try the workarounds.
628 # Respawn using $CONFIG_SHELL if that is set and works.
629 if test -z "$have_echo" \
630 && test "X$1" != "X--no-reexec" \
631 && test -n "$CONFIG_SHELL" \
632 && test -f "$CONFIG_SHELL" \
633 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
634 exec $CONFIG_SHELL "$0" --no-reexec "$@"
637 # For bash >= 2.04: unset the shell option xpg_echo.
638 if test -z "$have_echo" \
639 && test -n "$BASH_VERSION" \
640 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
644 # For bash >= 2.0: define echo to a function that uses the printf built-in.
645 # For bash < 2.0: define echo to a function that uses cat of a here document.
646 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
647 if test -z "$have_echo" \
648 && test -n "$BASH_VERSION"; then \
649 if type printf 2>/dev/null | grep / > /dev/null; then
650 # 'printf' is not a shell built-in.
658 # 'printf' is a shell built-in.
664 if echo '\t' | grep t > /dev/null; then
668 # For zsh: turn sh-emulation on.
669 if test -z "$have_echo" \
670 && test -n "$ZSH_VERSION" \
671 && (emulate sh) >/dev/null 2>&1; then
674 # For ksh: alias echo to 'print -r'.
675 if test -z "$have_echo" \
676 && (type print) >/dev/null 2>&1; then
677 # A 'print' command exists.
678 if type print 2>/dev/null | grep / > /dev/null; then
681 # 'print' is a shell built-in.
682 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
683 # 'print' is the ksh shell built-in.
684 alias echo='print -r'
688 if test -z "$have_echo" \
689 && echo '\t' | grep t > /dev/null; then
692 # For ksh: alias echo to a function that uses cat of a here document.
693 # The ksh manual page says:
694 # "Aliasing is performed when scripts are read, not while they are executed.
695 # Therefore, for an alias to take effect, the alias definition command has
696 # to be executed before the command which references the alias is read."
697 # Because of this, we have to play strange tricks with have_echo, to ensure
698 # that the top-level statement containing the test starts after the 'alias'
700 if test -z "$have_echo"; then
707 alias echo=bsd_echo 2>/dev/null
709 if test -z "$have_echo" \
710 && echo '\t' | grep t > /dev/null; then
713 if test -z "$have_echo"; then
714 unalias echo 2>/dev/null
716 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
717 if test -z "$have_echo" \
718 && test "X$1" != "X--no-reexec" \
719 && test -f /bin/ksh; then
720 exec /bin/ksh "$0" --no-reexec "$@"
723 # Otherwise: respawn using /bin/sh.
724 if test -z "$have_echo" \
725 && test "X$1" != "X--no-reexec" \
726 && test -f /bin/sh; then
727 exec /bin/sh "$0" --no-reexec "$@"
730 if test -z "$have_echo"; then
731 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
733 if echo '\t' | grep t > /dev/null; then
736 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
738 if test "X$1" = "X--no-reexec"; then
742 # Command-line option processing.
743 # Removes the OPTIONS from the arguments. Sets the variables:
744 # - mode list or import or create-testdir or create-megatestdir
745 # - destdir from --dir
746 # - local_gnulib_dir from --local-dir
747 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
748 # - libname, supplied_libname from --lib
749 # - sourcebase from --source-base
750 # - m4base from --m4-base
751 # - pobase from --po-base
752 # - docbase from --doc-base
753 # - testsbase from --tests-base
754 # - auxdir from --aux-dir
755 # - inctests true if --with-tests was given, blank otherwise
756 # - incobsolete true if --with-obsolete was given, blank otherwise
757 # - avoidlist list of modules to avoid, from --avoid
758 # - lgpl yes or a number if --lgpl was given, blank otherwise
759 # - makefile_name from --makefile-name
760 # - libtool true if --libtool was given, false if --no-libtool was
761 # given, blank otherwise
762 # - macro_prefix from --macro-prefix
763 # - po_domain from --po-domain
764 # - vc_files true if --vc-files was given, false if --no-vc-files was
765 # given, blank otherwise
766 # - autoconf_minversion minimum supported autoconf version
767 # - do_changelog false if --no-changelog was given, : otherwise
768 # - doit : if actions shall be executed, false if only to be printed
769 # - symbolic true if --symlink or --more-symlinks was given, blank
771 # - lsymbolic true if --local-symlink was given, blank otherwise
772 # - do_copyrights blank if --more-symlinks was given, true otherwise
803 while test $# -gt 0; do
808 --import | --impor | --impo | --imp | --im | --i )
811 --update | --updat | --upda | --upd | --up | --u )
814 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
817 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
818 mode=create-megatestdir
820 --test | --tes | --te | --t )
823 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
827 mode=`echo "X$1" | sed -e 's/^X--//'`
832 func_fatal_error "missing argument for --dir"
837 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
842 func_fatal_error "missing argument for --local-dir"
847 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
849 --verbose | --verbos | --verbo | --verb )
850 verbose=`expr $verbose + 1`
852 --quiet | --quie | --qui | --qu | --q )
853 verbose=`expr $verbose - 1`
858 func_fatal_error "missing argument for --lib"
861 supplied_libname=true
864 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
865 supplied_libname=true
870 func_fatal_error "missing argument for --source-base"
875 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
880 func_fatal_error "missing argument for --m4-base"
885 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
890 func_fatal_error "missing argument for --po-base"
895 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
900 func_fatal_error "missing argument for --doc-base"
905 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
910 func_fatal_error "missing argument for --tests-base"
915 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
920 func_fatal_error "missing argument for --aux-dir"
925 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
936 func_fatal_error "missing argument for --avoid"
938 func_append avoidlist " $1"
941 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
942 func_append avoidlist " $arg"
948 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
951 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
958 func_fatal_error "missing argument for --makefile-name"
963 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
974 func_fatal_error "missing argument for --macro-prefix"
979 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
984 func_fatal_error "missing argument for --po-domain"
989 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
997 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
1003 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1006 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1009 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1013 --help | --hel | --he | --h )
1016 --version | --versio | --versi | --vers )
1020 # Stop option processing
1024 echo "gnulib-tool: unknown option $1" 1>&2
1025 echo "Try 'gnulib-tool --help' for more information." 1>&2
1032 if test "$mode" = update; then
1033 if test $# != 0; then
1034 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1035 echo "Try 'gnulib-tool --help' for more information." 1>&2
1036 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1037 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1040 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1041 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1042 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1043 || test -n "$inctests" || test -n "$incobsolete" \
1044 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1045 || test -n "$macro_prefix" || test -n "$po_domain" \
1046 || test -n "$vc_files"; then
1047 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1048 echo "Try 'gnulib-tool --help' for more information." 1>&2
1049 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1050 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1055 if test -n "$pobase" && test -z "$po_domain"; then
1056 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1057 echo "Try 'gnulib-tool --help' for more information." 1>&2
1060 if test -z "$pobase" && test -n "$po_domain"; then
1061 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1064 # Determine the minimum supported autoconf version from the project's
1066 DEFAULT_AUTOCONF_MINVERSION="2.59"
1067 autoconf_minversion=
1069 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1070 if test -f "$destdir"/configure.ac; then
1071 configure_ac="$destdir/configure.ac"
1073 if test -f "$destdir"/configure.in; then
1074 configure_ac="$destdir/configure.in"
1078 if test -f configure.ac; then
1079 configure_ac="configure.ac"
1081 if test -f configure.in; then
1082 configure_ac="configure.in"
1086 if test -n "$configure_ac"; then
1087 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1088 # because when some m4 files are omitted from a CVS repository,
1089 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1090 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1091 # autom4te: m4 failed with exit status: 1
1098 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1100 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1101 if test -n "$prereqs"; then
1102 autoconf_minversion=`
1103 for version in $prereqs; do echo $version; done |
1104 LC_ALL=C sort -nru | sed 1q
1108 if test -z "$autoconf_minversion"; then
1109 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1111 case "$autoconf_minversion" in
1112 1.* | 2.[0-4]* | 2.5[0-8]*)
1113 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1116 # Remove trailing slashes from the directory names. This is necessary for
1117 # m4base (to avoid an error in func_import) and optional for the others.
1118 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1119 case "$local_gnulib_dir" in
1120 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1122 case "$sourcebase" in
1123 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1126 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1129 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1132 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1134 case "$testsbase" in
1135 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1138 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1144 trap 'exit_status=$?
1145 if test "$signal" != 0; then
1146 echo "caught signal $signal" >&2
1149 exit $exit_status' 0
1150 for signal in 1 2 3 13 15; do
1151 trap '{ signal='$signal'; func_exit 1; }' $signal
1155 # func_lookup_file file
1156 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1159 # - local_gnulib_dir from --local-dir
1161 # - lookedup_file name of the merged (combined) file
1162 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1166 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1167 lookedup_file="$local_gnulib_dir/$lkfile"
1170 if test -f "$gnulib_dir/$lkfile"; then
1171 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1172 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1173 rm -f "$tmp/$lkbase"
1174 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1175 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1176 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1177 lookedup_file="$tmp/$lkbase"
1180 lookedup_file="$gnulib_dir/$lkfile"
1184 func_fatal_error "file $gnulib_dir/$lkfile not found"
1191 # - local_gnulib_dir from --local-dir
1194 # Filter out metainformation files like README, which are not modules.
1195 # Filter out unit test modules; they can be retrieved through
1196 # --extract-tests-module if desired.
1198 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1199 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1200 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1203 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1204 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1205 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1206 -e '/^README$/d' -e '/\/README$/d' \
1207 -e '/^TEMPLATE$/d' \
1208 -e '/^TEMPLATE-EXTENDED$/d' \
1209 -e '/^TEMPLATE-TESTS$/d' \
1212 | sed -e '/-tests$/d' \
1216 # func_verify_module
1217 # verifies a module name
1219 # - local_gnulib_dir from --local-dir
1220 # - module module name argument
1221 func_verify_module ()
1223 if { test -f "$gnulib_dir/modules/$module" \
1224 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1225 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1226 && test "CVS" != "$module" \
1227 && test "ChangeLog" != "$module" \
1228 && test "COPYING" != "$module" \
1229 && test "README" != "$module" \
1230 && test "TEMPLATE" != "$module" \
1231 && test "TEMPLATE-EXTENDED" != "$module" \
1232 && test "TEMPLATE-TESTS" != "$module"; then
1233 # OK, $module is a correct module name.
1234 # Verify that building the module description with 'patch' succeeds.
1235 func_lookup_file "modules/$module"
1237 echo "gnulib-tool: module $module doesn't exist" 1>&2
1242 # func_verify_nontests_module
1243 # verifies a module name, excluding tests modules
1245 # - local_gnulib_dir from --local-dir
1246 # - module module name argument
1247 func_verify_nontests_module ()
1250 *-tests ) module= ;;
1251 * ) func_verify_module ;;
1255 # func_verify_tests_module
1256 # verifies a module name, considering only tests modules
1258 # - local_gnulib_dir from --local-dir
1259 # - module module name argument
1260 func_verify_tests_module ()
1263 *-tests ) func_verify_module ;;
1268 sed_extract_prog=':[ ]*$/ {
1271 s/^Description:[ ]*$//
1275 s/^Depends-on:[ ]*$//
1276 s/^configure\.ac-early:[ ]*$//
1277 s/^configure\.ac:[ ]*$//
1278 s/^Makefile\.am:[ ]*$//
1282 s/^Maintainer:[ ]*$//
1289 # func_get_description module
1291 # - local_gnulib_dir from --local-dir
1292 func_get_description ()
1294 func_lookup_file "modules/$1"
1295 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1298 # func_get_status module
1300 # - local_gnulib_dir from --local-dir
1303 func_lookup_file "modules/$1"
1304 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1307 # func_get_notice module
1309 # - local_gnulib_dir from --local-dir
1312 func_lookup_file "modules/$1"
1313 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1316 # func_get_filelist module
1318 # - local_gnulib_dir from --local-dir
1319 func_get_filelist ()
1321 func_lookup_file "modules/$1"
1322 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1323 echo m4/gnulib-common.m4
1324 case "$autoconf_minversion" in
1331 # func_get_dependencies module
1333 # - local_gnulib_dir from --local-dir
1334 func_get_dependencies ()
1336 # ${module}-tests always implicitly depends on ${module}.
1337 echo "$1" | sed -n -e 's/-tests$//p'
1338 # Then the explicit dependencies listed in the module description.
1339 func_lookup_file "modules/$1"
1340 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1343 # func_get_autoconf_early_snippet module
1345 # - local_gnulib_dir from --local-dir
1346 func_get_autoconf_early_snippet ()
1348 func_lookup_file "modules/$1"
1349 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1352 # func_get_autoconf_snippet module
1354 # - local_gnulib_dir from --local-dir
1355 func_get_autoconf_snippet ()
1357 func_lookup_file "modules/$1"
1358 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1361 # func_get_automake_snippet module
1363 # - local_gnulib_dir from --local-dir
1364 func_get_automake_snippet ()
1366 func_lookup_file "modules/$1"
1367 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1370 # *-tests module live in tests/, not lib/.
1371 # Synthesize an EXTRA_DIST augmentation.
1372 all_files=`func_get_filelist $1`
1373 tests_files=`for f in $all_files; do \
1375 tests/*) echo $f ;; \
1377 done | sed -e 's,^tests/,,'`
1378 extra_files="$tests_files"
1379 if test -n "$extra_files"; then
1380 echo "EXTRA_DIST +=" $extra_files
1385 # Synthesize an EXTRA_DIST augmentation.
1386 sed_combine_lines='/\\$/{
1393 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1394 already_mentioned_files=` \
1395 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1396 | sed -e "$sed_combine_lines" \
1397 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1398 all_files=`func_get_filelist $1`
1399 lib_files=`for f in $all_files; do \
1403 done | sed -e 's,^lib/,,'`
1404 # Remove $already_mentioned_files from $lib_files.
1405 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1406 extra_files=`func_reset_sigpipe; \
1407 for f in $already_mentioned_files; do echo $f; done \
1408 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1409 if test -n "$extra_files"; then
1410 echo "EXTRA_DIST +=" $extra_files
1413 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1414 # This is necessary so that automake can generate the right list of
1416 # A possible approach would be to use autom4te --trace of the redefined
1417 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1418 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1419 # inside autoconf's built-in macros are not missed).
1420 # But it's simpler and more robust to do it here, based on the file list.
1421 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1422 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1423 # automake will generate a useless dependency; this is harmless.
1425 relocatable-prog-wrapper) ;;
1427 sed_extract_c_files='/\.c$/p'
1428 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1429 if test -n "$extra_files"; then
1430 echo "EXTRA_lib_SOURCES +=" $extra_files
1435 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1436 buildaux_files=`for f in $all_files; do \
1438 build-aux/*) echo $f ;; \
1440 done | sed -e 's,^build-aux/,,'`
1441 if test -n "$buildaux_files"; then
1442 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1443 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1446 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1447 top_files=`for f in $all_files; do \
1451 done | sed -e 's,^top/,,'`
1452 if test -n "$top_files"; then
1453 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1454 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1461 # func_get_include_directive module
1463 # - local_gnulib_dir from --local-dir
1464 func_get_include_directive ()
1466 func_lookup_file "modules/$1"
1467 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1468 sed -e 's/^\(["<]\)/#include \1/'
1471 # func_get_link_directive module
1473 # - local_gnulib_dir from --local-dir
1474 func_get_link_directive ()
1476 func_lookup_file "modules/$1"
1477 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1480 # func_get_license module
1482 # - local_gnulib_dir from --local-dir
1485 func_lookup_file "modules/$1"
1486 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1487 # The default is GPL.
1489 } | sed -e 's,^ *$,,' | sed -e 1q
1492 # func_get_maintainer module
1494 # - local_gnulib_dir from --local-dir
1495 func_get_maintainer ()
1497 func_lookup_file "modules/$1"
1498 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1501 # func_get_tests_module module
1503 # - local_gnulib_dir from --local-dir
1504 func_get_tests_module ()
1506 # The naming convention for tests modules is hardwired: ${module}-tests.
1507 if test -f "$gnulib_dir/modules/$1"-tests \
1508 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1509 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1514 # func_acceptable module
1515 # tests whether a module is acceptable.
1517 # - avoidlist list of modules to avoid
1520 for avoid in $avoidlist; do
1521 if test "$avoid" = "$1"; then
1528 # func_modules_transitive_closure
1530 # - local_gnulib_dir from --local-dir
1531 # - modules list of specified modules
1532 # - inctests true if tests should be included, blank otherwise
1533 # - incobsolete true if obsolete modules among dependencies should be
1534 # included, blank otherwise
1535 # - avoidlist list of modules to avoid
1536 # - tmp pathname of a temporary directory
1538 # - modules list of modules, including dependencies
1539 func_modules_transitive_closure ()
1541 # In order to process every module only once (for speed), process an "input
1542 # list" of modules, producing an "output list" of modules. During each round,
1543 # more modules can be queued in the input list. Once a module on the input
1544 # list has been processed, it is added to the "handled list", so we can avoid
1545 # to process it again.
1547 inmodules="$modules"
1549 while test -n "$inmodules"; do
1550 inmodules_this_round="$inmodules"
1551 inmodules= # Accumulator, queue for next round
1552 for module in $inmodules_this_round; do
1554 if test -n "$module"; then
1555 if func_acceptable $module; then
1556 func_append outmodules " $module"
1557 deps=`func_get_dependencies $module`
1558 # Duplicate dependencies are harmless, but Jim wants a warning.
1559 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1560 if test -n "$duplicated_deps"; then
1561 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1563 for dep in $deps; do
1564 if test -n "$incobsolete" \
1565 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
1566 func_append inmodules " $dep"
1569 if test -n "$inctests"; then
1570 testsmodule=`func_get_tests_module $module`
1571 if test -n "$testsmodule"; then
1572 func_append inmodules " $testsmodule"
1578 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1579 # Remove $handledmodules from $inmodules.
1580 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1581 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1583 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1584 rm -f "$tmp"/queued-modules
1587 # func_modules_add_dummy
1589 # - local_gnulib_dir from --local-dir
1590 # - modules list of modules, including dependencies
1592 # - modules list of modules, including 'dummy' if needed
1593 func_modules_add_dummy ()
1595 # Determine whether any module provides a lib_SOURCES augmentation.
1597 sed_remove_backslash_newline=':a
1604 for module in $modules; do
1605 func_verify_nontests_module
1606 if test -n "$module"; then
1607 # Extract the value of "lib_SOURCES += ...".
1608 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1609 # Ignore .h files since they are not compiled.
1613 have_lib_SOURCES=yes
1620 # Add the dummy module, to make sure the library will be non-empty.
1621 if test -z "$have_lib_SOURCES"; then
1622 if func_acceptable "dummy"; then
1623 func_append modules " dummy"
1628 # func_modules_notice
1630 # - local_gnulib_dir from --local-dir
1631 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1632 # - modules list of modules, including dependencies
1633 func_modules_notice ()
1635 if test $verbose -ge -1; then
1636 for module in $modules; do
1638 if test -n "$module"; then
1639 msg=`func_get_notice $module`
1640 if test -n "$msg"; then
1641 echo "Notice from module $module:"
1642 echo "$msg" | sed -e 's/^/ /'
1649 # func_modules_to_filelist
1651 # - local_gnulib_dir from --local-dir
1652 # - modules list of modules, including dependencies
1654 # - files list of files
1655 func_modules_to_filelist ()
1658 for module in $modules; do
1660 if test -n "$module"; then
1661 fs=`func_get_filelist $module`
1662 func_append files " $fs"
1665 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1668 # func_execute_command command [args...]
1669 # Executes a command.
1670 # Uses also the variables
1671 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1672 func_execute_command ()
1674 if test $verbose -ge 0; then
1678 # Commands like automake produce output to stderr even when they succeed.
1679 # Turn this output off if the command succeeds.
1680 "$@" > "$tmp"/cmdout 2>&1
1682 if test $cmdret = 0; then
1686 cat "$tmp"/cmdout 1>&2
1693 # func_emit_lib_Makefile_am
1694 # emits the contents of library makefile to standard output.
1696 # - local_gnulib_dir from --local-dir
1697 # - modules list of modules, including dependencies
1698 # - libname library name
1699 # - pobase directory relative to destdir where to place *.po files
1700 # - auxdir directory relative to destdir where to place build aux files
1701 # - makefile_name from --makefile-name
1702 # - libtool true if libtool will be used, false or blank otherwise
1703 # - macro_prefix prefix of gl_LIBOBJS macros to use
1704 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1705 # - actioncmd (optional) command that will reproduce this invocation
1706 # - for_test true if creating a package for testing, false otherwise
1707 # - destfile filename relative to destdir of makefile being generated
1709 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1710 # list of edits to be done to Makefile.am variables
1712 # - uses_subdirs nonempty if object files in subdirs exist
1713 func_emit_lib_Makefile_am ()
1715 # When creating an includable Makefile.am snippet, augment variables with
1716 # += instead of assigning them.
1717 if test -n "$makefile_name"; then
1722 if test "$libtool" = true; then
1725 sed_eliminate_LDFLAGS="$sed_noop"
1729 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1732 # When creating a package for testing: Attempt to provoke failures,
1733 # especially link errors, already during "make" rather than during
1734 # "make check", because "make check" is not possible in a cross-compiling
1735 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1736 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1738 sed_transform_check_PROGRAMS="$sed_noop"
1740 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1741 echo "## Process this file with automake to produce Makefile.in."
1742 func_emit_copyright_notice
1743 if test -n "$actioncmd"; then
1744 echo "# Reproduce by: $actioncmd"
1749 for module in $modules; do
1750 func_verify_nontests_module
1751 if test -n "$module"; then
1753 func_get_automake_snippet "$module" |
1754 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1755 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1756 -e "$sed_eliminate_LDFLAGS" \
1757 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1758 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1759 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1760 -e "$sed_transform_check_PROGRAMS"
1761 if test "$module" = 'alloca'; then
1762 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1763 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1766 # Skip the contents if it's entirely empty.
1767 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1768 echo "## begin gnulib module $module"
1771 echo "## end gnulib module $module"
1775 # Test whether there are some source files in subdirectories.
1776 for f in `func_get_filelist "$module"`; do
1787 if test -z "$makefile_name"; then
1788 # If there are source files in subdirectories, prevent collision of the
1789 # object files (example: hash.c and libxml/hash.c).
1791 if test -n "$uses_subdirs"; then
1792 subdir_options=' subdir-objects'
1794 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1797 if test -z "$makefile_name"; then
1799 echo "noinst_HEADERS ="
1800 echo "noinst_LIBRARIES ="
1801 echo "noinst_LTLIBRARIES ="
1802 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1803 # if you specify pkgdata_DATA to empty. This is a workaround.
1804 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1805 echo "pkgdata_DATA ="
1808 echo "BUILT_SOURCES ="
1811 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1812 if test -z "$makefile_name"; then
1813 echo "MOSTLYCLEANDIRS ="
1815 echo "DISTCLEANFILES ="
1816 echo "MAINTAINERCLEANFILES ="
1818 # Execute edits that apply to the Makefile.am being generated.
1820 while test $edit != $makefile_am_edits; do
1821 edit=`expr $edit + 1`
1822 eval dir=\"\$makefile_am_edit${edit}_dir\"
1823 eval var=\"\$makefile_am_edit${edit}_var\"
1824 eval val=\"\$makefile_am_edit${edit}_val\"
1825 if test -n "$var"; then
1826 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
1827 echo "${var} += ${val}"
1828 eval "makefile_am_edit${edit}_var="
1832 if test -z "$makefile_name"; then
1834 echo "AM_CPPFLAGS ="
1837 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1838 # One of the snippets already specifies an installation location for the
1839 # library. Don't confuse automake by saying it should not be installed.
1842 # By default, the generated library should not be installed.
1843 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1846 echo "${libname}_${libext}_SOURCES ="
1847 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1848 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
1849 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1850 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1851 echo "EXTRA_${libname}_${libext}_SOURCES ="
1852 if test "$libtool" = true; then
1853 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1856 if test -n "$pobase"; then
1857 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1860 cat allsnippets.tmp \
1861 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1863 echo "mostlyclean-local: mostlyclean-generic"
1864 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1865 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1866 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1870 rm -f allsnippets.tmp
1873 # func_emit_po_Makevars
1874 # emits the contents of po/ makefile parameterization to standard output.
1876 # - local_gnulib_dir from --local-dir
1877 # - sourcebase directory relative to destdir where to place source code
1878 # - pobase directory relative to destdir where to place *.po files
1879 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1880 func_emit_po_Makevars ()
1882 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1883 func_emit_copyright_notice
1885 echo "# Usually the message domain is the same as the package name."
1886 echo "# But here it has a '-gnulib' suffix."
1887 echo "DOMAIN = ${po_domain}-gnulib"
1889 echo "# These two variables depend on the location of this directory."
1890 echo "subdir = ${pobase}"
1891 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1894 # These options get passed to xgettext.
1895 XGETTEXT_OPTIONS = \
1896 --keyword=_ --flag=_:1:pass-c-format \
1897 --keyword=N_ --flag=N_:1:pass-c-format \
1898 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1899 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1900 --flag=error:3:c-format --flag=error_at_line:5:c-format
1902 # This is the copyright holder that gets inserted into the header of the
1903 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1904 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1906 # This is the email address or URL to which the translators shall report
1907 # bugs in the untranslated strings:
1908 # - Strings which are not entire sentences, see the maintainer guidelines
1909 # in the GNU gettext documentation, section 'Preparing Strings'.
1910 # - Strings which use unclear terms or require additional context to be
1912 # - Strings which make invalid assumptions about notation of date, time or
1914 # - Pluralisation problems.
1915 # - Incorrect English spelling.
1916 # - Incorrect formatting.
1917 # It can be your email address, or a mailing list address where translators
1918 # can write to without being subscribed, or the URL of a web page through
1919 # which the translators can contact you.
1920 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1922 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1923 # message catalogs shall be used. It is usually empty.
1924 EXTRA_LOCALE_CATEGORIES =
1926 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1927 # context. Possible values are "yes" and "no". Set this to yes if the
1928 # package uses functions taking also a message context, like pgettext(), or
1929 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1934 # func_emit_po_POTFILES_in
1935 # emits the file list to be passed to xgettext to standard output.
1937 # - local_gnulib_dir from --local-dir
1938 # - sourcebase directory relative to destdir where to place source code
1939 # - files list of new files
1940 func_emit_po_POTFILES_in ()
1942 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1943 func_emit_copyright_notice
1945 echo "# List of files which contain translatable strings."
1946 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1949 # func_emit_tests_Makefile_am
1950 # emits the contents of tests makefile to standard output.
1952 # - local_gnulib_dir from --local-dir
1953 # - modules list of modules, including dependencies
1954 # - libname library name
1955 # - auxdir directory relative to destdir where to place build aux files
1956 # - makefile_name from --makefile-name
1957 # - libtool true if libtool will be used, false or blank otherwise
1958 # - sourcebase relative directory containing lib source code
1959 # - m4base relative directory containing autoconf macros
1960 # - testsbase relative directory containing unit test code
1961 # - macro_prefix prefix of gl_LIBOBJS macros to use
1962 # - for_test true if creating a package for testing, false otherwise
1963 # - use_libtests true if a libtests.a should be built, false otherwise
1964 # - destfile filename relative to destdir of makefile being generated
1966 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1967 # list of edits to be done to Makefile.am variables
1969 # - uses_subdirs nonempty if object files in subdirs exist
1970 func_emit_tests_Makefile_am ()
1972 if test "$libtool" = true; then
1974 sed_eliminate_LDFLAGS="$sed_noop"
1977 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1980 # When creating a package for testing: Attempt to provoke failures,
1981 # especially link errors, already during "make" rather than during
1982 # "make check", because "make check" is not possible in a cross-compiling
1983 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1984 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1986 sed_transform_check_PROGRAMS="$sed_noop"
1988 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1989 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1990 echo "## Process this file with automake to produce Makefile.in."
1991 func_emit_copyright_notice
1995 for module in $modules; do
1997 func_verify_tests_module
2001 if test -n "$module"; then
2003 func_get_automake_snippet "$module" |
2004 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2005 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2006 -e "$sed_eliminate_LDFLAGS" \
2007 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2008 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2009 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2010 -e "$sed_transform_check_PROGRAMS"
2011 if $use_libtests && test "$module" = 'alloca'; then
2012 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2013 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2016 # Skip the contents if it's entirely empty.
2017 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
2018 echo "## begin gnulib module $module"
2021 echo "## end gnulib module $module"
2025 # Test whether there are some source files in subdirectories.
2026 for f in `func_get_filelist "$module"`; do
2028 lib/*/*.c | tests/*/*.c)
2037 # Generate dependencies here, since it eases the debugging of test failures.
2038 # If there are source files in subdirectories, prevent collision of the
2039 # object files (example: hash.c and libxml/hash.c).
2041 if test -n "$uses_subdirs"; then
2042 subdir_options=' subdir-objects'
2044 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2047 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2050 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2051 # variable is needed to avoid an error from automake:
2052 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2055 echo "TESTS_ENVIRONMENT ="
2056 echo "noinst_PROGRAMS ="
2057 if ! $for_test; then
2058 echo "check_PROGRAMS ="
2060 echo "noinst_HEADERS ="
2061 echo "noinst_LIBRARIES ="
2062 if $use_libtests; then
2064 echo "noinst_LIBRARIES += libtests.a"
2066 echo "check_LIBRARIES = libtests.a"
2069 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2070 # if you specify pkgdata_DATA to empty. This is a workaround.
2071 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
2072 echo "pkgdata_DATA ="
2075 echo "BUILT_SOURCES ="
2077 echo "MOSTLYCLEANFILES = core *.stackdump"
2078 echo "MOSTLYCLEANDIRS ="
2080 echo "DISTCLEANFILES ="
2081 echo "MAINTAINERCLEANFILES ="
2082 # Execute edits that apply to the Makefile.am being generated.
2084 while test $edit != $makefile_am_edits; do
2085 edit=`expr $edit + 1`
2086 eval dir=\"\$makefile_am_edit${edit}_dir\"
2087 eval var=\"\$makefile_am_edit${edit}_var\"
2088 eval val=\"\$makefile_am_edit${edit}_val\"
2089 if test -n "$var"; then
2090 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2091 echo "${var} += ${val}"
2092 eval "makefile_am_edit${edit}_var="
2097 echo "AM_CPPFLAGS = \\"
2098 echo " -I. -I\$(srcdir) \\"
2099 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2100 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2102 local_ldadd_before=''
2103 local_ldadd_after=''
2104 if $use_libtests; then
2105 # All test programs need to be linked with libtests.a.
2106 # It needs to be passed to the linker before ${libname}.${libext}, since
2107 # the tests-related modules depend on the main modules.
2108 # It also needs to be passed to the linker after ${libname}.${libext}
2109 # because the latter might contain incomplete modules (such as the 'error'
2110 # module whose dependency to 'progname' is voluntarily omitted).
2111 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2113 local_ldadd_before=' libtests.a'
2114 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2116 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2118 if $use_libtests; then
2119 echo "libtests_a_SOURCES ="
2120 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2121 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2122 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2123 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2124 echo "EXTRA_libtests_a_SOURCES ="
2125 # The circular dependency in LDADD requires this.
2126 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2129 cat allsnippets.tmp \
2130 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2131 echo "# Clean up after Solaris cc."
2133 echo " rm -rf SunWS_cache"
2135 echo "mostlyclean-local: mostlyclean-generic"
2136 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2137 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2138 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2142 rm -f allsnippets.tmp
2145 # func_emit_initmacro_start macro_prefix
2146 # emits the first few statements of the gl_INIT macro to standard output.
2147 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2148 func_emit_initmacro_start ()
2150 macro_prefix_arg="$1"
2151 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2152 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2153 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2154 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2156 # Furthermore it avoids an automake error like this when a Makefile.am
2157 # that uses pieces of gnulib also uses $(LIBOBJ):
2158 # automatically discovered file `error.c' should not be explicitly mentioned
2159 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2160 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2161 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2162 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2163 # automatically discovered file `error.c' should not be explicitly mentioned
2164 # We let automake know about the files to be distributed through the
2165 # EXTRA_lib_SOURCES variable.
2166 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2167 # Create data variables for checking the presence of files that are mentioned
2168 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2169 # because we want the check to happen when the configure file is created,
2170 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2171 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2172 # in which to expect them.
2173 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2174 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2178 # func_emit_initmacro_end macro_prefix
2179 # emits the last few statements of the gl_INIT macro to standard output.
2180 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2181 func_emit_initmacro_end ()
2183 macro_prefix_arg="$1"
2184 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2185 # The check is performed only when autoconf is run from the directory where
2186 # the configure.ac resides; if it is run from a different directory, the
2188 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2189 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2190 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2191 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2192 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2196 echo " m4_if(m4_sysval, [0], [],"
2197 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2199 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2200 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2201 echo " m4_popdef([AC_LIBSOURCES])"
2202 echo " m4_popdef([AC_REPLACE_FUNCS])"
2203 echo " m4_popdef([AC_LIBOBJ])"
2204 echo " AC_CONFIG_COMMANDS_PRE(["
2205 echo " ${macro_prefix_arg}_libobjs="
2206 echo " ${macro_prefix_arg}_ltlibobjs="
2207 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2208 echo " # Remove the extension."
2209 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2210 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2211 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2212 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2215 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2216 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2220 # func_emit_initmacro_done macro_prefix sourcebase
2221 # emits a few statements after the gl_INIT macro to standard output.
2222 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2223 # - sourcebase directory relative to destdir where to place source code
2224 func_emit_initmacro_done ()
2226 macro_prefix_arg="$1"
2229 echo "# Like AC_LIBOBJ, except that the module name goes"
2230 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2231 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2232 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2233 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2236 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2237 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2238 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2239 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2240 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2243 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2244 echo "# expected is derived from the gnulib-tool parameterization,"
2245 echo "# and alloca is special cased (for the alloca-opt module)."
2246 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2247 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2248 echo " m4_foreach([_gl_NAME], [\$1], ["
2249 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2250 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2251 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2257 # func_import modules
2258 # Uses also the variables
2259 # - destdir target directory
2260 # - local_gnulib_dir from --local-dir
2261 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2262 # - libname library name
2263 # - sourcebase directory relative to destdir where to place source code
2264 # - m4base directory relative to destdir where to place *.m4 macros
2265 # - pobase directory relative to destdir where to place *.po files
2266 # - docbase directory relative to destdir where to place doc files
2267 # - testsbase directory relative to destdir where to place unit test code
2268 # - auxdir directory relative to destdir where to place build aux files
2269 # - inctests true if --with-tests was given, blank otherwise
2270 # - incobsolete true if --with-obsolete was given, blank otherwise
2271 # - avoidlist list of modules to avoid, from --avoid
2272 # - lgpl yes or a number if library's license shall be LGPL,
2274 # - makefile_name from --makefile-name
2275 # - libtool true if --libtool was given, false if --no-libtool was
2276 # given, blank otherwise
2277 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2278 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2279 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2280 # - vc_files true if --vc-files was given, false if --no-vc-files was
2281 # given, blank otherwise
2282 # - autoconf_minversion minimum supported autoconf version
2283 # - doit : if actions shall be executed, false if only to be printed
2284 # - symbolic true if files should be symlinked, copied otherwise
2285 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2287 # - do_copyrights true if copyright notices in files should be replaced,
2291 # Get the cached settings.
2292 cached_local_gnulib_dir=
2293 cached_specified_modules=
2304 cached_makefile_name=
2306 cached_macro_prefix=
2310 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2311 cached_libtool=false
2317 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
2327 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
2329 /gl_WITH_OBSOLETE/ {
2330 s,^.*$,cached_incobsolete=true,p
2333 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
2336 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
2339 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
2342 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
2345 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
2348 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
2351 s,^.*$,cached_inctests=true,p
2354 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
2357 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
2360 s,^.*$,cached_lgpl=yes,p
2362 /gl_MAKEFILE_NAME(/ {
2363 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
2366 s,^.*$,cached_libtool=true,p
2368 /gl_MACRO_PREFIX(/ {
2369 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
2372 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
2375 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
2377 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2378 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2383 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2384 s,^.*$,cached_files=",p
2397 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2401 # Merge the cached settings with the specified ones.
2402 # The m4base must be the same as expected from the pathname.
2403 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2404 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2406 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2407 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2408 if test -z "$local_gnulib_dir"; then
2409 if test -n "$cached_local_gnulib_dir"; then
2412 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2414 case "$cached_local_gnulib_dir" in
2416 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2418 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2419 local_gnulib_dir="$relconcat" ;;
2424 # Append the cached and the specified module names. So that
2425 # "gnulib-tool --import foo" means to add the module foo.
2426 specified_modules="$cached_specified_modules $1"
2427 # Included obsolete modules among the dependencies if specified either way.
2428 if test -z "$incobsolete"; then
2429 incobsolete="$cached_incobsolete"
2431 # Append the cached and the specified avoidlist. This is probably better
2432 # than dropping the cached one when --avoid is specified at least once.
2433 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2434 avoidlist=`echo $avoidlist`
2436 # The sourcebase defaults to the cached one.
2437 if test -z "$sourcebase"; then
2438 sourcebase="$cached_sourcebase"
2439 if test -z "$sourcebase"; then
2440 func_fatal_error "missing --source-base option"
2443 # The pobase defaults to the cached one.
2444 if test -z "$pobase"; then
2445 pobase="$cached_pobase"
2447 # The docbase defaults to the cached one.
2448 if test -z "$docbase"; then
2449 docbase="$cached_docbase"
2450 if test -z "$docbase"; then
2451 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."
2454 # The testsbase defaults to the cached one.
2455 if test -z "$testsbase"; then
2456 testsbase="$cached_testsbase"
2457 if test -z "$testsbase"; then
2458 func_fatal_error "missing --tests-base option"
2461 # Require the tests if specified either way.
2462 if test -z "$inctests"; then
2463 inctests="$cached_inctests"
2465 # The libname defaults to the cached one.
2466 if test -z "$supplied_libname"; then
2467 libname="$cached_libname"
2468 if test -z "$libname"; then
2469 func_fatal_error "missing --lib option"
2472 # Require LGPL if specified either way.
2473 if test -z "$lgpl"; then
2476 # The makefile_name defaults to the cached one.
2477 if test -z "$makefile_name"; then
2478 makefile_name="$cached_makefile_name"
2480 # Use libtool if specified either way, or if guessed.
2481 if test -z "$libtool"; then
2482 if test -n "$cached_m4base"; then
2483 libtool="$cached_libtool"
2485 libtool="$guessed_libtool"
2488 # The macro_prefix defaults to the cached one.
2489 if test -z "$macro_prefix"; then
2490 macro_prefix="$cached_macro_prefix"
2491 if test -z "$macro_prefix"; then
2492 func_fatal_error "missing --macro-prefix option"
2495 # The po_domain defaults to the cached one.
2496 if test -z "$po_domain"; then
2497 po_domain="$cached_po_domain"
2499 # The vc_files defaults to the cached one.
2500 if test -z "$vc_files"; then
2501 vc_files="$cached_vc_files"
2504 # Canonicalize the list of specified modules.
2505 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2507 # Determine final module list.
2508 modules="$specified_modules"
2509 func_modules_transitive_closure
2510 if test $verbose -ge 0; then
2511 echo "Module list with included dependencies:"
2512 echo "$modules" | sed -e 's/^/ /'
2514 final_modules="$modules"
2516 # Determine main module list and tests-related module list separately.
2517 # The main module list is the transitive closure of the specified modules,
2518 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2519 # is specified, it will consist only of LGPLed source.
2520 # The tests-related module list is the transitive closure of the specified
2521 # modules, including tests modules, minus the main module list. Its lib/*
2522 # sources (brought in through dependencies of *-tests modules) go into
2523 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2524 # Determine main module list.
2525 saved_inctests="$inctests"
2527 modules="$specified_modules"
2528 func_modules_transitive_closure
2529 main_modules="$modules"
2530 inctests="$saved_inctests"
2531 if test $verbose -ge 1; then
2532 echo "Main module list:"
2533 echo "$main_modules" | sed -e 's/^/ /'
2535 # Determine tests-related module list.
2536 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2537 testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2538 if test $verbose -ge 1; then
2539 echo "Tests-related module list:"
2540 echo "$testsrelated_modules" | sed -e 's/^/ /'
2543 # Add the dummy module to the main module list if needed.
2544 modules="$main_modules"
2545 func_modules_add_dummy
2546 main_modules="$modules"
2548 # Determine whether a $testsbase/libtests.a is needed.
2550 for module in $testsrelated_modules; do
2551 func_verify_nontests_module
2552 if test -n "$module"; then
2553 all_files=`func_get_filelist $module`
2554 # Test whether some file in $all_files lies in lib/.
2555 for f in $all_files; do
2566 # Add the dummy module to the tests-related module list if needed.
2567 if $use_libtests; then
2568 modules="$testsrelated_modules"
2569 func_modules_add_dummy
2570 testsrelated_modules="$modules"
2573 # If --lgpl, verify that the licenses of modules are compatible.
2574 if test -n "$lgpl"; then
2575 license_incompatibilities=
2576 for module in $main_modules; do
2577 license=`func_get_license $module`
2579 'GPLed build tool') ;;
2580 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2586 *) func_append license_incompatibilities "$module $license$nl" ;;
2592 *) func_append license_incompatibilities "$module $license$nl" ;;
2595 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2600 if test -n "$license_incompatibilities"; then
2601 # Format the license incompatibilities as a table.
2602 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
2603 s,^\(.................................................[^ ]*\) *, \1 ,'
2604 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
2605 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
2609 # Show banner notice of every module.
2610 modules="$main_modules"
2613 # Determine script to apply to imported library files.
2614 sed_transform_lib_file=
2615 for module in $main_modules; do
2616 if test $module = config-h; then
2617 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2618 sed_transform_lib_file=$sed_transform_lib_file'
2619 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2624 sed_transform_main_lib_file="$sed_transform_lib_file"
2625 if test -n "$do_copyrights"; then
2626 if test -n "$lgpl"; then
2630 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2631 s/GNU General/GNU Lesser General/g
2635 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2636 s/GNU General/GNU Lesser General/g
2637 s/version [23]\([ ,]\)/version 2.1\1/g
2640 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2644 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2645 s/GNU Lesser General/GNU General/g
2646 s/GNU Library General/GNU General/g
2647 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2652 # Determine script to apply to library files that go into $testsbase/.
2653 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2654 if test -n "$do_copyrights"; then
2656 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2657 s/GNU Lesser General/GNU General/g
2658 s/GNU Library General/GNU General/g
2659 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2663 # Determine the final file lists.
2664 # They must be computed separately, because files in lib/* go into
2665 # $sourcebase/ if they are in the main file list but into $testsbase/
2666 # if they are in the tests-related file list. Furthermore lib/dummy.c
2668 # Determine final main file list.
2669 modules="$main_modules"
2670 func_modules_to_filelist
2672 # Determine final tests-related file list.
2673 modules="$testsrelated_modules"
2674 func_modules_to_filelist
2675 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2676 # Merge both file lists.
2677 sed_remove_empty_lines='/^$/d'
2678 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2679 if test $verbose -ge 0; then
2681 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2682 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2686 || func_fatal_error "refusing to do nothing"
2688 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2689 new_files="$files m4/gnulib-tool.m4"
2690 old_files="$cached_files"
2691 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2692 func_append old_files " m4/gnulib-tool.m4"
2695 sed_rewrite_old_files="\
2696 s,^build-aux/,$auxdir/,
2697 s,^doc/,$cached_docbase/,
2698 s,^lib/,$cached_sourcebase/,
2699 s,^m4/,$cached_m4base/,
2700 s,^tests/,$cached_testsbase/,
2701 s,^tests=lib/,$cached_testsbase/,
2703 sed_rewrite_new_files="\
2704 s,^build-aux/,$auxdir/,
2706 s,^lib/,$sourcebase/,
2708 s,^tests/,$testsbase/,
2709 s,^tests=lib/,$testsbase/,
2712 # Create directories.
2713 { echo "$sourcebase"
2715 if test -n "$pobase"; then
2718 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2719 if test -n "$docfiles"; then
2722 if test -n "$inctests"; then
2726 for f in $files; do echo $f; done \
2727 | sed -e "$sed_rewrite_new_files" \
2728 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2731 { # Rearrange file descriptors. Needed because "while ... done < ..."
2732 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2733 exec 5<&0 < "$tmp"/dirs
2735 if test ! -d "$destdir/$d"; then
2737 echo "Creating directory $destdir/$d"
2738 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2740 echo "Create directory $destdir/$d"
2747 # func_dest_tmpfilename file
2748 # determines the name of a temporary file (file is relative to destdir).
2750 # - tmpfile absolute filename of the temporary file
2751 func_dest_tmpfilename ()
2754 # Put the new contents of $file in a file in the same directory (needed
2755 # to guarantee that an 'mv' to "$destdir/$file" works).
2756 tmpfile="$destdir/$1.tmp"
2758 # Put the new contents of $file in a file in a temporary directory
2759 # (because the directory of "$file" might not exist).
2760 tmpfile="$tmp"/`basename "$1"`.tmp
2764 # Copy files or make symbolic links. Remove obsolete files.
2768 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2769 # representing the files according to the last gnulib-tool invocation.
2770 for f in $old_files; do echo $f; done \
2771 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2774 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2775 # representing the files after this gnulib-tool invocation.
2776 for f in $new_files; do echo $f; done \
2777 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2780 # First the files that are in old-files, but not in new-files:
2781 sed_take_first_column='s,'"$delimiter"'.*,,'
2782 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2783 # Remove the file. Do nothing if the user already removed it.
2784 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2786 echo "Removing file $g (backup in ${g}~)"
2787 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2789 echo "Remove file $g (backup in ${g}~)"
2791 func_append removed_files "$g$nl"
2794 # func_add_or_update handles a file that ought to be present afterwards.
2796 # - f the original file name
2797 # - g the rewritten file name
2798 # - already_present nonempty if the file already exists, empty otherwise
2799 func_add_or_update ()
2803 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2805 func_dest_tmpfilename "$g"
2806 func_lookup_file "$f"
2807 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2808 if test -n "$sed_transform_main_lib_file"; then
2811 sed -e "$sed_transform_main_lib_file" \
2812 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2816 if test -n "$sed_transform_testsrelated_lib_file"; then
2819 sed -e "$sed_transform_testsrelated_lib_file" \
2820 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2824 if test -f "$destdir/$g"; then
2825 # The file already exists.
2826 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2827 : # The file has not changed.
2831 if test -n "$already_present"; then
2832 echo "Updating file $g (backup in ${g}~)"
2834 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2836 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2837 if { test -n "$symbolic" \
2838 || { test -n "$lsymbolic" \
2839 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2840 && test -z "$lookedup_tmp" \
2841 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2842 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2844 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2847 if test -n "$already_present"; then
2848 echo "Update file $g (backup in ${g}~)"
2850 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2856 # Don't protest if the file should be there but isn't: it happens
2857 # frequently that developers don't put autogenerated files into CVS.
2859 echo "Copying file $g"
2860 if { test -n "$symbolic" \
2861 || { test -n "$lsymbolic" \
2862 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2863 && test -z "$lookedup_tmp" \
2864 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2865 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2867 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2872 func_append added_files "$g$nl"
2876 # Then the files that are in new-files, but not in old-files:
2877 sed_take_last_column='s,^.*'"$delimiter"',,'
2879 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2880 | sed -e "$sed_take_last_column" \
2881 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2882 { # Rearrange file descriptors. Needed because "while ... done < ..."
2883 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2884 exec 5<&0 < "$tmp"/added-files
2890 # Then the files that are in new-files and in old-files:
2891 already_present=true
2892 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2893 | sed -e "$sed_take_last_column" \
2894 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2895 { # Rearrange file descriptors. Needed because "while ... done < ..."
2896 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2897 exec 5<&0 < "$tmp"/kept-files
2904 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2905 actioncmd="gnulib-tool --import"
2906 func_append actioncmd " --dir=$destdir"
2907 if test -n "$local_gnulib_dir"; then
2908 func_append actioncmd " --local-dir=$local_gnulib_dir"
2910 func_append actioncmd " --lib=$libname"
2911 func_append actioncmd " --source-base=$sourcebase"
2912 func_append actioncmd " --m4-base=$m4base"
2913 if test -n "$pobase"; then
2914 func_append actioncmd " --po-base=$pobase"
2916 func_append actioncmd " --doc-base=$docbase"
2917 func_append actioncmd " --tests-base=$testsbase"
2918 func_append actioncmd " --aux-dir=$auxdir"
2919 if test -n "$inctests"; then
2920 func_append actioncmd " --with-tests"
2922 if test -n "$incobsolete"; then
2923 func_append actioncmd " --with-obsolete"
2925 for module in $avoidlist; do
2926 func_append actioncmd " --avoid=$module"
2928 if test -n "$lgpl"; then
2929 if test "$lgpl" = yes; then
2930 func_append actioncmd " --lgpl"
2932 func_append actioncmd " --lgpl=$lgpl"
2935 if test -n "$makefile_name"; then
2936 func_append actioncmd " --makefile-name=$makefile_name"
2938 if test "$libtool" = true; then
2939 func_append actioncmd " --libtool"
2941 func_append actioncmd " --no-libtool"
2943 func_append actioncmd " --macro-prefix=$macro_prefix"
2944 if test -n "$po_domain"; then
2945 func_append actioncmd " --po-domain=$po_domain"
2947 if test -n "$vc_files"; then
2948 if test "$vc_files" = true; then
2949 func_append actioncmd " --vc-files"
2951 func_append actioncmd " --no-vc-files"
2954 func_append actioncmd " `echo $specified_modules`"
2956 # Default the makefile name to Makefile.am.
2957 if test -n "$makefile_name"; then
2958 makefile_am=$makefile_name
2960 makefile_am=Makefile.am
2963 # Create normal Makefile.ams.
2966 # Setup list of Makefile.am edits that are to be performed afterwards.
2967 # Some of these edits apply to files that we will generate; others are
2968 # under the responsibility of the developer.
2970 # func_note_Makefile_am_edit dir var value
2971 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
2973 func_note_Makefile_am_edit ()
2975 makefile_am_edits=`expr $makefile_am_edits + 1`
2976 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
2977 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
2978 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
2980 if test "$makefile_am" = Makefile.am; then
2981 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2982 sourcebase_base=`basename "$sourcebase"`
2983 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
2985 if test -n "$pobase"; then
2986 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
2987 pobase_base=`basename "$pobase"`
2988 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
2990 if test -n "$inctests"; then
2991 if test "$makefile_am" = Makefile.am; then
2992 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2993 testsbase_base=`basename "$testsbase"`
2994 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
2997 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
2999 # Find the first parent directory of $m4base that contains or will contain
3001 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3003 sed_butlast='s,[^/][^/]*//*$,,'
3004 dir1="${m4base}/"; dir2=""
3005 while test -n "$dir1" \
3006 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3007 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3008 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3009 || { test -n "$inctests" \
3010 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3011 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3012 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3013 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3015 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3018 # Create library makefile.
3019 func_dest_tmpfilename $sourcebase/$makefile_am
3020 destfile="$sourcebase/$makefile_am"
3021 modules="$main_modules"
3022 func_emit_lib_Makefile_am > "$tmpfile"
3023 if test -f "$destdir"/$sourcebase/$makefile_am; then
3024 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3028 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3029 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3030 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3032 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3038 echo "Creating $sourcebase/$makefile_am"
3039 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3041 echo "Create $sourcebase/$makefile_am"
3044 func_append added_files "$sourcebase/$makefile_am$nl"
3047 # Create po/ directory.
3048 if test -n "$pobase"; then
3049 # Create po makefile and auxiliary files.
3050 for file in Makefile.in.in remove-potcdate.sin; do
3051 func_dest_tmpfilename $pobase/$file
3052 func_lookup_file build-aux/po/$file
3053 cat "$lookedup_file" > "$tmpfile"
3054 if test -f "$destdir"/$pobase/$file; then
3055 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3059 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3060 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3061 mv -f "$tmpfile" "$destdir"/$pobase/$file
3063 echo "Update $pobase/$file (backup in $pobase/$file~)"
3069 echo "Creating $pobase/$file"
3070 mv -f "$tmpfile" "$destdir"/$pobase/$file
3072 echo "Create $pobase/$file"
3075 func_append added_files "$pobase/$file$nl"
3078 # Create po makefile parameterization, part 1.
3079 func_dest_tmpfilename $pobase/Makevars
3080 func_emit_po_Makevars > "$tmpfile"
3081 if test -f "$destdir"/$pobase/Makevars; then
3082 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3086 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3087 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3088 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3090 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3096 echo "Creating $pobase/Makevars"
3097 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3099 echo "Create $pobase/Makevars"
3102 func_append added_files "$pobase/Makevars$nl"
3104 # Create po makefile parameterization, part 2.
3105 func_dest_tmpfilename $pobase/POTFILES.in
3106 func_emit_po_POTFILES_in > "$tmpfile"
3107 if test -f "$destdir"/$pobase/POTFILES.in; then
3108 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3112 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3113 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3114 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3116 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3122 echo "Creating $pobase/POTFILES.in"
3123 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3125 echo "Create $pobase/POTFILES.in"
3128 func_append added_files "$pobase/POTFILES.in$nl"
3131 TP_URL="http://translationproject.org/latest/"
3132 TP_RSYNC_URI="translationproject.org::tp/latest/"
3134 echo "Fetching gnulib PO files from $TP_URL"
3135 (cd "$destdir"/$pobase \
3136 && { # Prefer rsync over wget if it is available, since it consumes
3137 # less network bandwidth, due to compression.
3138 if type rsync 2>/dev/null | grep / > /dev/null; then
3139 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3141 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3146 echo "Fetch gnulib PO files from $TP_URL"
3148 # Create po/LINGUAS.
3150 func_dest_tmpfilename $pobase/LINGUAS
3151 (cd "$destdir"/$pobase \
3152 && { echo '# Set of available languages.'
3153 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3156 if test -f "$destdir"/$pobase/LINGUAS; then
3157 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3160 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3161 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3162 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3165 echo "Creating $pobase/LINGUAS"
3166 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3167 func_append added_files "$pobase/LINGUAS$nl"
3170 if test -f "$destdir"/$pobase/LINGUAS; then
3171 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3173 echo "Create $pobase/LINGUAS"
3178 # Create m4/gnulib-cache.m4.
3179 func_dest_tmpfilename $m4base/gnulib-cache.m4
3181 func_emit_copyright_notice
3183 echo "# This file represents the specification of how gnulib-tool is used."
3184 echo "# It acts as a cache: It is written and read by gnulib-tool."
3185 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3186 echo "# like the configure.ac and various Makefile.am files."
3189 echo "# Specification in the form of a command-line invocation:"
3192 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3193 # Store the local_gnulib_dir relative to destdir.
3194 case "$local_gnulib_dir" in
3196 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3199 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3201 # destdir, local_gnulib_dir are both relative.
3202 func_relativize "$destdir" "$local_gnulib_dir"
3203 relative_local_gnulib_dir="$reldir" ;;
3206 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3208 echo "$specified_modules" | sed 's/^/ /g'
3210 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3211 echo "gl_AVOID([$avoidlist])"
3212 echo "gl_SOURCE_BASE([$sourcebase])"
3213 echo "gl_M4_BASE([$m4base])"
3214 echo "gl_PO_BASE([$pobase])"
3215 echo "gl_DOC_BASE([$docbase])"
3216 echo "gl_TESTS_BASE([$testsbase])"
3217 test -z "$inctests" || echo "gl_WITH_TESTS"
3218 echo "gl_LIB([$libname])"
3219 if test -n "$lgpl"; then
3220 if test "$lgpl" = yes; then
3223 echo "gl_LGPL([$lgpl])"
3226 echo "gl_MAKEFILE_NAME([$makefile_name])"
3227 if test "$libtool" = true; then
3230 echo "gl_MACRO_PREFIX([$macro_prefix])"
3231 echo "gl_PO_DOMAIN([$po_domain])"
3232 if test -n "$vc_files"; then
3233 echo "gl_VC_FILES([$vc_files])"
3236 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3237 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3241 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3242 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3243 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3245 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3249 echo "# gnulib-cache.m4 ends here"
3256 echo "Creating $m4base/gnulib-cache.m4"
3257 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3259 echo "Create $m4base/gnulib-cache.m4"
3265 # Create m4/gnulib-comp.m4.
3266 func_dest_tmpfilename $m4base/gnulib-comp.m4
3268 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3269 func_emit_copyright_notice
3271 echo "# This file represents the compiled summary of the specification in"
3272 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3273 echo "# to be invoked from configure.ac."
3274 echo "# In projects using CVS, this file can be treated like other built files."
3277 echo "# This macro should be invoked from $configure_ac, in the section"
3278 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3279 echo "# any checks for libraries, header files, types and library functions."
3280 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3282 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3283 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3284 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3285 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3286 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3287 if test -n "$uses_subdirs"; then
3288 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3290 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
3291 echo " AC_REQUIRE([AC_GNU_SOURCE])"
3293 for module in $final_modules; do
3295 if test -n "$module"; then
3296 func_get_autoconf_early_snippet "$module"
3299 | sed -e '/^$/d;' -e 's/^/ /'
3302 echo "# This macro should be invoked from $configure_ac, in the section"
3303 echo "# \"Check for header files, types and library functions\"."
3304 echo "AC_DEFUN([${macro_prefix}_INIT],"
3306 if test "$libtool" = true; then
3307 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3308 echo " gl_cond_libtool=true"
3310 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3311 echo " gl_cond_libtool=false"
3313 echo " gl_ltlibdeps="
3315 if test "$auxdir" != "build-aux"; then
3316 sed_replace_build_aux='
3318 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3319 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3323 sed_replace_build_aux="$sed_noop"
3325 func_emit_initmacro_start $macro_prefix
3326 echo " gl_source_base='$sourcebase'"
3327 for module in $main_modules; do
3329 if test -n "$module"; then
3330 func_get_autoconf_snippet "$module" \
3331 | sed -e '/^$/d;' -e 's/^/ /' \
3332 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3333 -e "$sed_replace_build_aux"
3334 if test "$module" = 'alloca' && test "$libtool" = true; then
3335 echo 'changequote(,)dnl'
3336 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3337 echo 'changequote([, ])dnl'
3338 echo 'AC_SUBST([LTALLOCA])'
3342 func_emit_initmacro_end $macro_prefix
3343 echo " gltests_libdeps="
3344 echo " gltests_ltlibdeps="
3345 func_emit_initmacro_start ${macro_prefix}tests
3346 echo " gl_source_base='$testsbase'"
3347 for module in $testsrelated_modules; do
3349 if test -n "$module"; then
3350 func_get_autoconf_snippet "$module" \
3351 | sed -e '/^$/d;' -e 's/^/ /' \
3352 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3353 -e "$sed_replace_build_aux" \
3354 -e 's/\$gl_cond_libtool/false/g' \
3355 -e 's/gl_libdeps/gltests_libdeps/g' \
3356 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3359 func_emit_initmacro_end ${macro_prefix}tests
3360 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3361 # created using libtool, because libtool already handles the dependencies.
3362 if test "$libtool" != true; then
3363 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3364 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3365 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3366 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3367 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3369 if $use_libtests; then
3370 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3371 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3374 func_emit_initmacro_done $macro_prefix $sourcebase
3375 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3377 echo "# This macro records the list of files which have been installed by"
3378 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3379 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3380 echo "$files" | sed -e 's,^, ,'
3383 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3384 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3388 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3389 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3390 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3392 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3396 echo "# gnulib-comp.m4 ends here"
3403 echo "Creating $m4base/gnulib-comp.m4"
3404 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3406 echo "Create $m4base/gnulib-comp.m4"
3412 if test -n "$inctests"; then
3413 # Create tests makefile.
3414 func_dest_tmpfilename $testsbase/$makefile_am
3415 destfile="$testsbase/$makefile_am"
3416 modules="$testsrelated_modules"
3417 func_emit_tests_Makefile_am > "$tmpfile"
3418 if test -f "$destdir"/$testsbase/$makefile_am; then
3419 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3423 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3424 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3425 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3427 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3433 echo "Creating $testsbase/$makefile_am"
3434 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3436 echo "Create $testsbase/$makefile_am"
3439 func_append added_files "$testsbase/$makefile_am$nl"
3443 if test "$vc_files" != false; then
3444 # Update the .cvsignore and .gitignore files.
3445 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3446 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3447 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3448 echo "$m4base/|A|gnulib-comp.m4"
3449 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3450 { # Rearrange file descriptors. Needed because "while ... done < ..."
3451 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3452 exec 5<&0 < "$tmp"/fileset-changes
3453 func_update_ignorelist ()
3456 if test "$ignore" = .gitignore; then
3457 # In a .gitignore file, "foo" applies to the current directory and all
3458 # subdirectories, whereas "/foo" applies to the current directory only.
3461 doubly_escaped_anchor='\\/'
3465 doubly_escaped_anchor=''
3467 if test -f "$destdir/$dir$ignore"; then
3468 if test -n "$dir_added" || test -n "$dir_removed"; then
3469 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3471 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3472 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
3473 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3474 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
3476 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3478 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3479 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3480 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3481 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,\$/d,' < "$tmp"/ignore-removed; fi
3482 } > "$tmp"/sed-ignore-removed
3483 { cat "$destdir/$dir$ignore"~
3484 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3485 } | sed -f "$tmp"/sed-ignore-removed \
3486 > "$destdir/$dir$ignore"
3488 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3493 if test -n "$dir_added"; then
3495 echo "Creating $destdir/$dir$ignore"
3497 if test "$ignore" = .cvsignore; then
3499 # Automake generates Makefile rules that create .dirstamp files.
3502 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3503 } > "$destdir/$dir$ignore"
3505 echo "Create $destdir/$dir$ignore"
3515 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3516 func_update_ignorelist .cvsignore
3518 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3519 func_update_ignorelist .gitignore
3526 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3527 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3528 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3529 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3530 if test "$next_dir" != "$last_dir"; then
3531 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3532 last_dir="$next_dir"
3537 A) func_append last_dir_added "$file$nl";;
3538 R) func_append last_dir_removed "$file$nl";;
3541 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3548 echo "You may need to add #include directives for the following .h files."
3549 # Intersect $specified_modules and $main_modules
3550 # (since $specified_modules is not necessarily of subset of $main_modules
3551 # - some may have been skipped through --avoid, and since the elements of
3552 # $main_modules but not in $specified_modules can go away without explicit
3553 # notice - through changes in the module dependencies).
3554 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3555 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3556 # First the #include <...> directives without #ifs, sorted for convenience,
3557 # then the #include "..." directives without #ifs, sorted for convenience,
3558 # then the #include directives that are surrounded by #ifs. Not sorted.
3559 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3560 include_directive=`func_get_include_directive "$module"`
3561 case "$nl$include_directive" in
3563 echo "$include_directive" 1>&5
3566 echo "$include_directive" | grep -v 'include "' 1>&6
3567 echo "$include_directive" | grep 'include "' 1>&7
3570 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3572 LC_ALL=C sort -u "$tmp"/include-angles
3573 LC_ALL=C sort -u "$tmp"/include-quotes
3574 cat "$tmp"/include-if
3575 ) | sed -e '/^$/d' -e 's/^/ /'
3576 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3578 for module in $main_modules; do
3579 func_get_link_directive "$module"
3581 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3582 if test `wc -l < "$tmp"/link` != 0; then
3584 echo "You may need to use the following Makefile variables when linking."
3585 echo "Use them in <program>_LDADD when linking a program, or"
3586 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3592 echo "Don't forget to"
3593 if test "$makefile_am" = Makefile.am; then
3594 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3596 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3598 if test -n "$pobase"; then
3599 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3601 if test -n "$inctests"; then
3602 if test "$makefile_am" = Makefile.am; then
3603 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3605 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3609 while test $edit != $makefile_am_edits; do
3610 edit=`expr $edit + 1`
3611 eval dir=\"\$makefile_am_edit${edit}_dir\"
3612 eval var=\"\$makefile_am_edit${edit}_var\"
3613 eval val=\"\$makefile_am_edit${edit}_val\"
3614 if test -n "$var"; then
3615 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
3618 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3619 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3622 # func_create_testdir testdir modules
3624 # - local_gnulib_dir from --local-dir
3625 # - auxdir directory relative to destdir where to place build aux files
3626 func_create_testdir ()
3630 if test -z "$modules"; then
3631 # All modules together.
3632 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3633 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3634 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3635 modules=`func_all_modules`
3636 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3638 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3640 # Check that the license of every module is consistent with the license of
3642 saved_modules="$modules"
3643 saved_inctests="$inctests"
3644 # When computing transitive closures, don't consider $module to depend on
3645 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3646 # on GPL modules - therefore we don't want a warning in this case.
3648 for requested_module in $saved_modules; do
3649 requested_license=`func_get_license "$requested_module"`
3650 if test "$requested_license" != GPL; then
3651 # Here we use func_modules_transitive_closure, not just
3652 # func_get_dependencies, so that we also detect weird situations like
3653 # an LGPL module which depends on a GPLed build tool module which depends
3655 modules="$requested_module"
3656 func_modules_transitive_closure
3657 for module in $modules; do
3658 license=`func_get_license "$module"`
3660 'GPLed build tool') ;;
3661 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3663 case "$requested_license" in
3666 GPLv2+ | LGPLv2+) ;;
3667 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3673 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3679 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3688 modules="$saved_modules"
3689 inctests="$saved_inctests"
3691 # Subdirectory names.
3701 # Determine final module list.
3702 func_modules_transitive_closure
3703 if test $verbose -ge 0; then
3704 echo "Module list with included dependencies:"
3705 echo "$modules" | sed -e 's/^/ /'
3708 # Add the dummy module if needed.
3709 func_modules_add_dummy
3711 # Show banner notice of every module.
3714 # Determine final file list.
3715 func_modules_to_filelist
3716 if test $verbose -ge 0; then
3718 echo "$files" | sed -e 's/^/ /'
3721 sed_rewrite_files="\
3722 s,^build-aux/,$auxdir/,
3724 s,^lib/,$sourcebase/,
3726 s,^tests/,$testsbase/,
3729 # Create directories.
3730 for f in $files; do echo $f; done \
3731 | sed -e "$sed_rewrite_files" \
3732 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3733 | LC_ALL=C sort -u \
3735 { # Rearrange file descriptors. Needed because "while ... done < ..."
3736 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3737 exec 5<&0 < "$tmp"/dirs
3739 mkdir -p "$testdir/$d"
3744 # Copy files or make symbolic links.
3746 for f in $files; do echo $f; done \
3747 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3750 { # Rearrange file descriptors. Needed because "while ... done < ..."
3751 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3752 exec 5<&0 < "$tmp"/files
3754 func_lookup_file "$f"
3755 if test -n "$lookedup_tmp"; then
3756 cp -p "$lookedup_file" "$testdir/$g"
3758 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3759 if { test -n "$symbolic" \
3760 || { test -n "$lsymbolic" \
3761 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3762 func_ln "$lookedup_file" "$testdir/$g"
3764 cp -p "$lookedup_file" "$testdir/$g"
3771 # Create Makefile.ams that are for testing.
3774 # No special edits are needed.
3777 # Create $sourcebase/Makefile.am.
3778 mkdir -p "$testdir/$sourcebase"
3779 destfile="$sourcebase/Makefile.am"
3780 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3781 any_uses_subdirs="$uses_subdirs"
3783 # Create $m4base/Makefile.am.
3784 mkdir -p "$testdir/$m4base"
3785 (echo "## Process this file with automake to produce Makefile.in."
3791 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3794 ) > "$testdir/$m4base/Makefile.am"
3796 subdirs="$sourcebase $m4base"
3797 subdirs_with_configure_ac=""
3799 if false && test -f "$testdir"/$m4base/gettext.m4; then
3800 # Avoid stupid error message from automake:
3801 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3802 mkdir -p "$testdir/po"
3803 (echo "## Process this file with automake to produce Makefile.in."
3804 ) > "$testdir/po/Makefile.am"
3805 func_append subdirs " po"
3808 if test -n "$inctests"; then
3809 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3810 # Viewed from the $testsbase subdirectory, $auxdir is different.
3811 saved_auxdir="$auxdir"
3812 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3813 # Create $testsbase/Makefile.am.
3815 destfile="$testsbase/Makefile.am"
3816 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3817 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3818 # Create $testsbase/configure.ac.
3819 (echo "# Process this file with autoconf to produce a configure script."
3820 echo "AC_INIT([dummy], [0])"
3821 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3822 echo "AM_INIT_AUTOMAKE"
3824 echo "AM_CONFIG_HEADER([config.h])"
3827 echo "AC_PROG_INSTALL"
3828 echo "AC_PROG_MAKE_SET"
3829 echo "AC_PROG_RANLIB"
3831 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3832 echo "AC_GNU_SOURCE"
3835 for module in $modules; do
3837 if test -n "$module"; then
3839 gnumakefile | maintainer-makefile)
3840 # These modules are meant to be used only in the top-level directory.
3843 func_get_autoconf_early_snippet "$module"
3848 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3849 if test "$libtool" = true; then
3850 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3851 echo "gl_cond_libtool=true"
3853 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3854 echo "gl_cond_libtool=false"
3856 echo "gl_ltlibdeps="
3858 # Wrap the set of autoconf snippets into an autoconf macro that is then
3859 # invoked. This is needed because autoconf does not support AC_REQUIRE
3861 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3862 # but we want the AC_REQUIRE to have its normal meaning (provide one
3863 # expansion of the required macro before the current point, and only one
3865 echo "AC_DEFUN([gl_INIT], ["
3866 sed_replace_build_aux='
3868 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3869 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3872 func_emit_initmacro_start $macro_prefix
3873 # We don't have explicit ordering constraints between the various
3874 # autoconf snippets. It's cleanest to put those of the library before
3875 # those of the tests.
3876 echo "gl_source_base='../$sourcebase'"
3877 for module in $modules; do
3878 func_verify_nontests_module
3879 if test -n "$module"; then
3881 gnumakefile | maintainer-makefile)
3882 # These modules are meant to be used only in the top-level directory.
3885 func_get_autoconf_snippet "$module" \
3886 | sed -e "$sed_replace_build_aux"
3891 echo "gl_source_base='.'"
3892 for module in $modules; do
3893 func_verify_tests_module
3894 if test -n "$module"; then
3895 func_get_autoconf_snippet "$module" \
3896 | sed -e "$sed_replace_build_aux"
3899 func_emit_initmacro_end $macro_prefix
3900 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3901 # created using libtool, because libtool already handles the dependencies.
3902 if test "$libtool" != true; then
3903 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3904 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3905 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3906 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3907 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3910 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3914 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3915 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3916 echo "AH_TOP([#include \"../config.h\"])"
3918 echo "AC_OUTPUT([Makefile])"
3919 ) > "$testdir/$testsbase/configure.ac"
3920 auxdir="$saved_auxdir"
3921 func_append subdirs " $testsbase"
3922 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3925 # Create Makefile.am.
3926 (echo "## Process this file with automake to produce Makefile.in."
3928 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3930 echo "SUBDIRS = $subdirs"
3932 echo "ACLOCAL_AMFLAGS = -I $m4base"
3933 ) > "$testdir/Makefile.am"
3935 # Create configure.ac.
3936 (echo "# Process this file with autoconf to produce a configure script."
3937 echo "AC_INIT([dummy], [0])"
3938 if test "$auxdir" != "."; then
3939 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3941 echo "AM_INIT_AUTOMAKE"
3943 echo "AM_CONFIG_HEADER([config.h])"
3946 echo "AC_PROG_INSTALL"
3947 echo "AC_PROG_MAKE_SET"
3949 echo "# For autobuild."
3950 echo "AC_CANONICAL_BUILD"
3951 echo "AC_CANONICAL_HOST"
3953 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3954 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3955 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3956 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3958 echo "AC_PROG_RANLIB"
3960 if test -n "$any_uses_subdirs"; then
3961 echo "AM_PROG_CC_C_O"
3964 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3965 echo "AC_GNU_SOURCE"
3968 for module in $modules; do
3969 func_verify_nontests_module
3970 if test -n "$module"; then
3971 func_get_autoconf_early_snippet "$module"
3974 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3975 if test "$libtool" = true; then
3976 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3977 echo "gl_cond_libtool=true"
3979 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3980 echo "gl_cond_libtool=false"
3982 echo "gl_ltlibdeps="
3984 # Wrap the set of autoconf snippets into an autoconf macro that is then
3985 # invoked. This is needed because autoconf does not support AC_REQUIRE
3987 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3988 # but we want the AC_REQUIRE to have its normal meaning (provide one
3989 # expansion of the required macro before the current point, and only one
3991 echo "AC_DEFUN([gl_INIT], ["
3992 if test "$auxdir" != "build-aux"; then
3993 sed_replace_build_aux='
3995 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3996 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4000 sed_replace_build_aux="$sed_noop"
4002 func_emit_initmacro_start $macro_prefix
4003 echo "gl_source_base='$sourcebase'"
4004 for module in $modules; do
4005 func_verify_nontests_module
4006 if test -n "$module"; then
4007 func_get_autoconf_snippet "$module" \
4008 | sed -e "$sed_replace_build_aux"
4011 func_emit_initmacro_end $macro_prefix
4012 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4013 # created using libtool, because libtool already handles the dependencies.
4014 if test "$libtool" != true; then
4015 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4016 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4017 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4018 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4019 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4022 func_emit_initmacro_done $macro_prefix $sourcebase
4026 if test -n "$subdirs_with_configure_ac"; then
4027 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4029 makefiles="Makefile"
4030 for d in $subdirs; do
4031 # For subdirs that have a configure.ac by their own, it's the subdir's
4032 # configure.ac which creates the subdir's Makefile.am, not this one.
4033 case " $subdirs_with_configure_ac " in
4035 *) func_append makefiles " $d/Makefile" ;;
4038 echo "AC_OUTPUT([$makefiles])"
4039 ) > "$testdir/configure.ac"
4041 # Create autogenerated files.
4043 # Do not use "${AUTORECONF} --force --install", because it may invoke
4044 # autopoint, which brings in older versions of some of our .m4 files.
4045 if test -f $m4base/gettext.m4; then
4046 func_execute_command ${AUTOPOINT} --force || func_exit 1
4047 for f in $m4base/*.m4~; do
4049 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4053 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4054 if ! test -d build-aux; then
4055 func_execute_command mkdir build-aux || func_exit 1
4057 func_execute_command ${AUTOCONF} || func_exit 1
4058 func_execute_command ${AUTOHEADER} || func_exit 1
4059 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4061 if test -n "$inctests"; then
4062 # Create autogenerated files.
4063 (cd "$testdir/$testsbase" || func_exit 1
4064 # Do not use "${AUTORECONF} --force --install", because it may invoke
4065 # autopoint, which brings in older versions of some of our .m4 files.
4066 if test -f ../$m4base/gettext.m4; then
4067 func_execute_command ${AUTOPOINT} --force || func_exit 1
4068 for f in ../$m4base/*.m4~; do
4070 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4074 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4075 if ! test -d ../build-aux; then
4076 func_execute_command mkdir ../build-aux
4078 func_execute_command ${AUTOCONF} || func_exit 1
4079 func_execute_command ${AUTOHEADER} || func_exit 1
4080 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4083 # Need to run configure and make once, to create built files that are to be
4084 # distributed (such as getdate.c).
4085 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4086 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4087 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4088 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4089 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4090 # such $(FOO_H) because they don't refer to distributed files.
4091 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4092 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4093 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4094 | sed -e "$sed_remove_make_variables"`
4095 distributed_built_sources=`for file in $built_sources; do
4096 case "$cleaned_files" in
4101 if test -n "$distributed_built_sources"; then
4103 ./configure || func_exit 1
4105 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4106 make built_sources || func_exit 1
4108 make distclean || func_exit 1
4113 # func_create_megatestdir megatestdir allmodules
4115 # - local_gnulib_dir from --local-dir
4116 # - auxdir directory relative to destdir where to place build aux files
4117 func_create_megatestdir ()
4121 if test -z "$allmodules"; then
4122 allmodules=`func_all_modules`
4126 # First, all modules one by one.
4127 for onemodule in $allmodules; do
4128 func_create_testdir "$megatestdir/$onemodule" $onemodule
4129 func_append megasubdirs "$onemodule "
4131 # Then, all modules all together.
4132 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4133 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
4134 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
4135 func_create_testdir "$megatestdir/ALL" "$allmodules"
4136 func_append megasubdirs "ALL"
4139 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4140 vc_witness="$gnulib_dir/CVS/Entries"; \
4142 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4144 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4145 | sed -e 's,January,01,' -e 's,Jan,01,' \
4146 -e 's,February,02,' -e 's,Feb,02,' \
4147 -e 's,March,03,' -e 's,Mar,03,' \
4148 -e 's,April,04,' -e 's,Apr,04,' \
4150 -e 's,June,06,' -e 's,Jun,06,' \
4151 -e 's,July,07,' -e 's,Jul,07,' \
4152 -e 's,August,08,' -e 's,Aug,08,' \
4153 -e 's,September,09,' -e 's,Sep,09,' \
4154 -e 's,October,10,' -e 's,Oct,10,' \
4155 -e 's,November,11,' -e 's,Nov,11,' \
4156 -e 's,December,12,' -e 's,Dec,12,' \
4157 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4158 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4160 echo "CVSDATE=$cvsdate"
4161 echo "test -d logs || mkdir logs"
4162 echo "for module in $megasubdirs; do"
4163 echo " echo \"Working on module \$module...\""
4164 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4165 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4168 echo " : autobuild project... \$module"
4169 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4170 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4171 echo " : autobuild hostname... \`hostname\`"
4172 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
4174 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4176 ) > "$megatestdir/do-autobuild"
4177 chmod a+x "$megatestdir/do-autobuild"
4179 # Create Makefile.am.
4180 (echo "## Process this file with automake to produce Makefile.in."
4182 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4184 echo "SUBDIRS = $megasubdirs"
4186 echo "EXTRA_DIST = do-autobuild"
4187 ) > "$megatestdir/Makefile.am"
4189 # Create configure.ac.
4190 (echo "# Process this file with autoconf to produce a configure script."
4191 echo "AC_INIT([dummy], [0])"
4192 if test "$auxdir" != "."; then
4193 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4195 echo "AM_INIT_AUTOMAKE"
4197 echo "AC_PROG_MAKE_SET"
4199 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4200 echo "AC_OUTPUT([Makefile])"
4201 ) > "$megatestdir/configure.ac"
4203 # Create autogenerated files.
4205 # Do not use "${AUTORECONF} --install", because autoreconf operates
4206 # recursively, but the subdirectories are already finished, therefore
4207 # calling autoreconf here would only waste lots of CPU time.
4208 func_execute_command ${ACLOCAL} || func_exit 1
4209 func_execute_command mkdir build-aux
4210 func_execute_command ${AUTOCONF} || func_exit 1
4211 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4217 func_fatal_error "no mode specified" ;;
4226 if test -z "$destdir"; then
4229 test -d "$destdir" \
4230 || func_fatal_error "destination directory does not exist: $destdir"
4232 # Prefer configure.ac to configure.in.
4233 if test -f "$destdir"/configure.ac; then
4234 configure_ac="$destdir/configure.ac"
4236 if test -f "$destdir"/configure.in; then
4237 configure_ac="$destdir/configure.in"
4239 func_fatal_error "cannot find $destdir/configure.ac"
4243 # Analyze configure.ac.
4245 guessed_libtool=false
4250 /AC_CONFIG_AUX_DIR/ {
4251 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
4253 /A[CM]_PROG_LIBTOOL/ {
4254 s,^.*$,guessed_libtool=true,p
4256 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4258 if test -z "$auxdir"; then
4259 auxdir="$guessed_auxdir"
4262 # Determine where to apply func_import.
4263 if test -n "$m4base"; then
4264 # Apply func_import to a particular gnulib directory.
4265 # Any number of additional modules can be given.
4266 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4267 # First use of gnulib in the given m4base.
4268 test -n "$supplied_libname" || supplied_libname=true
4269 test -n "$sourcebase" || sourcebase="lib"
4270 test -n "$docbase" || docbase="doc"
4271 test -n "$testsbase" || testsbase="tests"
4272 test -n "$macro_prefix" || macro_prefix="gl"
4276 # Apply func_import to all gnulib directories.
4277 # To get this list of directories, look at Makefile.am. (Not at
4278 # configure, because it may be omitted from CVS. Also, don't run
4279 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4282 if test -f "$destdir"/Makefile.am; then
4283 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4285 for arg in $aclocal_amflags; do
4286 if test -n "$m4dir_is_next"; then
4287 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4291 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4292 func_append m4dirs " $arg"
4293 m4dirs_count=`expr $m4dirs_count + 1`
4299 if test "X$arg" = "X-I"; then
4307 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4308 if test -f "$destdir"/aclocal.m4; then
4309 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4310 sedexpr2='s,^[^/]*$,.,'
4311 sedexpr3='s,/[^/]*$,,'
4312 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4313 m4dirs_count=`echo "$m4dirs" | wc -l`
4316 if test $m4dirs_count = 0; then
4317 # First use of gnulib in a package.
4318 # Any number of additional modules can be given.
4319 test -n "$supplied_libname" || supplied_libname=true
4320 test -n "$sourcebase" || sourcebase="lib"
4322 test -n "$docbase" || docbase="doc"
4323 test -n "$testsbase" || testsbase="tests"
4324 test -n "$macro_prefix" || macro_prefix="gl"
4327 if test $m4dirs_count = 1; then
4328 # There's only one use of gnulib here. Assume the user means it.
4329 # Any number of additional modules can be given.
4330 for m4base in $m4dirs; do
4334 # Ambiguous - guess what the user meant.
4335 if test $# = 0; then
4336 # No further arguments. Guess the user wants to update all of them.
4337 for m4base in $m4dirs; do
4338 # Perform func_import in a subshell, so that variable values
4340 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
4341 # pobase, docbase, testsbase, inctests, libname, lgpl,
4342 # makefile_name, libtool, macro_prefix, po_domain, vc_files
4343 # don't propagate from one directory to another.
4344 (func_import) || func_exit 1
4348 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4356 if test -z "$destdir"; then
4357 func_fatal_error "please specify --dir option"
4360 test -d "$destdir" \
4361 || func_fatal_error "could not create destination directory"
4362 test -n "$auxdir" || auxdir="build-aux"
4363 func_create_testdir "$destdir" "$*"
4366 create-megatestdir )
4367 if test -z "$destdir"; then
4368 func_fatal_error "please specify --dir option"
4370 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4371 test -n "$auxdir" || auxdir="build-aux"
4372 func_create_megatestdir "$destdir" "$*"
4376 test -n "$destdir" || destdir=testdir$$
4377 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4378 test -n "$auxdir" || auxdir="build-aux"
4379 func_create_testdir "$destdir" "$*"
4383 ../configure || func_exit 1
4385 make check || func_exit 1
4386 make distclean || func_exit 1
4387 remaining=`find . -type f -print`
4388 if test -n "$remaining"; then
4389 echo "Remaining files:" $remaining 1>&2
4390 echo "gnulib-tool: *** Stop." 1>&2
4399 test -n "$destdir" || destdir=testdir$$
4400 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4401 test -n "$auxdir" || auxdir="build-aux"
4402 func_create_megatestdir "$destdir" "$*"
4410 remaining=`find . -type f -print`
4411 if test -n "$remaining"; then
4412 echo "Remaining files:" $remaining 1>&2
4413 echo "gnulib-tool: *** Stop." 1>&2
4421 extract-description )
4425 if test -n "$module"; then
4426 func_get_description "$module"
4435 if test -n "$module"; then
4436 func_get_status "$module"
4445 if test -n "$module"; then
4446 func_get_notice "$module"
4455 if test -n "$module"; then
4456 func_get_filelist "$module"
4461 extract-dependencies )
4465 if test -n "$module"; then
4466 func_get_dependencies "$module"
4471 extract-autoconf-snippet )
4475 if test -n "$module"; then
4476 func_get_autoconf_snippet "$module"
4481 extract-automake-snippet )
4485 if test -n "$module"; then
4486 func_get_automake_snippet "$module"
4491 extract-include-directive )
4495 if test -n "$module"; then
4496 func_get_include_directive "$module"
4501 extract-link-directive )
4505 if test -n "$module"; then
4506 func_get_link_directive "$module"
4515 if test -n "$module"; then
4516 func_get_license "$module"
4521 extract-maintainer )
4525 if test -n "$module"; then
4526 func_get_maintainer "$module"
4531 extract-tests-module )
4535 if test -n "$module"; then
4536 func_get_tests_module "$module"
4542 func_fatal_error "unknown operation mode --$mode" ;;
4546 # Undo the effect of the previous 'trap' command. Some shellology:
4547 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4548 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4549 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4550 # 128 + signal number and is set before the trap-registered command is run.
4552 trap 'func_exit $?' 1 2 3 13 15
4557 # indent-tabs-mode: nil
4558 # whitespace-check-buffer-indent: nil