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.
582 # Note that Solaris sh does not understand "trap - SIGPIPE".
583 func_reset_sigpipe ()
588 func_reset_sigpipe ()
594 # Ensure an 'echo' command that does not interpret backslashes.
596 # echo '\n' | wc -l prints 1 when OK, 2 when KO
597 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
598 # This problem is a weird heritage from SVR4. BSD got it right (except that
599 # BSD echo interprets '-n' as an option, which is also not desirable).
600 # Nowadays the problem occurs in 4 situations:
601 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
602 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
603 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
604 # - in zsh, when sh-emulation is not set,
605 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
606 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
607 # - in Solaris /bin/sh and OSF/1 /bin/sh.
608 # We try the following workarounds:
609 # - for all: respawn using $CONFIG_SHELL if that is set and works.
610 # - for bash >= 2.04: unset the shell option xpg_echo.
611 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
612 # - for bash < 2.0: define echo to a function that uses cat of a here document.
613 # - for zsh: turn sh-emulation on.
614 # - for ksh: alias echo to 'print -r'.
615 # - for ksh: alias echo to a function that uses cat of a here document.
616 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
617 # the ksh workaround.
618 # - otherwise: respawn using /bin/sh and rely on the workarounds.
619 # When respawning, we pass --no-reexec as first argument, so as to avoid
620 # turning this script into a fork bomb in unlucky situations.
622 if echo '\t' | grep t > /dev/null; then
623 have_echo=yes # Lucky!
625 # Try the workarounds.
626 # Respawn using $CONFIG_SHELL if that is set and works.
627 if test -z "$have_echo" \
628 && test "X$1" != "X--no-reexec" \
629 && test -n "$CONFIG_SHELL" \
630 && test -f "$CONFIG_SHELL" \
631 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
632 exec $CONFIG_SHELL "$0" --no-reexec "$@"
635 # For bash >= 2.04: unset the shell option xpg_echo.
636 if test -z "$have_echo" \
637 && test -n "$BASH_VERSION" \
638 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
642 # For bash >= 2.0: define echo to a function that uses the printf built-in.
643 # For bash < 2.0: define echo to a function that uses cat of a here document.
644 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
645 if test -z "$have_echo" \
646 && test -n "$BASH_VERSION"; then \
647 if type printf 2>/dev/null | grep / > /dev/null; then
648 # 'printf' is not a shell built-in.
656 # 'printf' is a shell built-in.
662 if echo '\t' | grep t > /dev/null; then
666 # For zsh: turn sh-emulation on.
667 if test -z "$have_echo" \
668 && test -n "$ZSH_VERSION" \
669 && (emulate sh) >/dev/null 2>&1; then
672 # For ksh: alias echo to 'print -r'.
673 if test -z "$have_echo" \
674 && (type print) >/dev/null 2>&1; then
675 # A 'print' command exists.
676 if type print 2>/dev/null | grep / > /dev/null; then
679 # 'print' is a shell built-in.
680 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
681 # 'print' is the ksh shell built-in.
682 alias echo='print -r'
686 if test -z "$have_echo" \
687 && echo '\t' | grep t > /dev/null; then
690 # For ksh: alias echo to a function that uses cat of a here document.
691 # The ksh manual page says:
692 # "Aliasing is performed when scripts are read, not while they are executed.
693 # Therefore, for an alias to take effect, the alias definition command has
694 # to be executed before the command which references the alias is read."
695 # Because of this, we have to play strange tricks with have_echo, to ensure
696 # that the top-level statement containing the test starts after the 'alias'
698 if test -z "$have_echo"; then
705 alias echo=bsd_echo 2>/dev/null
707 if test -z "$have_echo" \
708 && echo '\t' | grep t > /dev/null; then
711 if test -z "$have_echo"; then
712 unalias echo 2>/dev/null
714 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
715 if test -z "$have_echo" \
716 && test "X$1" != "X--no-reexec" \
717 && test -f /bin/ksh; then
718 exec /bin/ksh "$0" --no-reexec "$@"
721 # Otherwise: respawn using /bin/sh.
722 if test -z "$have_echo" \
723 && test "X$1" != "X--no-reexec" \
724 && test -f /bin/sh; then
725 exec /bin/sh "$0" --no-reexec "$@"
728 if test -z "$have_echo"; then
729 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
731 if echo '\t' | grep t > /dev/null; then
734 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
736 if test "X$1" = "X--no-reexec"; then
740 # Command-line option processing.
741 # Removes the OPTIONS from the arguments. Sets the variables:
742 # - mode list or import or create-testdir or create-megatestdir
743 # - destdir from --dir
744 # - local_gnulib_dir from --local-dir
745 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
746 # - libname, supplied_libname from --lib
747 # - sourcebase from --source-base
748 # - m4base from --m4-base
749 # - pobase from --po-base
750 # - docbase from --doc-base
751 # - testsbase from --tests-base
752 # - auxdir from --aux-dir
753 # - inctests true if --with-tests was given, blank otherwise
754 # - incobsolete true if --with-obsolete was given, blank otherwise
755 # - avoidlist list of modules to avoid, from --avoid
756 # - lgpl yes or a number if --lgpl was given, blank otherwise
757 # - makefile_name from --makefile-name
758 # - libtool true if --libtool was given, false if --no-libtool was
759 # given, blank otherwise
760 # - macro_prefix from --macro-prefix
761 # - po_domain from --po-domain
762 # - vc_files true if --vc-files was given, false if --no-vc-files was
763 # given, blank otherwise
764 # - autoconf_minversion minimum supported autoconf version
765 # - do_changelog false if --no-changelog was given, : otherwise
766 # - doit : if actions shall be executed, false if only to be printed
767 # - symbolic true if --symlink or --more-symlinks was given, blank
769 # - lsymbolic true if --local-symlink was given, blank otherwise
770 # - do_copyrights blank if --more-symlinks was given, true otherwise
801 while test $# -gt 0; do
806 --import | --impor | --impo | --imp | --im | --i )
809 --update | --updat | --upda | --upd | --up | --u )
812 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
815 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
816 mode=create-megatestdir
818 --test | --tes | --te | --t )
821 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
825 mode=`echo "X$1" | sed -e 's/^X--//'`
830 func_fatal_error "missing argument for --dir"
835 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
840 func_fatal_error "missing argument for --local-dir"
845 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
847 --verbose | --verbos | --verbo | --verb )
848 verbose=`expr $verbose + 1`
850 --quiet | --quie | --qui | --qu | --q )
851 verbose=`expr $verbose - 1`
856 func_fatal_error "missing argument for --lib"
859 supplied_libname=true
862 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
863 supplied_libname=true
868 func_fatal_error "missing argument for --source-base"
873 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
878 func_fatal_error "missing argument for --m4-base"
883 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
888 func_fatal_error "missing argument for --po-base"
893 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
898 func_fatal_error "missing argument for --doc-base"
903 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
908 func_fatal_error "missing argument for --tests-base"
913 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
918 func_fatal_error "missing argument for --aux-dir"
923 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
934 func_fatal_error "missing argument for --avoid"
936 func_append avoidlist " $1"
939 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
940 func_append avoidlist " $arg"
946 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
949 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
956 func_fatal_error "missing argument for --makefile-name"
961 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
972 func_fatal_error "missing argument for --macro-prefix"
977 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
982 func_fatal_error "missing argument for --po-domain"
987 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
995 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
1001 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1004 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1007 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1011 --help | --hel | --he | --h )
1014 --version | --versio | --versi | --vers )
1018 # Stop option processing
1022 echo "gnulib-tool: unknown option $1" 1>&2
1023 echo "Try 'gnulib-tool --help' for more information." 1>&2
1030 if test "$mode" = update; then
1031 if test $# != 0; then
1032 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1033 echo "Try 'gnulib-tool --help' for more information." 1>&2
1034 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1035 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1038 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1039 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1040 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1041 || test -n "$inctests" || test -n "$incobsolete" \
1042 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1043 || test -n "$macro_prefix" || test -n "$po_domain" \
1044 || test -n "$vc_files"; then
1045 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1046 echo "Try 'gnulib-tool --help' for more information." 1>&2
1047 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1048 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1053 if test -n "$pobase" && test -z "$po_domain"; then
1054 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1055 echo "Try 'gnulib-tool --help' for more information." 1>&2
1058 if test -z "$pobase" && test -n "$po_domain"; then
1059 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1062 # Determine the minimum supported autoconf version from the project's
1064 DEFAULT_AUTOCONF_MINVERSION="2.59"
1065 autoconf_minversion=
1067 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1068 if test -f "$destdir"/configure.ac; then
1069 configure_ac="$destdir/configure.ac"
1071 if test -f "$destdir"/configure.in; then
1072 configure_ac="$destdir/configure.in"
1076 if test -f configure.ac; then
1077 configure_ac="configure.ac"
1079 if test -f configure.in; then
1080 configure_ac="configure.in"
1084 if test -n "$configure_ac"; then
1085 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1086 # because when some m4 files are omitted from a CVS repository,
1087 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1088 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1089 # autom4te: m4 failed with exit status: 1
1096 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1098 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1099 if test -n "$prereqs"; then
1100 autoconf_minversion=`
1101 for version in $prereqs; do echo $version; done |
1102 LC_ALL=C sort -nru | sed 1q
1106 if test -z "$autoconf_minversion"; then
1107 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1109 case "$autoconf_minversion" in
1110 1.* | 2.[0-4]* | 2.5[0-8]*)
1111 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1114 # Remove trailing slashes from the directory names. This is necessary for
1115 # m4base (to avoid an error in func_import) and optional for the others.
1116 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1117 case "$local_gnulib_dir" in
1118 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1120 case "$sourcebase" in
1121 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1124 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1127 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1130 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1132 case "$testsbase" in
1133 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1136 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1142 trap 'exit_status=$?
1143 if test "$signal" != 0; then
1144 echo "caught signal $signal" >&2
1147 exit $exit_status' 0
1148 for signal in 1 2 3 13 15; do
1149 trap '{ signal='$signal'; func_exit 1; }' $signal
1153 # func_lookup_file file
1154 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1157 # - local_gnulib_dir from --local-dir
1159 # - lookedup_file name of the merged (combined) file
1160 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1164 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1165 lookedup_file="$local_gnulib_dir/$lkfile"
1168 if test -f "$gnulib_dir/$lkfile"; then
1169 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1170 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1171 rm -f "$tmp/$lkbase"
1172 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1173 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1174 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1175 lookedup_file="$tmp/$lkbase"
1178 lookedup_file="$gnulib_dir/$lkfile"
1182 func_fatal_error "file $gnulib_dir/$lkfile not found"
1189 # - local_gnulib_dir from --local-dir
1192 # Filter out metainformation files like README, which are not modules.
1193 # Filter out unit test modules; they can be retrieved through
1194 # --extract-tests-module if desired.
1196 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1197 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1198 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1201 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1202 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1203 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1204 -e '/^README$/d' -e '/\/README$/d' \
1205 -e '/^TEMPLATE$/d' \
1206 -e '/^TEMPLATE-EXTENDED$/d' \
1207 -e '/^TEMPLATE-TESTS$/d' \
1210 | sed -e '/-tests$/d' \
1214 # func_verify_module
1215 # verifies a module name
1217 # - local_gnulib_dir from --local-dir
1218 # - module module name argument
1219 func_verify_module ()
1221 if { test -f "$gnulib_dir/modules/$module" \
1222 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1223 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1224 && test "CVS" != "$module" \
1225 && test "ChangeLog" != "$module" \
1226 && test "COPYING" != "$module" \
1227 && test "README" != "$module" \
1228 && test "TEMPLATE" != "$module" \
1229 && test "TEMPLATE-EXTENDED" != "$module" \
1230 && test "TEMPLATE-TESTS" != "$module"; then
1231 # OK, $module is a correct module name.
1232 # Verify that building the module description with 'patch' succeeds.
1233 func_lookup_file "modules/$module"
1235 echo "gnulib-tool: module $module doesn't exist" 1>&2
1240 # func_verify_nontests_module
1241 # verifies a module name, excluding tests modules
1243 # - local_gnulib_dir from --local-dir
1244 # - module module name argument
1245 func_verify_nontests_module ()
1248 *-tests ) module= ;;
1249 * ) func_verify_module ;;
1253 # func_verify_tests_module
1254 # verifies a module name, considering only tests modules
1256 # - local_gnulib_dir from --local-dir
1257 # - module module name argument
1258 func_verify_tests_module ()
1261 *-tests ) func_verify_module ;;
1266 sed_extract_prog=':[ ]*$/ {
1269 s/^Description:[ ]*$//
1273 s/^Depends-on:[ ]*$//
1274 s/^configure\.ac-early:[ ]*$//
1275 s/^configure\.ac:[ ]*$//
1276 s/^Makefile\.am:[ ]*$//
1280 s/^Maintainer:[ ]*$//
1287 # func_get_description module
1289 # - local_gnulib_dir from --local-dir
1290 func_get_description ()
1292 func_lookup_file "modules/$1"
1293 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1296 # func_get_status module
1298 # - local_gnulib_dir from --local-dir
1301 func_lookup_file "modules/$1"
1302 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1305 # func_get_notice module
1307 # - local_gnulib_dir from --local-dir
1310 func_lookup_file "modules/$1"
1311 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1314 # func_get_filelist module
1316 # - local_gnulib_dir from --local-dir
1317 func_get_filelist ()
1319 func_lookup_file "modules/$1"
1320 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1321 echo m4/gnulib-common.m4
1322 case "$autoconf_minversion" in
1329 # func_get_dependencies module
1331 # - local_gnulib_dir from --local-dir
1332 func_get_dependencies ()
1334 # ${module}-tests always implicitly depends on ${module}.
1335 echo "$1" | sed -n -e 's/-tests$//p'
1336 # Then the explicit dependencies listed in the module description.
1337 func_lookup_file "modules/$1"
1338 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1341 # func_get_autoconf_early_snippet module
1343 # - local_gnulib_dir from --local-dir
1344 func_get_autoconf_early_snippet ()
1346 func_lookup_file "modules/$1"
1347 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1350 # func_get_autoconf_snippet module
1352 # - local_gnulib_dir from --local-dir
1353 func_get_autoconf_snippet ()
1355 func_lookup_file "modules/$1"
1356 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1359 # func_get_automake_snippet module
1361 # - local_gnulib_dir from --local-dir
1362 func_get_automake_snippet ()
1364 func_lookup_file "modules/$1"
1365 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1368 # *-tests module live in tests/, not lib/.
1369 # Synthesize an EXTRA_DIST augmentation.
1370 all_files=`func_get_filelist $1`
1371 tests_files=`for f in $all_files; do \
1373 tests/*) echo $f ;; \
1375 done | sed -e 's,^tests/,,'`
1376 extra_files="$tests_files"
1377 if test -n "$extra_files"; then
1378 echo "EXTRA_DIST +=" $extra_files
1383 # Synthesize an EXTRA_DIST augmentation.
1384 sed_combine_lines='/\\$/{
1391 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1392 already_mentioned_files=` \
1393 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1394 | sed -e "$sed_combine_lines" \
1395 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1396 all_files=`func_get_filelist $1`
1397 lib_files=`for f in $all_files; do \
1401 done | sed -e 's,^lib/,,'`
1402 # Remove $already_mentioned_files from $lib_files.
1403 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1404 extra_files=`func_reset_sigpipe; \
1405 for f in $already_mentioned_files; do echo $f; done \
1406 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1407 if test -n "$extra_files"; then
1408 echo "EXTRA_DIST +=" $extra_files
1411 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1412 # This is necessary so that automake can generate the right list of
1414 # A possible approach would be to use autom4te --trace of the redefined
1415 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1416 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1417 # inside autoconf's built-in macros are not missed).
1418 # But it's simpler and more robust to do it here, based on the file list.
1419 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1420 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1421 # automake will generate a useless dependency; this is harmless.
1423 relocatable-prog-wrapper) ;;
1425 sed_extract_c_files='/\.c$/p'
1426 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1427 if test -n "$extra_files"; then
1428 echo "EXTRA_lib_SOURCES +=" $extra_files
1433 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1434 buildaux_files=`for f in $all_files; do \
1436 build-aux/*) echo $f ;; \
1438 done | sed -e 's,^build-aux/,,'`
1439 if test -n "$buildaux_files"; then
1440 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1441 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1444 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1445 top_files=`for f in $all_files; do \
1449 done | sed -e 's,^top/,,'`
1450 if test -n "$top_files"; then
1451 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1452 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1459 # func_get_include_directive module
1461 # - local_gnulib_dir from --local-dir
1462 func_get_include_directive ()
1464 func_lookup_file "modules/$1"
1465 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1466 sed -e 's/^\(["<]\)/#include \1/'
1469 # func_get_link_directive module
1471 # - local_gnulib_dir from --local-dir
1472 func_get_link_directive ()
1474 func_lookup_file "modules/$1"
1475 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1478 # func_get_license module
1480 # - local_gnulib_dir from --local-dir
1483 func_lookup_file "modules/$1"
1484 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1485 # The default is GPL.
1487 } | sed -e 's,^ *$,,' | sed -e 1q
1490 # func_get_maintainer module
1492 # - local_gnulib_dir from --local-dir
1493 func_get_maintainer ()
1495 func_lookup_file "modules/$1"
1496 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1499 # func_get_tests_module module
1501 # - local_gnulib_dir from --local-dir
1502 func_get_tests_module ()
1504 # The naming convention for tests modules is hardwired: ${module}-tests.
1505 if test -f "$gnulib_dir/modules/$1"-tests \
1506 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1507 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1512 # func_acceptable module
1513 # tests whether a module is acceptable.
1515 # - avoidlist list of modules to avoid
1518 for avoid in $avoidlist; do
1519 if test "$avoid" = "$1"; then
1526 # func_modules_transitive_closure
1528 # - local_gnulib_dir from --local-dir
1529 # - modules list of specified modules
1530 # - inctests true if tests should be included, blank otherwise
1531 # - incobsolete true if obsolete modules among dependencies should be
1532 # included, blank otherwise
1533 # - avoidlist list of modules to avoid
1534 # - tmp pathname of a temporary directory
1536 # - modules list of modules, including dependencies
1537 func_modules_transitive_closure ()
1539 # In order to process every module only once (for speed), process an "input
1540 # list" of modules, producing an "output list" of modules. During each round,
1541 # more modules can be queued in the input list. Once a module on the input
1542 # list has been processed, it is added to the "handled list", so we can avoid
1543 # to process it again.
1545 inmodules="$modules"
1547 while test -n "$inmodules"; do
1548 inmodules_this_round="$inmodules"
1549 inmodules= # Accumulator, queue for next round
1550 for module in $inmodules_this_round; do
1552 if test -n "$module"; then
1553 if func_acceptable $module; then
1554 func_append outmodules " $module"
1555 deps=`func_get_dependencies $module`
1556 # Duplicate dependencies are harmless, but Jim wants a warning.
1557 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1558 if test -n "$duplicated_deps"; then
1559 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1561 for dep in $deps; do
1562 if test -n "$incobsolete" \
1563 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
1564 func_append inmodules " $dep"
1567 if test -n "$inctests"; then
1568 testsmodule=`func_get_tests_module $module`
1569 if test -n "$testsmodule"; then
1570 func_append inmodules " $testsmodule"
1576 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1577 # Remove $handledmodules from $inmodules.
1578 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1579 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1581 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1582 rm -f "$tmp"/queued-modules
1585 # func_modules_add_dummy
1587 # - local_gnulib_dir from --local-dir
1588 # - modules list of modules, including dependencies
1590 # - modules list of modules, including 'dummy' if needed
1591 func_modules_add_dummy ()
1593 # Determine whether any module provides a lib_SOURCES augmentation.
1595 sed_remove_backslash_newline=':a
1602 for module in $modules; do
1603 func_verify_nontests_module
1604 if test -n "$module"; then
1605 # Extract the value of "lib_SOURCES += ...".
1606 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1607 # Ignore .h files since they are not compiled.
1611 have_lib_SOURCES=yes
1618 # Add the dummy module, to make sure the library will be non-empty.
1619 if test -z "$have_lib_SOURCES"; then
1620 if func_acceptable "dummy"; then
1621 func_append modules " dummy"
1626 # func_modules_notice
1628 # - local_gnulib_dir from --local-dir
1629 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1630 # - modules list of modules, including dependencies
1631 func_modules_notice ()
1633 if test $verbose -ge -1; then
1634 for module in $modules; do
1636 if test -n "$module"; then
1637 msg=`func_get_notice $module`
1638 if test -n "$msg"; then
1639 echo "Notice from module $module:"
1640 echo "$msg" | sed -e 's/^/ /'
1647 # func_modules_to_filelist
1649 # - local_gnulib_dir from --local-dir
1650 # - modules list of modules, including dependencies
1652 # - files list of files
1653 func_modules_to_filelist ()
1656 for module in $modules; do
1658 if test -n "$module"; then
1659 fs=`func_get_filelist $module`
1660 func_append files " $fs"
1663 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1666 # func_execute_command command [args...]
1667 # Executes a command.
1668 # Uses also the variables
1669 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1670 func_execute_command ()
1672 if test $verbose -ge 0; then
1676 # Commands like automake produce output to stderr even when they succeed.
1677 # Turn this output off if the command succeeds.
1678 "$@" > "$tmp"/cmdout 2>&1
1680 if test $cmdret = 0; then
1684 cat "$tmp"/cmdout 1>&2
1691 # func_emit_lib_Makefile_am
1692 # emits the contents of library makefile to standard output.
1694 # - local_gnulib_dir from --local-dir
1695 # - modules list of modules, including dependencies
1696 # - libname library name
1697 # - pobase directory relative to destdir where to place *.po files
1698 # - auxdir directory relative to destdir where to place build aux files
1699 # - makefile_name from --makefile-name
1700 # - libtool true if libtool will be used, false or blank otherwise
1701 # - macro_prefix prefix of gl_LIBOBJS macros to use
1702 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1703 # - actioncmd (optional) command that will reproduce this invocation
1704 # - for_test true if creating a package for testing, false otherwise
1705 # - destfile filename relative to destdir of makefile being generated
1707 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1708 # list of edits to be done to Makefile.am variables
1710 # - uses_subdirs nonempty if object files in subdirs exist
1711 func_emit_lib_Makefile_am ()
1713 # When creating an includable Makefile.am snippet, augment variables with
1714 # += instead of assigning them.
1715 if test -n "$makefile_name"; then
1720 if test "$libtool" = true; then
1723 sed_eliminate_LDFLAGS="$sed_noop"
1727 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1730 # When creating a package for testing: Attempt to provoke failures,
1731 # especially link errors, already during "make" rather than during
1732 # "make check", because "make check" is not possible in a cross-compiling
1733 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1734 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1736 sed_transform_check_PROGRAMS="$sed_noop"
1738 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1739 echo "## Process this file with automake to produce Makefile.in."
1740 func_emit_copyright_notice
1741 if test -n "$actioncmd"; then
1742 echo "# Reproduce by: $actioncmd"
1747 for module in $modules; do
1748 func_verify_nontests_module
1749 if test -n "$module"; then
1751 func_get_automake_snippet "$module" |
1752 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1753 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1754 -e "$sed_eliminate_LDFLAGS" \
1755 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1756 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1757 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1758 -e "$sed_transform_check_PROGRAMS"
1759 if test "$module" = 'alloca'; then
1760 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1761 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1764 # Skip the contents if it's entirely empty.
1765 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1766 echo "## begin gnulib module $module"
1769 echo "## end gnulib module $module"
1773 # Test whether there are some source files in subdirectories.
1774 for f in `func_get_filelist "$module"`; do
1785 if test -z "$makefile_name"; then
1786 # If there are source files in subdirectories, prevent collision of the
1787 # object files (example: hash.c and libxml/hash.c).
1789 if test -n "$uses_subdirs"; then
1790 subdir_options=' subdir-objects'
1792 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1795 if test -z "$makefile_name"; then
1797 echo "noinst_HEADERS ="
1798 echo "noinst_LIBRARIES ="
1799 echo "noinst_LTLIBRARIES ="
1800 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1801 # if you specify pkgdata_DATA to empty. This is a workaround.
1802 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1803 echo "pkgdata_DATA ="
1806 echo "BUILT_SOURCES ="
1809 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1810 if test -z "$makefile_name"; then
1811 echo "MOSTLYCLEANDIRS ="
1813 echo "DISTCLEANFILES ="
1814 echo "MAINTAINERCLEANFILES ="
1816 # Execute edits that apply to the Makefile.am being generated.
1818 while test $edit != $makefile_am_edits; do
1819 edit=`expr $edit + 1`
1820 eval dir=\"\$makefile_am_edit${edit}_dir\"
1821 eval var=\"\$makefile_am_edit${edit}_var\"
1822 eval val=\"\$makefile_am_edit${edit}_val\"
1823 if test -n "$var"; then
1824 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
1825 echo "${var} += ${val}"
1826 eval "makefile_am_edit${edit}_var="
1830 if test -z "$makefile_name"; then
1832 echo "AM_CPPFLAGS ="
1835 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1836 # One of the snippets already specifies an installation location for the
1837 # library. Don't confuse automake by saying it should not be installed.
1840 # By default, the generated library should not be installed.
1841 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1844 echo "${libname}_${libext}_SOURCES ="
1845 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1846 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
1847 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1848 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1849 echo "EXTRA_${libname}_${libext}_SOURCES ="
1850 if test "$libtool" = true; then
1851 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1854 if test -n "$pobase"; then
1855 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1858 cat allsnippets.tmp \
1859 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1861 echo "mostlyclean-local: mostlyclean-generic"
1862 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1863 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1864 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1868 rm -f allsnippets.tmp
1871 # func_emit_po_Makevars
1872 # emits the contents of po/ makefile parameterization to standard output.
1874 # - local_gnulib_dir from --local-dir
1875 # - sourcebase directory relative to destdir where to place source code
1876 # - pobase directory relative to destdir where to place *.po files
1877 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1878 func_emit_po_Makevars ()
1880 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1881 func_emit_copyright_notice
1883 echo "# Usually the message domain is the same as the package name."
1884 echo "# But here it has a '-gnulib' suffix."
1885 echo "DOMAIN = ${po_domain}-gnulib"
1887 echo "# These two variables depend on the location of this directory."
1888 echo "subdir = ${pobase}"
1889 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1892 # These options get passed to xgettext.
1893 XGETTEXT_OPTIONS = \
1894 --keyword=_ --flag=_:1:pass-c-format \
1895 --keyword=N_ --flag=N_:1:pass-c-format \
1896 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1897 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1898 --flag=error:3:c-format --flag=error_at_line:5:c-format
1900 # This is the copyright holder that gets inserted into the header of the
1901 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1902 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1904 # This is the email address or URL to which the translators shall report
1905 # bugs in the untranslated strings:
1906 # - Strings which are not entire sentences, see the maintainer guidelines
1907 # in the GNU gettext documentation, section 'Preparing Strings'.
1908 # - Strings which use unclear terms or require additional context to be
1910 # - Strings which make invalid assumptions about notation of date, time or
1912 # - Pluralisation problems.
1913 # - Incorrect English spelling.
1914 # - Incorrect formatting.
1915 # It can be your email address, or a mailing list address where translators
1916 # can write to without being subscribed, or the URL of a web page through
1917 # which the translators can contact you.
1918 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1920 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1921 # message catalogs shall be used. It is usually empty.
1922 EXTRA_LOCALE_CATEGORIES =
1924 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1925 # context. Possible values are "yes" and "no". Set this to yes if the
1926 # package uses functions taking also a message context, like pgettext(), or
1927 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1932 # func_emit_po_POTFILES_in
1933 # emits the file list to be passed to xgettext to standard output.
1935 # - local_gnulib_dir from --local-dir
1936 # - sourcebase directory relative to destdir where to place source code
1937 # - files list of new files
1938 func_emit_po_POTFILES_in ()
1940 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1941 func_emit_copyright_notice
1943 echo "# List of files which contain translatable strings."
1944 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1947 # func_emit_tests_Makefile_am
1948 # emits the contents of tests makefile to standard output.
1950 # - local_gnulib_dir from --local-dir
1951 # - modules list of modules, including dependencies
1952 # - libname library name
1953 # - auxdir directory relative to destdir where to place build aux files
1954 # - makefile_name from --makefile-name
1955 # - libtool true if libtool will be used, false or blank otherwise
1956 # - sourcebase relative directory containing lib source code
1957 # - m4base relative directory containing autoconf macros
1958 # - testsbase relative directory containing unit test code
1959 # - macro_prefix prefix of gl_LIBOBJS macros to use
1960 # - for_test true if creating a package for testing, false otherwise
1961 # - use_libtests true if a libtests.a should be built, false otherwise
1962 # - destfile filename relative to destdir of makefile being generated
1964 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1965 # list of edits to be done to Makefile.am variables
1967 # - uses_subdirs nonempty if object files in subdirs exist
1968 func_emit_tests_Makefile_am ()
1970 if test "$libtool" = true; then
1972 sed_eliminate_LDFLAGS="$sed_noop"
1975 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1978 # When creating a package for testing: Attempt to provoke failures,
1979 # especially link errors, already during "make" rather than during
1980 # "make check", because "make check" is not possible in a cross-compiling
1981 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1982 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1984 sed_transform_check_PROGRAMS="$sed_noop"
1986 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1987 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1988 echo "## Process this file with automake to produce Makefile.in."
1989 func_emit_copyright_notice
1993 for module in $modules; do
1995 func_verify_tests_module
1999 if test -n "$module"; then
2001 func_get_automake_snippet "$module" |
2002 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2003 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2004 -e "$sed_eliminate_LDFLAGS" \
2005 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2006 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2007 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2008 -e "$sed_transform_check_PROGRAMS"
2009 if $use_libtests && test "$module" = 'alloca'; then
2010 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2011 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2014 # Skip the contents if it's entirely empty.
2015 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
2016 echo "## begin gnulib module $module"
2019 echo "## end gnulib module $module"
2023 # Test whether there are some source files in subdirectories.
2024 for f in `func_get_filelist "$module"`; do
2026 lib/*/*.c | tests/*/*.c)
2035 # Generate dependencies here, since it eases the debugging of test failures.
2036 # If there are source files in subdirectories, prevent collision of the
2037 # object files (example: hash.c and libxml/hash.c).
2039 if test -n "$uses_subdirs"; then
2040 subdir_options=' subdir-objects'
2042 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2045 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2048 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2049 # variable is needed to avoid an error from automake:
2050 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2053 echo "TESTS_ENVIRONMENT ="
2054 echo "noinst_PROGRAMS ="
2055 if ! $for_test; then
2056 echo "check_PROGRAMS ="
2058 echo "noinst_HEADERS ="
2059 echo "noinst_LIBRARIES ="
2060 if $use_libtests; then
2062 echo "noinst_LIBRARIES += libtests.a"
2064 echo "check_LIBRARIES = libtests.a"
2067 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2068 # if you specify pkgdata_DATA to empty. This is a workaround.
2069 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
2070 echo "pkgdata_DATA ="
2073 echo "BUILT_SOURCES ="
2075 echo "MOSTLYCLEANFILES = core *.stackdump"
2076 echo "MOSTLYCLEANDIRS ="
2078 echo "DISTCLEANFILES ="
2079 echo "MAINTAINERCLEANFILES ="
2080 # Execute edits that apply to the Makefile.am being generated.
2082 while test $edit != $makefile_am_edits; do
2083 edit=`expr $edit + 1`
2084 eval dir=\"\$makefile_am_edit${edit}_dir\"
2085 eval var=\"\$makefile_am_edit${edit}_var\"
2086 eval val=\"\$makefile_am_edit${edit}_val\"
2087 if test -n "$var"; then
2088 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2089 echo "${var} += ${val}"
2090 eval "makefile_am_edit${edit}_var="
2095 echo "AM_CPPFLAGS = \\"
2096 echo " -I. -I\$(srcdir) \\"
2097 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2098 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2100 local_ldadd_before=''
2101 local_ldadd_after=''
2102 if $use_libtests; then
2103 # All test programs need to be linked with libtests.a.
2104 # It needs to be passed to the linker before ${libname}.${libext}, since
2105 # the tests-related modules depend on the main modules.
2106 # It also needs to be passed to the linker after ${libname}.${libext}
2107 # because the latter might contain incomplete modules (such as the 'error'
2108 # module whose dependency to 'progname' is voluntarily omitted).
2109 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2111 local_ldadd_before=' libtests.a'
2112 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2114 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2116 if $use_libtests; then
2117 echo "libtests_a_SOURCES ="
2118 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2119 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2120 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2121 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2122 echo "EXTRA_libtests_a_SOURCES ="
2123 # The circular dependency in LDADD requires this.
2124 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2127 cat allsnippets.tmp \
2128 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2129 echo "# Clean up after Solaris cc."
2131 echo " rm -rf SunWS_cache"
2133 echo "mostlyclean-local: mostlyclean-generic"
2134 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2135 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2136 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2140 rm -f allsnippets.tmp
2143 # func_emit_initmacro_start macro_prefix
2144 # emits the first few statements of the gl_INIT macro to standard output.
2145 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2146 func_emit_initmacro_start ()
2148 macro_prefix_arg="$1"
2149 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2150 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2151 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2152 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2154 # Furthermore it avoids an automake error like this when a Makefile.am
2155 # that uses pieces of gnulib also uses $(LIBOBJ):
2156 # automatically discovered file `error.c' should not be explicitly mentioned
2157 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2158 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2159 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2160 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2161 # automatically discovered file `error.c' should not be explicitly mentioned
2162 # We let automake know about the files to be distributed through the
2163 # EXTRA_lib_SOURCES variable.
2164 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2165 # Create data variables for checking the presence of files that are mentioned
2166 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2167 # because we want the check to happen when the configure file is created,
2168 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2169 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2170 # in which to expect them.
2171 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2172 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2176 # func_emit_initmacro_end macro_prefix
2177 # emits the last few statements of the gl_INIT macro to standard output.
2178 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2179 func_emit_initmacro_end ()
2181 macro_prefix_arg="$1"
2182 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2183 # The check is performed only when autoconf is run from the directory where
2184 # the configure.ac resides; if it is run from a different directory, the
2186 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2187 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2188 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2189 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2190 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2194 echo " m4_if(m4_sysval, [0], [],"
2195 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2197 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2198 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2199 echo " m4_popdef([AC_LIBSOURCES])"
2200 echo " m4_popdef([AC_REPLACE_FUNCS])"
2201 echo " m4_popdef([AC_LIBOBJ])"
2202 echo " AC_CONFIG_COMMANDS_PRE(["
2203 echo " ${macro_prefix_arg}_libobjs="
2204 echo " ${macro_prefix_arg}_ltlibobjs="
2205 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2206 echo " # Remove the extension."
2207 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2208 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2209 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2210 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2213 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2214 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2218 # func_emit_initmacro_done macro_prefix sourcebase
2219 # emits a few statements after the gl_INIT macro to standard output.
2220 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2221 # - sourcebase directory relative to destdir where to place source code
2222 func_emit_initmacro_done ()
2224 macro_prefix_arg="$1"
2227 echo "# Like AC_LIBOBJ, except that the module name goes"
2228 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2229 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2230 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2231 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2234 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2235 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2236 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2237 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2238 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2241 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2242 echo "# expected is derived from the gnulib-tool parameterization,"
2243 echo "# and alloca is special cased (for the alloca-opt module)."
2244 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2245 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2246 echo " m4_foreach([_gl_NAME], [\$1], ["
2247 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2248 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2249 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2255 # func_import modules
2256 # Uses also the variables
2257 # - destdir target directory
2258 # - local_gnulib_dir from --local-dir
2259 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2260 # - libname library name
2261 # - sourcebase directory relative to destdir where to place source code
2262 # - m4base directory relative to destdir where to place *.m4 macros
2263 # - pobase directory relative to destdir where to place *.po files
2264 # - docbase directory relative to destdir where to place doc files
2265 # - testsbase directory relative to destdir where to place unit test code
2266 # - auxdir directory relative to destdir where to place build aux files
2267 # - inctests true if --with-tests was given, blank otherwise
2268 # - incobsolete true if --with-obsolete was given, blank otherwise
2269 # - avoidlist list of modules to avoid, from --avoid
2270 # - lgpl yes or a number if library's license shall be LGPL,
2272 # - makefile_name from --makefile-name
2273 # - libtool true if --libtool was given, false if --no-libtool was
2274 # given, blank otherwise
2275 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2276 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2277 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2278 # - vc_files true if --vc-files was given, false if --no-vc-files was
2279 # given, blank otherwise
2280 # - autoconf_minversion minimum supported autoconf version
2281 # - doit : if actions shall be executed, false if only to be printed
2282 # - symbolic true if files should be symlinked, copied otherwise
2283 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2285 # - do_copyrights true if copyright notices in files should be replaced,
2289 # Get the cached settings.
2290 cached_local_gnulib_dir=
2291 cached_specified_modules=
2302 cached_makefile_name=
2304 cached_macro_prefix=
2308 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2309 cached_libtool=false
2315 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2325 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2327 /gl_WITH_OBSOLETE/ {
2328 s,^.*$,cached_incobsolete=true,p
2331 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2334 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2337 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2340 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2343 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2346 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2349 s,^.*$,cached_inctests=true,p
2352 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2355 s,^.*gl_LGPL([[ ]*\([^])]*\).*$,cached_lgpl="\1",p
2358 s,^.*$,cached_lgpl=yes,p
2360 /gl_MAKEFILE_NAME(/ {
2361 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2364 s,^.*$,cached_libtool=true,p
2366 /gl_MACRO_PREFIX(/ {
2367 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2370 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2373 s,^.*gl_VC_FILES([[ ]*\([^])]*\).*$,cached_vc_files="\1",p
2375 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2376 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2381 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2382 s,^.*$,cached_files=",p
2394 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2398 # Merge the cached settings with the specified ones.
2399 # The m4base must be the same as expected from the pathname.
2400 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2401 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2403 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2404 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2405 if test -z "$local_gnulib_dir"; then
2406 if test -n "$cached_local_gnulib_dir"; then
2409 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2411 case "$cached_local_gnulib_dir" in
2413 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2415 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2416 local_gnulib_dir="$relconcat" ;;
2421 # Append the cached and the specified module names. So that
2422 # "gnulib-tool --import foo" means to add the module foo.
2423 specified_modules="$cached_specified_modules $1"
2424 # Included obsolete modules among the dependencies if specified either way.
2425 if test -z "$incobsolete"; then
2426 incobsolete="$cached_incobsolete"
2428 # Append the cached and the specified avoidlist. This is probably better
2429 # than dropping the cached one when --avoid is specified at least once.
2430 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2431 avoidlist=`echo $avoidlist`
2433 # The sourcebase defaults to the cached one.
2434 if test -z "$sourcebase"; then
2435 sourcebase="$cached_sourcebase"
2436 if test -z "$sourcebase"; then
2437 func_fatal_error "missing --source-base option"
2440 # The pobase defaults to the cached one.
2441 if test -z "$pobase"; then
2442 pobase="$cached_pobase"
2444 # The docbase defaults to the cached one.
2445 if test -z "$docbase"; then
2446 docbase="$cached_docbase"
2447 if test -z "$docbase"; then
2448 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."
2451 # The testsbase defaults to the cached one.
2452 if test -z "$testsbase"; then
2453 testsbase="$cached_testsbase"
2454 if test -z "$testsbase"; then
2455 func_fatal_error "missing --tests-base option"
2458 # Require the tests if specified either way.
2459 if test -z "$inctests"; then
2460 inctests="$cached_inctests"
2462 # The libname defaults to the cached one.
2463 if test -z "$supplied_libname"; then
2464 libname="$cached_libname"
2465 if test -z "$libname"; then
2466 func_fatal_error "missing --lib option"
2469 # Require LGPL if specified either way.
2470 if test -z "$lgpl"; then
2473 # The makefile_name defaults to the cached one.
2474 if test -z "$makefile_name"; then
2475 makefile_name="$cached_makefile_name"
2477 # Use libtool if specified either way, or if guessed.
2478 if test -z "$libtool"; then
2479 if test -n "$cached_m4base"; then
2480 libtool="$cached_libtool"
2482 libtool="$guessed_libtool"
2485 # The macro_prefix defaults to the cached one.
2486 if test -z "$macro_prefix"; then
2487 macro_prefix="$cached_macro_prefix"
2488 if test -z "$macro_prefix"; then
2489 func_fatal_error "missing --macro-prefix option"
2492 # The po_domain defaults to the cached one.
2493 if test -z "$po_domain"; then
2494 po_domain="$cached_po_domain"
2496 # The vc_files defaults to the cached one.
2497 if test -z "$vc_files"; then
2498 vc_files="$cached_vc_files"
2501 # Canonicalize the list of specified modules.
2502 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2504 # Determine final module list.
2505 modules="$specified_modules"
2506 func_modules_transitive_closure
2507 if test $verbose -ge 0; then
2508 echo "Module list with included dependencies:"
2509 echo "$modules" | sed -e 's/^/ /'
2511 final_modules="$modules"
2513 # Determine main module list and tests-related module list separately.
2514 # The main module list is the transitive closure of the specified modules,
2515 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2516 # is specified, it will consist only of LGPLed source.
2517 # The tests-related module list is the transitive closure of the specified
2518 # modules, including tests modules, minus the main module list. Its lib/*
2519 # sources (brought in through dependencies of *-tests modules) go into
2520 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2521 # Determine main module list.
2522 saved_inctests="$inctests"
2524 modules="$specified_modules"
2525 func_modules_transitive_closure
2526 main_modules="$modules"
2527 inctests="$saved_inctests"
2528 if test $verbose -ge 1; then
2529 echo "Main module list:"
2530 echo "$main_modules" | sed -e 's/^/ /'
2532 # Determine tests-related module list.
2533 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2534 testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2535 if test $verbose -ge 1; then
2536 echo "Tests-related module list:"
2537 echo "$testsrelated_modules" | sed -e 's/^/ /'
2540 # Add the dummy module to the main module list if needed.
2541 modules="$main_modules"
2542 func_modules_add_dummy
2543 main_modules="$modules"
2545 # Determine whether a $testsbase/libtests.a is needed.
2547 for module in $testsrelated_modules; do
2548 func_verify_nontests_module
2549 if test -n "$module"; then
2550 all_files=`func_get_filelist $module`
2551 # Test whether some file in $all_files lies in lib/.
2552 for f in $all_files; do
2563 # Add the dummy module to the tests-related module list if needed.
2564 if $use_libtests; then
2565 modules="$testsrelated_modules"
2566 func_modules_add_dummy
2567 testsrelated_modules="$modules"
2570 # If --lgpl, verify that the licenses of modules are compatible.
2571 if test -n "$lgpl"; then
2572 license_incompatibilities=
2573 for module in $main_modules; do
2574 license=`func_get_license $module`
2576 'GPLed build tool') ;;
2577 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2583 *) func_append license_incompatibilities "$module $license$nl" ;;
2589 *) func_append license_incompatibilities "$module $license$nl" ;;
2592 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2597 if test -n "$license_incompatibilities"; then
2598 # Format the license incompatibilities as a table.
2599 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
2600 s,^\(.................................................[^ ]*\) *, \1 ,'
2601 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
2602 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
2606 # Show banner notice of every module.
2607 modules="$main_modules"
2610 # Determine script to apply to imported library files.
2611 sed_transform_lib_file=
2612 for module in $main_modules; do
2613 if test $module = config-h; then
2614 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2615 sed_transform_lib_file=$sed_transform_lib_file'
2616 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2621 sed_transform_main_lib_file="$sed_transform_lib_file"
2622 if test -n "$do_copyrights"; then
2623 if test -n "$lgpl"; then
2627 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2628 s/GNU General/GNU Lesser General/g
2632 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2633 s/GNU General/GNU Lesser General/g
2634 s/version [23]\([ ,]\)/version 2.1\1/g
2637 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2641 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2642 s/GNU Lesser General/GNU General/g
2643 s/GNU Library General/GNU General/g
2644 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2649 # Determine script to apply to library files that go into $testsbase/.
2650 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2651 if test -n "$do_copyrights"; then
2653 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2654 s/GNU Lesser General/GNU General/g
2655 s/GNU Library General/GNU General/g
2656 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2660 # Determine the final file lists.
2661 # They must be computed separately, because files in lib/* go into
2662 # $sourcebase/ if they are in the main file list but into $testsbase/
2663 # if they are in the tests-related file list. Furthermore lib/dummy.c
2665 # Determine final main file list.
2666 modules="$main_modules"
2667 func_modules_to_filelist
2669 # Determine final tests-related file list.
2670 modules="$testsrelated_modules"
2671 func_modules_to_filelist
2672 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2673 # Merge both file lists.
2674 sed_remove_empty_lines='/^$/d'
2675 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2676 if test $verbose -ge 0; then
2678 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2679 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2683 || func_fatal_error "refusing to do nothing"
2685 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2686 new_files="$files m4/gnulib-tool.m4"
2687 old_files="$cached_files"
2688 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2689 func_append old_files " m4/gnulib-tool.m4"
2692 sed_rewrite_old_files="\
2693 s,^build-aux/,$auxdir/,
2694 s,^doc/,$cached_docbase/,
2695 s,^lib/,$cached_sourcebase/,
2696 s,^m4/,$cached_m4base/,
2697 s,^tests/,$cached_testsbase/,
2698 s,^tests=lib/,$cached_testsbase/,
2700 sed_rewrite_new_files="\
2701 s,^build-aux/,$auxdir/,
2703 s,^lib/,$sourcebase/,
2705 s,^tests/,$testsbase/,
2706 s,^tests=lib/,$testsbase/,
2709 # Create directories.
2710 { echo "$sourcebase"
2712 if test -n "$pobase"; then
2715 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2716 if test -n "$docfiles"; then
2719 if test -n "$inctests"; then
2723 for f in $files; do echo $f; done \
2724 | sed -e "$sed_rewrite_new_files" \
2725 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2728 { # Rearrange file descriptors. Needed because "while ... done < ..."
2729 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2730 exec 5<&0 < "$tmp"/dirs
2732 if test ! -d "$destdir/$d"; then
2734 echo "Creating directory $destdir/$d"
2735 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2737 echo "Create directory $destdir/$d"
2744 # func_dest_tmpfilename file
2745 # determines the name of a temporary file (file is relative to destdir).
2747 # - tmpfile absolute filename of the temporary file
2748 func_dest_tmpfilename ()
2751 # Put the new contents of $file in a file in the same directory (needed
2752 # to guarantee that an 'mv' to "$destdir/$file" works).
2753 tmpfile="$destdir/$1.tmp"
2755 # Put the new contents of $file in a file in a temporary directory
2756 # (because the directory of "$file" might not exist).
2757 tmpfile="$tmp"/`basename "$1"`.tmp
2761 # Copy files or make symbolic links. Remove obsolete files.
2765 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2766 # representing the files according to the last gnulib-tool invocation.
2767 for f in $old_files; do echo $f; done \
2768 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2771 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2772 # representing the files after this gnulib-tool invocation.
2773 for f in $new_files; do echo $f; done \
2774 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2777 # First the files that are in old-files, but not in new-files:
2778 sed_take_first_column='s,'"$delimiter"'.*,,'
2779 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2780 # Remove the file. Do nothing if the user already removed it.
2781 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2783 echo "Removing file $g (backup in ${g}~)"
2784 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2786 echo "Remove file $g (backup in ${g}~)"
2788 func_append removed_files "$g$nl"
2791 # func_add_or_update handles a file that ought to be present afterwards.
2793 # - f the original file name
2794 # - g the rewritten file name
2795 # - already_present nonempty if the file already exists, empty otherwise
2796 func_add_or_update ()
2800 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2802 func_dest_tmpfilename "$g"
2803 func_lookup_file "$f"
2804 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2805 if test -n "$sed_transform_main_lib_file"; then
2808 sed -e "$sed_transform_main_lib_file" \
2809 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2813 if test -n "$sed_transform_testsrelated_lib_file"; then
2816 sed -e "$sed_transform_testsrelated_lib_file" \
2817 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2821 if test -f "$destdir/$g"; then
2822 # The file already exists.
2823 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2824 : # The file has not changed.
2828 if test -n "$already_present"; then
2829 echo "Updating file $g (backup in ${g}~)"
2831 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2833 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2834 if { test -n "$symbolic" \
2835 || { test -n "$lsymbolic" \
2836 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2837 && test -z "$lookedup_tmp" \
2838 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2839 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2841 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2844 if test -n "$already_present"; then
2845 echo "Update file $g (backup in ${g}~)"
2847 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2853 # Don't protest if the file should be there but isn't: it happens
2854 # frequently that developers don't put autogenerated files into CVS.
2856 echo "Copying file $g"
2857 if { test -n "$symbolic" \
2858 || { test -n "$lsymbolic" \
2859 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2860 && test -z "$lookedup_tmp" \
2861 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2862 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2864 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2869 func_append added_files "$g$nl"
2873 # Then the files that are in new-files, but not in old-files:
2874 sed_take_last_column='s,^.*'"$delimiter"',,'
2876 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2877 | sed -e "$sed_take_last_column" \
2878 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2879 { # Rearrange file descriptors. Needed because "while ... done < ..."
2880 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2881 exec 5<&0 < "$tmp"/added-files
2887 # Then the files that are in new-files and in old-files:
2888 already_present=true
2889 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2890 | sed -e "$sed_take_last_column" \
2891 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2892 { # Rearrange file descriptors. Needed because "while ... done < ..."
2893 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2894 exec 5<&0 < "$tmp"/kept-files
2901 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2902 actioncmd="gnulib-tool --import"
2903 func_append actioncmd " --dir=$destdir"
2904 if test -n "$local_gnulib_dir"; then
2905 func_append actioncmd " --local-dir=$local_gnulib_dir"
2907 func_append actioncmd " --lib=$libname"
2908 func_append actioncmd " --source-base=$sourcebase"
2909 func_append actioncmd " --m4-base=$m4base"
2910 if test -n "$pobase"; then
2911 func_append actioncmd " --po-base=$pobase"
2913 func_append actioncmd " --doc-base=$docbase"
2914 func_append actioncmd " --tests-base=$testsbase"
2915 func_append actioncmd " --aux-dir=$auxdir"
2916 if test -n "$inctests"; then
2917 func_append actioncmd " --with-tests"
2919 if test -n "$incobsolete"; then
2920 func_append actioncmd " --with-obsolete"
2922 for module in $avoidlist; do
2923 func_append actioncmd " --avoid=$module"
2925 if test -n "$lgpl"; then
2926 if test "$lgpl" = yes; then
2927 func_append actioncmd " --lgpl"
2929 func_append actioncmd " --lgpl=$lgpl"
2932 if test -n "$makefile_name"; then
2933 func_append actioncmd " --makefile-name=$makefile_name"
2935 if test "$libtool" = true; then
2936 func_append actioncmd " --libtool"
2938 func_append actioncmd " --no-libtool"
2940 func_append actioncmd " --macro-prefix=$macro_prefix"
2941 if test -n "$po_domain"; then
2942 func_append actioncmd " --po-domain=$po_domain"
2944 if test -n "$vc_files"; then
2945 if test "$vc_files" = true; then
2946 func_append actioncmd " --vc-files"
2948 func_append actioncmd " --no-vc-files"
2951 func_append actioncmd " `echo $specified_modules`"
2953 # Default the makefile name to Makefile.am.
2954 if test -n "$makefile_name"; then
2955 makefile_am=$makefile_name
2957 makefile_am=Makefile.am
2960 # Create normal Makefile.ams.
2963 # Setup list of Makefile.am edits that are to be performed afterwards.
2964 # Some of these edits apply to files that we will generate; others are
2965 # under the responsibility of the developer.
2967 # func_note_Makefile_am_edit dir var value
2968 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
2970 func_note_Makefile_am_edit ()
2972 makefile_am_edits=`expr $makefile_am_edits + 1`
2973 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
2974 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
2975 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
2977 if test "$makefile_am" = Makefile.am; then
2978 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2979 sourcebase_base=`basename "$sourcebase"`
2980 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
2982 if test -n "$pobase"; then
2983 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
2984 pobase_base=`basename "$pobase"`
2985 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
2987 if test -n "$inctests"; then
2988 if test "$makefile_am" = Makefile.am; then
2989 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2990 testsbase_base=`basename "$testsbase"`
2991 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
2994 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
2996 # Find the first parent directory of $m4base that contains or will contain
2998 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3000 sed_butlast='s,[^/][^/]*//*$,,'
3001 dir1="${m4base}/"; dir2=""
3002 while test -n "$dir1" \
3003 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3004 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3005 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3006 || { test -n "$inctests" \
3007 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3008 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3009 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3010 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3012 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3015 # Create library makefile.
3016 func_dest_tmpfilename $sourcebase/$makefile_am
3017 destfile="$sourcebase/$makefile_am"
3018 modules="$main_modules"
3019 func_emit_lib_Makefile_am > "$tmpfile"
3020 if test -f "$destdir"/$sourcebase/$makefile_am; then
3021 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3025 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3026 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3027 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3029 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3035 echo "Creating $sourcebase/$makefile_am"
3036 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3038 echo "Create $sourcebase/$makefile_am"
3041 func_append added_files "$sourcebase/$makefile_am$nl"
3044 # Create po/ directory.
3045 if test -n "$pobase"; then
3046 # Create po makefile and auxiliary files.
3047 for file in Makefile.in.in remove-potcdate.sin; do
3048 func_dest_tmpfilename $pobase/$file
3049 func_lookup_file build-aux/po/$file
3050 cat "$lookedup_file" > "$tmpfile"
3051 if test -f "$destdir"/$pobase/$file; then
3052 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3056 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3057 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3058 mv -f "$tmpfile" "$destdir"/$pobase/$file
3060 echo "Update $pobase/$file (backup in $pobase/$file~)"
3066 echo "Creating $pobase/$file"
3067 mv -f "$tmpfile" "$destdir"/$pobase/$file
3069 echo "Create $pobase/$file"
3072 func_append added_files "$pobase/$file$nl"
3075 # Create po makefile parameterization, part 1.
3076 func_dest_tmpfilename $pobase/Makevars
3077 func_emit_po_Makevars > "$tmpfile"
3078 if test -f "$destdir"/$pobase/Makevars; then
3079 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3083 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3084 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3085 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3087 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3093 echo "Creating $pobase/Makevars"
3094 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3096 echo "Create $pobase/Makevars"
3099 func_append added_files "$pobase/Makevars$nl"
3101 # Create po makefile parameterization, part 2.
3102 func_dest_tmpfilename $pobase/POTFILES.in
3103 func_emit_po_POTFILES_in > "$tmpfile"
3104 if test -f "$destdir"/$pobase/POTFILES.in; then
3105 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3109 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3110 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3111 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3113 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3119 echo "Creating $pobase/POTFILES.in"
3120 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3122 echo "Create $pobase/POTFILES.in"
3125 func_append added_files "$pobase/POTFILES.in$nl"
3128 TP_URL="http://translationproject.org/latest/"
3129 TP_RSYNC_URI="translationproject.org::tp/latest/"
3131 echo "Fetching gnulib PO files from $TP_URL"
3132 (cd "$destdir"/$pobase \
3133 && { # Prefer rsync over wget if it is available, since it consumes
3134 # less network bandwidth, due to compression.
3135 if type rsync 2>/dev/null | grep / > /dev/null; then
3136 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3138 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3143 echo "Fetch gnulib PO files from $TP_URL"
3145 # Create po/LINGUAS.
3147 func_dest_tmpfilename $pobase/LINGUAS
3148 (cd "$destdir"/$pobase \
3149 && { echo '# Set of available languages.'
3150 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3153 if test -f "$destdir"/$pobase/LINGUAS; then
3154 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3157 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3158 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3159 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3162 echo "Creating $pobase/LINGUAS"
3163 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3164 func_append added_files "$pobase/LINGUAS$nl"
3167 if test -f "$destdir"/$pobase/LINGUAS; then
3168 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3170 echo "Create $pobase/LINGUAS"
3175 # Create m4/gnulib-cache.m4.
3176 func_dest_tmpfilename $m4base/gnulib-cache.m4
3178 func_emit_copyright_notice
3180 echo "# This file represents the specification of how gnulib-tool is used."
3181 echo "# It acts as a cache: It is written and read by gnulib-tool."
3182 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3183 echo "# like the configure.ac and various Makefile.am files."
3186 echo "# Specification in the form of a command-line invocation:"
3189 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3190 # Store the local_gnulib_dir relative to destdir.
3191 case "$local_gnulib_dir" in
3193 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3196 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3198 # destdir, local_gnulib_dir are both relative.
3199 func_relativize "$destdir" "$local_gnulib_dir"
3200 relative_local_gnulib_dir="$reldir" ;;
3203 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3205 echo "$specified_modules" | sed 's/^/ /g'
3207 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3208 echo "gl_AVOID([$avoidlist])"
3209 echo "gl_SOURCE_BASE([$sourcebase])"
3210 echo "gl_M4_BASE([$m4base])"
3211 echo "gl_PO_BASE([$pobase])"
3212 echo "gl_DOC_BASE([$docbase])"
3213 echo "gl_TESTS_BASE([$testsbase])"
3214 test -z "$inctests" || echo "gl_WITH_TESTS"
3215 echo "gl_LIB([$libname])"
3216 if test -n "$lgpl"; then
3217 if test "$lgpl" = yes; then
3220 echo "gl_LGPL([$lgpl])"
3223 echo "gl_MAKEFILE_NAME([$makefile_name])"
3224 if test "$libtool" = true; then
3227 echo "gl_MACRO_PREFIX([$macro_prefix])"
3228 echo "gl_PO_DOMAIN([$po_domain])"
3229 if test -n "$vc_files"; then
3230 echo "gl_VC_FILES([$vc_files])"
3233 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3234 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3238 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3239 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3240 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3242 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3246 echo "# gnulib-cache.m4 ends here"
3253 echo "Creating $m4base/gnulib-cache.m4"
3254 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3256 echo "Create $m4base/gnulib-cache.m4"
3262 # Create m4/gnulib-comp.m4.
3263 func_dest_tmpfilename $m4base/gnulib-comp.m4
3265 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3266 func_emit_copyright_notice
3268 echo "# This file represents the compiled summary of the specification in"
3269 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3270 echo "# to be invoked from configure.ac."
3271 echo "# In projects using CVS, this file can be treated like other built files."
3274 echo "# This macro should be invoked from $configure_ac, in the section"
3275 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3276 echo "# any checks for libraries, header files, types and library functions."
3277 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3279 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3280 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3281 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3282 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3283 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3284 if test -n "$uses_subdirs"; then
3285 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3287 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
3288 echo " AC_REQUIRE([AC_GNU_SOURCE])"
3290 for module in $final_modules; do
3292 if test -n "$module"; then
3293 func_get_autoconf_early_snippet "$module"
3296 | sed -e '/^$/d;' -e 's/^/ /'
3299 echo "# This macro should be invoked from $configure_ac, in the section"
3300 echo "# \"Check for header files, types and library functions\"."
3301 echo "AC_DEFUN([${macro_prefix}_INIT],"
3303 if test "$libtool" = true; then
3304 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3305 echo " gl_cond_libtool=true"
3307 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3308 echo " gl_cond_libtool=false"
3310 echo " gl_ltlibdeps="
3312 if test "$auxdir" != "build-aux"; then
3313 sed_replace_build_aux='
3315 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3316 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3320 sed_replace_build_aux="$sed_noop"
3322 func_emit_initmacro_start $macro_prefix
3323 echo " gl_source_base='$sourcebase'"
3324 for module in $main_modules; do
3326 if test -n "$module"; then
3327 func_get_autoconf_snippet "$module" \
3328 | sed -e '/^$/d;' -e 's/^/ /' \
3329 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3330 -e "$sed_replace_build_aux"
3331 if test "$module" = 'alloca' && test "$libtool" = true; then
3332 echo 'changequote(,)dnl'
3333 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3334 echo 'changequote([, ])dnl'
3335 echo 'AC_SUBST([LTALLOCA])'
3339 func_emit_initmacro_end $macro_prefix
3340 echo " gltests_libdeps="
3341 echo " gltests_ltlibdeps="
3342 func_emit_initmacro_start ${macro_prefix}tests
3343 echo " gl_source_base='$testsbase'"
3344 for module in $testsrelated_modules; do
3346 if test -n "$module"; then
3347 func_get_autoconf_snippet "$module" \
3348 | sed -e '/^$/d;' -e 's/^/ /' \
3349 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3350 -e "$sed_replace_build_aux" \
3351 -e 's/\$gl_cond_libtool/false/g' \
3352 -e 's/gl_libdeps/gltests_libdeps/g' \
3353 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3356 func_emit_initmacro_end ${macro_prefix}tests
3357 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3358 # created using libtool, because libtool already handles the dependencies.
3359 if test "$libtool" != true; then
3360 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3361 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3362 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3363 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3364 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3366 if $use_libtests; then
3367 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3368 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3371 func_emit_initmacro_done $macro_prefix $sourcebase
3372 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3374 echo "# This macro records the list of files which have been installed by"
3375 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3376 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3377 echo "$files" | sed -e 's,^, ,'
3380 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3381 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3385 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3386 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3387 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3389 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3393 echo "# gnulib-comp.m4 ends here"
3400 echo "Creating $m4base/gnulib-comp.m4"
3401 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3403 echo "Create $m4base/gnulib-comp.m4"
3409 if test -n "$inctests"; then
3410 # Create tests makefile.
3411 func_dest_tmpfilename $testsbase/$makefile_am
3412 destfile="$testsbase/$makefile_am"
3413 modules="$testsrelated_modules"
3414 func_emit_tests_Makefile_am > "$tmpfile"
3415 if test -f "$destdir"/$testsbase/$makefile_am; then
3416 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3420 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3421 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3422 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3424 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3430 echo "Creating $testsbase/$makefile_am"
3431 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3433 echo "Create $testsbase/$makefile_am"
3436 func_append added_files "$testsbase/$makefile_am$nl"
3440 if test "$vc_files" != false; then
3441 # Update the .cvsignore and .gitignore files.
3442 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3443 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3444 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3445 echo "$m4base/|A|gnulib-comp.m4"
3446 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3447 { # Rearrange file descriptors. Needed because "while ... done < ..."
3448 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3449 exec 5<&0 < "$tmp"/fileset-changes
3450 func_update_ignorelist ()
3453 if test "$ignore" = .gitignore; then
3454 # In a .gitignore file, "foo" applies to the current directory and all
3455 # subdirectories, whereas "/foo" applies to the current directory only.
3458 doubly_escaped_anchor='\\/'
3462 doubly_escaped_anchor=''
3464 if test -f "$destdir/$dir$ignore"; then
3465 if test -n "$dir_added" || test -n "$dir_removed"; then
3466 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3468 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3469 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
3470 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3471 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
3473 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3475 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3476 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3477 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3478 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,\$/d,' < "$tmp"/ignore-removed; fi
3479 } > "$tmp"/sed-ignore-removed
3480 { cat "$destdir/$dir$ignore"~
3481 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3482 } | sed -f "$tmp"/sed-ignore-removed \
3483 > "$destdir/$dir$ignore"
3485 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3490 if test -n "$dir_added"; then
3492 echo "Creating $destdir/$dir$ignore"
3494 if test "$ignore" = .cvsignore; then
3496 # Automake generates Makefile rules that create .dirstamp files.
3499 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3500 } > "$destdir/$dir$ignore"
3502 echo "Create $destdir/$dir$ignore"
3512 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3513 func_update_ignorelist .cvsignore
3515 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3516 func_update_ignorelist .gitignore
3523 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3524 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3525 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3526 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3527 if test "$next_dir" != "$last_dir"; then
3528 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3529 last_dir="$next_dir"
3534 A) func_append last_dir_added "$file$nl";;
3535 R) func_append last_dir_removed "$file$nl";;
3538 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3545 echo "You may need to add #include directives for the following .h files."
3546 # Intersect $specified_modules and $main_modules
3547 # (since $specified_modules is not necessarily of subset of $main_modules
3548 # - some may have been skipped through --avoid, and since the elements of
3549 # $main_modules but not in $specified_modules can go away without explicit
3550 # notice - through changes in the module dependencies).
3551 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3552 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3553 # First the #include <...> directives without #ifs, sorted for convenience,
3554 # then the #include "..." directives without #ifs, sorted for convenience,
3555 # then the #include directives that are surrounded by #ifs. Not sorted.
3556 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3557 include_directive=`func_get_include_directive "$module"`
3558 case "$nl$include_directive" in
3560 echo "$include_directive" 1>&5
3563 echo "$include_directive" | grep -v 'include "' 1>&6
3564 echo "$include_directive" | grep 'include "' 1>&7
3567 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3569 LC_ALL=C sort -u "$tmp"/include-angles
3570 LC_ALL=C sort -u "$tmp"/include-quotes
3571 cat "$tmp"/include-if
3572 ) | sed -e '/^$/d' -e 's/^/ /'
3573 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3575 for module in $main_modules; do
3576 func_get_link_directive "$module"
3578 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3579 if test `wc -l < "$tmp"/link` != 0; then
3581 echo "You may need to use the following Makefile variables when linking."
3582 echo "Use them in <program>_LDADD when linking a program, or"
3583 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3589 echo "Don't forget to"
3590 if test "$makefile_am" = Makefile.am; then
3591 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3593 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3595 if test -n "$pobase"; then
3596 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3598 if test -n "$inctests"; then
3599 if test "$makefile_am" = Makefile.am; then
3600 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3602 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3606 while test $edit != $makefile_am_edits; do
3607 edit=`expr $edit + 1`
3608 eval dir=\"\$makefile_am_edit${edit}_dir\"
3609 eval var=\"\$makefile_am_edit${edit}_var\"
3610 eval val=\"\$makefile_am_edit${edit}_val\"
3611 if test -n "$var"; then
3612 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
3615 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3616 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3619 # func_create_testdir testdir modules
3621 # - local_gnulib_dir from --local-dir
3622 # - auxdir directory relative to destdir where to place build aux files
3623 func_create_testdir ()
3627 if test -z "$modules"; then
3628 # All modules together.
3629 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3630 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3631 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3632 modules=`func_all_modules`
3633 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3635 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3637 # Check that the license of every module is consistent with the license of
3639 saved_modules="$modules"
3640 saved_inctests="$inctests"
3641 # When computing transitive closures, don't consider $module to depend on
3642 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3643 # on GPL modules - therefore we don't want a warning in this case.
3645 for requested_module in $saved_modules; do
3646 requested_license=`func_get_license "$requested_module"`
3647 if test "$requested_license" != GPL; then
3648 # Here we use func_modules_transitive_closure, not just
3649 # func_get_dependencies, so that we also detect weird situations like
3650 # an LGPL module which depends on a GPLed build tool module which depends
3652 modules="$requested_module"
3653 func_modules_transitive_closure
3654 for module in $modules; do
3655 license=`func_get_license "$module"`
3657 'GPLed build tool') ;;
3658 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3660 case "$requested_license" in
3663 GPLv2+ | LGPLv2+) ;;
3664 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3670 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3676 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3685 modules="$saved_modules"
3686 inctests="$saved_inctests"
3688 # Subdirectory names.
3698 # Determine final module list.
3699 func_modules_transitive_closure
3700 if test $verbose -ge 0; then
3701 echo "Module list with included dependencies:"
3702 echo "$modules" | sed -e 's/^/ /'
3705 # Add the dummy module if needed.
3706 func_modules_add_dummy
3708 # Show banner notice of every module.
3711 # Determine final file list.
3712 func_modules_to_filelist
3713 if test $verbose -ge 0; then
3715 echo "$files" | sed -e 's/^/ /'
3718 sed_rewrite_files="\
3719 s,^build-aux/,$auxdir/,
3721 s,^lib/,$sourcebase/,
3723 s,^tests/,$testsbase/,
3726 # Create directories.
3727 for f in $files; do echo $f; done \
3728 | sed -e "$sed_rewrite_files" \
3729 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3730 | LC_ALL=C sort -u \
3732 { # Rearrange file descriptors. Needed because "while ... done < ..."
3733 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3734 exec 5<&0 < "$tmp"/dirs
3736 mkdir -p "$testdir/$d"
3741 # Copy files or make symbolic links.
3743 for f in $files; do echo $f; done \
3744 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3747 { # Rearrange file descriptors. Needed because "while ... done < ..."
3748 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3749 exec 5<&0 < "$tmp"/files
3751 func_lookup_file "$f"
3752 if test -n "$lookedup_tmp"; then
3753 cp -p "$lookedup_file" "$testdir/$g"
3755 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3756 if { test -n "$symbolic" \
3757 || { test -n "$lsymbolic" \
3758 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3759 func_ln "$lookedup_file" "$testdir/$g"
3761 cp -p "$lookedup_file" "$testdir/$g"
3768 # Create Makefile.ams that are for testing.
3771 # No special edits are needed.
3774 # Create $sourcebase/Makefile.am.
3775 mkdir -p "$testdir/$sourcebase"
3776 destfile="$sourcebase/Makefile.am"
3777 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3778 any_uses_subdirs="$uses_subdirs"
3780 # Create $m4base/Makefile.am.
3781 mkdir -p "$testdir/$m4base"
3782 (echo "## Process this file with automake to produce Makefile.in."
3788 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3791 ) > "$testdir/$m4base/Makefile.am"
3793 subdirs="$sourcebase $m4base"
3794 subdirs_with_configure_ac=""
3796 if false && test -f "$testdir"/$m4base/gettext.m4; then
3797 # Avoid stupid error message from automake:
3798 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3799 mkdir -p "$testdir/po"
3800 (echo "## Process this file with automake to produce Makefile.in."
3801 ) > "$testdir/po/Makefile.am"
3802 func_append subdirs " po"
3805 if test -n "$inctests"; then
3806 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3807 # Viewed from the $testsbase subdirectory, $auxdir is different.
3808 saved_auxdir="$auxdir"
3809 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3810 # Create $testsbase/Makefile.am.
3812 destfile="$testsbase/Makefile.am"
3813 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3814 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3815 # Create $testsbase/configure.ac.
3816 (echo "# Process this file with autoconf to produce a configure script."
3817 echo "AC_INIT([dummy], [0])"
3818 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3819 echo "AM_INIT_AUTOMAKE"
3821 echo "AM_CONFIG_HEADER([config.h])"
3824 echo "AC_PROG_INSTALL"
3825 echo "AC_PROG_MAKE_SET"
3826 echo "AC_PROG_RANLIB"
3828 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3829 echo "AC_GNU_SOURCE"
3832 for module in $modules; do
3834 if test -n "$module"; then
3836 gnumakefile | maintainer-makefile)
3837 # These modules are meant to be used only in the top-level directory.
3840 func_get_autoconf_early_snippet "$module"
3845 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3846 if test "$libtool" = true; then
3847 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3848 echo "gl_cond_libtool=true"
3850 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3851 echo "gl_cond_libtool=false"
3853 echo "gl_ltlibdeps="
3855 # Wrap the set of autoconf snippets into an autoconf macro that is then
3856 # invoked. This is needed because autoconf does not support AC_REQUIRE
3858 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3859 # but we want the AC_REQUIRE to have its normal meaning (provide one
3860 # expansion of the required macro before the current point, and only one
3862 echo "AC_DEFUN([gl_INIT], ["
3863 sed_replace_build_aux='
3865 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3866 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3869 func_emit_initmacro_start $macro_prefix
3870 # We don't have explicit ordering constraints between the various
3871 # autoconf snippets. It's cleanest to put those of the library before
3872 # those of the tests.
3873 echo "gl_source_base='../$sourcebase'"
3874 for module in $modules; do
3875 func_verify_nontests_module
3876 if test -n "$module"; then
3878 gnumakefile | maintainer-makefile)
3879 # These modules are meant to be used only in the top-level directory.
3882 func_get_autoconf_snippet "$module" \
3883 | sed -e "$sed_replace_build_aux"
3888 echo "gl_source_base='.'"
3889 for module in $modules; do
3890 func_verify_tests_module
3891 if test -n "$module"; then
3892 func_get_autoconf_snippet "$module" \
3893 | sed -e "$sed_replace_build_aux"
3896 func_emit_initmacro_end $macro_prefix
3897 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3898 # created using libtool, because libtool already handles the dependencies.
3899 if test "$libtool" != true; then
3900 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3901 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3902 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3903 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3904 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3907 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3911 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3912 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3913 echo "AH_TOP([#include \"../config.h\"])"
3915 echo "AC_OUTPUT([Makefile])"
3916 ) > "$testdir/$testsbase/configure.ac"
3917 auxdir="$saved_auxdir"
3918 func_append subdirs " $testsbase"
3919 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3922 # Create Makefile.am.
3923 (echo "## Process this file with automake to produce Makefile.in."
3925 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3927 echo "SUBDIRS = $subdirs"
3929 echo "ACLOCAL_AMFLAGS = -I $m4base"
3930 ) > "$testdir/Makefile.am"
3932 # Create configure.ac.
3933 (echo "# Process this file with autoconf to produce a configure script."
3934 echo "AC_INIT([dummy], [0])"
3935 if test "$auxdir" != "."; then
3936 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3938 echo "AM_INIT_AUTOMAKE"
3940 echo "AM_CONFIG_HEADER([config.h])"
3943 echo "AC_PROG_INSTALL"
3944 echo "AC_PROG_MAKE_SET"
3946 echo "# For autobuild."
3947 echo "AC_CANONICAL_BUILD"
3948 echo "AC_CANONICAL_HOST"
3950 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3951 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3952 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3953 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3955 echo "AC_PROG_RANLIB"
3957 if test -n "$any_uses_subdirs"; then
3958 echo "AM_PROG_CC_C_O"
3961 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3962 echo "AC_GNU_SOURCE"
3965 for module in $modules; do
3966 func_verify_nontests_module
3967 if test -n "$module"; then
3968 func_get_autoconf_early_snippet "$module"
3971 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3972 if test "$libtool" = true; then
3973 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3974 echo "gl_cond_libtool=true"
3976 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3977 echo "gl_cond_libtool=false"
3979 echo "gl_ltlibdeps="
3981 # Wrap the set of autoconf snippets into an autoconf macro that is then
3982 # invoked. This is needed because autoconf does not support AC_REQUIRE
3984 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3985 # but we want the AC_REQUIRE to have its normal meaning (provide one
3986 # expansion of the required macro before the current point, and only one
3988 echo "AC_DEFUN([gl_INIT], ["
3989 if test "$auxdir" != "build-aux"; then
3990 sed_replace_build_aux='
3992 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3993 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3997 sed_replace_build_aux="$sed_noop"
3999 func_emit_initmacro_start $macro_prefix
4000 echo "gl_source_base='$sourcebase'"
4001 for module in $modules; do
4002 func_verify_nontests_module
4003 if test -n "$module"; then
4004 func_get_autoconf_snippet "$module" \
4005 | sed -e "$sed_replace_build_aux"
4008 func_emit_initmacro_end $macro_prefix
4009 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4010 # created using libtool, because libtool already handles the dependencies.
4011 if test "$libtool" != true; then
4012 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4013 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4014 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4015 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4016 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4019 func_emit_initmacro_done $macro_prefix $sourcebase
4023 if test -n "$subdirs_with_configure_ac"; then
4024 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4026 makefiles="Makefile"
4027 for d in $subdirs; do
4028 # For subdirs that have a configure.ac by their own, it's the subdir's
4029 # configure.ac which creates the subdir's Makefile.am, not this one.
4030 case " $subdirs_with_configure_ac " in
4032 *) func_append makefiles " $d/Makefile" ;;
4035 echo "AC_OUTPUT([$makefiles])"
4036 ) > "$testdir/configure.ac"
4038 # Create autogenerated files.
4040 # Do not use "${AUTORECONF} --force --install", because it may invoke
4041 # autopoint, which brings in older versions of some of our .m4 files.
4042 if test -f $m4base/gettext.m4; then
4043 func_execute_command ${AUTOPOINT} --force || func_exit 1
4044 for f in $m4base/*.m4~; do
4046 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4050 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4051 if ! test -d build-aux; then
4052 func_execute_command mkdir build-aux || func_exit 1
4054 func_execute_command ${AUTOCONF} || func_exit 1
4055 func_execute_command ${AUTOHEADER} || func_exit 1
4056 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4058 if test -n "$inctests"; then
4059 # Create autogenerated files.
4060 (cd "$testdir/$testsbase" || func_exit 1
4061 # Do not use "${AUTORECONF} --force --install", because it may invoke
4062 # autopoint, which brings in older versions of some of our .m4 files.
4063 if test -f ../$m4base/gettext.m4; then
4064 func_execute_command ${AUTOPOINT} --force || func_exit 1
4065 for f in ../$m4base/*.m4~; do
4067 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4071 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4072 if ! test -d ../build-aux; then
4073 func_execute_command mkdir ../build-aux
4075 func_execute_command ${AUTOCONF} || func_exit 1
4076 func_execute_command ${AUTOHEADER} || func_exit 1
4077 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4080 # Need to run configure and make once, to create built files that are to be
4081 # distributed (such as getdate.c).
4082 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4083 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4084 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4085 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4086 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4087 # such $(FOO_H) because they don't refer to distributed files.
4088 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4089 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4090 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4091 | sed -e "$sed_remove_make_variables"`
4092 distributed_built_sources=`for file in $built_sources; do
4093 case "$cleaned_files" in
4098 if test -n "$distributed_built_sources"; then
4100 ./configure || func_exit 1
4102 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4103 make built_sources || func_exit 1
4105 make distclean || func_exit 1
4110 # func_create_megatestdir megatestdir allmodules
4112 # - local_gnulib_dir from --local-dir
4113 # - auxdir directory relative to destdir where to place build aux files
4114 func_create_megatestdir ()
4118 if test -z "$allmodules"; then
4119 allmodules=`func_all_modules`
4123 # First, all modules one by one.
4124 for onemodule in $allmodules; do
4125 func_create_testdir "$megatestdir/$onemodule" $onemodule
4126 func_append megasubdirs "$onemodule "
4128 # Then, all modules all together.
4129 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4130 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
4131 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
4132 func_create_testdir "$megatestdir/ALL" "$allmodules"
4133 func_append megasubdirs "ALL"
4136 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4137 vc_witness="$gnulib_dir/CVS/Entries"; \
4139 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4141 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4142 | sed -e 's,January,01,' -e 's,Jan,01,' \
4143 -e 's,February,02,' -e 's,Feb,02,' \
4144 -e 's,March,03,' -e 's,Mar,03,' \
4145 -e 's,April,04,' -e 's,Apr,04,' \
4147 -e 's,June,06,' -e 's,Jun,06,' \
4148 -e 's,July,07,' -e 's,Jul,07,' \
4149 -e 's,August,08,' -e 's,Aug,08,' \
4150 -e 's,September,09,' -e 's,Sep,09,' \
4151 -e 's,October,10,' -e 's,Oct,10,' \
4152 -e 's,November,11,' -e 's,Nov,11,' \
4153 -e 's,December,12,' -e 's,Dec,12,' \
4154 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4155 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4157 echo "CVSDATE=$cvsdate"
4158 echo "test -d logs || mkdir logs"
4159 echo "for module in $megasubdirs; do"
4160 echo " echo \"Working on module \$module...\""
4161 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4162 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4165 echo " : autobuild project... \$module"
4166 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4167 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4168 echo " : autobuild hostname... \`hostname\`"
4169 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
4171 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4173 ) > "$megatestdir/do-autobuild"
4174 chmod a+x "$megatestdir/do-autobuild"
4176 # Create Makefile.am.
4177 (echo "## Process this file with automake to produce Makefile.in."
4179 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4181 echo "SUBDIRS = $megasubdirs"
4183 echo "EXTRA_DIST = do-autobuild"
4184 ) > "$megatestdir/Makefile.am"
4186 # Create configure.ac.
4187 (echo "# Process this file with autoconf to produce a configure script."
4188 echo "AC_INIT([dummy], [0])"
4189 if test "$auxdir" != "."; then
4190 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4192 echo "AM_INIT_AUTOMAKE"
4194 echo "AC_PROG_MAKE_SET"
4196 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4197 echo "AC_OUTPUT([Makefile])"
4198 ) > "$megatestdir/configure.ac"
4200 # Create autogenerated files.
4202 # Do not use "${AUTORECONF} --install", because autoreconf operates
4203 # recursively, but the subdirectories are already finished, therefore
4204 # calling autoreconf here would only waste lots of CPU time.
4205 func_execute_command ${ACLOCAL} || func_exit 1
4206 func_execute_command mkdir build-aux
4207 func_execute_command ${AUTOCONF} || func_exit 1
4208 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4214 func_fatal_error "no mode specified" ;;
4223 if test -z "$destdir"; then
4226 test -d "$destdir" \
4227 || func_fatal_error "destination directory does not exist: $destdir"
4229 # Prefer configure.ac to configure.in.
4230 if test -f "$destdir"/configure.ac; then
4231 configure_ac="$destdir/configure.ac"
4233 if test -f "$destdir"/configure.in; then
4234 configure_ac="$destdir/configure.in"
4236 func_fatal_error "cannot find $destdir/configure.ac"
4240 # Analyze configure.ac.
4242 guessed_libtool=false
4247 /AC_CONFIG_AUX_DIR/ {
4248 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
4250 /A[CM]_PROG_LIBTOOL/ {
4251 s,^.*$,guessed_libtool=true,p
4253 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4255 if test -z "$auxdir"; then
4256 auxdir="$guessed_auxdir"
4259 # Determine where to apply func_import.
4260 if test -n "$m4base"; then
4261 # Apply func_import to a particular gnulib directory.
4262 # Any number of additional modules can be given.
4263 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4264 # First use of gnulib in the given m4base.
4265 test -n "$supplied_libname" || supplied_libname=true
4266 test -n "$sourcebase" || sourcebase="lib"
4267 test -n "$docbase" || docbase="doc"
4268 test -n "$testsbase" || testsbase="tests"
4269 test -n "$macro_prefix" || macro_prefix="gl"
4273 # Apply func_import to all gnulib directories.
4274 # To get this list of directories, look at Makefile.am. (Not at
4275 # configure, because it may be omitted from CVS. Also, don't run
4276 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4279 if test -f "$destdir"/Makefile.am; then
4280 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4282 for arg in $aclocal_amflags; do
4283 if test -n "$m4dir_is_next"; then
4284 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4288 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4289 func_append m4dirs " $arg"
4290 m4dirs_count=`expr $m4dirs_count + 1`
4296 if test "X$arg" = "X-I"; then
4304 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4305 if test -f "$destdir"/aclocal.m4; then
4306 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4307 sedexpr2='s,^[^/]*$,.,'
4308 sedexpr3='s,/[^/]*$,,'
4309 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4310 m4dirs_count=`echo "$m4dirs" | wc -l`
4313 if test $m4dirs_count = 0; then
4314 # First use of gnulib in a package.
4315 # Any number of additional modules can be given.
4316 test -n "$supplied_libname" || supplied_libname=true
4317 test -n "$sourcebase" || sourcebase="lib"
4319 test -n "$docbase" || docbase="doc"
4320 test -n "$testsbase" || testsbase="tests"
4321 test -n "$macro_prefix" || macro_prefix="gl"
4324 if test $m4dirs_count = 1; then
4325 # There's only one use of gnulib here. Assume the user means it.
4326 # Any number of additional modules can be given.
4327 for m4base in $m4dirs; do
4331 # Ambiguous - guess what the user meant.
4332 if test $# = 0; then
4333 # No further arguments. Guess the user wants to update all of them.
4334 for m4base in $m4dirs; do
4335 # Perform func_import in a subshell, so that variable values
4337 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
4338 # pobase, docbase, testsbase, inctests, libname, lgpl,
4339 # makefile_name, libtool, macro_prefix, po_domain, vc_files
4340 # don't propagate from one directory to another.
4341 (func_import) || func_exit 1
4345 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4353 if test -z "$destdir"; then
4354 func_fatal_error "please specify --dir option"
4357 test -d "$destdir" \
4358 || func_fatal_error "could not create destination directory"
4359 test -n "$auxdir" || auxdir="build-aux"
4360 func_create_testdir "$destdir" "$*"
4363 create-megatestdir )
4364 if test -z "$destdir"; then
4365 func_fatal_error "please specify --dir option"
4367 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4368 test -n "$auxdir" || auxdir="build-aux"
4369 func_create_megatestdir "$destdir" "$*"
4373 test -n "$destdir" || destdir=testdir$$
4374 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4375 test -n "$auxdir" || auxdir="build-aux"
4376 func_create_testdir "$destdir" "$*"
4380 ../configure || func_exit 1
4382 make check || func_exit 1
4383 make distclean || func_exit 1
4384 remaining=`find . -type f -print`
4385 if test -n "$remaining"; then
4386 echo "Remaining files:" $remaining 1>&2
4387 echo "gnulib-tool: *** Stop." 1>&2
4396 test -n "$destdir" || destdir=testdir$$
4397 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4398 test -n "$auxdir" || auxdir="build-aux"
4399 func_create_megatestdir "$destdir" "$*"
4407 remaining=`find . -type f -print`
4408 if test -n "$remaining"; then
4409 echo "Remaining files:" $remaining 1>&2
4410 echo "gnulib-tool: *** Stop." 1>&2
4418 extract-description )
4422 if test -n "$module"; then
4423 func_get_description "$module"
4432 if test -n "$module"; then
4433 func_get_status "$module"
4442 if test -n "$module"; then
4443 func_get_notice "$module"
4452 if test -n "$module"; then
4453 func_get_filelist "$module"
4458 extract-dependencies )
4462 if test -n "$module"; then
4463 func_get_dependencies "$module"
4468 extract-autoconf-snippet )
4472 if test -n "$module"; then
4473 func_get_autoconf_snippet "$module"
4478 extract-automake-snippet )
4482 if test -n "$module"; then
4483 func_get_automake_snippet "$module"
4488 extract-include-directive )
4492 if test -n "$module"; then
4493 func_get_include_directive "$module"
4498 extract-link-directive )
4502 if test -n "$module"; then
4503 func_get_link_directive "$module"
4512 if test -n "$module"; then
4513 func_get_license "$module"
4518 extract-maintainer )
4522 if test -n "$module"; then
4523 func_get_maintainer "$module"
4528 extract-tests-module )
4532 if test -n "$module"; then
4533 func_get_tests_module "$module"
4539 func_fatal_error "unknown operation mode --$mode" ;;
4543 # Undo the effect of the previous 'trap' command. Some shellology:
4544 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4545 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4546 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4547 # 128 + signal number and is set before the trap-registered command is run.
4549 trap 'func_exit $?' 1 2 3 13 15
4554 # indent-tabs-mode: nil
4555 # whitespace-check-buffer-indent: nil