3 # Copyright (C) 2002-2009 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
44 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
45 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
46 AUTOCONF="${AUTOCONFPATH}autoconf"
48 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
49 AUTOHEADER="${AUTOCONFPATH}autoheader"
51 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
52 ACLOCAL="${AUTOMAKEPATH}aclocal"
54 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
55 AUTOMAKE="${AUTOMAKEPATH}automake"
57 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
58 AUTORECONF="${AUTOCONFPATH}autoreconf"
61 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
62 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
63 AUTOPOINT="${GETTEXTPATH}autopoint"
66 # When using GNU sed, turn off as many GNU extensions as possible,
67 # to minimize the risk of accidentally using non-portable features.
68 # However, do this only for gnulib-tool itself, not for the code that
69 # gnulib-tool generates, since we don't want "sed --posix" to leak
71 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
72 # Define sed as an alias.
73 # It is not always possible to use aliases. Aliases are guaranteed to work
74 # if the executing shell is bash and either it is invoked as /bin/sh or
75 # is a version >= 2.0, supporting shopt. This is the common case.
76 # Two other approaches (use of a variable $sed or of a function func_sed
77 # instead of an alias) require massive, fragile code changes.
78 # An other approach (use of function sed) requires `which sed` - but 'which'
79 # is hard to emulate, due to missing "test -x" on some platforms.
80 if test -n "$BASH_VERSION"; then
81 shopt -s expand_aliases >/dev/null 2>&1
83 alias sed='sed --posix'
86 # sed_noop is a sed expression that does nothing.
87 # An empty expression does not work with the native 'sed' on AIX 6.1.
91 # outputs to stdout the --help usage message.
95 Usage: gnulib-tool --list
96 gnulib-tool --import [module1 ... moduleN]
98 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
99 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
100 gnulib-tool --test --dir=directory module1 ... moduleN
101 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
102 gnulib-tool --extract-description module
103 gnulib-tool --extract-status module
104 gnulib-tool --extract-notice module
105 gnulib-tool --extract-filelist module
106 gnulib-tool --extract-dependencies module
107 gnulib-tool --extract-autoconf-snippet module
108 gnulib-tool --extract-automake-snippet module
109 gnulib-tool --extract-include-directive module
110 gnulib-tool --extract-link-directive module
111 gnulib-tool --extract-license module
112 gnulib-tool --extract-maintainer module
113 gnulib-tool --extract-tests-module module
116 --list print the available module names
117 --import import the given modules into the current package;
118 if no modules are specified, update the current
119 package from the current gnulib
120 --update update the current package, restore files omitted
122 --create-testdir create a scratch package with the given modules
123 --create-megatestdir create a mega scratch package with the given modules
124 one by one and all together
125 --test test the combination of the given modules
126 (recommended to use CC=\"gcc -Wall\" here)
127 --megatest test the given modules one by one and all together
128 (recommended to use CC=\"gcc -Wall\" here)
129 --extract-description extract the description
130 --extract-status extract the status (obsolete or not)
131 --extract-notice extract the notice or banner
132 --extract-filelist extract the list of files
133 --extract-dependencies extract the dependencies
134 --extract-autoconf-snippet extract the snippet for configure.ac
135 --extract-automake-snippet extract the snippet for library makefile
136 --extract-include-directive extract the #include directive
137 --extract-link-directive extract the linker directive
138 --extract-license report the license terms of the source files
140 --extract-maintainer report the maintainer(s) inside gnulib
141 --extract-tests-module report the unit test module, if it exists
144 --dir=DIRECTORY Specify the target directory.
145 For --import, this specifies where your
146 configure.ac can be found. Defaults to current
148 --local-dir=DIRECTORY Specify a local override directory where to look
149 up files before looking in gnulib's directory.
150 --verbose Increase verbosity. May be repeated.
151 --quiet Decrease verbosity. May be repeated.
153 Options for --import:
154 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
155 --source-base=DIRECTORY
156 Directory relative to --dir where source code is
157 placed (default \"lib\").
158 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
159 placed (default \"m4\").
160 --po-base=DIRECTORY Directory relative to --dir where *.po files are
161 placed (default \"po\").
162 --doc-base=DIRECTORY Directory relative to --dir where doc files are
163 placed (default \"doc\").
164 --tests-base=DIRECTORY
165 Directory relative to --dir where unit tests are
166 placed (default \"tests\").
167 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
168 tools are placed (default \"build-aux\").
169 --with-tests Include unit tests for the included modules.
170 --with-obsolete Include obsolete modules when they occur among the
171 dependencies. By default, dependencies to obsolete
173 --avoid=MODULE Avoid including the given MODULE. Useful if you
174 have code that provides equivalent functionality.
175 This option can be repeated.
176 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
177 Also modify license template from GPL to LGPL.
178 The version number of the LGPL can be specified;
179 the default is currently LGPLv3.
180 --makefile-name=NAME Name of makefile in automake syntax in the
181 source-base and tests-base directories
182 (default \"Makefile.am\").
183 --libtool Use libtool rules.
184 --no-libtool Don't use libtool rules.
185 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
186 'gl_INIT'. Default is 'gl'.
187 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
188 the package name. A suffix '-gnulib' is appended.
189 --vc-files Update version control related files.
190 --no-vc-files Don't update version control related files
191 (.gitignore and/or .cvsignore).
192 --no-changelog Don't update or create ChangeLog files.
194 Options for --import and --update:
195 --dry-run For --import, only print what would have been done.
196 -s, --symbolic, --symlink Make symbolic links instead of copying files.
197 --local-symlink Make symbolic links instead of copying files, only
198 for files from the local override directory.
199 -S, --more-symlinks Make symbolic links instead of copying files, and
200 don't replace copyright notices.
202 Report bugs to <bug-gnulib@gnu.org>."
206 # outputs to stdout the --version message.
210 if test -d "$gnulib_dir"/.git \
211 && (git --version) >/dev/null 2>/dev/null \
212 && (date --version) >/dev/null 2>/dev/null; then
213 # gnulib checked out from git.
214 sed_extract_first_date='/^Date/{
218 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
219 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
220 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
221 date=`echo "$date" | sed -e "$sed_year_before_time"`
222 # Use GNU date to compute the time in GMT.
223 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
224 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
226 if test -d "$gnulib_dir"/CVS \
227 && (cvs --version) >/dev/null 2>/dev/null; then
228 # gnulib checked out from CVS.
229 sed_extract_first_date='/^date: /{
230 s/^date: \([0-9][0-9][0-9][0-9]\).\([0-9][0-9]\).\([0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1-\2-\3 \4/p
233 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
235 # gnulib copy without versioning information.
236 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
240 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
242 gnulib-tool (GNU $package $date)$version
243 Copyright (C) $year Free Software Foundation, Inc.
244 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
245 This is free software: you are free to change and redistribute it.
246 There is NO WARRANTY, to the extent permitted by law.
248 Written by" "Bruno Haible" "and" "Simon Josefsson"
251 # func_emit_copyright_notice
252 # outputs to stdout a header for a generated file.
253 func_emit_copyright_notice ()
255 sed -n '/Copyright/ {
258 }' < "$self_abspathname"
260 echo "# This file is free software, distributed under the terms of the GNU"
261 echo "# General Public License. As a special exception to the GNU General"
262 echo "# Public License, this file may be distributed as part of a program"
263 echo "# that contains a configuration script generated by Autoconf, under"
264 echo "# the same distribution terms as the rest of that program."
266 echo "# Generated by gnulib-tool."
270 # exits with a given status.
271 # This function needs to be used, rather than 'exit', when a 'trap' handler is
272 # in effect that refers to $?.
279 # locates the directory where the gnulib repository lives
281 # - progname name of this program
283 # - self_abspathname absolute pathname of gnulib-tool
284 # - gnulib_dir absolute pathname of gnulib repository
288 /*) self_abspathname="$progname" ;;
289 */*) self_abspathname=`pwd`/"$progname" ;;
292 # Iterate through the elements of $PATH.
293 # We use IFS=: instead of
294 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
295 # because the latter does not work when some PATH element contains spaces.
296 # We use a canonicalized $pathx instead of $PATH, because empty PATH
297 # elements are by definition equivalent to '.', however field splitting
298 # according to IFS=: loses empty fields in many shells:
299 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
300 # beginning, at the end, and in the middle),
301 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
302 # at the beginning and at the end,
303 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
304 # Solaris lose empty fields at the end.
305 # The 'case' statement is an optimization, to avoid evaluating the
306 # explicit canonicalization command when $PATH contains no empty fields.
308 if test "${PATH_SEPARATOR+set}" != set; then
310 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
311 chmod +x "$tmp"/conf.sh
312 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
319 if test "$PATH_SEPARATOR" = ";"; then
320 # On Windows, programs are searched in "." before $PATH.
323 # On Unix, we have to convert empty PATH elements to ".".
327 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
332 IFS="$PATH_SEPARATOR"
336 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
337 self_abspathname="$d/$progname"
342 if test -z "$self_abspathname"; then
343 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
347 while test -h "$self_abspathname"; do
348 # Resolve symbolic link.
349 linkval=`func_readlink "$self_abspathname"`
350 test -n "$linkval" || break
352 /* ) self_abspathname="$linkval" ;;
353 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
356 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
360 # creates a temporary directory.
362 # - progname name of this program
364 # - tmp pathname of freshly created temporary directory
367 # Use the environment variable TMPDIR, falling back to /tmp. This allows
368 # users to specify a different temporary directory, for example, if their
369 # /tmp is filled up or too small.
372 # Use the mktemp program if available. If not available, hide the error
374 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
375 test -n "$tmp" && test -d "$tmp"
378 # Use a simple mkdir command. It is guaranteed to fail if the directory
379 # already exists. $RANDOM is bash specific and expands to empty in shells
380 # other than bash, ksh and zsh. Its use does not increase security;
381 # rather, it minimizes the probability of failure in a very cluttered /tmp
383 tmp=$TMPDIR/gl$$-$RANDOM
384 (umask 077 && mkdir "$tmp")
387 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
392 # func_append var value
393 # appends the given value to the shell variable var.
394 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
395 # Use bash's += operator. It reduces complexity of appending repeatedly to
396 # a single variable from O(n^2) to O(n).
401 fast_func_append=true
405 eval "$1=\"\$$1\$2\""
407 fast_func_append=false
410 # func_remove_prefix var prefix
411 # removes the given prefix from the value of the shell variable var.
412 # var should be the name of a shell variable.
413 # Its value should not contain a newline and not start or end with whitespace.
414 # prefix should not contain the characters "$`\{}|.
415 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
416 func_remove_prefix ()
420 fast_func_remove_prefix=true
422 func_remove_prefix ()
424 eval "value=\"\$$1\""
426 value=`echo "$value" | sed -e "s|^${prefix}||"`
427 eval "$1=\"\$value\""
429 fast_func_remove_prefix=false
432 # func_remove_suffix var suffix
433 # removes the given suffix from the value of the shell variable var.
434 # var should be the name of a shell variable.
435 # Its value should not contain a newline and not start or end with whitespace.
436 # suffix should not contain the characters "$`\{}|.
437 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
438 func_remove_suffix ()
442 fast_func_remove_suffix=true
444 func_remove_suffix ()
446 eval "value=\"\$$1\""
448 value=`echo "$value" | sed -e "s|${suffix}\$||"`
449 eval "$1=\"\$value\""
451 fast_func_remove_suffix=false
454 # func_fatal_error message
455 # outputs to stderr a fatal error message, and terminates the program.
457 # - progname name of this program
460 echo "$progname: *** $1" 1>&2
461 echo "$progname: *** Stop." 1>&2
465 # func_readlink SYMLINK
466 # outputs the target of the given symlink.
467 if (type -p readlink) > /dev/null 2>&1; then
470 # Use the readlink program from GNU coreutils.
476 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
477 # would do the wrong thing if the link target contains " -> ".
478 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
482 # func_relativize DIR1 DIR2
483 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
485 # - DIR1 relative pathname, relative to the current directory
486 # - DIR2 relative pathname, relative to the current directory
488 # - reldir relative pathname of DIR2, relative to DIR1
494 sed_first='s,^\([^/]*\)/.*$,\1,'
495 sed_rest='s,^[^/]*/*,,'
496 sed_last='s,^.*/\([^/]*\)$,\1,'
497 sed_butlast='s,/*[^/]*$,,'
498 while test -n "$dir1"; do
499 first=`echo "$dir1" | sed -e "$sed_first"`
500 if test "$first" != "."; then
501 if test "$first" = ".."; then
502 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
503 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
505 first2=`echo "$dir2" | sed -e "$sed_first"`
506 if test "$first2" = "$first"; then
507 dir2=`echo "$dir2" | sed -e "$sed_rest"`
511 dir0="$dir0"/"$first"
514 dir1=`echo "$dir1" | sed -e "$sed_rest"`
519 # func_relconcat DIR1 DIR2
520 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
522 # - DIR1 relative pathname, relative to the current directory
523 # - DIR2 relative pathname, relative to DIR1
525 # - relconcat DIR1/DIR2, relative to the current directory
530 sed_first='s,^\([^/]*\)/.*$,\1,'
531 sed_rest='s,^[^/]*/*,,'
532 sed_last='s,^.*/\([^/]*\)$,\1,'
533 sed_butlast='s,/*[^/]*$,,'
535 first=`echo "$dir2" | sed -e "$sed_first"`
536 if test "$first" = "."; then
537 dir2=`echo "$dir2" | sed -e "$sed_rest"`
538 if test -z "$dir2"; then
543 last=`echo "$dir1" | sed -e "$sed_last"`
544 while test "$last" = "."; do
545 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
546 last=`echo "$dir1" | sed -e "$sed_last"`
548 if test -z "$dir1"; then
552 if test "$first" = ".."; then
553 if test "$last" = ".."; then
554 relconcat="$dir1/$dir2"
557 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
558 dir2=`echo "$dir2" | sed -e "$sed_rest"`
559 if test -z "$dir1"; then
563 if test -z "$dir2"; then
568 relconcat="$dir1/$dir2"
576 # Like ln -s, except that SRC is given relative to the current directory (or
577 # absolute), not given relative to the directory of DEST.
583 *) # SRC is relative.
586 ln -s "`pwd`/$1" "$2" ;;
587 *) # DEST is relative too.
588 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
589 test -n "$ln_destdir" || ln_destdir="."
590 func_relativize "$ln_destdir" "$1"
598 # func_ln_if_changed SRC DEST
599 # Like func_ln, but avoids munging timestamps if the link is correct.
600 func_ln_if_changed ()
602 if test $# -ne 2; then
603 echo "usage: func_ln_if_changed SRC DEST" >&2
605 ln_target=`func_readlink "$2"`
606 if test -h "$2" && test "$1" = "$ln_target"; then
615 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
616 # writes into a pipe with no readers, i.e. a pipe where all readers have
617 # already closed their file descriptor that read from it or exited entirely.
618 # The default behaviour is to terminate the current process without an error
620 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
621 # terminate the current process with an error message.
622 # This function should be called at the beginning of a command that only
623 # produces output to stdout (i.e. no side effects!), when the command that
624 # will read from this pipe might prematurely exit or close its standard input
626 if test -n "$BASH_VERSION"; then
627 # The problem has only been reported with bash. Probably it occurs only with
628 # bash-3.2. For the reasons, see
629 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
630 # Note that Solaris sh does not understand "trap - SIGPIPE".
631 func_reset_sigpipe ()
636 func_reset_sigpipe ()
642 # Ensure an 'echo' command that does not interpret backslashes.
644 # echo '\n' | wc -l prints 1 when OK, 2 when KO
645 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
646 # This problem is a weird heritage from SVR4. BSD got it right (except that
647 # BSD echo interprets '-n' as an option, which is also not desirable).
648 # Nowadays the problem occurs in 4 situations:
649 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
650 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
651 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
652 # - in zsh, when sh-emulation is not set,
653 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
654 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
655 # - in Solaris /bin/sh and OSF/1 /bin/sh.
656 # We try the following workarounds:
657 # - for all: respawn using $CONFIG_SHELL if that is set and works.
658 # - for bash >= 2.04: unset the shell option xpg_echo.
659 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
660 # - for bash < 2.0: define echo to a function that uses cat of a here document.
661 # - for zsh: turn sh-emulation on.
662 # - for ksh: alias echo to 'print -r'.
663 # - for ksh: alias echo to a function that uses cat of a here document.
664 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
665 # the ksh workaround.
666 # - otherwise: respawn using /bin/sh and rely on the workarounds.
667 # When respawning, we pass --no-reexec as first argument, so as to avoid
668 # turning this script into a fork bomb in unlucky situations.
670 if echo '\t' | grep t > /dev/null; then
671 have_echo=yes # Lucky!
673 # Try the workarounds.
674 # Respawn using $CONFIG_SHELL if that is set and works.
675 if test -z "$have_echo" \
676 && test "X$1" != "X--no-reexec" \
677 && test -n "$CONFIG_SHELL" \
678 && test -f "$CONFIG_SHELL" \
679 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
680 exec $CONFIG_SHELL "$0" --no-reexec "$@"
683 # For bash >= 2.04: unset the shell option xpg_echo.
684 if test -z "$have_echo" \
685 && test -n "$BASH_VERSION" \
686 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
690 # For bash >= 2.0: define echo to a function that uses the printf built-in.
691 # For bash < 2.0: define echo to a function that uses cat of a here document.
692 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
693 if test -z "$have_echo" \
694 && test -n "$BASH_VERSION"; then \
695 if type printf 2>/dev/null | grep / > /dev/null; then
696 # 'printf' is not a shell built-in.
704 # 'printf' is a shell built-in.
710 if echo '\t' | grep t > /dev/null; then
714 # For zsh: turn sh-emulation on.
715 if test -z "$have_echo" \
716 && test -n "$ZSH_VERSION" \
717 && (emulate sh) >/dev/null 2>&1; then
720 # For ksh: alias echo to 'print -r'.
721 if test -z "$have_echo" \
722 && (type print) >/dev/null 2>&1; then
723 # A 'print' command exists.
724 if type print 2>/dev/null | grep / > /dev/null; then
727 # 'print' is a shell built-in.
728 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
729 # 'print' is the ksh shell built-in.
730 alias echo='print -r'
734 if test -z "$have_echo" \
735 && echo '\t' | grep t > /dev/null; then
738 # For ksh: alias echo to a function that uses cat of a here document.
739 # The ksh manual page says:
740 # "Aliasing is performed when scripts are read, not while they are executed.
741 # Therefore, for an alias to take effect, the alias definition command has
742 # to be executed before the command which references the alias is read."
743 # Because of this, we have to play strange tricks with have_echo, to ensure
744 # that the top-level statement containing the test starts after the 'alias'
746 if test -z "$have_echo"; then
753 alias echo=bsd_echo 2>/dev/null
755 if test -z "$have_echo" \
756 && echo '\t' | grep t > /dev/null; then
759 if test -z "$have_echo"; then
760 unalias echo 2>/dev/null
762 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
763 if test -z "$have_echo" \
764 && test "X$1" != "X--no-reexec" \
765 && test -f /bin/ksh; then
766 exec /bin/ksh "$0" --no-reexec "$@"
769 # Otherwise: respawn using /bin/sh.
770 if test -z "$have_echo" \
771 && test "X$1" != "X--no-reexec" \
772 && test -f /bin/sh; then
773 exec /bin/sh "$0" --no-reexec "$@"
776 if test -z "$have_echo"; then
777 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
779 if echo '\t' | grep t > /dev/null; then
782 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
784 if test "X$1" = "X--no-reexec"; then
788 # Command-line option processing.
789 # Removes the OPTIONS from the arguments. Sets the variables:
790 # - mode list or import or create-testdir or create-megatestdir
791 # - destdir from --dir
792 # - local_gnulib_dir from --local-dir
793 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
794 # - libname, supplied_libname from --lib
795 # - sourcebase from --source-base
796 # - m4base from --m4-base
797 # - pobase from --po-base
798 # - docbase from --doc-base
799 # - testsbase from --tests-base
800 # - auxdir from --aux-dir
801 # - inctests true if --with-tests was given, blank otherwise
802 # - incobsolete true if --with-obsolete was given, blank otherwise
803 # - avoidlist list of modules to avoid, from --avoid
804 # - lgpl yes or a number if --lgpl was given, blank otherwise
805 # - makefile_name from --makefile-name
806 # - libtool true if --libtool was given, false if --no-libtool was
807 # given, blank otherwise
808 # - macro_prefix from --macro-prefix
809 # - po_domain from --po-domain
810 # - vc_files true if --vc-files was given, false if --no-vc-files was
811 # given, blank otherwise
812 # - autoconf_minversion minimum supported autoconf version
813 # - do_changelog false if --no-changelog was given, : otherwise
814 # - doit : if actions shall be executed, false if only to be printed
815 # - symbolic true if --symlink or --more-symlinks was given, blank
817 # - lsymbolic true if --local-symlink was given, blank otherwise
818 # - do_copyrights blank if --more-symlinks was given, true otherwise
849 while test $# -gt 0; do
854 --import | --impor | --impo | --imp | --im | --i )
857 --update | --updat | --upda | --upd | --up | --u )
860 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
863 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
864 mode=create-megatestdir
866 --test | --tes | --te | --t )
869 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
873 mode=`echo "X$1" | sed -e 's/^X--//'`
878 func_fatal_error "missing argument for --dir"
883 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
888 func_fatal_error "missing argument for --local-dir"
893 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
895 --verbose | --verbos | --verbo | --verb )
896 verbose=`expr $verbose + 1`
898 --quiet | --quie | --qui | --qu | --q )
899 verbose=`expr $verbose - 1`
904 func_fatal_error "missing argument for --lib"
907 supplied_libname=true
910 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
911 supplied_libname=true
916 func_fatal_error "missing argument for --source-base"
921 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
926 func_fatal_error "missing argument for --m4-base"
931 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
936 func_fatal_error "missing argument for --po-base"
941 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
946 func_fatal_error "missing argument for --doc-base"
951 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
956 func_fatal_error "missing argument for --tests-base"
961 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
966 func_fatal_error "missing argument for --aux-dir"
971 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
982 func_fatal_error "missing argument for --avoid"
984 func_append avoidlist " $1"
987 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
988 func_append avoidlist " $arg"
994 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
997 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1003 if test $# = 0; then
1004 func_fatal_error "missing argument for --makefile-name"
1009 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1019 if test $# = 0; then
1020 func_fatal_error "missing argument for --macro-prefix"
1025 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1029 if test $# = 0; then
1030 func_fatal_error "missing argument for --po-domain"
1035 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1043 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
1049 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1052 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1055 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1059 --help | --hel | --he | --h )
1062 --version | --versio | --versi | --vers )
1066 # Stop option processing
1070 echo "gnulib-tool: unknown option $1" 1>&2
1071 echo "Try 'gnulib-tool --help' for more information." 1>&2
1078 if test "$mode" = update; then
1079 if test $# != 0; then
1080 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1081 echo "Try 'gnulib-tool --help' for more information." 1>&2
1082 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1083 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1086 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1087 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1088 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1089 || test -n "$inctests" || test -n "$incobsolete" \
1090 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1091 || test -n "$macro_prefix" || test -n "$po_domain" \
1092 || test -n "$vc_files"; then
1093 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1094 echo "Try 'gnulib-tool --help' for more information." 1>&2
1095 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1096 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1101 if test -n "$pobase" && test -z "$po_domain"; then
1102 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1103 echo "Try 'gnulib-tool --help' for more information." 1>&2
1106 if test -z "$pobase" && test -n "$po_domain"; then
1107 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1110 # Determine the minimum supported autoconf version from the project's
1112 DEFAULT_AUTOCONF_MINVERSION="2.59"
1113 autoconf_minversion=
1115 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1116 if test -f "$destdir"/configure.ac; then
1117 configure_ac="$destdir/configure.ac"
1119 if test -f "$destdir"/configure.in; then
1120 configure_ac="$destdir/configure.in"
1124 if test -f configure.ac; then
1125 configure_ac="configure.ac"
1127 if test -f configure.in; then
1128 configure_ac="configure.in"
1132 if test -n "$configure_ac"; then
1133 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1134 # because when some m4 files are omitted from a CVS repository,
1135 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1136 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1137 # autom4te: m4 failed with exit status: 1
1144 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1146 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1147 if test -n "$prereqs"; then
1148 autoconf_minversion=`
1149 for version in $prereqs; do echo $version; done |
1150 LC_ALL=C sort -nru | sed 1q
1154 if test -z "$autoconf_minversion"; then
1155 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1157 case "$autoconf_minversion" in
1158 1.* | 2.[0-4]* | 2.5[0-8]*)
1159 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1162 # Remove trailing slashes from the directory names. This is necessary for
1163 # m4base (to avoid an error in func_import) and optional for the others.
1164 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1165 case "$local_gnulib_dir" in
1166 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1168 case "$sourcebase" in
1169 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1172 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1175 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1178 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1180 case "$testsbase" in
1181 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1184 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1190 trap 'exit_status=$?
1191 if test "$signal" != 0; then
1192 echo "caught signal $signal" >&2
1195 exit $exit_status' 0
1196 for signal in 1 2 3 13 15; do
1197 trap '{ signal='$signal'; func_exit 1; }' $signal
1201 # func_lookup_file file
1202 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1205 # - local_gnulib_dir from --local-dir
1207 # - lookedup_file name of the merged (combined) file
1208 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1212 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1213 lookedup_file="$local_gnulib_dir/$lkfile"
1216 if test -f "$gnulib_dir/$lkfile"; then
1217 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1218 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1219 rm -f "$tmp/$lkbase"
1220 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1221 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1222 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1223 lookedup_file="$tmp/$lkbase"
1226 lookedup_file="$gnulib_dir/$lkfile"
1230 func_fatal_error "file $gnulib_dir/$lkfile not found"
1237 # - local_gnulib_dir from --local-dir
1240 # Filter out metainformation files like README, which are not modules.
1241 # Filter out unit test modules; they can be retrieved through
1242 # --extract-tests-module if desired.
1244 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1245 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1246 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1249 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1250 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1251 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1252 -e '/^README$/d' -e '/\/README$/d' \
1253 -e '/^TEMPLATE$/d' \
1254 -e '/^TEMPLATE-EXTENDED$/d' \
1255 -e '/^TEMPLATE-TESTS$/d' \
1258 | sed -e '/-tests$/d' \
1262 # func_verify_module
1263 # verifies a module name
1265 # - local_gnulib_dir from --local-dir
1266 # - module module name argument
1267 func_verify_module ()
1269 if { test -f "$gnulib_dir/modules/$module" \
1270 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1271 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1272 && test "CVS" != "$module" \
1273 && test "ChangeLog" != "$module" \
1274 && test "COPYING" != "$module" \
1275 && test "README" != "$module" \
1276 && test "TEMPLATE" != "$module" \
1277 && test "TEMPLATE-EXTENDED" != "$module" \
1278 && test "TEMPLATE-TESTS" != "$module"; then
1279 # OK, $module is a correct module name.
1280 # Verify that building the module description with 'patch' succeeds.
1281 func_lookup_file "modules/$module"
1283 echo "gnulib-tool: module $module doesn't exist" 1>&2
1288 # func_verify_nontests_module
1289 # verifies a module name, excluding tests modules
1291 # - local_gnulib_dir from --local-dir
1292 # - module module name argument
1293 func_verify_nontests_module ()
1296 *-tests ) module= ;;
1297 * ) func_verify_module ;;
1301 # func_verify_tests_module
1302 # verifies a module name, considering only tests modules
1304 # - local_gnulib_dir from --local-dir
1305 # - module module name argument
1306 func_verify_tests_module ()
1309 *-tests ) func_verify_module ;;
1314 sed_extract_prog=':[ ]*$/ {
1317 s/^Description:[ ]*$//
1321 s/^Depends-on:[ ]*$//
1322 s/^configure\.ac-early:[ ]*$//
1323 s/^configure\.ac:[ ]*$//
1324 s/^Makefile\.am:[ ]*$//
1328 s/^Maintainer:[ ]*$//
1335 # func_get_description module
1337 # - local_gnulib_dir from --local-dir
1338 func_get_description ()
1340 func_lookup_file "modules/$1"
1341 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1344 # func_get_status module
1346 # - local_gnulib_dir from --local-dir
1349 func_lookup_file "modules/$1"
1350 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1353 # func_get_notice module
1355 # - local_gnulib_dir from --local-dir
1358 func_lookup_file "modules/$1"
1359 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1362 # func_get_filelist module
1364 # - local_gnulib_dir from --local-dir
1365 func_get_filelist ()
1367 func_lookup_file "modules/$1"
1368 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1369 echo m4/gnulib-common.m4
1370 case "$autoconf_minversion" in
1377 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1378 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1379 # elements starting with prefix and ending with suffix are considered.
1380 # Processing: removed_prefix and removed_suffix are removed from each element,
1381 # added_prefix and added_suffix are added to each element.
1382 # removed_prefix, removed_suffix should not contain the characters "$`\{}|.
1383 # added_prefix, added_suffix should not contain the characters \|.
1384 func_filter_filelist ()
1386 if test "$2" != "$nl" \
1387 || { $fast_func_append \
1388 && { test -z "$6" || $fast_func_remove_prefix; } \
1389 && { test -z "$7" || $fast_func_remove_suffix; }; \
1395 if test -n "$6"; then
1396 func_remove_prefix fff "$6"
1398 if test -n "$7"; then
1399 func_remove_suffix fff "$7"
1402 if test -z "$ffflist"; then
1405 func_append ffflist "$2${fff}"
1411 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1412 ffflist=`for fff in $3; do
1414 "$4"*"$5") echo "$fff" ;;
1416 done | sed -e "$sed_fff_filter"`
1418 eval "$1=\"\$ffflist\""
1421 # func_get_dependencies module
1423 # - local_gnulib_dir from --local-dir
1424 func_get_dependencies ()
1426 # ${module}-tests always implicitly depends on ${module}.
1430 func_remove_suffix fgd1 '-tests'
1434 # Then the explicit dependencies listed in the module description.
1435 func_lookup_file "modules/$1"
1436 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1439 # func_get_autoconf_early_snippet module
1441 # - local_gnulib_dir from --local-dir
1442 func_get_autoconf_early_snippet ()
1444 func_lookup_file "modules/$1"
1445 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1448 # func_get_autoconf_snippet module
1450 # - local_gnulib_dir from --local-dir
1451 func_get_autoconf_snippet ()
1453 func_lookup_file "modules/$1"
1454 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1457 # func_get_automake_snippet module
1459 # - local_gnulib_dir from --local-dir
1460 func_get_automake_snippet ()
1462 func_lookup_file "modules/$1"
1463 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1466 # *-tests module live in tests/, not lib/.
1467 # Synthesize an EXTRA_DIST augmentation.
1468 all_files=`func_get_filelist $1`
1469 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1470 extra_files="$tests_files"
1471 if test -n "$extra_files"; then
1472 echo "EXTRA_DIST +=" $extra_files
1477 # Synthesize an EXTRA_DIST augmentation.
1478 sed_combine_lines='/\\$/{
1485 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1486 already_mentioned_files=` \
1487 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1488 | sed -e "$sed_combine_lines" \
1489 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1490 all_files=`func_get_filelist $1`
1491 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
1492 # Remove $already_mentioned_files from $lib_files.
1493 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1494 extra_files=`func_reset_sigpipe; \
1495 for f in $already_mentioned_files; do echo $f; done \
1496 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1497 if test -n "$extra_files"; then
1498 echo "EXTRA_DIST +=" $extra_files
1501 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1502 # This is necessary so that automake can generate the right list of
1504 # A possible approach would be to use autom4te --trace of the redefined
1505 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1506 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1507 # inside autoconf's built-in macros are not missed).
1508 # But it's simpler and more robust to do it here, based on the file list.
1509 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1510 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1511 # automake will generate a useless dependency; this is harmless.
1513 relocatable-prog-wrapper) ;;
1515 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
1516 if test -n "$extra_files"; then
1517 echo "EXTRA_lib_SOURCES +=" $extra_files
1522 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1523 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
1524 if test -n "$buildaux_files"; then
1525 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1526 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1529 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1530 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
1531 if test -n "$top_files"; then
1532 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1533 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1540 # func_get_include_directive module
1542 # - local_gnulib_dir from --local-dir
1543 func_get_include_directive ()
1545 func_lookup_file "modules/$1"
1546 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1547 sed -e 's/^\(["<]\)/#include \1/'
1550 # func_get_link_directive module
1552 # - local_gnulib_dir from --local-dir
1553 func_get_link_directive ()
1555 func_lookup_file "modules/$1"
1556 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1559 # func_get_license module
1561 # - local_gnulib_dir from --local-dir
1564 func_lookup_file "modules/$1"
1565 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1566 # The default is GPL.
1568 } | sed -e 's,^ *$,,' | sed -e 1q
1571 # func_get_maintainer module
1573 # - local_gnulib_dir from --local-dir
1574 func_get_maintainer ()
1576 func_lookup_file "modules/$1"
1577 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1580 # func_get_tests_module module
1582 # - local_gnulib_dir from --local-dir
1583 func_get_tests_module ()
1585 # The naming convention for tests modules is hardwired: ${module}-tests.
1586 if test -f "$gnulib_dir/modules/$1"-tests \
1587 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1588 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1593 # func_acceptable module
1594 # tests whether a module is acceptable.
1596 # - avoidlist list of modules to avoid
1599 for avoid in $avoidlist; do
1600 if test "$avoid" = "$1"; then
1607 # func_modules_transitive_closure
1609 # - local_gnulib_dir from --local-dir
1610 # - modules list of specified modules
1611 # - inctests true if tests should be included, blank otherwise
1612 # - incobsolete true if obsolete modules among dependencies should be
1613 # included, blank otherwise
1614 # - avoidlist list of modules to avoid
1615 # - tmp pathname of a temporary directory
1617 # - modules list of modules, including dependencies
1618 func_modules_transitive_closure ()
1620 # In order to process every module only once (for speed), process an "input
1621 # list" of modules, producing an "output list" of modules. During each round,
1622 # more modules can be queued in the input list. Once a module on the input
1623 # list has been processed, it is added to the "handled list", so we can avoid
1624 # to process it again.
1626 inmodules="$modules"
1628 while test -n "$inmodules"; do
1629 inmodules_this_round="$inmodules"
1630 inmodules= # Accumulator, queue for next round
1631 for module in $inmodules_this_round; do
1633 if test -n "$module"; then
1634 if func_acceptable $module; then
1635 func_append outmodules " $module"
1636 deps=`func_get_dependencies $module`
1637 # Duplicate dependencies are harmless, but Jim wants a warning.
1638 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1639 if test -n "$duplicated_deps"; then
1640 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1642 for dep in $deps; do
1643 if test -n "$incobsolete" \
1644 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
1645 func_append inmodules " $dep"
1648 if test -n "$inctests"; then
1649 testsmodule=`func_get_tests_module $module`
1650 if test -n "$testsmodule"; then
1651 func_append inmodules " $testsmodule"
1657 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1658 # Remove $handledmodules from $inmodules.
1659 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1660 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1662 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1663 rm -f "$tmp"/queued-modules
1666 # func_modules_add_dummy
1668 # - local_gnulib_dir from --local-dir
1669 # - modules list of modules, including dependencies
1671 # - modules list of modules, including 'dummy' if needed
1672 func_modules_add_dummy ()
1674 # Determine whether any module provides a lib_SOURCES augmentation.
1676 sed_remove_backslash_newline=':a
1683 for module in $modules; do
1684 func_verify_nontests_module
1685 if test -n "$module"; then
1686 # Extract the value of "lib_SOURCES += ...".
1687 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1688 # Ignore .h files since they are not compiled.
1692 have_lib_SOURCES=yes
1699 # Add the dummy module, to make sure the library will be non-empty.
1700 if test -z "$have_lib_SOURCES"; then
1701 if func_acceptable "dummy"; then
1702 func_append modules " dummy"
1707 # func_modules_notice
1709 # - local_gnulib_dir from --local-dir
1710 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1711 # - modules list of modules, including dependencies
1712 func_modules_notice ()
1714 if test $verbose -ge -1; then
1715 for module in $modules; do
1717 if test -n "$module"; then
1718 msg=`func_get_notice $module`
1719 if test -n "$msg"; then
1720 echo "Notice from module $module:"
1721 echo "$msg" | sed -e 's/^/ /'
1728 # func_modules_to_filelist
1730 # - local_gnulib_dir from --local-dir
1731 # - modules list of modules, including dependencies
1733 # - files list of files
1734 func_modules_to_filelist ()
1737 for module in $modules; do
1739 if test -n "$module"; then
1740 fs=`func_get_filelist $module`
1741 func_append files " $fs"
1744 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1747 # func_execute_command command [args...]
1748 # Executes a command.
1749 # Uses also the variables
1750 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1751 func_execute_command ()
1753 if test $verbose -ge 0; then
1757 # Commands like automake produce output to stderr even when they succeed.
1758 # Turn this output off if the command succeeds.
1759 "$@" > "$tmp"/cmdout 2>&1
1761 if test $cmdret = 0; then
1765 cat "$tmp"/cmdout 1>&2
1772 # func_emit_lib_Makefile_am
1773 # emits the contents of library makefile to standard output.
1775 # - local_gnulib_dir from --local-dir
1776 # - modules list of modules, including dependencies
1777 # - libname library name
1778 # - pobase directory relative to destdir where to place *.po files
1779 # - auxdir directory relative to destdir where to place build aux files
1780 # - makefile_name from --makefile-name
1781 # - libtool true if libtool will be used, false or blank otherwise
1782 # - macro_prefix prefix of gl_LIBOBJS macros to use
1783 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1784 # - actioncmd (optional) command that will reproduce this invocation
1785 # - for_test true if creating a package for testing, false otherwise
1786 # - destfile filename relative to destdir of makefile being generated
1788 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1789 # list of edits to be done to Makefile.am variables
1791 # - uses_subdirs nonempty if object files in subdirs exist
1792 func_emit_lib_Makefile_am ()
1794 # When creating an includable Makefile.am snippet, augment variables with
1795 # += instead of assigning them.
1796 if test -n "$makefile_name"; then
1801 if test "$libtool" = true; then
1804 sed_eliminate_LDFLAGS="$sed_noop"
1808 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1811 # When creating a package for testing: Attempt to provoke failures,
1812 # especially link errors, already during "make" rather than during
1813 # "make check", because "make check" is not possible in a cross-compiling
1814 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1815 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1817 sed_transform_check_PROGRAMS="$sed_noop"
1819 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1820 echo "## Process this file with automake to produce Makefile.in."
1821 func_emit_copyright_notice
1822 if test -n "$actioncmd"; then
1823 echo "# Reproduce by: $actioncmd"
1828 for module in $modules; do
1829 func_verify_nontests_module
1830 if test -n "$module"; then
1832 func_get_automake_snippet "$module" |
1833 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1834 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1835 -e "$sed_eliminate_LDFLAGS" \
1836 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1837 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1838 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1839 -e "$sed_transform_check_PROGRAMS"
1840 if test "$module" = 'alloca'; then
1841 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1842 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1845 # Skip the contents if it's entirely empty.
1846 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1847 echo "## begin gnulib module $module"
1850 echo "## end gnulib module $module"
1854 # Test whether there are some source files in subdirectories.
1855 for f in `func_get_filelist "$module"`; do
1866 if test -z "$makefile_name"; then
1867 # If there are source files in subdirectories, prevent collision of the
1868 # object files (example: hash.c and libxml/hash.c).
1870 if test -n "$uses_subdirs"; then
1871 subdir_options=' subdir-objects'
1873 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1876 if test -z "$makefile_name"; then
1878 echo "noinst_HEADERS ="
1879 echo "noinst_LIBRARIES ="
1880 echo "noinst_LTLIBRARIES ="
1881 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1882 # if you specify pkgdata_DATA to empty. This is a workaround.
1883 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1884 echo "pkgdata_DATA ="
1887 echo "BUILT_SOURCES ="
1890 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1891 if test -z "$makefile_name"; then
1892 echo "MOSTLYCLEANDIRS ="
1894 echo "DISTCLEANFILES ="
1895 echo "MAINTAINERCLEANFILES ="
1897 # Execute edits that apply to the Makefile.am being generated.
1899 while test $edit != $makefile_am_edits; do
1900 edit=`expr $edit + 1`
1901 eval dir=\"\$makefile_am_edit${edit}_dir\"
1902 eval var=\"\$makefile_am_edit${edit}_var\"
1903 eval val=\"\$makefile_am_edit${edit}_val\"
1904 if test -n "$var"; then
1905 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
1906 echo "${var} += ${val}"
1907 eval "makefile_am_edit${edit}_var="
1911 if test -z "$makefile_name"; then
1913 echo "AM_CPPFLAGS ="
1916 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1917 # One of the snippets already specifies an installation location for the
1918 # library. Don't confuse automake by saying it should not be installed.
1921 # By default, the generated library should not be installed.
1922 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1925 echo "${libname}_${libext}_SOURCES ="
1926 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1927 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
1928 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1929 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1930 echo "EXTRA_${libname}_${libext}_SOURCES ="
1931 if test "$libtool" = true; then
1932 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1935 if test -n "$pobase"; then
1936 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1939 cat allsnippets.tmp \
1940 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1942 echo "mostlyclean-local: mostlyclean-generic"
1943 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1944 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1945 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1949 rm -f allsnippets.tmp
1952 # func_emit_po_Makevars
1953 # emits the contents of po/ makefile parameterization to standard output.
1955 # - local_gnulib_dir from --local-dir
1956 # - sourcebase directory relative to destdir where to place source code
1957 # - pobase directory relative to destdir where to place *.po files
1958 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1959 func_emit_po_Makevars ()
1961 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1962 func_emit_copyright_notice
1964 echo "# Usually the message domain is the same as the package name."
1965 echo "# But here it has a '-gnulib' suffix."
1966 echo "DOMAIN = ${po_domain}-gnulib"
1968 echo "# These two variables depend on the location of this directory."
1969 echo "subdir = ${pobase}"
1970 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1973 # These options get passed to xgettext.
1974 XGETTEXT_OPTIONS = \
1975 --keyword=_ --flag=_:1:pass-c-format \
1976 --keyword=N_ --flag=N_:1:pass-c-format \
1977 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1978 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1979 --flag=error:3:c-format --flag=error_at_line:5:c-format
1981 # This is the copyright holder that gets inserted into the header of the
1982 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1983 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1985 # This is the email address or URL to which the translators shall report
1986 # bugs in the untranslated strings:
1987 # - Strings which are not entire sentences, see the maintainer guidelines
1988 # in the GNU gettext documentation, section 'Preparing Strings'.
1989 # - Strings which use unclear terms or require additional context to be
1991 # - Strings which make invalid assumptions about notation of date, time or
1993 # - Pluralisation problems.
1994 # - Incorrect English spelling.
1995 # - Incorrect formatting.
1996 # It can be your email address, or a mailing list address where translators
1997 # can write to without being subscribed, or the URL of a web page through
1998 # which the translators can contact you.
1999 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2001 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2002 # message catalogs shall be used. It is usually empty.
2003 EXTRA_LOCALE_CATEGORIES =
2005 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2006 # context. Possible values are "yes" and "no". Set this to yes if the
2007 # package uses functions taking also a message context, like pgettext(), or
2008 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2013 # func_emit_po_POTFILES_in
2014 # emits the file list to be passed to xgettext to standard output.
2016 # - local_gnulib_dir from --local-dir
2017 # - sourcebase directory relative to destdir where to place source code
2018 # - files list of new files
2019 func_emit_po_POTFILES_in ()
2021 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2022 func_emit_copyright_notice
2024 echo "# List of files which contain translatable strings."
2025 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2028 # func_emit_tests_Makefile_am
2029 # emits the contents of tests makefile to standard output.
2031 # - local_gnulib_dir from --local-dir
2032 # - modules list of modules, including dependencies
2033 # - libname library name
2034 # - auxdir directory relative to destdir where to place build aux files
2035 # - makefile_name from --makefile-name
2036 # - libtool true if libtool will be used, false or blank otherwise
2037 # - sourcebase relative directory containing lib source code
2038 # - m4base relative directory containing autoconf macros
2039 # - testsbase relative directory containing unit test code
2040 # - macro_prefix prefix of gl_LIBOBJS macros to use
2041 # - for_test true if creating a package for testing, false otherwise
2042 # - use_libtests true if a libtests.a should be built, false otherwise
2043 # - destfile filename relative to destdir of makefile being generated
2045 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2046 # list of edits to be done to Makefile.am variables
2048 # - uses_subdirs nonempty if object files in subdirs exist
2049 func_emit_tests_Makefile_am ()
2051 if test "$libtool" = true; then
2053 sed_eliminate_LDFLAGS="$sed_noop"
2056 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2059 # When creating a package for testing: Attempt to provoke failures,
2060 # especially link errors, already during "make" rather than during
2061 # "make check", because "make check" is not possible in a cross-compiling
2062 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2063 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2065 sed_transform_check_PROGRAMS="$sed_noop"
2067 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2068 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2069 echo "## Process this file with automake to produce Makefile.in."
2070 func_emit_copyright_notice
2074 for module in $modules; do
2076 func_verify_tests_module
2080 if test -n "$module"; then
2082 func_get_automake_snippet "$module" |
2083 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2084 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2085 -e "$sed_eliminate_LDFLAGS" \
2086 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2087 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2088 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2089 -e "$sed_transform_check_PROGRAMS"
2090 if $use_libtests && test "$module" = 'alloca'; then
2091 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2092 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2095 # Skip the contents if it's entirely empty.
2096 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
2097 echo "## begin gnulib module $module"
2100 echo "## end gnulib module $module"
2104 # Test whether there are some source files in subdirectories.
2105 for f in `func_get_filelist "$module"`; do
2107 lib/*/*.c | tests/*/*.c)
2116 # Generate dependencies here, since it eases the debugging of test failures.
2117 # If there are source files in subdirectories, prevent collision of the
2118 # object files (example: hash.c and libxml/hash.c).
2120 if test -n "$uses_subdirs"; then
2121 subdir_options=' subdir-objects'
2123 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2126 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2129 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2130 # variable is needed to avoid an error from automake:
2131 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2134 echo "TESTS_ENVIRONMENT ="
2135 echo "noinst_PROGRAMS ="
2136 if ! $for_test; then
2137 echo "check_PROGRAMS ="
2139 echo "noinst_HEADERS ="
2140 echo "noinst_LIBRARIES ="
2141 if $use_libtests; then
2143 echo "noinst_LIBRARIES += libtests.a"
2145 echo "check_LIBRARIES = libtests.a"
2148 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2149 # if you specify pkgdata_DATA to empty. This is a workaround.
2150 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
2151 echo "pkgdata_DATA ="
2154 echo "BUILT_SOURCES ="
2156 echo "MOSTLYCLEANFILES = core *.stackdump"
2157 echo "MOSTLYCLEANDIRS ="
2159 echo "DISTCLEANFILES ="
2160 echo "MAINTAINERCLEANFILES ="
2161 # Execute edits that apply to the Makefile.am being generated.
2163 while test $edit != $makefile_am_edits; do
2164 edit=`expr $edit + 1`
2165 eval dir=\"\$makefile_am_edit${edit}_dir\"
2166 eval var=\"\$makefile_am_edit${edit}_var\"
2167 eval val=\"\$makefile_am_edit${edit}_val\"
2168 if test -n "$var"; then
2169 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2170 echo "${var} += ${val}"
2171 eval "makefile_am_edit${edit}_var="
2176 echo "AM_CPPFLAGS = \\"
2177 echo " -I. -I\$(srcdir) \\"
2178 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2179 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2181 local_ldadd_before=''
2182 local_ldadd_after=''
2183 if $use_libtests; then
2184 # All test programs need to be linked with libtests.a.
2185 # It needs to be passed to the linker before ${libname}.${libext}, since
2186 # the tests-related modules depend on the main modules.
2187 # It also needs to be passed to the linker after ${libname}.${libext}
2188 # because the latter might contain incomplete modules (such as the 'error'
2189 # module whose dependency to 'progname' is voluntarily omitted).
2190 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2192 local_ldadd_before=' libtests.a'
2193 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2195 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2197 if $use_libtests; then
2198 echo "libtests_a_SOURCES ="
2199 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2200 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2201 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2202 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2203 echo "EXTRA_libtests_a_SOURCES ="
2204 # The circular dependency in LDADD requires this.
2205 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2208 cat allsnippets.tmp \
2209 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2210 echo "# Clean up after Solaris cc."
2212 echo " rm -rf SunWS_cache"
2214 echo "mostlyclean-local: mostlyclean-generic"
2215 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2216 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2217 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2221 rm -f allsnippets.tmp
2224 # func_emit_initmacro_start macro_prefix
2225 # emits the first few statements of the gl_INIT macro to standard output.
2226 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2227 func_emit_initmacro_start ()
2229 macro_prefix_arg="$1"
2230 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2231 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2232 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2233 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2235 # Furthermore it avoids an automake error like this when a Makefile.am
2236 # that uses pieces of gnulib also uses $(LIBOBJ):
2237 # automatically discovered file `error.c' should not be explicitly mentioned
2238 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2239 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2240 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2241 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2242 # automatically discovered file `error.c' should not be explicitly mentioned
2243 # We let automake know about the files to be distributed through the
2244 # EXTRA_lib_SOURCES variable.
2245 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2246 # Create data variables for checking the presence of files that are mentioned
2247 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2248 # because we want the check to happen when the configure file is created,
2249 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2250 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2251 # in which to expect them.
2252 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2253 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2257 # func_emit_initmacro_end macro_prefix
2258 # emits the last few statements of the gl_INIT macro to standard output.
2259 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2260 func_emit_initmacro_end ()
2262 macro_prefix_arg="$1"
2263 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2264 # The check is performed only when autoconf is run from the directory where
2265 # the configure.ac resides; if it is run from a different directory, the
2267 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2268 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2269 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2270 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2271 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2275 echo " m4_if(m4_sysval, [0], [],"
2276 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2278 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2279 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2280 echo " m4_popdef([AC_LIBSOURCES])"
2281 echo " m4_popdef([AC_REPLACE_FUNCS])"
2282 echo " m4_popdef([AC_LIBOBJ])"
2283 echo " AC_CONFIG_COMMANDS_PRE(["
2284 echo " ${macro_prefix_arg}_libobjs="
2285 echo " ${macro_prefix_arg}_ltlibobjs="
2286 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2287 echo " # Remove the extension."
2288 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2289 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2290 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2291 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2294 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2295 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2299 # func_emit_initmacro_done macro_prefix sourcebase
2300 # emits a few statements after the gl_INIT macro to standard output.
2301 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2302 # - sourcebase directory relative to destdir where to place source code
2303 func_emit_initmacro_done ()
2305 macro_prefix_arg="$1"
2308 echo "# Like AC_LIBOBJ, except that the module name goes"
2309 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2310 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2311 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2312 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2315 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2316 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2317 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2318 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2319 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2322 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2323 echo "# expected is derived from the gnulib-tool parameterization,"
2324 echo "# and alloca is special cased (for the alloca-opt module)."
2325 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2326 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2327 echo " m4_foreach([_gl_NAME], [\$1], ["
2328 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2329 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2330 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2336 # func_import modules
2337 # Uses also the variables
2338 # - destdir target directory
2339 # - local_gnulib_dir from --local-dir
2340 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2341 # - libname library name
2342 # - sourcebase directory relative to destdir where to place source code
2343 # - m4base directory relative to destdir where to place *.m4 macros
2344 # - pobase directory relative to destdir where to place *.po files
2345 # - docbase directory relative to destdir where to place doc files
2346 # - testsbase directory relative to destdir where to place unit test code
2347 # - auxdir directory relative to destdir where to place build aux files
2348 # - inctests true if --with-tests was given, blank otherwise
2349 # - incobsolete true if --with-obsolete was given, blank otherwise
2350 # - avoidlist list of modules to avoid, from --avoid
2351 # - lgpl yes or a number if library's license shall be LGPL,
2353 # - makefile_name from --makefile-name
2354 # - libtool true if --libtool was given, false if --no-libtool was
2355 # given, blank otherwise
2356 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2357 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2358 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2359 # - vc_files true if --vc-files was given, false if --no-vc-files was
2360 # given, blank otherwise
2361 # - autoconf_minversion minimum supported autoconf version
2362 # - doit : if actions shall be executed, false if only to be printed
2363 # - symbolic true if files should be symlinked, copied otherwise
2364 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2366 # - do_copyrights true if copyright notices in files should be replaced,
2370 # Get the cached settings.
2371 cached_local_gnulib_dir=
2372 cached_specified_modules=
2383 cached_makefile_name=
2385 cached_macro_prefix=
2389 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2390 cached_libtool=false
2396 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
2406 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
2408 /gl_WITH_OBSOLETE/ {
2409 s,^.*$,cached_incobsolete=true,p
2412 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
2415 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
2418 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
2421 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
2424 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
2427 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
2430 s,^.*$,cached_inctests=true,p
2433 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
2436 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
2439 s,^.*$,cached_lgpl=yes,p
2441 /gl_MAKEFILE_NAME(/ {
2442 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
2445 s,^.*$,cached_libtool=true,p
2447 /gl_MACRO_PREFIX(/ {
2448 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
2451 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
2454 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
2456 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2457 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2462 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2463 s,^.*$,cached_files=",p
2476 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2480 # Merge the cached settings with the specified ones.
2481 # The m4base must be the same as expected from the pathname.
2482 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2483 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2485 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2486 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2487 if test -z "$local_gnulib_dir"; then
2488 if test -n "$cached_local_gnulib_dir"; then
2491 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2493 case "$cached_local_gnulib_dir" in
2495 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2497 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2498 local_gnulib_dir="$relconcat" ;;
2503 # Append the cached and the specified module names. So that
2504 # "gnulib-tool --import foo" means to add the module foo.
2505 specified_modules="$cached_specified_modules $1"
2506 # Included obsolete modules among the dependencies if specified either way.
2507 if test -z "$incobsolete"; then
2508 incobsolete="$cached_incobsolete"
2510 # Append the cached and the specified avoidlist. This is probably better
2511 # than dropping the cached one when --avoid is specified at least once.
2512 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2513 avoidlist=`echo $avoidlist`
2515 # The sourcebase defaults to the cached one.
2516 if test -z "$sourcebase"; then
2517 sourcebase="$cached_sourcebase"
2518 if test -z "$sourcebase"; then
2519 func_fatal_error "missing --source-base option"
2522 # The pobase defaults to the cached one.
2523 if test -z "$pobase"; then
2524 pobase="$cached_pobase"
2526 # The docbase defaults to the cached one.
2527 if test -z "$docbase"; then
2528 docbase="$cached_docbase"
2529 if test -z "$docbase"; then
2530 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."
2533 # The testsbase defaults to the cached one.
2534 if test -z "$testsbase"; then
2535 testsbase="$cached_testsbase"
2536 if test -z "$testsbase"; then
2537 func_fatal_error "missing --tests-base option"
2540 # Require the tests if specified either way.
2541 if test -z "$inctests"; then
2542 inctests="$cached_inctests"
2544 # The libname defaults to the cached one.
2545 if test -z "$supplied_libname"; then
2546 libname="$cached_libname"
2547 if test -z "$libname"; then
2548 func_fatal_error "missing --lib option"
2551 # Require LGPL if specified either way.
2552 if test -z "$lgpl"; then
2555 # The makefile_name defaults to the cached one.
2556 if test -z "$makefile_name"; then
2557 makefile_name="$cached_makefile_name"
2559 # Use libtool if specified either way, or if guessed.
2560 if test -z "$libtool"; then
2561 if test -n "$cached_m4base"; then
2562 libtool="$cached_libtool"
2564 libtool="$guessed_libtool"
2567 # The macro_prefix defaults to the cached one.
2568 if test -z "$macro_prefix"; then
2569 macro_prefix="$cached_macro_prefix"
2570 if test -z "$macro_prefix"; then
2571 func_fatal_error "missing --macro-prefix option"
2574 # The po_domain defaults to the cached one.
2575 if test -z "$po_domain"; then
2576 po_domain="$cached_po_domain"
2578 # The vc_files defaults to the cached one.
2579 if test -z "$vc_files"; then
2580 vc_files="$cached_vc_files"
2583 # Canonicalize the list of specified modules.
2584 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2586 # Determine final module list.
2587 modules="$specified_modules"
2588 func_modules_transitive_closure
2589 if test $verbose -ge 0; then
2590 echo "Module list with included dependencies:"
2591 echo "$modules" | sed -e 's/^/ /'
2593 final_modules="$modules"
2595 # Determine main module list and tests-related module list separately.
2596 # The main module list is the transitive closure of the specified modules,
2597 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2598 # is specified, it will consist only of LGPLed source.
2599 # The tests-related module list is the transitive closure of the specified
2600 # modules, including tests modules, minus the main module list. Its lib/*
2601 # sources (brought in through dependencies of *-tests modules) go into
2602 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2603 # Determine main module list.
2604 saved_inctests="$inctests"
2606 modules="$specified_modules"
2607 func_modules_transitive_closure
2608 main_modules="$modules"
2609 inctests="$saved_inctests"
2610 if test $verbose -ge 1; then
2611 echo "Main module list:"
2612 echo "$main_modules" | sed -e 's/^/ /'
2614 # Determine tests-related module list.
2615 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2616 testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2617 if test $verbose -ge 1; then
2618 echo "Tests-related module list:"
2619 echo "$testsrelated_modules" | sed -e 's/^/ /'
2622 # Add the dummy module to the main module list if needed.
2623 modules="$main_modules"
2624 func_modules_add_dummy
2625 main_modules="$modules"
2627 # Determine whether a $testsbase/libtests.a is needed.
2629 for module in $testsrelated_modules; do
2630 func_verify_nontests_module
2631 if test -n "$module"; then
2632 all_files=`func_get_filelist $module`
2633 # Test whether some file in $all_files lies in lib/.
2634 for f in $all_files; do
2645 # Add the dummy module to the tests-related module list if needed.
2646 if $use_libtests; then
2647 modules="$testsrelated_modules"
2648 func_modules_add_dummy
2649 testsrelated_modules="$modules"
2652 # If --lgpl, verify that the licenses of modules are compatible.
2653 if test -n "$lgpl"; then
2654 license_incompatibilities=
2655 for module in $main_modules; do
2656 license=`func_get_license $module`
2658 'GPLed build tool') ;;
2659 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2665 *) func_append license_incompatibilities "$module $license$nl" ;;
2671 *) func_append license_incompatibilities "$module $license$nl" ;;
2674 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2679 if test -n "$license_incompatibilities"; then
2680 # Format the license incompatibilities as a table.
2681 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
2682 s,^\(.................................................[^ ]*\) *, \1 ,'
2683 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
2684 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
2688 # Show banner notice of every module.
2689 modules="$main_modules"
2692 # Determine script to apply to imported library files.
2693 sed_transform_lib_file=
2694 for module in $main_modules; do
2695 if test $module = config-h; then
2696 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2697 sed_transform_lib_file=$sed_transform_lib_file'
2698 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2703 sed_transform_main_lib_file="$sed_transform_lib_file"
2704 if test -n "$do_copyrights"; then
2705 if test -n "$lgpl"; then
2709 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2710 s/GNU General/GNU Lesser General/g
2714 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2715 s/GNU General/GNU Lesser General/g
2716 s/version [23]\([ ,]\)/version 2.1\1/g
2719 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2723 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2724 s/GNU Lesser General/GNU General/g
2725 s/GNU Library General/GNU General/g
2726 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2731 # Determine script to apply to library files that go into $testsbase/.
2732 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2733 if test -n "$do_copyrights"; then
2735 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2736 s/GNU Lesser General/GNU General/g
2737 s/GNU Library General/GNU General/g
2738 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2742 # Determine the final file lists.
2743 # They must be computed separately, because files in lib/* go into
2744 # $sourcebase/ if they are in the main file list but into $testsbase/
2745 # if they are in the tests-related file list. Furthermore lib/dummy.c
2747 # Determine final main file list.
2748 modules="$main_modules"
2749 func_modules_to_filelist
2751 # Determine final tests-related file list.
2752 modules="$testsrelated_modules"
2753 func_modules_to_filelist
2754 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2755 # Merge both file lists.
2756 sed_remove_empty_lines='/^$/d'
2757 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2758 if test $verbose -ge 0; then
2760 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2761 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2765 || func_fatal_error "refusing to do nothing"
2767 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2768 new_files="$files m4/gnulib-tool.m4"
2769 old_files="$cached_files"
2770 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2771 func_append old_files " m4/gnulib-tool.m4"
2774 sed_rewrite_old_files="\
2775 s,^build-aux/,$auxdir/,
2776 s,^doc/,$cached_docbase/,
2777 s,^lib/,$cached_sourcebase/,
2778 s,^m4/,$cached_m4base/,
2779 s,^tests/,$cached_testsbase/,
2780 s,^tests=lib/,$cached_testsbase/,
2782 sed_rewrite_new_files="\
2783 s,^build-aux/,$auxdir/,
2785 s,^lib/,$sourcebase/,
2787 s,^tests/,$testsbase/,
2788 s,^tests=lib/,$testsbase/,
2791 # Create directories.
2792 { echo "$sourcebase"
2794 if test -n "$pobase"; then
2797 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2798 if test -n "$docfiles"; then
2801 if test -n "$inctests"; then
2805 for f in $files; do echo $f; done \
2806 | sed -e "$sed_rewrite_new_files" \
2807 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2810 { # Rearrange file descriptors. Needed because "while ... done < ..."
2811 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2812 exec 5<&0 < "$tmp"/dirs
2814 if test ! -d "$destdir/$d"; then
2816 echo "Creating directory $destdir/$d"
2817 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2819 echo "Create directory $destdir/$d"
2826 # func_dest_tmpfilename file
2827 # determines the name of a temporary file (file is relative to destdir).
2829 # - tmpfile absolute filename of the temporary file
2830 func_dest_tmpfilename ()
2833 # Put the new contents of $file in a file in the same directory (needed
2834 # to guarantee that an 'mv' to "$destdir/$file" works).
2835 tmpfile="$destdir/$1.tmp"
2837 # Put the new contents of $file in a file in a temporary directory
2838 # (because the directory of "$file" might not exist).
2839 tmpfile="$tmp"/`basename "$1"`.tmp
2843 # Copy files or make symbolic links. Remove obsolete files.
2847 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2848 # representing the files according to the last gnulib-tool invocation.
2849 for f in $old_files; do echo $f; done \
2850 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2853 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2854 # representing the files after this gnulib-tool invocation.
2855 for f in $new_files; do echo $f; done \
2856 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2859 # First the files that are in old-files, but not in new-files:
2860 sed_take_first_column='s,'"$delimiter"'.*,,'
2861 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2862 # Remove the file. Do nothing if the user already removed it.
2863 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2865 echo "Removing file $g (backup in ${g}~)"
2866 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2868 echo "Remove file $g (backup in ${g}~)"
2870 func_append removed_files "$g$nl"
2873 # func_add_or_update handles a file that ought to be present afterwards.
2875 # - f the original file name
2876 # - g the rewritten file name
2877 # - already_present nonempty if the file already exists, empty otherwise
2878 func_add_or_update ()
2882 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2884 func_dest_tmpfilename "$g"
2885 func_lookup_file "$f"
2886 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2887 if test -n "$sed_transform_main_lib_file"; then
2890 sed -e "$sed_transform_main_lib_file" \
2891 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2895 if test -n "$sed_transform_testsrelated_lib_file"; then
2898 sed -e "$sed_transform_testsrelated_lib_file" \
2899 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2903 if test -f "$destdir/$g"; then
2904 # The file already exists.
2905 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2906 : # The file has not changed.
2910 if test -n "$already_present"; then
2911 echo "Updating file $g (backup in ${g}~)"
2913 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2915 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2916 if { test -n "$symbolic" \
2917 || { test -n "$lsymbolic" \
2918 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2919 && test -z "$lookedup_tmp" \
2920 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2921 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2923 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2926 if test -n "$already_present"; then
2927 echo "Update file $g (backup in ${g}~)"
2929 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2935 # Don't protest if the file should be there but isn't: it happens
2936 # frequently that developers don't put autogenerated files into CVS.
2938 echo "Copying file $g"
2939 if { test -n "$symbolic" \
2940 || { test -n "$lsymbolic" \
2941 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2942 && test -z "$lookedup_tmp" \
2943 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2944 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2946 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2951 func_append added_files "$g$nl"
2955 # Then the files that are in new-files, but not in old-files:
2956 sed_take_last_column='s,^.*'"$delimiter"',,'
2958 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2959 | sed -e "$sed_take_last_column" \
2960 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2961 { # Rearrange file descriptors. Needed because "while ... done < ..."
2962 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2963 exec 5<&0 < "$tmp"/added-files
2969 # Then the files that are in new-files and in old-files:
2970 already_present=true
2971 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2972 | sed -e "$sed_take_last_column" \
2973 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2974 { # Rearrange file descriptors. Needed because "while ... done < ..."
2975 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2976 exec 5<&0 < "$tmp"/kept-files
2983 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2984 actioncmd="gnulib-tool --import"
2985 func_append actioncmd " --dir=$destdir"
2986 if test -n "$local_gnulib_dir"; then
2987 func_append actioncmd " --local-dir=$local_gnulib_dir"
2989 func_append actioncmd " --lib=$libname"
2990 func_append actioncmd " --source-base=$sourcebase"
2991 func_append actioncmd " --m4-base=$m4base"
2992 if test -n "$pobase"; then
2993 func_append actioncmd " --po-base=$pobase"
2995 func_append actioncmd " --doc-base=$docbase"
2996 func_append actioncmd " --tests-base=$testsbase"
2997 func_append actioncmd " --aux-dir=$auxdir"
2998 if test -n "$inctests"; then
2999 func_append actioncmd " --with-tests"
3001 if test -n "$incobsolete"; then
3002 func_append actioncmd " --with-obsolete"
3004 for module in $avoidlist; do
3005 func_append actioncmd " --avoid=$module"
3007 if test -n "$lgpl"; then
3008 if test "$lgpl" = yes; then
3009 func_append actioncmd " --lgpl"
3011 func_append actioncmd " --lgpl=$lgpl"
3014 if test -n "$makefile_name"; then
3015 func_append actioncmd " --makefile-name=$makefile_name"
3017 if test "$libtool" = true; then
3018 func_append actioncmd " --libtool"
3020 func_append actioncmd " --no-libtool"
3022 func_append actioncmd " --macro-prefix=$macro_prefix"
3023 if test -n "$po_domain"; then
3024 func_append actioncmd " --po-domain=$po_domain"
3026 if test -n "$vc_files"; then
3027 if test "$vc_files" = true; then
3028 func_append actioncmd " --vc-files"
3030 func_append actioncmd " --no-vc-files"
3033 func_append actioncmd " `echo $specified_modules`"
3035 # Default the makefile name to Makefile.am.
3036 if test -n "$makefile_name"; then
3037 makefile_am=$makefile_name
3039 makefile_am=Makefile.am
3042 # Create normal Makefile.ams.
3045 # Setup list of Makefile.am edits that are to be performed afterwards.
3046 # Some of these edits apply to files that we will generate; others are
3047 # under the responsibility of the developer.
3049 # func_note_Makefile_am_edit dir var value
3050 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3052 func_note_Makefile_am_edit ()
3054 makefile_am_edits=`expr $makefile_am_edits + 1`
3055 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3056 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3057 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3059 if test "$makefile_am" = Makefile.am; then
3060 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3061 sourcebase_base=`basename "$sourcebase"`
3062 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3064 if test -n "$pobase"; then
3065 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3066 pobase_base=`basename "$pobase"`
3067 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3069 if test -n "$inctests"; then
3070 if test "$makefile_am" = Makefile.am; then
3071 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3072 testsbase_base=`basename "$testsbase"`
3073 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3076 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3078 # Find the first parent directory of $m4base that contains or will contain
3080 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3082 sed_butlast='s,[^/][^/]*//*$,,'
3083 dir1="${m4base}/"; dir2=""
3084 while test -n "$dir1" \
3085 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3086 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3087 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3088 || { test -n "$inctests" \
3089 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3090 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3091 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3092 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3094 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3097 # Create library makefile.
3098 func_dest_tmpfilename $sourcebase/$makefile_am
3099 destfile="$sourcebase/$makefile_am"
3100 modules="$main_modules"
3101 func_emit_lib_Makefile_am > "$tmpfile"
3102 if test -f "$destdir"/$sourcebase/$makefile_am; then
3103 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3107 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3108 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3109 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3111 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3117 echo "Creating $sourcebase/$makefile_am"
3118 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3120 echo "Create $sourcebase/$makefile_am"
3123 func_append added_files "$sourcebase/$makefile_am$nl"
3126 # Create po/ directory.
3127 if test -n "$pobase"; then
3128 # Create po makefile and auxiliary files.
3129 for file in Makefile.in.in remove-potcdate.sin; do
3130 func_dest_tmpfilename $pobase/$file
3131 func_lookup_file build-aux/po/$file
3132 cat "$lookedup_file" > "$tmpfile"
3133 if test -f "$destdir"/$pobase/$file; then
3134 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3138 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3139 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3140 mv -f "$tmpfile" "$destdir"/$pobase/$file
3142 echo "Update $pobase/$file (backup in $pobase/$file~)"
3148 echo "Creating $pobase/$file"
3149 mv -f "$tmpfile" "$destdir"/$pobase/$file
3151 echo "Create $pobase/$file"
3154 func_append added_files "$pobase/$file$nl"
3157 # Create po makefile parameterization, part 1.
3158 func_dest_tmpfilename $pobase/Makevars
3159 func_emit_po_Makevars > "$tmpfile"
3160 if test -f "$destdir"/$pobase/Makevars; then
3161 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3165 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3166 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3167 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3169 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3175 echo "Creating $pobase/Makevars"
3176 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3178 echo "Create $pobase/Makevars"
3181 func_append added_files "$pobase/Makevars$nl"
3183 # Create po makefile parameterization, part 2.
3184 func_dest_tmpfilename $pobase/POTFILES.in
3185 func_emit_po_POTFILES_in > "$tmpfile"
3186 if test -f "$destdir"/$pobase/POTFILES.in; then
3187 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3191 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3192 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3193 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3195 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3201 echo "Creating $pobase/POTFILES.in"
3202 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3204 echo "Create $pobase/POTFILES.in"
3207 func_append added_files "$pobase/POTFILES.in$nl"
3210 TP_URL="http://translationproject.org/latest/"
3211 TP_RSYNC_URI="translationproject.org::tp/latest/"
3213 echo "Fetching gnulib PO files from $TP_URL"
3214 (cd "$destdir"/$pobase \
3215 && { # Prefer rsync over wget if it is available, since it consumes
3216 # less network bandwidth, due to compression.
3217 if type rsync 2>/dev/null | grep / > /dev/null; then
3218 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3220 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3225 echo "Fetch gnulib PO files from $TP_URL"
3227 # Create po/LINGUAS.
3229 func_dest_tmpfilename $pobase/LINGUAS
3230 (cd "$destdir"/$pobase \
3231 && { echo '# Set of available languages.'
3232 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3235 if test -f "$destdir"/$pobase/LINGUAS; then
3236 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3239 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3240 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3241 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3244 echo "Creating $pobase/LINGUAS"
3245 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3246 func_append added_files "$pobase/LINGUAS$nl"
3249 if test -f "$destdir"/$pobase/LINGUAS; then
3250 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3252 echo "Create $pobase/LINGUAS"
3257 # Create m4/gnulib-cache.m4.
3258 func_dest_tmpfilename $m4base/gnulib-cache.m4
3260 func_emit_copyright_notice
3262 echo "# This file represents the specification of how gnulib-tool is used."
3263 echo "# It acts as a cache: It is written and read by gnulib-tool."
3264 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3265 echo "# like the configure.ac and various Makefile.am files."
3268 echo "# Specification in the form of a command-line invocation:"
3271 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3272 # Store the local_gnulib_dir relative to destdir.
3273 case "$local_gnulib_dir" in
3275 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3278 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3280 # destdir, local_gnulib_dir are both relative.
3281 func_relativize "$destdir" "$local_gnulib_dir"
3282 relative_local_gnulib_dir="$reldir" ;;
3285 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3287 echo "$specified_modules" | sed 's/^/ /g'
3289 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3290 echo "gl_AVOID([$avoidlist])"
3291 echo "gl_SOURCE_BASE([$sourcebase])"
3292 echo "gl_M4_BASE([$m4base])"
3293 echo "gl_PO_BASE([$pobase])"
3294 echo "gl_DOC_BASE([$docbase])"
3295 echo "gl_TESTS_BASE([$testsbase])"
3296 test -z "$inctests" || echo "gl_WITH_TESTS"
3297 echo "gl_LIB([$libname])"
3298 if test -n "$lgpl"; then
3299 if test "$lgpl" = yes; then
3302 echo "gl_LGPL([$lgpl])"
3305 echo "gl_MAKEFILE_NAME([$makefile_name])"
3306 if test "$libtool" = true; then
3309 echo "gl_MACRO_PREFIX([$macro_prefix])"
3310 echo "gl_PO_DOMAIN([$po_domain])"
3311 if test -n "$vc_files"; then
3312 echo "gl_VC_FILES([$vc_files])"
3315 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3316 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3320 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3321 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3322 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3324 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3328 echo "# gnulib-cache.m4 ends here"
3335 echo "Creating $m4base/gnulib-cache.m4"
3336 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3338 echo "Create $m4base/gnulib-cache.m4"
3344 # Create m4/gnulib-comp.m4.
3345 func_dest_tmpfilename $m4base/gnulib-comp.m4
3347 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3348 func_emit_copyright_notice
3350 echo "# This file represents the compiled summary of the specification in"
3351 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3352 echo "# to be invoked from configure.ac."
3353 echo "# In projects using CVS, this file can be treated like other built files."
3356 echo "# This macro should be invoked from $configure_ac, in the section"
3357 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3358 echo "# any checks for libraries, header files, types and library functions."
3359 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3361 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3362 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3363 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3364 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3365 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3366 if test -n "$uses_subdirs"; then
3367 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3369 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
3370 echo " AC_REQUIRE([AC_GNU_SOURCE])"
3372 for module in $final_modules; do
3374 if test -n "$module"; then
3375 func_get_autoconf_early_snippet "$module"
3378 | sed -e '/^$/d;' -e 's/^/ /'
3381 echo "# This macro should be invoked from $configure_ac, in the section"
3382 echo "# \"Check for header files, types and library functions\"."
3383 echo "AC_DEFUN([${macro_prefix}_INIT],"
3385 if test "$libtool" = true; then
3386 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3387 echo " gl_cond_libtool=true"
3389 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3390 echo " gl_cond_libtool=false"
3392 echo " gl_ltlibdeps="
3394 if test "$auxdir" != "build-aux"; then
3395 sed_replace_build_aux='
3397 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3398 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3402 sed_replace_build_aux="$sed_noop"
3404 func_emit_initmacro_start $macro_prefix
3405 echo " gl_source_base='$sourcebase'"
3406 for module in $main_modules; do
3408 if test -n "$module"; then
3409 func_get_autoconf_snippet "$module" \
3410 | sed -e '/^$/d;' -e 's/^/ /' \
3411 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3412 -e "$sed_replace_build_aux"
3413 if test "$module" = 'alloca' && test "$libtool" = true; then
3414 echo 'changequote(,)dnl'
3415 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3416 echo 'changequote([, ])dnl'
3417 echo 'AC_SUBST([LTALLOCA])'
3421 func_emit_initmacro_end $macro_prefix
3422 echo " gltests_libdeps="
3423 echo " gltests_ltlibdeps="
3424 func_emit_initmacro_start ${macro_prefix}tests
3425 echo " gl_source_base='$testsbase'"
3426 for module in $testsrelated_modules; do
3428 if test -n "$module"; then
3429 func_get_autoconf_snippet "$module" \
3430 | sed -e '/^$/d;' -e 's/^/ /' \
3431 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3432 -e "$sed_replace_build_aux" \
3433 -e 's/\$gl_cond_libtool/false/g' \
3434 -e 's/gl_libdeps/gltests_libdeps/g' \
3435 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3438 func_emit_initmacro_end ${macro_prefix}tests
3439 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3440 # created using libtool, because libtool already handles the dependencies.
3441 if test "$libtool" != true; then
3442 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3443 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3444 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3445 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3446 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3448 if $use_libtests; then
3449 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3450 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3453 func_emit_initmacro_done $macro_prefix $sourcebase
3454 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3456 echo "# This macro records the list of files which have been installed by"
3457 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3458 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3459 echo "$files" | sed -e 's,^, ,'
3462 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3463 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3467 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3468 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3469 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3471 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3475 echo "# gnulib-comp.m4 ends here"
3482 echo "Creating $m4base/gnulib-comp.m4"
3483 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3485 echo "Create $m4base/gnulib-comp.m4"
3491 if test -n "$inctests"; then
3492 # Create tests makefile.
3493 func_dest_tmpfilename $testsbase/$makefile_am
3494 destfile="$testsbase/$makefile_am"
3495 modules="$testsrelated_modules"
3496 func_emit_tests_Makefile_am > "$tmpfile"
3497 if test -f "$destdir"/$testsbase/$makefile_am; then
3498 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3502 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3503 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3504 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3506 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3512 echo "Creating $testsbase/$makefile_am"
3513 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3515 echo "Create $testsbase/$makefile_am"
3518 func_append added_files "$testsbase/$makefile_am$nl"
3522 if test "$vc_files" != false; then
3523 # Update the .cvsignore and .gitignore files.
3524 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3525 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3526 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3527 echo "$m4base/|A|gnulib-comp.m4"
3528 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3529 { # Rearrange file descriptors. Needed because "while ... done < ..."
3530 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3531 exec 5<&0 < "$tmp"/fileset-changes
3532 func_update_ignorelist ()
3535 if test "$ignore" = .gitignore; then
3536 # In a .gitignore file, "foo" applies to the current directory and all
3537 # subdirectories, whereas "/foo" applies to the current directory only.
3540 doubly_escaped_anchor='\\/'
3544 doubly_escaped_anchor=''
3546 if test -f "$destdir/$dir$ignore"; then
3547 if test -n "$dir_added" || test -n "$dir_removed"; then
3548 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3550 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3551 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
3552 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3553 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
3555 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3557 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3558 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3559 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3560 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,\$/d,' < "$tmp"/ignore-removed; fi
3561 } > "$tmp"/sed-ignore-removed
3562 { cat "$destdir/$dir$ignore"~
3563 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3564 } | sed -f "$tmp"/sed-ignore-removed \
3565 > "$destdir/$dir$ignore"
3567 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3572 if test -n "$dir_added"; then
3574 echo "Creating $destdir/$dir$ignore"
3576 if test "$ignore" = .cvsignore; then
3578 # Automake generates Makefile rules that create .dirstamp files.
3581 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3582 } > "$destdir/$dir$ignore"
3584 echo "Create $destdir/$dir$ignore"
3594 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3595 func_update_ignorelist .cvsignore
3597 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3598 func_update_ignorelist .gitignore
3605 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3606 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3607 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3608 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3609 if test "$next_dir" != "$last_dir"; then
3610 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3611 last_dir="$next_dir"
3616 A) func_append last_dir_added "$file$nl";;
3617 R) func_append last_dir_removed "$file$nl";;
3620 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3627 echo "You may need to add #include directives for the following .h files."
3628 # Intersect $specified_modules and $main_modules
3629 # (since $specified_modules is not necessarily of subset of $main_modules
3630 # - some may have been skipped through --avoid, and since the elements of
3631 # $main_modules but not in $specified_modules can go away without explicit
3632 # notice - through changes in the module dependencies).
3633 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3634 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3635 # First the #include <...> directives without #ifs, sorted for convenience,
3636 # then the #include "..." directives without #ifs, sorted for convenience,
3637 # then the #include directives that are surrounded by #ifs. Not sorted.
3638 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3639 include_directive=`func_get_include_directive "$module"`
3640 case "$nl$include_directive" in
3642 echo "$include_directive" 1>&5
3645 echo "$include_directive" | grep -v 'include "' 1>&6
3646 echo "$include_directive" | grep 'include "' 1>&7
3649 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3651 LC_ALL=C sort -u "$tmp"/include-angles
3652 LC_ALL=C sort -u "$tmp"/include-quotes
3653 cat "$tmp"/include-if
3654 ) | sed -e '/^$/d' -e 's/^/ /'
3655 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3657 for module in $main_modules; do
3658 func_get_link_directive "$module"
3660 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3661 if test `wc -l < "$tmp"/link` != 0; then
3663 echo "You may need to use the following Makefile variables when linking."
3664 echo "Use them in <program>_LDADD when linking a program, or"
3665 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3671 echo "Don't forget to"
3672 if test "$makefile_am" = Makefile.am; then
3673 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3675 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3677 if test -n "$pobase"; then
3678 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3680 if test -n "$inctests"; then
3681 if test "$makefile_am" = Makefile.am; then
3682 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3684 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3688 while test $edit != $makefile_am_edits; do
3689 edit=`expr $edit + 1`
3690 eval dir=\"\$makefile_am_edit${edit}_dir\"
3691 eval var=\"\$makefile_am_edit${edit}_var\"
3692 eval val=\"\$makefile_am_edit${edit}_val\"
3693 if test -n "$var"; then
3694 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
3697 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3698 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3701 # func_create_testdir testdir modules
3703 # - local_gnulib_dir from --local-dir
3704 # - auxdir directory relative to destdir where to place build aux files
3705 func_create_testdir ()
3709 if test -z "$modules"; then
3710 # All modules together.
3711 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3712 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3713 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3714 modules=`func_all_modules`
3715 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3717 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3719 # Check that the license of every module is consistent with the license of
3721 saved_modules="$modules"
3722 saved_inctests="$inctests"
3723 # When computing transitive closures, don't consider $module to depend on
3724 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3725 # on GPL modules - therefore we don't want a warning in this case.
3727 for requested_module in $saved_modules; do
3728 requested_license=`func_get_license "$requested_module"`
3729 if test "$requested_license" != GPL; then
3730 # Here we use func_modules_transitive_closure, not just
3731 # func_get_dependencies, so that we also detect weird situations like
3732 # an LGPL module which depends on a GPLed build tool module which depends
3734 modules="$requested_module"
3735 func_modules_transitive_closure
3736 for module in $modules; do
3737 license=`func_get_license "$module"`
3739 'GPLed build tool') ;;
3740 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3742 case "$requested_license" in
3745 GPLv2+ | LGPLv2+) ;;
3746 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3752 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3758 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3767 modules="$saved_modules"
3768 inctests="$saved_inctests"
3770 # Subdirectory names.
3780 # Determine final module list.
3781 func_modules_transitive_closure
3782 if test $verbose -ge 0; then
3783 echo "Module list with included dependencies:"
3784 echo "$modules" | sed -e 's/^/ /'
3787 # Add the dummy module if needed.
3788 func_modules_add_dummy
3790 # Show banner notice of every module.
3793 # Determine final file list.
3794 func_modules_to_filelist
3795 if test $verbose -ge 0; then
3797 echo "$files" | sed -e 's/^/ /'
3800 sed_rewrite_files="\
3801 s,^build-aux/,$auxdir/,
3803 s,^lib/,$sourcebase/,
3805 s,^tests/,$testsbase/,
3808 # Create directories.
3809 for f in $files; do echo $f; done \
3810 | sed -e "$sed_rewrite_files" \
3811 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3812 | LC_ALL=C sort -u \
3814 { # Rearrange file descriptors. Needed because "while ... done < ..."
3815 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3816 exec 5<&0 < "$tmp"/dirs
3818 mkdir -p "$testdir/$d"
3823 # Copy files or make symbolic links.
3825 for f in $files; do echo $f; done \
3826 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3829 { # Rearrange file descriptors. Needed because "while ... done < ..."
3830 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3831 exec 5<&0 < "$tmp"/files
3833 func_lookup_file "$f"
3834 if test -n "$lookedup_tmp"; then
3835 cp -p "$lookedup_file" "$testdir/$g"
3837 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3838 if { test -n "$symbolic" \
3839 || { test -n "$lsymbolic" \
3840 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3841 func_ln "$lookedup_file" "$testdir/$g"
3843 cp -p "$lookedup_file" "$testdir/$g"
3850 # Create Makefile.ams that are for testing.
3853 # No special edits are needed.
3856 # Create $sourcebase/Makefile.am.
3857 mkdir -p "$testdir/$sourcebase"
3858 destfile="$sourcebase/Makefile.am"
3859 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3860 any_uses_subdirs="$uses_subdirs"
3862 # Create $m4base/Makefile.am.
3863 mkdir -p "$testdir/$m4base"
3864 (echo "## Process this file with automake to produce Makefile.in."
3870 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3873 ) > "$testdir/$m4base/Makefile.am"
3875 subdirs="$sourcebase $m4base"
3876 subdirs_with_configure_ac=""
3878 if false && test -f "$testdir"/$m4base/gettext.m4; then
3879 # Avoid stupid error message from automake:
3880 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3881 mkdir -p "$testdir/po"
3882 (echo "## Process this file with automake to produce Makefile.in."
3883 ) > "$testdir/po/Makefile.am"
3884 func_append subdirs " po"
3887 if test -n "$inctests"; then
3888 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3889 # Viewed from the $testsbase subdirectory, $auxdir is different.
3890 saved_auxdir="$auxdir"
3891 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3892 # Create $testsbase/Makefile.am.
3894 destfile="$testsbase/Makefile.am"
3895 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3896 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3897 # Create $testsbase/configure.ac.
3898 (echo "# Process this file with autoconf to produce a configure script."
3899 echo "AC_INIT([dummy], [0])"
3900 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3901 echo "AM_INIT_AUTOMAKE"
3903 echo "AM_CONFIG_HEADER([config.h])"
3906 echo "AC_PROG_INSTALL"
3907 echo "AC_PROG_MAKE_SET"
3908 echo "AC_PROG_RANLIB"
3910 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3911 echo "AC_GNU_SOURCE"
3914 for module in $modules; do
3916 if test -n "$module"; then
3918 gnumakefile | maintainer-makefile)
3919 # These modules are meant to be used only in the top-level directory.
3922 func_get_autoconf_early_snippet "$module"
3927 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3928 if test "$libtool" = true; then
3929 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3930 echo "gl_cond_libtool=true"
3932 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3933 echo "gl_cond_libtool=false"
3935 echo "gl_ltlibdeps="
3937 # Wrap the set of autoconf snippets into an autoconf macro that is then
3938 # invoked. This is needed because autoconf does not support AC_REQUIRE
3940 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3941 # but we want the AC_REQUIRE to have its normal meaning (provide one
3942 # expansion of the required macro before the current point, and only one
3944 echo "AC_DEFUN([gl_INIT], ["
3945 sed_replace_build_aux='
3947 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3948 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3951 func_emit_initmacro_start $macro_prefix
3952 # We don't have explicit ordering constraints between the various
3953 # autoconf snippets. It's cleanest to put those of the library before
3954 # those of the tests.
3955 echo "gl_source_base='../$sourcebase'"
3956 for module in $modules; do
3957 func_verify_nontests_module
3958 if test -n "$module"; then
3960 gnumakefile | maintainer-makefile)
3961 # These modules are meant to be used only in the top-level directory.
3964 func_get_autoconf_snippet "$module" \
3965 | sed -e "$sed_replace_build_aux"
3970 echo "gl_source_base='.'"
3971 for module in $modules; do
3972 func_verify_tests_module
3973 if test -n "$module"; then
3974 func_get_autoconf_snippet "$module" \
3975 | sed -e "$sed_replace_build_aux"
3978 func_emit_initmacro_end $macro_prefix
3979 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3980 # created using libtool, because libtool already handles the dependencies.
3981 if test "$libtool" != true; then
3982 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3983 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3984 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3985 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3986 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3989 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3993 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3994 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3995 echo "AH_TOP([#include \"../config.h\"])"
3997 echo "AC_OUTPUT([Makefile])"
3998 ) > "$testdir/$testsbase/configure.ac"
3999 auxdir="$saved_auxdir"
4000 func_append subdirs " $testsbase"
4001 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4004 # Create Makefile.am.
4005 (echo "## Process this file with automake to produce Makefile.in."
4007 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4009 echo "SUBDIRS = $subdirs"
4011 echo "ACLOCAL_AMFLAGS = -I $m4base"
4012 ) > "$testdir/Makefile.am"
4014 # Create configure.ac.
4015 (echo "# Process this file with autoconf to produce a configure script."
4016 echo "AC_INIT([dummy], [0])"
4017 if test "$auxdir" != "."; then
4018 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4020 echo "AM_INIT_AUTOMAKE"
4022 echo "AM_CONFIG_HEADER([config.h])"
4025 echo "AC_PROG_INSTALL"
4026 echo "AC_PROG_MAKE_SET"
4028 echo "# For autobuild."
4029 echo "AC_CANONICAL_BUILD"
4030 echo "AC_CANONICAL_HOST"
4032 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4033 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4034 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4035 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4037 echo "AC_PROG_RANLIB"
4039 if test -n "$any_uses_subdirs"; then
4040 echo "AM_PROG_CC_C_O"
4043 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
4044 echo "AC_GNU_SOURCE"
4047 for module in $modules; do
4048 func_verify_nontests_module
4049 if test -n "$module"; then
4050 func_get_autoconf_early_snippet "$module"
4053 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4054 if test "$libtool" = true; then
4055 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4056 echo "gl_cond_libtool=true"
4058 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4059 echo "gl_cond_libtool=false"
4061 echo "gl_ltlibdeps="
4063 # Wrap the set of autoconf snippets into an autoconf macro that is then
4064 # invoked. This is needed because autoconf does not support AC_REQUIRE
4066 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4067 # but we want the AC_REQUIRE to have its normal meaning (provide one
4068 # expansion of the required macro before the current point, and only one
4070 echo "AC_DEFUN([gl_INIT], ["
4071 if test "$auxdir" != "build-aux"; then
4072 sed_replace_build_aux='
4074 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4075 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4079 sed_replace_build_aux="$sed_noop"
4081 func_emit_initmacro_start $macro_prefix
4082 echo "gl_source_base='$sourcebase'"
4083 for module in $modules; do
4084 func_verify_nontests_module
4085 if test -n "$module"; then
4086 func_get_autoconf_snippet "$module" \
4087 | sed -e "$sed_replace_build_aux"
4090 func_emit_initmacro_end $macro_prefix
4091 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4092 # created using libtool, because libtool already handles the dependencies.
4093 if test "$libtool" != true; then
4094 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4095 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4096 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4097 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4098 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4101 func_emit_initmacro_done $macro_prefix $sourcebase
4105 if test -n "$subdirs_with_configure_ac"; then
4106 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4108 makefiles="Makefile"
4109 for d in $subdirs; do
4110 # For subdirs that have a configure.ac by their own, it's the subdir's
4111 # configure.ac which creates the subdir's Makefile.am, not this one.
4112 case " $subdirs_with_configure_ac " in
4114 *) func_append makefiles " $d/Makefile" ;;
4117 echo "AC_OUTPUT([$makefiles])"
4118 ) > "$testdir/configure.ac"
4120 # Create autogenerated files.
4122 # Do not use "${AUTORECONF} --force --install", because it may invoke
4123 # autopoint, which brings in older versions of some of our .m4 files.
4124 if test -f $m4base/gettext.m4; then
4125 func_execute_command ${AUTOPOINT} --force || func_exit 1
4126 for f in $m4base/*.m4~; do
4128 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4132 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4133 if ! test -d build-aux; then
4134 func_execute_command mkdir build-aux || func_exit 1
4136 func_execute_command ${AUTOCONF} || func_exit 1
4137 func_execute_command ${AUTOHEADER} || func_exit 1
4138 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4140 if test -n "$inctests"; then
4141 # Create autogenerated files.
4142 (cd "$testdir/$testsbase" || func_exit 1
4143 # Do not use "${AUTORECONF} --force --install", because it may invoke
4144 # autopoint, which brings in older versions of some of our .m4 files.
4145 if test -f ../$m4base/gettext.m4; then
4146 func_execute_command ${AUTOPOINT} --force || func_exit 1
4147 for f in ../$m4base/*.m4~; do
4149 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4153 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4154 if ! test -d ../build-aux; then
4155 func_execute_command mkdir ../build-aux
4157 func_execute_command ${AUTOCONF} || func_exit 1
4158 func_execute_command ${AUTOHEADER} || func_exit 1
4159 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4162 # Need to run configure and make once, to create built files that are to be
4163 # distributed (such as getdate.c).
4164 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4165 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4166 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4167 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4168 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4169 # such $(FOO_H) because they don't refer to distributed files.
4170 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4171 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4172 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4173 | sed -e "$sed_remove_make_variables"`
4174 distributed_built_sources=`for file in $built_sources; do
4175 case "$cleaned_files" in
4180 if test -n "$distributed_built_sources"; then
4182 ./configure || func_exit 1
4184 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4185 make built_sources || func_exit 1
4187 make distclean || func_exit 1
4192 # func_create_megatestdir megatestdir allmodules
4194 # - local_gnulib_dir from --local-dir
4195 # - auxdir directory relative to destdir where to place build aux files
4196 func_create_megatestdir ()
4200 if test -z "$allmodules"; then
4201 allmodules=`func_all_modules`
4205 # First, all modules one by one.
4206 for onemodule in $allmodules; do
4207 func_create_testdir "$megatestdir/$onemodule" $onemodule
4208 func_append megasubdirs "$onemodule "
4210 # Then, all modules all together.
4211 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4212 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
4213 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
4214 func_create_testdir "$megatestdir/ALL" "$allmodules"
4215 func_append megasubdirs "ALL"
4218 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4219 vc_witness="$gnulib_dir/CVS/Entries"; \
4221 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4223 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4224 | sed -e 's,January,01,' -e 's,Jan,01,' \
4225 -e 's,February,02,' -e 's,Feb,02,' \
4226 -e 's,March,03,' -e 's,Mar,03,' \
4227 -e 's,April,04,' -e 's,Apr,04,' \
4229 -e 's,June,06,' -e 's,Jun,06,' \
4230 -e 's,July,07,' -e 's,Jul,07,' \
4231 -e 's,August,08,' -e 's,Aug,08,' \
4232 -e 's,September,09,' -e 's,Sep,09,' \
4233 -e 's,October,10,' -e 's,Oct,10,' \
4234 -e 's,November,11,' -e 's,Nov,11,' \
4235 -e 's,December,12,' -e 's,Dec,12,' \
4236 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4237 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4239 echo "CVSDATE=$cvsdate"
4240 echo "test -d logs || mkdir logs"
4241 echo "for module in $megasubdirs; do"
4242 echo " echo \"Working on module \$module...\""
4243 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4244 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4247 echo " : autobuild project... \$module"
4248 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4249 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4250 echo " : autobuild hostname... \`hostname\`"
4251 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
4253 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4255 ) > "$megatestdir/do-autobuild"
4256 chmod a+x "$megatestdir/do-autobuild"
4258 # Create Makefile.am.
4259 (echo "## Process this file with automake to produce Makefile.in."
4261 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4263 echo "SUBDIRS = $megasubdirs"
4265 echo "EXTRA_DIST = do-autobuild"
4266 ) > "$megatestdir/Makefile.am"
4268 # Create configure.ac.
4269 (echo "# Process this file with autoconf to produce a configure script."
4270 echo "AC_INIT([dummy], [0])"
4271 if test "$auxdir" != "."; then
4272 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4274 echo "AM_INIT_AUTOMAKE"
4276 echo "AC_PROG_MAKE_SET"
4278 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4279 echo "AC_OUTPUT([Makefile])"
4280 ) > "$megatestdir/configure.ac"
4282 # Create autogenerated files.
4284 # Do not use "${AUTORECONF} --install", because autoreconf operates
4285 # recursively, but the subdirectories are already finished, therefore
4286 # calling autoreconf here would only waste lots of CPU time.
4287 func_execute_command ${ACLOCAL} || func_exit 1
4288 func_execute_command mkdir build-aux
4289 func_execute_command ${AUTOCONF} || func_exit 1
4290 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4296 func_fatal_error "no mode specified" ;;
4305 if test -z "$destdir"; then
4308 test -d "$destdir" \
4309 || func_fatal_error "destination directory does not exist: $destdir"
4311 # Prefer configure.ac to configure.in.
4312 if test -f "$destdir"/configure.ac; then
4313 configure_ac="$destdir/configure.ac"
4315 if test -f "$destdir"/configure.in; then
4316 configure_ac="$destdir/configure.in"
4318 func_fatal_error "cannot find $destdir/configure.ac"
4322 # Analyze configure.ac.
4324 guessed_libtool=false
4329 /AC_CONFIG_AUX_DIR/ {
4330 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
4332 /A[CM]_PROG_LIBTOOL/ {
4333 s,^.*$,guessed_libtool=true,p
4335 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4337 if test -z "$auxdir"; then
4338 auxdir="$guessed_auxdir"
4341 # Determine where to apply func_import.
4342 if test -n "$m4base"; then
4343 # Apply func_import to a particular gnulib directory.
4344 # Any number of additional modules can be given.
4345 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4346 # First use of gnulib in the given m4base.
4347 test -n "$supplied_libname" || supplied_libname=true
4348 test -n "$sourcebase" || sourcebase="lib"
4349 test -n "$docbase" || docbase="doc"
4350 test -n "$testsbase" || testsbase="tests"
4351 test -n "$macro_prefix" || macro_prefix="gl"
4355 # Apply func_import to all gnulib directories.
4356 # To get this list of directories, look at Makefile.am. (Not at
4357 # configure, because it may be omitted from CVS. Also, don't run
4358 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4361 if test -f "$destdir"/Makefile.am; then
4362 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4364 for arg in $aclocal_amflags; do
4365 if test -n "$m4dir_is_next"; then
4366 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4370 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4371 func_append m4dirs " $arg"
4372 m4dirs_count=`expr $m4dirs_count + 1`
4378 if test "X$arg" = "X-I"; then
4386 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4387 if test -f "$destdir"/aclocal.m4; then
4388 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4389 sedexpr2='s,^[^/]*$,.,'
4390 sedexpr3='s,/[^/]*$,,'
4391 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4392 m4dirs_count=`echo "$m4dirs" | wc -l`
4395 if test $m4dirs_count = 0; then
4396 # First use of gnulib in a package.
4397 # Any number of additional modules can be given.
4398 test -n "$supplied_libname" || supplied_libname=true
4399 test -n "$sourcebase" || sourcebase="lib"
4401 test -n "$docbase" || docbase="doc"
4402 test -n "$testsbase" || testsbase="tests"
4403 test -n "$macro_prefix" || macro_prefix="gl"
4406 if test $m4dirs_count = 1; then
4407 # There's only one use of gnulib here. Assume the user means it.
4408 # Any number of additional modules can be given.
4409 for m4base in $m4dirs; do
4413 # Ambiguous - guess what the user meant.
4414 if test $# = 0; then
4415 # No further arguments. Guess the user wants to update all of them.
4416 for m4base in $m4dirs; do
4417 # Perform func_import in a subshell, so that variable values
4419 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
4420 # pobase, docbase, testsbase, inctests, libname, lgpl,
4421 # makefile_name, libtool, macro_prefix, po_domain, vc_files
4422 # don't propagate from one directory to another.
4423 (func_import) || func_exit 1
4427 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4435 if test -z "$destdir"; then
4436 func_fatal_error "please specify --dir option"
4439 test -d "$destdir" \
4440 || func_fatal_error "could not create destination directory"
4441 test -n "$auxdir" || auxdir="build-aux"
4442 func_create_testdir "$destdir" "$*"
4445 create-megatestdir )
4446 if test -z "$destdir"; then
4447 func_fatal_error "please specify --dir option"
4449 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4450 test -n "$auxdir" || auxdir="build-aux"
4451 func_create_megatestdir "$destdir" "$*"
4455 test -n "$destdir" || destdir=testdir$$
4456 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4457 test -n "$auxdir" || auxdir="build-aux"
4458 func_create_testdir "$destdir" "$*"
4462 ../configure || func_exit 1
4464 make check || func_exit 1
4465 make distclean || func_exit 1
4466 remaining=`find . -type f -print`
4467 if test -n "$remaining"; then
4468 echo "Remaining files:" $remaining 1>&2
4469 echo "gnulib-tool: *** Stop." 1>&2
4478 test -n "$destdir" || destdir=testdir$$
4479 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4480 test -n "$auxdir" || auxdir="build-aux"
4481 func_create_megatestdir "$destdir" "$*"
4489 remaining=`find . -type f -print`
4490 if test -n "$remaining"; then
4491 echo "Remaining files:" $remaining 1>&2
4492 echo "gnulib-tool: *** Stop." 1>&2
4500 extract-description )
4504 if test -n "$module"; then
4505 func_get_description "$module"
4514 if test -n "$module"; then
4515 func_get_status "$module"
4524 if test -n "$module"; then
4525 func_get_notice "$module"
4534 if test -n "$module"; then
4535 func_get_filelist "$module"
4540 extract-dependencies )
4544 if test -n "$module"; then
4545 func_get_dependencies "$module"
4550 extract-autoconf-snippet )
4554 if test -n "$module"; then
4555 func_get_autoconf_snippet "$module"
4560 extract-automake-snippet )
4564 if test -n "$module"; then
4565 func_get_automake_snippet "$module"
4570 extract-include-directive )
4574 if test -n "$module"; then
4575 func_get_include_directive "$module"
4580 extract-link-directive )
4584 if test -n "$module"; then
4585 func_get_link_directive "$module"
4594 if test -n "$module"; then
4595 func_get_license "$module"
4600 extract-maintainer )
4604 if test -n "$module"; then
4605 func_get_maintainer "$module"
4610 extract-tests-module )
4614 if test -n "$module"; then
4615 func_get_tests_module "$module"
4621 func_fatal_error "unknown operation mode --$mode" ;;
4625 # Undo the effect of the previous 'trap' command. Some shellology:
4626 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4627 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4628 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4629 # 128 + signal number and is set before the trap-registered command is run.
4631 trap 'func_exit $?' 1 2 3 13 15
4636 # indent-tabs-mode: nil
4637 # whitespace-check-buffer-indent: nil