3 # Copyright (C) 2002-2008 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
44 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
45 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
46 AUTOCONF="${AUTOCONFPATH}autoconf"
48 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
49 AUTOHEADER="${AUTOCONFPATH}autoheader"
51 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
52 ACLOCAL="${AUTOMAKEPATH}aclocal"
54 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
55 AUTOMAKE="${AUTOMAKEPATH}automake"
57 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
58 AUTORECONF="${AUTOCONFPATH}autoreconf"
61 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
62 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
63 AUTOPOINT="${GETTEXTPATH}autopoint"
66 # When using GNU sed, turn off as many GNU extensions as possible,
67 # to minimize the risk of accidentally using non-portable features.
68 # However, do this only for gnulib-tool itself, not for the code that
69 # gnulib-tool generates, since we don't want "sed --posix" to leak
71 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
72 # Define sed as an alias.
73 # It is not always possible to use aliases. Aliases are guaranteed to work
74 # if the executing shell is bash and either it is invoked as /bin/sh or
75 # is a version >= 2.0, supporting shopt. This is the common case.
76 # Two other approaches (use of a variable $sed or of a function func_sed
77 # instead of an alias) require massive, fragile code changes.
78 # An other approach (use of function sed) requires `which sed` - but 'which'
79 # is hard to emulate, due to missing "test -x" on some platforms.
80 if test -n "$BASH_VERSION"; then
81 shopt -s expand_aliases >/dev/null 2>&1
83 alias sed='sed --posix'
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 ()
1594 sed_remove_backslash_newline=':a
1601 for module in $modules; do
1602 func_verify_nontests_module
1603 if test -n "$module"; then
1604 # Extract the value of "lib_SOURCES += ...".
1605 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1606 # Ignore .h files since they are not compiled.
1609 *) have_lib_SOURCES=yes ;;
1614 # Add the dummy module, to make sure the library will be non-empty.
1615 if test -z "$have_lib_SOURCES"; then
1616 if func_acceptable "dummy"; then
1617 func_append modules " dummy"
1622 # func_modules_notice
1624 # - local_gnulib_dir from --local-dir
1625 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1626 # - modules list of modules, including dependencies
1627 func_modules_notice ()
1629 if test $verbose -ge -1; then
1630 for module in $modules; do
1632 if test -n "$module"; then
1633 msg=`func_get_notice $module`
1634 if test -n "$msg"; then
1635 echo "Notice from module $module:"
1636 echo "$msg" | sed -e 's/^/ /'
1643 # func_modules_to_filelist
1645 # - local_gnulib_dir from --local-dir
1646 # - modules list of modules, including dependencies
1648 # - files list of files
1649 func_modules_to_filelist ()
1652 for module in $modules; do
1654 if test -n "$module"; then
1655 fs=`func_get_filelist $module`
1656 func_append files " $fs"
1659 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1662 # func_execute_command command [args...]
1663 # Executes a command.
1664 # Uses also the variables
1665 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1666 func_execute_command ()
1668 if test $verbose -ge 0; then
1672 # Commands like automake produce output to stderr even when they succeed.
1673 # Turn this output off if the command succeeds.
1674 "$@" > "$tmp"/cmdout 2>&1
1676 if test $cmdret = 0; then
1680 cat "$tmp"/cmdout 1>&2
1687 # func_emit_lib_Makefile_am
1688 # emits the contents of library makefile to standard output.
1690 # - local_gnulib_dir from --local-dir
1691 # - modules list of modules, including dependencies
1692 # - libname library name
1693 # - pobase directory relative to destdir where to place *.po files
1694 # - auxdir directory relative to destdir where to place build aux files
1695 # - makefile_name from --makefile-name
1696 # - libtool true if libtool will be used, false or blank otherwise
1697 # - macro_prefix prefix of gl_LIBOBJS macros to use
1698 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1699 # - actioncmd (optional) command that will reproduce this invocation
1700 # - for_test true if creating a package for testing, false otherwise
1701 # - destfile filename relative to destdir of makefile being generated
1703 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1704 # list of edits to be done to Makefile.am variables
1706 # - uses_subdirs nonempty if object files in subdirs exist
1707 func_emit_lib_Makefile_am ()
1709 # When creating an includable Makefile.am snippet, augment variables with
1710 # += instead of assigning them.
1711 if test -n "$makefile_name"; then
1716 if test "$libtool" = true; then
1719 sed_eliminate_LDFLAGS="$sed_noop"
1723 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1726 # When creating a package for testing: Attempt to provoke failures,
1727 # especially link errors, already during "make" rather than during
1728 # "make check", because "make check" is not possible in a cross-compiling
1729 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1730 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1732 sed_transform_check_PROGRAMS="$sed_noop"
1734 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1735 echo "## Process this file with automake to produce Makefile.in."
1736 func_emit_copyright_notice
1737 if test -n "$actioncmd"; then
1738 echo "# Reproduce by: $actioncmd"
1743 for module in $modules; do
1744 func_verify_nontests_module
1745 if test -n "$module"; then
1747 func_get_automake_snippet "$module" |
1748 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1749 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1750 -e "$sed_eliminate_LDFLAGS" \
1751 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1752 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1753 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1754 -e "$sed_transform_check_PROGRAMS"
1755 if test "$module" = 'alloca'; then
1756 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1757 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1760 # Skip the contents if it's entirely empty.
1761 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1762 echo "## begin gnulib module $module"
1765 echo "## end gnulib module $module"
1769 # Test whether there are some source files in subdirectories.
1770 for f in `func_get_filelist "$module"`; do
1772 lib/*/*.c) uses_subdirs=yes ;;
1778 if test -z "$makefile_name"; then
1779 # If there are source files in subdirectories, prevent collision of the
1780 # object files (example: hash.c and libxml/hash.c).
1782 if test -n "$uses_subdirs"; then
1783 subdir_options=' subdir-objects'
1785 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1788 if test -z "$makefile_name"; then
1790 echo "noinst_HEADERS ="
1791 echo "noinst_LIBRARIES ="
1792 echo "noinst_LTLIBRARIES ="
1793 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1794 # if you specify pkgdata_DATA to empty. This is a workaround.
1795 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1796 echo "pkgdata_DATA ="
1799 echo "BUILT_SOURCES ="
1802 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1803 if test -z "$makefile_name"; then
1804 echo "MOSTLYCLEANDIRS ="
1806 echo "DISTCLEANFILES ="
1807 echo "MAINTAINERCLEANFILES ="
1809 # Execute edits that apply to the Makefile.am being generated.
1811 while test $edit != $makefile_am_edits; do
1812 edit=`expr $edit + 1`
1813 eval dir=\"\$makefile_am_edit${edit}_dir\"
1814 eval var=\"\$makefile_am_edit${edit}_var\"
1815 eval val=\"\$makefile_am_edit${edit}_val\"
1816 if test -n "$var"; then
1817 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
1818 echo "${var} += ${val}"
1819 eval "makefile_am_edit${edit}_var="
1823 if test -z "$makefile_name"; then
1825 echo "AM_CPPFLAGS ="
1828 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1829 # One of the snippets already specifies an installation location for the
1830 # library. Don't confuse automake by saying it should not be installed.
1833 # By default, the generated library should not be installed.
1834 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1837 echo "${libname}_${libext}_SOURCES ="
1838 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1839 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
1840 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1841 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1842 echo "EXTRA_${libname}_${libext}_SOURCES ="
1843 if test "$libtool" = true; then
1844 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1847 if test -n "$pobase"; then
1848 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1851 cat allsnippets.tmp \
1852 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1854 echo "mostlyclean-local: mostlyclean-generic"
1855 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1856 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1857 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1861 rm -f allsnippets.tmp
1864 # func_emit_po_Makevars
1865 # emits the contents of po/ makefile parameterization to standard output.
1867 # - local_gnulib_dir from --local-dir
1868 # - sourcebase directory relative to destdir where to place source code
1869 # - pobase directory relative to destdir where to place *.po files
1870 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1871 func_emit_po_Makevars ()
1873 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1874 func_emit_copyright_notice
1876 echo "# Usually the message domain is the same as the package name."
1877 echo "# But here it has a '-gnulib' suffix."
1878 echo "DOMAIN = ${po_domain}-gnulib"
1880 echo "# These two variables depend on the location of this directory."
1881 echo "subdir = ${pobase}"
1882 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1885 # These options get passed to xgettext.
1886 XGETTEXT_OPTIONS = \
1887 --keyword=_ --flag=_:1:pass-c-format \
1888 --keyword=N_ --flag=N_:1:pass-c-format \
1889 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1890 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1891 --flag=error:3:c-format --flag=error_at_line:5:c-format
1893 # This is the copyright holder that gets inserted into the header of the
1894 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1895 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1897 # This is the email address or URL to which the translators shall report
1898 # bugs in the untranslated strings:
1899 # - Strings which are not entire sentences, see the maintainer guidelines
1900 # in the GNU gettext documentation, section 'Preparing Strings'.
1901 # - Strings which use unclear terms or require additional context to be
1903 # - Strings which make invalid assumptions about notation of date, time or
1905 # - Pluralisation problems.
1906 # - Incorrect English spelling.
1907 # - Incorrect formatting.
1908 # It can be your email address, or a mailing list address where translators
1909 # can write to without being subscribed, or the URL of a web page through
1910 # which the translators can contact you.
1911 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1913 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1914 # message catalogs shall be used. It is usually empty.
1915 EXTRA_LOCALE_CATEGORIES =
1917 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1918 # context. Possible values are "yes" and "no". Set this to yes if the
1919 # package uses functions taking also a message context, like pgettext(), or
1920 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1925 # func_emit_po_POTFILES_in
1926 # emits the file list to be passed to xgettext to standard output.
1928 # - local_gnulib_dir from --local-dir
1929 # - sourcebase directory relative to destdir where to place source code
1930 # - files list of new files
1931 func_emit_po_POTFILES_in ()
1933 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1934 func_emit_copyright_notice
1936 echo "# List of files which contain translatable strings."
1937 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1940 # func_emit_tests_Makefile_am
1941 # emits the contents of tests makefile to standard output.
1943 # - local_gnulib_dir from --local-dir
1944 # - modules list of modules, including dependencies
1945 # - libname library name
1946 # - auxdir directory relative to destdir where to place build aux files
1947 # - makefile_name from --makefile-name
1948 # - libtool true if libtool will be used, false or blank otherwise
1949 # - sourcebase relative directory containing lib source code
1950 # - m4base relative directory containing autoconf macros
1951 # - testsbase relative directory containing unit test code
1952 # - macro_prefix prefix of gl_LIBOBJS macros to use
1953 # - for_test true if creating a package for testing, false otherwise
1954 # - use_libtests true if a libtests.a should be built, false otherwise
1955 # - destfile filename relative to destdir of makefile being generated
1957 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1958 # list of edits to be done to Makefile.am variables
1960 # - uses_subdirs nonempty if object files in subdirs exist
1961 func_emit_tests_Makefile_am ()
1963 if test "$libtool" = true; then
1965 sed_eliminate_LDFLAGS="$sed_noop"
1968 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1971 # When creating a package for testing: Attempt to provoke failures,
1972 # especially link errors, already during "make" rather than during
1973 # "make check", because "make check" is not possible in a cross-compiling
1974 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1975 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1977 sed_transform_check_PROGRAMS="$sed_noop"
1979 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1980 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1981 echo "## Process this file with automake to produce Makefile.in."
1982 func_emit_copyright_notice
1986 for module in $modules; do
1988 func_verify_tests_module
1992 if test -n "$module"; then
1994 func_get_automake_snippet "$module" |
1995 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1996 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1997 -e "$sed_eliminate_LDFLAGS" \
1998 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
1999 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2000 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2001 -e "$sed_transform_check_PROGRAMS"
2002 if $use_libtests && test "$module" = 'alloca'; then
2003 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2004 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2007 # Skip the contents if it's entirely empty.
2008 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
2009 echo "## begin gnulib module $module"
2012 echo "## end gnulib module $module"
2016 # Test whether there are some source files in subdirectories.
2017 for f in `func_get_filelist "$module"`; do
2019 lib/*/*.c | tests/*/*.c) uses_subdirs=yes ;;
2025 # Generate dependencies here, since it eases the debugging of test failures.
2026 # If there are source files in subdirectories, prevent collision of the
2027 # object files (example: hash.c and libxml/hash.c).
2029 if test -n "$uses_subdirs"; then
2030 subdir_options=' subdir-objects'
2032 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2035 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2038 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2039 # variable is needed to avoid an error from automake:
2040 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2043 echo "TESTS_ENVIRONMENT ="
2044 echo "noinst_PROGRAMS ="
2045 if ! $for_test; then
2046 echo "check_PROGRAMS ="
2048 echo "noinst_HEADERS ="
2049 echo "noinst_LIBRARIES ="
2050 if $use_libtests; then
2052 echo "noinst_LIBRARIES += libtests.a"
2054 echo "check_LIBRARIES = libtests.a"
2057 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2058 # if you specify pkgdata_DATA to empty. This is a workaround.
2059 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
2060 echo "pkgdata_DATA ="
2063 echo "BUILT_SOURCES ="
2065 echo "MOSTLYCLEANFILES = core *.stackdump"
2066 echo "MOSTLYCLEANDIRS ="
2068 echo "DISTCLEANFILES ="
2069 echo "MAINTAINERCLEANFILES ="
2070 # Execute edits that apply to the Makefile.am being generated.
2072 while test $edit != $makefile_am_edits; do
2073 edit=`expr $edit + 1`
2074 eval dir=\"\$makefile_am_edit${edit}_dir\"
2075 eval var=\"\$makefile_am_edit${edit}_var\"
2076 eval val=\"\$makefile_am_edit${edit}_val\"
2077 if test -n "$var"; then
2078 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2079 echo "${var} += ${val}"
2080 eval "makefile_am_edit${edit}_var="
2085 echo "AM_CPPFLAGS = \\"
2086 echo " -I. -I\$(srcdir) \\"
2087 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2088 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2090 local_ldadd_before=''
2091 local_ldadd_after=''
2092 if $use_libtests; then
2093 # All test programs need to be linked with libtests.a.
2094 # It needs to be passed to the linker before ${libname}.${libext}, since
2095 # the tests-related modules depend on the main modules.
2096 # It also needs to be passed to the linker after ${libname}.${libext}
2097 # because the latter might contain incomplete modules (such as the 'error'
2098 # module whose dependency to 'progname' is voluntarily omitted).
2099 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2101 local_ldadd_before=' libtests.a'
2102 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2104 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2106 if $use_libtests; then
2107 echo "libtests_a_SOURCES ="
2108 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2109 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2110 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2111 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2112 echo "EXTRA_libtests_a_SOURCES ="
2113 # The circular dependency in LDADD requires this.
2114 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2117 cat allsnippets.tmp \
2118 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2119 echo "# Clean up after Solaris cc."
2121 echo " rm -rf SunWS_cache"
2123 echo "mostlyclean-local: mostlyclean-generic"
2124 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2125 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2126 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2130 rm -f allsnippets.tmp
2133 # func_emit_initmacro_start macro_prefix
2134 # emits the first few statements of the gl_INIT macro to standard output.
2135 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2136 func_emit_initmacro_start ()
2138 macro_prefix_arg="$1"
2139 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2140 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2141 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2142 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2144 # Furthermore it avoids an automake error like this when a Makefile.am
2145 # that uses pieces of gnulib also uses $(LIBOBJ):
2146 # automatically discovered file `error.c' should not be explicitly mentioned
2147 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2148 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2149 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2150 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2151 # automatically discovered file `error.c' should not be explicitly mentioned
2152 # We let automake know about the files to be distributed through the
2153 # EXTRA_lib_SOURCES variable.
2154 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2155 # Create data variables for checking the presence of files that are mentioned
2156 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2157 # because we want the check to happen when the configure file is created,
2158 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2159 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2160 # in which to expect them.
2161 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2162 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2166 # func_emit_initmacro_end macro_prefix
2167 # emits the last few statements of the gl_INIT macro to standard output.
2168 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2169 func_emit_initmacro_end ()
2171 macro_prefix_arg="$1"
2172 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2173 # The check is performed only when autoconf is run from the directory where
2174 # the configure.ac resides; if it is run from a different directory, the
2176 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2177 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2178 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2179 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2180 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2184 echo " m4_if(m4_sysval, [0], [],"
2185 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2187 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2188 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2189 echo " m4_popdef([AC_LIBSOURCES])"
2190 echo " m4_popdef([AC_REPLACE_FUNCS])"
2191 echo " m4_popdef([AC_LIBOBJ])"
2192 echo " AC_CONFIG_COMMANDS_PRE(["
2193 echo " ${macro_prefix_arg}_libobjs="
2194 echo " ${macro_prefix_arg}_ltlibobjs="
2195 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2196 echo " # Remove the extension."
2197 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2198 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2199 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2200 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2203 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2204 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2208 # func_emit_initmacro_done macro_prefix sourcebase
2209 # emits a few statements after the gl_INIT macro to standard output.
2210 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2211 # - sourcebase directory relative to destdir where to place source code
2212 func_emit_initmacro_done ()
2214 macro_prefix_arg="$1"
2217 echo "# Like AC_LIBOBJ, except that the module name goes"
2218 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2219 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2220 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2221 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2224 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2225 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2226 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2227 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2228 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2231 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2232 echo "# expected is derived from the gnulib-tool parameterization,"
2233 echo "# and alloca is special cased (for the alloca-opt module)."
2234 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2235 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2236 echo " m4_foreach([_gl_NAME], [\$1], ["
2237 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2238 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2239 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2245 # func_import modules
2246 # Uses also the variables
2247 # - destdir target directory
2248 # - local_gnulib_dir from --local-dir
2249 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2250 # - libname library name
2251 # - sourcebase directory relative to destdir where to place source code
2252 # - m4base directory relative to destdir where to place *.m4 macros
2253 # - pobase directory relative to destdir where to place *.po files
2254 # - docbase directory relative to destdir where to place doc files
2255 # - testsbase directory relative to destdir where to place unit test code
2256 # - auxdir directory relative to destdir where to place build aux files
2257 # - inctests true if --with-tests was given, blank otherwise
2258 # - incobsolete true if --with-obsolete was given, blank otherwise
2259 # - avoidlist list of modules to avoid, from --avoid
2260 # - lgpl yes or a number if library's license shall be LGPL,
2262 # - makefile_name from --makefile-name
2263 # - libtool true if --libtool was given, false if --no-libtool was
2264 # given, blank otherwise
2265 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2266 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2267 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2268 # - vc_files true if --vc-files was given, false if --no-vc-files was
2269 # given, blank otherwise
2270 # - autoconf_minversion minimum supported autoconf version
2271 # - doit : if actions shall be executed, false if only to be printed
2272 # - symbolic true if files should be symlinked, copied otherwise
2273 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2275 # - do_copyrights true if copyright notices in files should be replaced,
2279 # Get the cached settings.
2280 cached_local_gnulib_dir=
2281 cached_specified_modules=
2292 cached_makefile_name=
2294 cached_macro_prefix=
2298 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2299 cached_libtool=false
2305 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2315 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2317 /gl_WITH_OBSOLETE/ {
2318 s,^.*$,cached_incobsolete=true,p
2321 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2324 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2327 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2330 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2333 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2336 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2339 s,^.*$,cached_inctests=true,p
2342 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2345 s,^.*gl_LGPL([[ ]*\([^])]*\).*$,cached_lgpl="\1",p
2348 s,^.*$,cached_lgpl=yes,p
2350 /gl_MAKEFILE_NAME(/ {
2351 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2354 s,^.*$,cached_libtool=true,p
2356 /gl_MACRO_PREFIX(/ {
2357 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2360 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2363 s,^.*gl_VC_FILES([[ ]*\([^])]*\).*$,cached_vc_files="\1",p
2365 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2366 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2371 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2372 s,^.*$,cached_files=",p
2384 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2388 # Merge the cached settings with the specified ones.
2389 # The m4base must be the same as expected from the pathname.
2390 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2391 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2393 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2394 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2395 if test -z "$local_gnulib_dir"; then
2396 if test -n "$cached_local_gnulib_dir"; then
2399 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2401 case "$cached_local_gnulib_dir" in
2403 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2405 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2406 local_gnulib_dir="$relconcat" ;;
2411 # Append the cached and the specified module names. So that
2412 # "gnulib-tool --import foo" means to add the module foo.
2413 specified_modules="$cached_specified_modules $1"
2414 # Included obsolete modules among the dependencies if specified either way.
2415 if test -z "$incobsolete"; then
2416 incobsolete="$cached_incobsolete"
2418 # Append the cached and the specified avoidlist. This is probably better
2419 # than dropping the cached one when --avoid is specified at least once.
2420 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2421 avoidlist=`echo $avoidlist`
2423 # The sourcebase defaults to the cached one.
2424 if test -z "$sourcebase"; then
2425 sourcebase="$cached_sourcebase"
2426 if test -z "$sourcebase"; then
2427 func_fatal_error "missing --source-base option"
2430 # The pobase defaults to the cached one.
2431 if test -z "$pobase"; then
2432 pobase="$cached_pobase"
2434 # The docbase defaults to the cached one.
2435 if test -z "$docbase"; then
2436 docbase="$cached_docbase"
2437 if test -z "$docbase"; then
2438 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."
2441 # The testsbase defaults to the cached one.
2442 if test -z "$testsbase"; then
2443 testsbase="$cached_testsbase"
2444 if test -z "$testsbase"; then
2445 func_fatal_error "missing --tests-base option"
2448 # Require the tests if specified either way.
2449 if test -z "$inctests"; then
2450 inctests="$cached_inctests"
2452 # The libname defaults to the cached one.
2453 if test -z "$supplied_libname"; then
2454 libname="$cached_libname"
2455 if test -z "$libname"; then
2456 func_fatal_error "missing --lib option"
2459 # Require LGPL if specified either way.
2460 if test -z "$lgpl"; then
2463 # The makefile_name defaults to the cached one.
2464 if test -z "$makefile_name"; then
2465 makefile_name="$cached_makefile_name"
2467 # Use libtool if specified either way, or if guessed.
2468 if test -z "$libtool"; then
2469 if test -n "$cached_m4base"; then
2470 libtool="$cached_libtool"
2472 libtool="$guessed_libtool"
2475 # The macro_prefix defaults to the cached one.
2476 if test -z "$macro_prefix"; then
2477 macro_prefix="$cached_macro_prefix"
2478 if test -z "$macro_prefix"; then
2479 func_fatal_error "missing --macro-prefix option"
2482 # The po_domain defaults to the cached one.
2483 if test -z "$po_domain"; then
2484 po_domain="$cached_po_domain"
2486 # The vc_files defaults to the cached one.
2487 if test -z "$vc_files"; then
2488 vc_files="$cached_vc_files"
2491 # Canonicalize the list of specified modules.
2492 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2494 # Determine final module list.
2495 modules="$specified_modules"
2496 func_modules_transitive_closure
2497 if test $verbose -ge 0; then
2498 echo "Module list with included dependencies:"
2499 echo "$modules" | sed -e 's/^/ /'
2501 final_modules="$modules"
2503 # Determine main module list and tests-related module list separately.
2504 # The main module list is the transitive closure of the specified modules,
2505 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2506 # is specified, it will consist only of LGPLed source.
2507 # The tests-related module list is the transitive closure of the specified
2508 # modules, including tests modules, minus the main module list. Its lib/*
2509 # sources (brought in through dependencies of *-tests modules) go into
2510 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2511 # Determine main module list.
2512 saved_inctests="$inctests"
2514 modules="$specified_modules"
2515 func_modules_transitive_closure
2516 main_modules="$modules"
2517 inctests="$saved_inctests"
2518 if test $verbose -ge 1; then
2519 echo "Main module list:"
2520 echo "$main_modules" | sed -e 's/^/ /'
2522 # Determine tests-related module list.
2523 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2524 testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2525 if test $verbose -ge 1; then
2526 echo "Tests-related module list:"
2527 echo "$testsrelated_modules" | sed -e 's/^/ /'
2530 # Add the dummy module to the main module list if needed.
2531 modules="$main_modules"
2532 func_modules_add_dummy
2533 main_modules="$modules"
2535 # Determine whether a $testsbase/libtests.a is needed.
2537 for module in $testsrelated_modules; do
2538 func_verify_nontests_module
2539 if test -n "$module"; then
2540 all_files=`func_get_filelist $module`
2541 lib_files=`for f in $all_files; do \
2545 done | sed -e 's,^lib/,,'`
2546 if test -n "$lib_files"; then
2553 # Add the dummy module to the tests-related module list if needed.
2554 if $use_libtests; then
2555 modules="$testsrelated_modules"
2556 func_modules_add_dummy
2557 testsrelated_modules="$modules"
2560 # If --lgpl, verify that the licenses of modules are compatible.
2561 if test -n "$lgpl"; then
2562 license_incompatibilities=
2563 for module in $main_modules; do
2564 license=`func_get_license $module`
2566 'GPLed build tool') ;;
2567 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2573 *) func_append license_incompatibilities "$module $license$nl" ;;
2579 *) func_append license_incompatibilities "$module $license$nl" ;;
2582 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2587 if test -n "$license_incompatibilities"; then
2588 # Format the license incompatibilities as a table.
2589 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
2590 s,^\(.................................................[^ ]*\) *, \1 ,'
2591 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
2592 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
2596 # Show banner notice of every module.
2597 modules="$main_modules"
2600 # Determine script to apply to imported library files.
2601 sed_transform_lib_file=
2602 for module in $main_modules; do
2603 if test $module = config-h; then
2604 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2605 sed_transform_lib_file=$sed_transform_lib_file'
2606 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2611 sed_transform_main_lib_file="$sed_transform_lib_file"
2612 if test -n "$do_copyrights"; then
2613 if test -n "$lgpl"; then
2617 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2618 s/GNU General/GNU Lesser General/g
2622 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2623 s/GNU General/GNU Lesser General/g
2624 s/version [23]\([ ,]\)/version 2.1\1/g
2627 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2631 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2632 s/GNU Lesser General/GNU General/g
2633 s/GNU Library General/GNU General/g
2634 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2639 # Determine script to apply to library files that go into $testsbase/.
2640 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2641 if test -n "$do_copyrights"; then
2643 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2644 s/GNU Lesser General/GNU General/g
2645 s/GNU Library General/GNU General/g
2646 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2650 # Determine the final file lists.
2651 # They must be computed separately, because files in lib/* go into
2652 # $sourcebase/ if they are in the main file list but into $testsbase/
2653 # if they are in the tests-related file list. Furthermore lib/dummy.c
2655 # Determine final main file list.
2656 modules="$main_modules"
2657 func_modules_to_filelist
2659 # Determine final tests-related file list.
2660 modules="$testsrelated_modules"
2661 func_modules_to_filelist
2662 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2663 # Merge both file lists.
2664 sed_remove_empty_lines='/^$/d'
2665 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2666 if test $verbose -ge 0; then
2668 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2669 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2673 || func_fatal_error "refusing to do nothing"
2675 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2676 new_files="$files m4/gnulib-tool.m4"
2677 old_files="$cached_files"
2678 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2679 func_append old_files " m4/gnulib-tool.m4"
2682 sed_rewrite_old_files="\
2683 s,^build-aux/,$auxdir/,
2684 s,^doc/,$cached_docbase/,
2685 s,^lib/,$cached_sourcebase/,
2686 s,^m4/,$cached_m4base/,
2687 s,^tests/,$cached_testsbase/,
2688 s,^tests=lib/,$cached_testsbase/,
2690 sed_rewrite_new_files="\
2691 s,^build-aux/,$auxdir/,
2693 s,^lib/,$sourcebase/,
2695 s,^tests/,$testsbase/,
2696 s,^tests=lib/,$testsbase/,
2699 # Create directories.
2700 { echo "$sourcebase"
2702 if test -n "$pobase"; then
2705 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2706 if test -n "$docfiles"; then
2709 if test -n "$inctests"; then
2713 for f in $files; do echo $f; done \
2714 | sed -e "$sed_rewrite_new_files" \
2715 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2718 { # Rearrange file descriptors. Needed because "while ... done < ..."
2719 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2720 exec 5<&0 < "$tmp"/dirs
2722 if test ! -d "$destdir/$d"; then
2724 echo "Creating directory $destdir/$d"
2725 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2727 echo "Create directory $destdir/$d"
2734 # func_dest_tmpfilename file
2735 # determines the name of a temporary file (file is relative to destdir).
2737 # - tmpfile absolute filename of the temporary file
2738 func_dest_tmpfilename ()
2741 # Put the new contents of $file in a file in the same directory (needed
2742 # to guarantee that an 'mv' to "$destdir/$file" works).
2743 tmpfile="$destdir/$1.tmp"
2745 # Put the new contents of $file in a file in a temporary directory
2746 # (because the directory of "$file" might not exist).
2747 tmpfile="$tmp"/`basename "$1"`.tmp
2751 # Copy files or make symbolic links. Remove obsolete files.
2755 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2756 # representing the files according to the last gnulib-tool invocation.
2757 for f in $old_files; do echo $f; done \
2758 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2761 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2762 # representing the files after this gnulib-tool invocation.
2763 for f in $new_files; do echo $f; done \
2764 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2767 # First the files that are in old-files, but not in new-files:
2768 sed_take_first_column='s,'"$delimiter"'.*,,'
2769 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2770 # Remove the file. Do nothing if the user already removed it.
2771 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2773 echo "Removing file $g (backup in ${g}~)"
2774 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2776 echo "Remove file $g (backup in ${g}~)"
2778 func_append removed_files "$g$nl"
2781 # func_add_or_update handles a file that ought to be present afterwards.
2783 # - f the original file name
2784 # - g the rewritten file name
2785 # - already_present nonempty if the file already exists, empty otherwise
2786 func_add_or_update ()
2790 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2792 func_dest_tmpfilename "$g"
2793 func_lookup_file "$f"
2794 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2795 if test -n "$sed_transform_main_lib_file"; then
2798 sed -e "$sed_transform_main_lib_file" \
2799 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2803 if test -n "$sed_transform_testsrelated_lib_file"; then
2806 sed -e "$sed_transform_testsrelated_lib_file" \
2807 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2811 if test -f "$destdir/$g"; then
2812 # The file already exists.
2813 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2814 : # The file has not changed.
2818 if test -n "$already_present"; then
2819 echo "Updating file $g (backup in ${g}~)"
2821 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2823 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2824 if { test -n "$symbolic" \
2825 || { test -n "$lsymbolic" \
2826 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2827 && test -z "$lookedup_tmp" \
2828 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2829 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2831 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2834 if test -n "$already_present"; then
2835 echo "Update file $g (backup in ${g}~)"
2837 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2843 # Don't protest if the file should be there but isn't: it happens
2844 # frequently that developers don't put autogenerated files into CVS.
2846 echo "Copying file $g"
2847 if { test -n "$symbolic" \
2848 || { test -n "$lsymbolic" \
2849 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2850 && test -z "$lookedup_tmp" \
2851 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2852 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2854 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2859 func_append added_files "$g$nl"
2863 # Then the files that are in new-files, but not in old-files:
2864 sed_take_last_column='s,^.*'"$delimiter"',,'
2866 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2867 | sed -e "$sed_take_last_column" \
2868 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2869 { # Rearrange file descriptors. Needed because "while ... done < ..."
2870 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2871 exec 5<&0 < "$tmp"/added-files
2877 # Then the files that are in new-files and in old-files:
2878 already_present=true
2879 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2880 | sed -e "$sed_take_last_column" \
2881 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2882 { # Rearrange file descriptors. Needed because "while ... done < ..."
2883 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2884 exec 5<&0 < "$tmp"/kept-files
2891 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2892 actioncmd="gnulib-tool --import"
2893 func_append actioncmd " --dir=$destdir"
2894 if test -n "$local_gnulib_dir"; then
2895 func_append actioncmd " --local-dir=$local_gnulib_dir"
2897 func_append actioncmd " --lib=$libname"
2898 func_append actioncmd " --source-base=$sourcebase"
2899 func_append actioncmd " --m4-base=$m4base"
2900 if test -n "$pobase"; then
2901 func_append actioncmd " --po-base=$pobase"
2903 func_append actioncmd " --doc-base=$docbase"
2904 func_append actioncmd " --tests-base=$testsbase"
2905 func_append actioncmd " --aux-dir=$auxdir"
2906 if test -n "$inctests"; then
2907 func_append actioncmd " --with-tests"
2909 if test -n "$incobsolete"; then
2910 func_append actioncmd " --with-obsolete"
2912 for module in $avoidlist; do
2913 func_append actioncmd " --avoid=$module"
2915 if test -n "$lgpl"; then
2916 if test "$lgpl" = yes; then
2917 func_append actioncmd " --lgpl"
2919 func_append actioncmd " --lgpl=$lgpl"
2922 if test -n "$makefile_name"; then
2923 func_append actioncmd " --makefile-name=$makefile_name"
2925 if test "$libtool" = true; then
2926 func_append actioncmd " --libtool"
2928 func_append actioncmd " --no-libtool"
2930 func_append actioncmd " --macro-prefix=$macro_prefix"
2931 if test -n "$po_domain"; then
2932 func_append actioncmd " --po-domain=$po_domain"
2934 if test -n "$vc_files"; then
2935 if test "$vc_files" = true; then
2936 func_append actioncmd " --vc-files"
2938 func_append actioncmd " --no-vc-files"
2941 func_append actioncmd " `echo $specified_modules`"
2943 # Default the makefile name to Makefile.am.
2944 if test -n "$makefile_name"; then
2945 makefile_am=$makefile_name
2947 makefile_am=Makefile.am
2950 # Create normal Makefile.ams.
2953 # Setup list of Makefile.am edits that are to be performed afterwards.
2954 # Some of these edits apply to files that we will generate; others are
2955 # under the responsibility of the developer.
2957 # func_note_Makefile_am_edit dir var value
2958 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
2960 func_note_Makefile_am_edit ()
2962 makefile_am_edits=`expr $makefile_am_edits + 1`
2963 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
2964 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
2965 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
2967 if test "$makefile_am" = Makefile.am; then
2968 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2969 sourcebase_base=`basename "$sourcebase"`
2970 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
2972 if test -n "$pobase"; then
2973 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
2974 pobase_base=`basename "$pobase"`
2975 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
2977 if test -n "$inctests"; then
2978 if test "$makefile_am" = Makefile.am; then
2979 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2980 testsbase_base=`basename "$testsbase"`
2981 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
2984 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
2986 # Find the first parent directory of $m4base that contains or will contain
2988 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
2990 sed_butlast='s,[^/][^/]*//*$,,'
2991 dir1="${m4base}/"; dir2=""
2992 while test -n "$dir1" \
2993 && ! { test -f "${destdir}/${dir1}Makefile.am" \
2994 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
2995 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
2996 || { test -n "$inctests" \
2997 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
2998 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
2999 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3000 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3002 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3005 # Create library makefile.
3006 func_dest_tmpfilename $sourcebase/$makefile_am
3007 destfile="$sourcebase/$makefile_am"
3008 modules="$main_modules"
3009 func_emit_lib_Makefile_am > "$tmpfile"
3010 if test -f "$destdir"/$sourcebase/$makefile_am; then
3011 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3015 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3016 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3017 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3019 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3025 echo "Creating $sourcebase/$makefile_am"
3026 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3028 echo "Create $sourcebase/$makefile_am"
3031 func_append added_files "$sourcebase/$makefile_am$nl"
3034 # Create po/ directory.
3035 if test -n "$pobase"; then
3036 # Create po makefile and auxiliary files.
3037 for file in Makefile.in.in remove-potcdate.sin; do
3038 func_dest_tmpfilename $pobase/$file
3039 func_lookup_file build-aux/po/$file
3040 cat "$lookedup_file" > "$tmpfile"
3041 if test -f "$destdir"/$pobase/$file; then
3042 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3046 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3047 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3048 mv -f "$tmpfile" "$destdir"/$pobase/$file
3050 echo "Update $pobase/$file (backup in $pobase/$file~)"
3056 echo "Creating $pobase/$file"
3057 mv -f "$tmpfile" "$destdir"/$pobase/$file
3059 echo "Create $pobase/$file"
3062 func_append added_files "$pobase/$file$nl"
3065 # Create po makefile parameterization, part 1.
3066 func_dest_tmpfilename $pobase/Makevars
3067 func_emit_po_Makevars > "$tmpfile"
3068 if test -f "$destdir"/$pobase/Makevars; then
3069 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3073 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3074 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3075 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3077 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3083 echo "Creating $pobase/Makevars"
3084 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3086 echo "Create $pobase/Makevars"
3089 func_append added_files "$pobase/Makevars$nl"
3091 # Create po makefile parameterization, part 2.
3092 func_dest_tmpfilename $pobase/POTFILES.in
3093 func_emit_po_POTFILES_in > "$tmpfile"
3094 if test -f "$destdir"/$pobase/POTFILES.in; then
3095 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3099 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3100 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3101 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3103 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3109 echo "Creating $pobase/POTFILES.in"
3110 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3112 echo "Create $pobase/POTFILES.in"
3115 func_append added_files "$pobase/POTFILES.in$nl"
3118 TP_URL="http://translationproject.org/latest/"
3119 TP_RSYNC_URI="translationproject.org::tp/latest/"
3121 echo "Fetching gnulib PO files from $TP_URL"
3122 (cd "$destdir"/$pobase \
3123 && { # Prefer rsync over wget if it is available, since it consumes
3124 # less network bandwidth, due to compression.
3125 if type rsync 2>/dev/null | grep / > /dev/null; then
3126 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3128 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3133 echo "Fetch gnulib PO files from $TP_URL"
3135 # Create po/LINGUAS.
3137 func_dest_tmpfilename $pobase/LINGUAS
3138 (cd "$destdir"/$pobase \
3139 && { echo '# Set of available languages.'
3140 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3143 if test -f "$destdir"/$pobase/LINGUAS; then
3144 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3147 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3148 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3149 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3152 echo "Creating $pobase/LINGUAS"
3153 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3154 func_append added_files "$pobase/LINGUAS$nl"
3157 if test -f "$destdir"/$pobase/LINGUAS; then
3158 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3160 echo "Create $pobase/LINGUAS"
3165 # Create m4/gnulib-cache.m4.
3166 func_dest_tmpfilename $m4base/gnulib-cache.m4
3168 func_emit_copyright_notice
3170 echo "# This file represents the specification of how gnulib-tool is used."
3171 echo "# It acts as a cache: It is written and read by gnulib-tool."
3172 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3173 echo "# like the configure.ac and various Makefile.am files."
3176 echo "# Specification in the form of a command-line invocation:"
3179 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3180 # Store the local_gnulib_dir relative to destdir.
3181 case "$local_gnulib_dir" in
3183 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3186 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3188 # destdir, local_gnulib_dir are both relative.
3189 func_relativize "$destdir" "$local_gnulib_dir"
3190 relative_local_gnulib_dir="$reldir" ;;
3193 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3195 echo "$specified_modules" | sed 's/^/ /g'
3197 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3198 echo "gl_AVOID([$avoidlist])"
3199 echo "gl_SOURCE_BASE([$sourcebase])"
3200 echo "gl_M4_BASE([$m4base])"
3201 echo "gl_PO_BASE([$pobase])"
3202 echo "gl_DOC_BASE([$docbase])"
3203 echo "gl_TESTS_BASE([$testsbase])"
3204 test -z "$inctests" || echo "gl_WITH_TESTS"
3205 echo "gl_LIB([$libname])"
3206 if test -n "$lgpl"; then
3207 if test "$lgpl" = yes; then
3210 echo "gl_LGPL([$lgpl])"
3213 echo "gl_MAKEFILE_NAME([$makefile_name])"
3214 if test "$libtool" = true; then
3217 echo "gl_MACRO_PREFIX([$macro_prefix])"
3218 echo "gl_PO_DOMAIN([$po_domain])"
3219 if test -n "$vc_files"; then
3220 echo "gl_VC_FILES([$vc_files])"
3223 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3224 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3228 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3229 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3230 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3232 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3236 echo "# gnulib-cache.m4 ends here"
3243 echo "Creating $m4base/gnulib-cache.m4"
3244 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3246 echo "Create $m4base/gnulib-cache.m4"
3252 # Create m4/gnulib-comp.m4.
3253 func_dest_tmpfilename $m4base/gnulib-comp.m4
3255 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3256 func_emit_copyright_notice
3258 echo "# This file represents the compiled summary of the specification in"
3259 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3260 echo "# to be invoked from configure.ac."
3261 echo "# In projects using CVS, this file can be treated like other built files."
3264 echo "# This macro should be invoked from $configure_ac, in the section"
3265 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3266 echo "# any checks for libraries, header files, types and library functions."
3267 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3269 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3270 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3271 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3272 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3273 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3274 if test -n "$uses_subdirs"; then
3275 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3277 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
3278 echo " AC_REQUIRE([AC_GNU_SOURCE])"
3280 for module in $final_modules; do
3282 if test -n "$module"; then
3283 func_get_autoconf_early_snippet "$module"
3286 | sed -e '/^$/d;' -e 's/^/ /'
3289 echo "# This macro should be invoked from $configure_ac, in the section"
3290 echo "# \"Check for header files, types and library functions\"."
3291 echo "AC_DEFUN([${macro_prefix}_INIT],"
3293 if test "$libtool" = true; then
3294 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3295 echo " gl_cond_libtool=true"
3297 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3298 echo " gl_cond_libtool=false"
3300 echo " gl_ltlibdeps="
3302 if test "$auxdir" != "build-aux"; then
3303 sed_replace_build_aux='
3305 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3306 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3310 sed_replace_build_aux="$sed_noop"
3312 func_emit_initmacro_start $macro_prefix
3313 echo " gl_source_base='$sourcebase'"
3314 for module in $main_modules; do
3316 if test -n "$module"; then
3317 func_get_autoconf_snippet "$module" \
3318 | sed -e '/^$/d;' -e 's/^/ /' \
3319 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3320 -e "$sed_replace_build_aux"
3321 if test "$module" = 'alloca' && test "$libtool" = true; then
3322 echo 'changequote(,)dnl'
3323 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3324 echo 'changequote([, ])dnl'
3325 echo 'AC_SUBST([LTALLOCA])'
3329 func_emit_initmacro_end $macro_prefix
3330 echo " gltests_libdeps="
3331 echo " gltests_ltlibdeps="
3332 func_emit_initmacro_start ${macro_prefix}tests
3333 echo " gl_source_base='$testsbase'"
3334 for module in $testsrelated_modules; do
3336 if test -n "$module"; then
3337 func_get_autoconf_snippet "$module" \
3338 | sed -e '/^$/d;' -e 's/^/ /' \
3339 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3340 -e "$sed_replace_build_aux" \
3341 -e 's/\$gl_cond_libtool/false/g' \
3342 -e 's/gl_libdeps/gltests_libdeps/g' \
3343 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3346 func_emit_initmacro_end ${macro_prefix}tests
3347 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3348 # created using libtool, because libtool already handles the dependencies.
3349 if test "$libtool" != true; then
3350 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3351 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3352 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3353 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3354 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3356 if $use_libtests; then
3357 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3358 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3361 func_emit_initmacro_done $macro_prefix $sourcebase
3362 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3364 echo "# This macro records the list of files which have been installed by"
3365 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3366 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3367 echo "$files" | sed -e 's,^, ,'
3370 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3371 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3375 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3376 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3377 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3379 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3383 echo "# gnulib-comp.m4 ends here"
3390 echo "Creating $m4base/gnulib-comp.m4"
3391 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3393 echo "Create $m4base/gnulib-comp.m4"
3399 if test -n "$inctests"; then
3400 # Create tests makefile.
3401 func_dest_tmpfilename $testsbase/$makefile_am
3402 destfile="$testsbase/$makefile_am"
3403 modules="$testsrelated_modules"
3404 func_emit_tests_Makefile_am > "$tmpfile"
3405 if test -f "$destdir"/$testsbase/$makefile_am; then
3406 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3410 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3411 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3412 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3414 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3420 echo "Creating $testsbase/$makefile_am"
3421 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3423 echo "Create $testsbase/$makefile_am"
3426 func_append added_files "$testsbase/$makefile_am$nl"
3430 if test "$vc_files" != false; then
3431 # Update the .cvsignore and .gitignore files.
3432 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3433 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3434 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3435 echo "$m4base/|A|gnulib-comp.m4"
3436 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3437 { # Rearrange file descriptors. Needed because "while ... done < ..."
3438 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3439 exec 5<&0 < "$tmp"/fileset-changes
3440 func_update_ignorelist ()
3443 if test "$ignore" = .gitignore; then
3444 # In a .gitignore file, "foo" applies to the current directory and all
3445 # subdirectories, whereas "/foo" applies to the current directory only.
3448 doubly_escaped_anchor='\\/'
3452 doubly_escaped_anchor=''
3454 if test -f "$destdir/$dir$ignore"; then
3455 if test -n "$dir_added" || test -n "$dir_removed"; then
3456 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3458 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3459 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
3460 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3461 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
3463 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3465 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3466 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3467 { sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3468 if test -n "$anchor"; then sed -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,\$/d,' < "$tmp"/ignore-removed; fi
3469 } > "$tmp"/sed-ignore-removed
3470 { cat "$destdir/$dir$ignore"~
3471 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3472 } | sed -f "$tmp"/sed-ignore-removed \
3473 > "$destdir/$dir$ignore"
3475 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3480 if test -n "$dir_added"; then
3482 echo "Creating $destdir/$dir$ignore"
3484 if test "$ignore" = .cvsignore; then
3486 # Automake generates Makefile rules that create .dirstamp files.
3489 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3490 } > "$destdir/$dir$ignore"
3492 echo "Create $destdir/$dir$ignore"
3502 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3503 func_update_ignorelist .cvsignore
3505 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3506 func_update_ignorelist .gitignore
3513 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3514 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3515 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3516 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3517 if test "$next_dir" != "$last_dir"; then
3518 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3519 last_dir="$next_dir"
3524 A) func_append last_dir_added "$file$nl";;
3525 R) func_append last_dir_removed "$file$nl";;
3528 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3535 echo "You may need to add #include directives for the following .h files."
3536 # Intersect $specified_modules and $main_modules
3537 # (since $specified_modules is not necessarily of subset of $main_modules
3538 # - some may have been skipped through --avoid, and since the elements of
3539 # $main_modules but not in $specified_modules can go away without explicit
3540 # notice - through changes in the module dependencies).
3541 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3542 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3543 # First the #include <...> directives without #ifs, sorted for convenience,
3544 # then the #include "..." directives without #ifs, sorted for convenience,
3545 # then the #include directives that are surrounded by #ifs. Not sorted.
3546 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3547 include_directive=`func_get_include_directive "$module"`
3548 case "$nl$include_directive" in
3550 echo "$include_directive" 1>&5
3553 echo "$include_directive" | grep -v 'include "' 1>&6
3554 echo "$include_directive" | grep 'include "' 1>&7
3557 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3559 LC_ALL=C sort -u "$tmp"/include-angles
3560 LC_ALL=C sort -u "$tmp"/include-quotes
3561 cat "$tmp"/include-if
3562 ) | sed -e '/^$/d' -e 's/^/ /'
3563 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3565 for module in $main_modules; do
3566 func_get_link_directive "$module"
3568 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3569 if test `wc -l < "$tmp"/link` != 0; then
3571 echo "You may need to use the following Makefile variables when linking."
3572 echo "Use them in <program>_LDADD when linking a program, or"
3573 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3579 echo "Don't forget to"
3580 if test "$makefile_am" = Makefile.am; then
3581 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3583 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3585 if test -n "$pobase"; then
3586 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3588 if test -n "$inctests"; then
3589 if test "$makefile_am" = Makefile.am; then
3590 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3592 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3596 while test $edit != $makefile_am_edits; do
3597 edit=`expr $edit + 1`
3598 eval dir=\"\$makefile_am_edit${edit}_dir\"
3599 eval var=\"\$makefile_am_edit${edit}_var\"
3600 eval val=\"\$makefile_am_edit${edit}_val\"
3601 if test -n "$var"; then
3602 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
3605 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3606 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3609 # func_create_testdir testdir modules
3611 # - local_gnulib_dir from --local-dir
3612 # - auxdir directory relative to destdir where to place build aux files
3613 func_create_testdir ()
3617 if test -z "$modules"; then
3618 # All modules together.
3619 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3620 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3621 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3622 modules=`func_all_modules`
3623 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3625 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3627 # Check that the license of every module is consistent with the license of
3629 saved_modules="$modules"
3630 saved_inctests="$inctests"
3631 # When computing transitive closures, don't consider $module to depend on
3632 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3633 # on GPL modules - therefore we don't want a warning in this case.
3635 for requested_module in $saved_modules; do
3636 requested_license=`func_get_license "$requested_module"`
3637 if test "$requested_license" != GPL; then
3638 # Here we use func_modules_transitive_closure, not just
3639 # func_get_dependencies, so that we also detect weird situations like
3640 # an LGPL module which depends on a GPLed build tool module which depends
3642 modules="$requested_module"
3643 func_modules_transitive_closure
3644 for module in $modules; do
3645 license=`func_get_license "$module"`
3647 'GPLed build tool') ;;
3648 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3650 case "$requested_license" in
3653 GPLv2+ | LGPLv2+) ;;
3654 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3660 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3666 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3675 modules="$saved_modules"
3676 inctests="$saved_inctests"
3678 # Subdirectory names.
3688 # Determine final module list.
3689 func_modules_transitive_closure
3690 if test $verbose -ge 0; then
3691 echo "Module list with included dependencies:"
3692 echo "$modules" | sed -e 's/^/ /'
3695 # Add the dummy module if needed.
3696 func_modules_add_dummy
3698 # Show banner notice of every module.
3701 # Determine final file list.
3702 func_modules_to_filelist
3703 if test $verbose -ge 0; then
3705 echo "$files" | sed -e 's/^/ /'
3708 sed_rewrite_files="\
3709 s,^build-aux/,$auxdir/,
3711 s,^lib/,$sourcebase/,
3713 s,^tests/,$testsbase/,
3716 # Create directories.
3717 for f in $files; do echo $f; done \
3718 | sed -e "$sed_rewrite_files" \
3719 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3720 | LC_ALL=C sort -u \
3722 { # Rearrange file descriptors. Needed because "while ... done < ..."
3723 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3724 exec 5<&0 < "$tmp"/dirs
3726 mkdir -p "$testdir/$d"
3731 # Copy files or make symbolic links.
3733 for f in $files; do echo $f; done \
3734 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3737 { # Rearrange file descriptors. Needed because "while ... done < ..."
3738 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3739 exec 5<&0 < "$tmp"/files
3741 func_lookup_file "$f"
3742 if test -n "$lookedup_tmp"; then
3743 cp -p "$lookedup_file" "$testdir/$g"
3745 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3746 if { test -n "$symbolic" \
3747 || { test -n "$lsymbolic" \
3748 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3749 func_ln "$lookedup_file" "$testdir/$g"
3751 cp -p "$lookedup_file" "$testdir/$g"
3758 # Create Makefile.ams that are for testing.
3761 # No special edits are needed.
3764 # Create $sourcebase/Makefile.am.
3765 mkdir -p "$testdir/$sourcebase"
3766 destfile="$sourcebase/Makefile.am"
3767 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3768 any_uses_subdirs="$uses_subdirs"
3770 # Create $m4base/Makefile.am.
3771 mkdir -p "$testdir/$m4base"
3772 (echo "## Process this file with automake to produce Makefile.in."
3778 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3781 ) > "$testdir/$m4base/Makefile.am"
3783 subdirs="$sourcebase $m4base"
3784 subdirs_with_configure_ac=""
3786 if false && test -f "$testdir"/$m4base/gettext.m4; then
3787 # Avoid stupid error message from automake:
3788 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3789 mkdir -p "$testdir/po"
3790 (echo "## Process this file with automake to produce Makefile.in."
3791 ) > "$testdir/po/Makefile.am"
3792 func_append subdirs " po"
3795 if test -n "$inctests"; then
3796 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3797 # Viewed from the $testsbase subdirectory, $auxdir is different.
3798 saved_auxdir="$auxdir"
3799 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3800 # Create $testsbase/Makefile.am.
3802 destfile="$testsbase/Makefile.am"
3803 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3804 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3805 # Create $testsbase/configure.ac.
3806 (echo "# Process this file with autoconf to produce a configure script."
3807 echo "AC_INIT([dummy], [0])"
3808 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3809 echo "AM_INIT_AUTOMAKE"
3811 echo "AM_CONFIG_HEADER([config.h])"
3814 echo "AC_PROG_INSTALL"
3815 echo "AC_PROG_MAKE_SET"
3816 echo "AC_PROG_RANLIB"
3818 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3819 echo "AC_GNU_SOURCE"
3822 for module in $modules; do
3824 if test -n "$module"; then
3825 func_get_autoconf_early_snippet "$module"
3828 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3829 if test "$libtool" = true; then
3830 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3831 echo "gl_cond_libtool=true"
3833 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3834 echo "gl_cond_libtool=false"
3836 echo "gl_ltlibdeps="
3838 # Wrap the set of autoconf snippets into an autoconf macro that is then
3839 # invoked. This is needed because autoconf does not support AC_REQUIRE
3841 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3842 # but we want the AC_REQUIRE to have its normal meaning (provide one
3843 # expansion of the required macro before the current point, and only one
3845 echo "AC_DEFUN([gl_INIT], ["
3846 sed_replace_build_aux='
3848 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3849 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3852 func_emit_initmacro_start $macro_prefix
3853 # We don't have explicit ordering constraints between the various
3854 # autoconf snippets. It's cleanest to put those of the library before
3855 # those of the tests.
3856 echo "gl_source_base='../$sourcebase'"
3857 for module in $modules; do
3858 func_verify_nontests_module
3859 if test -n "$module"; then
3860 func_get_autoconf_snippet "$module" \
3861 | sed -e "$sed_replace_build_aux"
3864 echo "gl_source_base='.'"
3865 for module in $modules; do
3866 func_verify_tests_module
3867 if test -n "$module"; then
3868 func_get_autoconf_snippet "$module" \
3869 | sed -e "$sed_replace_build_aux"
3872 func_emit_initmacro_end $macro_prefix
3873 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3874 # created using libtool, because libtool already handles the dependencies.
3875 if test "$libtool" != true; then
3876 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3877 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3878 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3879 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3880 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3883 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3887 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3888 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3889 echo "AH_TOP([#include \"../config.h\"])"
3891 echo "AC_OUTPUT([Makefile])"
3892 ) > "$testdir/$testsbase/configure.ac"
3893 auxdir="$saved_auxdir"
3894 func_append subdirs " $testsbase"
3895 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3898 # Create Makefile.am.
3899 (echo "## Process this file with automake to produce Makefile.in."
3901 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3903 echo "SUBDIRS = $subdirs"
3905 echo "ACLOCAL_AMFLAGS = -I $m4base"
3906 ) > "$testdir/Makefile.am"
3908 # Create configure.ac.
3909 (echo "# Process this file with autoconf to produce a configure script."
3910 echo "AC_INIT([dummy], [0])"
3911 if test "$auxdir" != "."; then
3912 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3914 echo "AM_INIT_AUTOMAKE"
3916 echo "AM_CONFIG_HEADER([config.h])"
3919 echo "AC_PROG_INSTALL"
3920 echo "AC_PROG_MAKE_SET"
3922 echo "# For autobuild."
3923 echo "AC_CANONICAL_BUILD"
3924 echo "AC_CANONICAL_HOST"
3926 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3927 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3928 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3929 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3931 echo "AC_PROG_RANLIB"
3933 if test -n "$any_uses_subdirs"; then
3934 echo "AM_PROG_CC_C_O"
3937 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3938 echo "AC_GNU_SOURCE"
3941 for module in $modules; do
3942 func_verify_nontests_module
3943 if test -n "$module"; then
3944 func_get_autoconf_early_snippet "$module"
3947 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3948 if test "$libtool" = true; then
3949 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3950 echo "gl_cond_libtool=true"
3952 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3953 echo "gl_cond_libtool=false"
3955 echo "gl_ltlibdeps="
3957 # Wrap the set of autoconf snippets into an autoconf macro that is then
3958 # invoked. This is needed because autoconf does not support AC_REQUIRE
3960 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3961 # but we want the AC_REQUIRE to have its normal meaning (provide one
3962 # expansion of the required macro before the current point, and only one
3964 echo "AC_DEFUN([gl_INIT], ["
3965 if test "$auxdir" != "build-aux"; then
3966 sed_replace_build_aux='
3968 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3969 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3973 sed_replace_build_aux="$sed_noop"
3975 func_emit_initmacro_start $macro_prefix
3976 echo "gl_source_base='$sourcebase'"
3977 for module in $modules; do
3978 func_verify_nontests_module
3979 if test -n "$module"; then
3980 func_get_autoconf_snippet "$module" \
3981 | sed -e "$sed_replace_build_aux"
3984 func_emit_initmacro_end $macro_prefix
3985 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3986 # created using libtool, because libtool already handles the dependencies.
3987 if test "$libtool" != true; then
3988 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3989 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3990 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3991 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3992 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3995 func_emit_initmacro_done $macro_prefix $sourcebase
3999 if test -n "$subdirs_with_configure_ac"; then
4000 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4002 makefiles="Makefile"
4003 for d in $subdirs; do
4004 # For subdirs that have a configure.ac by their own, it's the subdir's
4005 # configure.ac which creates the subdir's Makefile.am, not this one.
4006 case " $subdirs_with_configure_ac " in
4008 *) func_append makefiles " $d/Makefile" ;;
4011 echo "AC_OUTPUT([$makefiles])"
4012 ) > "$testdir/configure.ac"
4014 # Create autogenerated files.
4016 # Do not use "${AUTORECONF} --force --install", because it may invoke
4017 # autopoint, which brings in older versions of some of our .m4 files.
4018 if test -f $m4base/gettext.m4; then
4019 func_execute_command ${AUTOPOINT} --force || func_exit 1
4020 for f in $m4base/*.m4~; do
4021 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4024 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4025 if ! test -d build-aux; then
4026 func_execute_command mkdir build-aux || func_exit 1
4028 func_execute_command ${AUTOCONF} || func_exit 1
4029 func_execute_command ${AUTOHEADER} || func_exit 1
4030 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4032 if test -n "$inctests"; then
4033 # Create autogenerated files.
4034 (cd "$testdir/$testsbase" || func_exit 1
4035 # Do not use "${AUTORECONF} --force --install", because it may invoke
4036 # autopoint, which brings in older versions of some of our .m4 files.
4037 if test -f ../$m4base/gettext.m4; then
4038 func_execute_command ${AUTOPOINT} --force || func_exit 1
4039 for f in ../$m4base/*.m4~; do
4040 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4043 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4044 if ! test -d ../build-aux; then
4045 func_execute_command mkdir ../build-aux
4047 func_execute_command ${AUTOCONF} || func_exit 1
4048 func_execute_command ${AUTOHEADER} || func_exit 1
4049 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4052 # Need to run configure and make once, to create built files that are to be
4053 # distributed (such as getdate.c).
4054 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4055 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4056 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4057 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4058 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4059 # such $(FOO_H) because they don't refer to distributed files.
4060 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4061 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4062 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4063 | sed -e "$sed_remove_make_variables"`
4064 distributed_built_sources=`for file in $built_sources; do
4065 case "$cleaned_files" in
4070 if test -n "$distributed_built_sources"; then
4072 ./configure || func_exit 1
4074 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4075 make built_sources || func_exit 1
4077 make distclean || func_exit 1
4082 # func_create_megatestdir megatestdir allmodules
4084 # - local_gnulib_dir from --local-dir
4085 # - auxdir directory relative to destdir where to place build aux files
4086 func_create_megatestdir ()
4090 if test -z "$allmodules"; then
4091 allmodules=`func_all_modules`
4095 # First, all modules one by one.
4096 for onemodule in $allmodules; do
4097 func_create_testdir "$megatestdir/$onemodule" $onemodule
4098 func_append megasubdirs "$onemodule "
4100 # Then, all modules all together.
4101 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4102 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
4103 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
4104 func_create_testdir "$megatestdir/ALL" "$allmodules"
4105 func_append megasubdirs "ALL"
4108 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4109 vc_witness="$gnulib_dir/CVS/Entries"; \
4111 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4113 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4114 | sed -e 's,January,01,' -e 's,Jan,01,' \
4115 -e 's,February,02,' -e 's,Feb,02,' \
4116 -e 's,March,03,' -e 's,Mar,03,' \
4117 -e 's,April,04,' -e 's,Apr,04,' \
4119 -e 's,June,06,' -e 's,Jun,06,' \
4120 -e 's,July,07,' -e 's,Jul,07,' \
4121 -e 's,August,08,' -e 's,Aug,08,' \
4122 -e 's,September,09,' -e 's,Sep,09,' \
4123 -e 's,October,10,' -e 's,Oct,10,' \
4124 -e 's,November,11,' -e 's,Nov,11,' \
4125 -e 's,December,12,' -e 's,Dec,12,' \
4126 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4127 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4129 echo "CVSDATE=$cvsdate"
4130 echo "test -d logs || mkdir logs"
4131 echo "for module in $megasubdirs; do"
4132 echo " echo \"Working on module \$module...\""
4133 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4134 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4137 echo " : autobuild project... \$module"
4138 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4139 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4140 echo " : autobuild hostname... \`hostname\`"
4141 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
4143 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4145 ) > "$megatestdir/do-autobuild"
4146 chmod a+x "$megatestdir/do-autobuild"
4148 # Create Makefile.am.
4149 (echo "## Process this file with automake to produce Makefile.in."
4151 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4153 echo "SUBDIRS = $megasubdirs"
4155 echo "EXTRA_DIST = do-autobuild"
4156 ) > "$megatestdir/Makefile.am"
4158 # Create configure.ac.
4159 (echo "# Process this file with autoconf to produce a configure script."
4160 echo "AC_INIT([dummy], [0])"
4161 if test "$auxdir" != "."; then
4162 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4164 echo "AM_INIT_AUTOMAKE"
4166 echo "AC_PROG_MAKE_SET"
4168 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4169 echo "AC_OUTPUT([Makefile])"
4170 ) > "$megatestdir/configure.ac"
4172 # Create autogenerated files.
4174 # Do not use "${AUTORECONF} --install", because autoreconf operates
4175 # recursively, but the subdirectories are already finished, therefore
4176 # calling autoreconf here would only waste lots of CPU time.
4177 func_execute_command ${ACLOCAL} || func_exit 1
4178 func_execute_command mkdir build-aux
4179 func_execute_command ${AUTOCONF} || func_exit 1
4180 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4186 func_fatal_error "no mode specified" ;;
4195 if test -z "$destdir"; then
4198 test -d "$destdir" \
4199 || func_fatal_error "destination directory does not exist: $destdir"
4201 # Prefer configure.ac to configure.in.
4202 if test -f "$destdir"/configure.ac; then
4203 configure_ac="$destdir/configure.ac"
4205 if test -f "$destdir"/configure.in; then
4206 configure_ac="$destdir/configure.in"
4208 func_fatal_error "cannot find $destdir/configure.ac"
4212 # Analyze configure.ac.
4214 guessed_libtool=false
4219 /AC_CONFIG_AUX_DIR/ {
4220 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
4222 /A[CM]_PROG_LIBTOOL/ {
4223 s,^.*$,guessed_libtool=true,p
4225 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4227 if test -z "$auxdir"; then
4228 auxdir="$guessed_auxdir"
4231 # Determine where to apply func_import.
4232 if test -n "$m4base"; then
4233 # Apply func_import to a particular gnulib directory.
4234 # Any number of additional modules can be given.
4235 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4236 # First use of gnulib in the given m4base.
4237 test -n "$supplied_libname" || supplied_libname=true
4238 test -n "$sourcebase" || sourcebase="lib"
4239 test -n "$docbase" || docbase="doc"
4240 test -n "$testsbase" || testsbase="tests"
4241 test -n "$macro_prefix" || macro_prefix="gl"
4245 # Apply func_import to all gnulib directories.
4246 # To get this list of directories, look at Makefile.am. (Not at
4247 # configure, because it may be omitted from CVS. Also, don't run
4248 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4251 if test -f "$destdir"/Makefile.am; then
4252 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4254 for arg in $aclocal_amflags; do
4255 if test -n "$m4dir_is_next"; then
4256 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4260 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4261 func_append m4dirs " $arg"
4262 m4dirs_count=`expr $m4dirs_count + 1`
4268 if test "X$arg" = "X-I"; then
4276 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4277 if test -f "$destdir"/aclocal.m4; then
4278 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4279 sedexpr2='s,^[^/]*$,.,'
4280 sedexpr3='s,/[^/]*$,,'
4281 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4282 m4dirs_count=`echo "$m4dirs" | wc -l`
4285 if test $m4dirs_count = 0; then
4286 # First use of gnulib in a package.
4287 # Any number of additional modules can be given.
4288 test -n "$supplied_libname" || supplied_libname=true
4289 test -n "$sourcebase" || sourcebase="lib"
4291 test -n "$docbase" || docbase="doc"
4292 test -n "$testsbase" || testsbase="tests"
4293 test -n "$macro_prefix" || macro_prefix="gl"
4296 if test $m4dirs_count = 1; then
4297 # There's only one use of gnulib here. Assume the user means it.
4298 # Any number of additional modules can be given.
4299 for m4base in $m4dirs; do
4303 # Ambiguous - guess what the user meant.
4304 if test $# = 0; then
4305 # No further arguments. Guess the user wants to update all of them.
4306 for m4base in $m4dirs; do
4307 # Perform func_import in a subshell, so that variable values
4309 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
4310 # pobase, docbase, testsbase, inctests, libname, lgpl,
4311 # makefile_name, libtool, macro_prefix, po_domain, vc_files
4312 # don't propagate from one directory to another.
4313 (func_import) || func_exit 1
4317 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4325 if test -z "$destdir"; then
4326 func_fatal_error "please specify --dir option"
4329 test -d "$destdir" \
4330 || func_fatal_error "could not create destination directory"
4331 test -n "$auxdir" || auxdir="build-aux"
4332 func_create_testdir "$destdir" "$*"
4335 create-megatestdir )
4336 if test -z "$destdir"; then
4337 func_fatal_error "please specify --dir option"
4339 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4340 test -n "$auxdir" || auxdir="build-aux"
4341 func_create_megatestdir "$destdir" "$*"
4345 test -n "$destdir" || destdir=testdir$$
4346 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4347 test -n "$auxdir" || auxdir="build-aux"
4348 func_create_testdir "$destdir" "$*"
4352 ../configure || func_exit 1
4354 make check || func_exit 1
4355 make distclean || func_exit 1
4356 remaining=`find . -type f -print`
4357 if test -n "$remaining"; then
4358 echo "Remaining files:" $remaining 1>&2
4359 echo "gnulib-tool: *** Stop." 1>&2
4368 test -n "$destdir" || destdir=testdir$$
4369 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4370 test -n "$auxdir" || auxdir="build-aux"
4371 func_create_megatestdir "$destdir" "$*"
4379 remaining=`find . -type f -print`
4380 if test -n "$remaining"; then
4381 echo "Remaining files:" $remaining 1>&2
4382 echo "gnulib-tool: *** Stop." 1>&2
4390 extract-description )
4394 if test -n "$module"; then
4395 func_get_description "$module"
4404 if test -n "$module"; then
4405 func_get_status "$module"
4414 if test -n "$module"; then
4415 func_get_notice "$module"
4424 if test -n "$module"; then
4425 func_get_filelist "$module"
4430 extract-dependencies )
4434 if test -n "$module"; then
4435 func_get_dependencies "$module"
4440 extract-autoconf-snippet )
4444 if test -n "$module"; then
4445 func_get_autoconf_snippet "$module"
4450 extract-automake-snippet )
4454 if test -n "$module"; then
4455 func_get_automake_snippet "$module"
4460 extract-include-directive )
4464 if test -n "$module"; then
4465 func_get_include_directive "$module"
4470 extract-link-directive )
4474 if test -n "$module"; then
4475 func_get_link_directive "$module"
4484 if test -n "$module"; then
4485 func_get_license "$module"
4490 extract-maintainer )
4494 if test -n "$module"; then
4495 func_get_maintainer "$module"
4500 extract-tests-module )
4504 if test -n "$module"; then
4505 func_get_tests_module "$module"
4511 func_fatal_error "unknown operation mode --$mode" ;;
4515 # Undo the effect of the previous 'trap' command. Some shellology:
4516 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4517 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4518 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4519 # 128 + signal number and is set before the trap-registered command is run.
4521 trap 'func_exit $?' 1 2 3 13 15
4526 # indent-tabs-mode: nil
4527 # whitespace-check-buffer-indent: nil