3 # Copyright (C) 2002-2010 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"
67 if test -z "${MAKE}"; then
71 # When using GNU sed, turn off as many GNU extensions as possible,
72 # to minimize the risk of accidentally using non-portable features.
73 # However, do this only for gnulib-tool itself, not for the code that
74 # gnulib-tool generates, since we don't want "sed --posix" to leak
75 # into makefiles. And do it only for sed versions 4.2 or newer,
76 # because "sed --posix" is buggy in GNU sed 4.1.5, see
77 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
78 if (alias) > /dev/null 2>&1 \
79 && echo | sed --posix -e d >/dev/null 2>&1 \
80 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
81 [1-3]* | 4.[01]*) false;; \
85 # Define sed as an alias.
86 # It is not always possible to use aliases. Aliases are guaranteed to work
87 # if the executing shell is bash and either it is invoked as /bin/sh or
88 # is a version >= 2.0, supporting shopt. This is the common case.
89 # Two other approaches (use of a variable $sed or of a function func_sed
90 # instead of an alias) require massive, fragile code changes.
91 # An other approach (use of function sed) requires `which sed` - but
92 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
93 if test -n "$BASH_VERSION"; then
94 shopt -s expand_aliases >/dev/null 2>&1
96 alias sed='sed --posix'
99 # sed_noop is a sed expression that does nothing.
100 # An empty expression does not work with the native 'sed' on AIX 6.1.
103 # sed_comments is true or false, depending whether 'sed' supports comments.
104 # (The GNU autoconf doc says that sed comments are not portable, but does
105 # not say which 'sed' versions are affected.)
106 if echo fo | sed -e 's/f/g/
108 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
115 # outputs to stdout the --help usage message.
119 Usage: gnulib-tool --list
120 gnulib-tool --find filename
121 gnulib-tool --import [module1 ... moduleN]
123 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
124 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
125 gnulib-tool --test --dir=directory module1 ... moduleN
126 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
127 gnulib-tool --extract-description module
128 gnulib-tool --extract-status module
129 gnulib-tool --extract-notice module
130 gnulib-tool --extract-applicability module
131 gnulib-tool --extract-filelist module
132 gnulib-tool --extract-dependencies module
133 gnulib-tool --extract-autoconf-snippet module
134 gnulib-tool --extract-automake-snippet module
135 gnulib-tool --extract-include-directive module
136 gnulib-tool --extract-link-directive module
137 gnulib-tool --extract-license module
138 gnulib-tool --extract-maintainer module
139 gnulib-tool --extract-tests-module module
140 gnulib-tool --copy-file file [destination]
143 --list print the available module names
144 --find find the modules which contain the specified file
145 --import import the given modules into the current package;
146 if no modules are specified, update the current
147 package from the current gnulib
148 --update update the current package, restore files omitted
150 --create-testdir create a scratch package with the given modules
151 --create-megatestdir create a mega scratch package with the given modules
152 one by one and all together
153 --test test the combination of the given modules
154 (recommended to use CC=\"gcc -Wall\" here)
155 --megatest test the given modules one by one and all together
156 (recommended to use CC=\"gcc -Wall\" here)
157 --extract-description extract the description
158 --extract-status extract the status (obsolete or not)
159 --extract-notice extract the notice or banner
160 --extract-filelist extract the list of files
161 --extract-dependencies extract the dependencies
162 --extract-autoconf-snippet extract the snippet for configure.ac
163 --extract-automake-snippet extract the snippet for library makefile
164 --extract-include-directive extract the #include directive
165 --extract-link-directive extract the linker directive
166 --extract-license report the license terms of the source files
168 --extract-maintainer report the maintainer(s) inside gnulib
169 --extract-tests-module report the unit test module, if it exists
170 --copy-file copy a file that is not part of any module
173 --dir=DIRECTORY Specify the target directory.
174 For --import, this specifies where your
175 configure.ac can be found. Defaults to current
177 --local-dir=DIRECTORY Specify a local override directory where to look
178 up files before looking in gnulib's directory.
179 --cache-modules Enable module caching optimization.
180 --no-cache-modules Disable module caching optimization.
181 --verbose Increase verbosity. May be repeated.
182 --quiet Decrease verbosity. May be repeated.
184 Options for --import:
185 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
186 --source-base=DIRECTORY
187 Directory relative to --dir where source code is
188 placed (default \"lib\").
189 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
190 placed (default \"m4\").
191 --po-base=DIRECTORY Directory relative to --dir where *.po files are
192 placed (default \"po\").
193 --doc-base=DIRECTORY Directory relative to --dir where doc files are
194 placed (default \"doc\").
195 --tests-base=DIRECTORY
196 Directory relative to --dir where unit tests are
197 placed (default \"tests\").
198 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
199 tools are placed (default \"build-aux\").
200 --with-tests Include unit tests for the included modules.
201 --with-obsolete Include obsolete modules when they occur among the
202 dependencies. By default, dependencies to obsolete
204 --avoid=MODULE Avoid including the given MODULE. Useful if you
205 have code that provides equivalent functionality.
206 This option can be repeated.
207 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
208 Also modify license template from GPL to LGPL.
209 The version number of the LGPL can be specified;
210 the default is currently LGPLv3.
211 --makefile-name=NAME Name of makefile in automake syntax in the
212 source-base and tests-base directories
213 (default \"Makefile.am\").
214 --libtool Use libtool rules.
215 --no-libtool Don't use libtool rules.
216 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
217 'gl_INIT'. Default is 'gl'.
218 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
219 the package name. A suffix '-gnulib' is appended.
220 --vc-files Update version control related files.
221 --no-vc-files Don't update version control related files
222 (.gitignore and/or .cvsignore).
223 --no-changelog Don't update or create ChangeLog files.
225 Options for --import and --update:
226 --dry-run For --import, only print what would have been done.
227 -s, --symbolic, --symlink Make symbolic links instead of copying files.
228 --local-symlink Make symbolic links instead of copying files, only
229 for files from the local override directory.
230 -S, --more-symlinks Make symbolic links instead of copying files, and
231 don't replace copyright notices.
233 Report bugs to <bug-gnulib@gnu.org>."
237 # outputs to stdout the --version message.
241 if test -d "$gnulib_dir"/.git \
242 && (git --version) >/dev/null 2>/dev/null \
243 && (date --version) >/dev/null 2>/dev/null; then
244 # gnulib checked out from git.
245 sed_extract_first_date='/^Date/{
249 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
250 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
251 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
252 date=`echo "$date" | sed -e "$sed_year_before_time"`
253 # Use GNU date to compute the time in GMT.
254 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
255 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
257 if test -d "$gnulib_dir"/CVS \
258 && (cvs --version) >/dev/null 2>/dev/null; then
259 # gnulib checked out from CVS.
260 sed_extract_first_date='/^date: /{
261 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
264 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
266 # gnulib copy without versioning information.
267 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
271 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
273 gnulib-tool (GNU $package $date)$version
274 Copyright (C) $year Free Software Foundation, Inc.
275 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
276 This is free software: you are free to change and redistribute it.
277 There is NO WARRANTY, to the extent permitted by law.
279 Written by" "Bruno Haible" "and" "Simon Josefsson"
282 # func_emit_copyright_notice
283 # outputs to stdout a header for a generated file.
284 func_emit_copyright_notice ()
286 sed -n -e '/Copyright/ {
289 }' < "$self_abspathname"
291 echo "# This file is free software, distributed under the terms of the GNU"
292 echo "# General Public License. As a special exception to the GNU General"
293 echo "# Public License, this file may be distributed as part of a program"
294 echo "# that contains a configuration script generated by Autoconf, under"
295 echo "# the same distribution terms as the rest of that program."
297 echo "# Generated by gnulib-tool."
301 # exits with a given status.
302 # This function needs to be used, rather than 'exit', when a 'trap' handler is
303 # in effect that refers to $?.
310 # locates the directory where the gnulib repository lives
312 # - progname name of this program
314 # - self_abspathname absolute pathname of gnulib-tool
315 # - gnulib_dir absolute pathname of gnulib repository
319 /*) self_abspathname="$progname" ;;
320 */*) self_abspathname=`pwd`/"$progname" ;;
323 # Iterate through the elements of $PATH.
324 # We use IFS=: instead of
325 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
326 # because the latter does not work when some PATH element contains spaces.
327 # We use a canonicalized $pathx instead of $PATH, because empty PATH
328 # elements are by definition equivalent to '.', however field splitting
329 # according to IFS=: loses empty fields in many shells:
330 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
331 # beginning, at the end, and in the middle),
332 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
333 # at the beginning and at the end,
334 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
335 # Solaris lose empty fields at the end.
336 # The 'case' statement is an optimization, to avoid evaluating the
337 # explicit canonicalization command when $PATH contains no empty fields.
339 if test "${PATH_SEPARATOR+set}" != set; then
341 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
342 chmod +x "$tmp"/conf.sh
343 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
350 if test "$PATH_SEPARATOR" = ";"; then
351 # On Windows, programs are searched in "." before $PATH.
354 # On Unix, we have to convert empty PATH elements to ".".
358 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
363 IFS="$PATH_SEPARATOR"
367 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
368 self_abspathname="$d/$progname"
373 if test -z "$self_abspathname"; then
374 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
378 while test -h "$self_abspathname"; do
379 # Resolve symbolic link.
380 linkval=`func_readlink "$self_abspathname"`
381 test -n "$linkval" || break
383 /* ) self_abspathname="$linkval" ;;
384 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
387 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
391 # creates a temporary directory.
393 # - progname name of this program
395 # - tmp pathname of freshly created temporary directory
398 # Use the environment variable TMPDIR, falling back to /tmp. This allows
399 # users to specify a different temporary directory, for example, if their
400 # /tmp is filled up or too small.
403 # Use the mktemp program if available. If not available, hide the error
405 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
406 test -n "$tmp" && test -d "$tmp"
409 # Use a simple mkdir command. It is guaranteed to fail if the directory
410 # already exists. $RANDOM is bash specific and expands to empty in shells
411 # other than bash, ksh and zsh. Its use does not increase security;
412 # rather, it minimizes the probability of failure in a very cluttered /tmp
414 tmp=$TMPDIR/gl$$-$RANDOM
415 (umask 077 && mkdir "$tmp")
418 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
423 # func_append var value
424 # appends the given value to the shell variable var.
425 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
426 # Use bash's += operator. It reduces complexity of appending repeatedly to
427 # a single variable from O(n^2) to O(n).
432 fast_func_append=true
436 eval "$1=\"\$$1\$2\""
438 fast_func_append=false
441 # func_remove_prefix var prefix
442 # removes the given prefix from the value of the shell variable var.
443 # var should be the name of a shell variable.
444 # Its value should not contain a newline and not start or end with whitespace.
445 # prefix should not contain the characters "$`\{}[]^|.
446 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
447 func_remove_prefix ()
451 fast_func_remove_prefix=true
453 func_remove_prefix ()
455 eval "value=\"\$$1\""
459 sed_escape_dots='s/\([.]\)/\\\1/g'
460 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
463 value=`echo "$value" | sed -e "s|^${prefix}||"`
464 eval "$1=\"\$value\""
466 fast_func_remove_prefix=false
469 # func_remove_suffix var suffix
470 # removes the given suffix from the value of the shell variable var.
471 # var should be the name of a shell variable.
472 # Its value should not contain a newline and not start or end with whitespace.
473 # suffix should not contain the characters "$`\{}[]^|.
474 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
475 func_remove_suffix ()
479 fast_func_remove_suffix=true
481 func_remove_suffix ()
483 eval "value=\"\$$1\""
487 sed_escape_dots='s/\([.]\)/\\\1/g'
488 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
491 value=`echo "$value" | sed -e "s|${suffix}\$||"`
492 eval "$1=\"\$value\""
494 fast_func_remove_suffix=false
497 # func_fatal_error message
498 # outputs to stderr a fatal error message, and terminates the program.
500 # - progname name of this program
503 echo "$progname: *** $1" 1>&2
504 echo "$progname: *** Stop." 1>&2
508 # func_warning message
509 # Outputs to stderr a warning message,
512 echo "gnulib-tool: warning: $1" 1>&2
515 # func_readlink SYMLINK
516 # outputs the target of the given symlink.
517 if (type -p readlink) > /dev/null 2>&1; then
520 # Use the readlink program from GNU coreutils.
526 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
527 # would do the wrong thing if the link target contains " -> ".
528 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
532 # func_relativize DIR1 DIR2
533 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
535 # - DIR1 relative pathname, relative to the current directory
536 # - DIR2 relative pathname, relative to the current directory
538 # - reldir relative pathname of DIR2, relative to DIR1
544 sed_first='s,^\([^/]*\)/.*$,\1,'
545 sed_rest='s,^[^/]*/*,,'
546 sed_last='s,^.*/\([^/]*\)$,\1,'
547 sed_butlast='s,/*[^/]*$,,'
548 while test -n "$dir1"; do
549 first=`echo "$dir1" | sed -e "$sed_first"`
550 if test "$first" != "."; then
551 if test "$first" = ".."; then
552 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
553 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
555 first2=`echo "$dir2" | sed -e "$sed_first"`
556 if test "$first2" = "$first"; then
557 dir2=`echo "$dir2" | sed -e "$sed_rest"`
561 dir0="$dir0"/"$first"
564 dir1=`echo "$dir1" | sed -e "$sed_rest"`
569 # func_relconcat DIR1 DIR2
570 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
572 # - DIR1 relative pathname, relative to the current directory
573 # - DIR2 relative pathname, relative to DIR1
575 # - relconcat DIR1/DIR2, relative to the current directory
580 sed_first='s,^\([^/]*\)/.*$,\1,'
581 sed_rest='s,^[^/]*/*,,'
582 sed_last='s,^.*/\([^/]*\)$,\1,'
583 sed_butlast='s,/*[^/]*$,,'
585 first=`echo "$dir2" | sed -e "$sed_first"`
586 if test "$first" = "."; then
587 dir2=`echo "$dir2" | sed -e "$sed_rest"`
588 if test -z "$dir2"; then
593 last=`echo "$dir1" | sed -e "$sed_last"`
594 while test "$last" = "."; do
595 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
596 last=`echo "$dir1" | sed -e "$sed_last"`
598 if test -z "$dir1"; then
602 if test "$first" = ".."; then
603 if test "$last" = ".."; then
604 relconcat="$dir1/$dir2"
607 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
608 dir2=`echo "$dir2" | sed -e "$sed_rest"`
609 if test -z "$dir1"; then
613 if test -z "$dir2"; then
618 relconcat="$dir1/$dir2"
626 # Like ln -s, except that SRC is given relative to the current directory (or
627 # absolute), not given relative to the directory of DEST.
633 *) # SRC is relative.
636 ln -s "`pwd`/$1" "$2" ;;
637 *) # DEST is relative too.
638 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
639 test -n "$ln_destdir" || ln_destdir="."
640 func_relativize "$ln_destdir" "$1"
648 # func_ln_if_changed SRC DEST
649 # Like func_ln, but avoids munging timestamps if the link is correct.
650 func_ln_if_changed ()
652 if test $# -ne 2; then
653 echo "usage: func_ln_if_changed SRC DEST" >&2
655 ln_target=`func_readlink "$2"`
656 if test -h "$2" && test "$1" = "$ln_target"; then
665 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
666 # writes into a pipe with no readers, i.e. a pipe where all readers have
667 # already closed their file descriptor that read from it or exited entirely.
668 # The default behaviour is to terminate the current process without an error
670 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
671 # terminate the current process with an error message.
672 # This function should be called at the beginning of a command that only
673 # produces output to stdout (i.e. no side effects!), when the command that
674 # will read from this pipe might prematurely exit or close its standard input
676 if test -n "$BASH_VERSION"; then
677 # The problem has only been reported with bash. Probably it occurs only with
678 # bash-3.2. For the reasons, see
679 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
680 # Note that Solaris sh does not understand "trap - SIGPIPE".
681 func_reset_sigpipe ()
686 func_reset_sigpipe ()
692 # Ensure an 'echo' command that does not interpret backslashes.
694 # echo '\n' | wc -l prints 1 when OK, 2 when KO
695 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
696 # This problem is a weird heritage from SVR4. BSD got it right (except that
697 # BSD echo interprets '-n' as an option, which is also not desirable).
698 # Nowadays the problem occurs in 4 situations:
699 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
700 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
701 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
702 # - in zsh, when sh-emulation is not set,
703 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
704 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
705 # - in Solaris /bin/sh and OSF/1 /bin/sh.
706 # We try the following workarounds:
707 # - for all: respawn using $CONFIG_SHELL if that is set and works.
708 # - for bash >= 2.04: unset the shell option xpg_echo.
709 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
710 # - for bash < 2.0: define echo to a function that uses cat of a here document.
711 # - for zsh: turn sh-emulation on.
712 # - for ksh: alias echo to 'print -r'.
713 # - for ksh: alias echo to a function that uses cat of a here document.
714 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
715 # the ksh workaround.
716 # - otherwise: respawn using /bin/sh and rely on the workarounds.
717 # When respawning, we pass --no-reexec as first argument, so as to avoid
718 # turning this script into a fork bomb in unlucky situations.
720 if echo '\t' | grep t > /dev/null; then
721 have_echo=yes # Lucky!
723 # Try the workarounds.
724 # Respawn using $CONFIG_SHELL if that is set and works.
725 if test -z "$have_echo" \
726 && test "X$1" != "X--no-reexec" \
727 && test -n "$CONFIG_SHELL" \
728 && test -f "$CONFIG_SHELL" \
729 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
730 exec $CONFIG_SHELL "$0" --no-reexec "$@"
733 # For bash >= 2.04: unset the shell option xpg_echo.
734 if test -z "$have_echo" \
735 && test -n "$BASH_VERSION" \
736 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
740 # For bash >= 2.0: define echo to a function that uses the printf built-in.
741 # For bash < 2.0: define echo to a function that uses cat of a here document.
742 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
743 if test -z "$have_echo" \
744 && test -n "$BASH_VERSION"; then \
745 if type printf 2>/dev/null | grep / > /dev/null; then
746 # 'printf' is not a shell built-in.
754 # 'printf' is a shell built-in.
760 if echo '\t' | grep t > /dev/null; then
764 # For zsh: turn sh-emulation on.
765 if test -z "$have_echo" \
766 && test -n "$ZSH_VERSION" \
767 && (emulate sh) >/dev/null 2>&1; then
770 # For ksh: alias echo to 'print -r'.
771 if test -z "$have_echo" \
772 && (type print) >/dev/null 2>&1; then
773 # A 'print' command exists.
774 if type print 2>/dev/null | grep / > /dev/null; then
777 # 'print' is a shell built-in.
778 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
779 # 'print' is the ksh shell built-in.
780 alias echo='print -r'
784 if test -z "$have_echo" \
785 && echo '\t' | grep t > /dev/null; then
788 # For ksh: alias echo to a function that uses cat of a here document.
789 # The ksh manual page says:
790 # "Aliasing is performed when scripts are read, not while they are executed.
791 # Therefore, for an alias to take effect, the alias definition command has
792 # to be executed before the command which references the alias is read."
793 # Because of this, we have to play strange tricks with have_echo, to ensure
794 # that the top-level statement containing the test starts after the 'alias'
796 if test -z "$have_echo"; then
803 alias echo=bsd_echo 2>/dev/null
805 if test -z "$have_echo" \
806 && echo '\t' | grep t > /dev/null; then
809 if test -z "$have_echo"; then
810 unalias echo 2>/dev/null
812 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
813 if test -z "$have_echo" \
814 && test "X$1" != "X--no-reexec" \
815 && test -f /bin/ksh; then
816 exec /bin/ksh "$0" --no-reexec "$@"
819 # Otherwise: respawn using /bin/sh.
820 if test -z "$have_echo" \
821 && test "X$1" != "X--no-reexec" \
822 && test -f /bin/sh; then
823 exec /bin/sh "$0" --no-reexec "$@"
826 if test -z "$have_echo"; then
827 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
829 if echo '\t' | grep t > /dev/null; then
832 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
834 if test "X$1" = "X--no-reexec"; then
838 # Command-line option processing.
839 # Removes the OPTIONS from the arguments. Sets the variables:
840 # - mode list or import or create-testdir or create-megatestdir
841 # - destdir from --dir
842 # - local_gnulib_dir from --local-dir
843 # - modcache true or false, from --cache-modules/--no-cache-modules
844 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
845 # - libname, supplied_libname from --lib
846 # - sourcebase from --source-base
847 # - m4base from --m4-base
848 # - pobase from --po-base
849 # - docbase from --doc-base
850 # - testsbase from --tests-base
851 # - auxdir from --aux-dir
852 # - inctests true if --with-tests was given, blank otherwise
853 # - incobsolete true if --with-obsolete was given, blank otherwise
854 # - avoidlist list of modules to avoid, from --avoid
855 # - lgpl yes or a number if --lgpl was given, blank otherwise
856 # - makefile_name from --makefile-name
857 # - libtool true if --libtool was given, false if --no-libtool was
858 # given, blank otherwise
859 # - macro_prefix from --macro-prefix
860 # - po_domain from --po-domain
861 # - vc_files true if --vc-files was given, false if --no-vc-files was
862 # given, blank otherwise
863 # - autoconf_minversion minimum supported autoconf version
864 # - do_changelog false if --no-changelog was given, : otherwise
865 # - doit : if actions shall be executed, false if only to be printed
866 # - symbolic true if --symlink or --more-symlinks was given, blank
868 # - lsymbolic true if --local-symlink was given, blank otherwise
869 # - do_copyrights blank if --more-symlinks was given, true otherwise
901 while test $# -gt 0; do
906 --find | --fin | --fi | --f )
909 --import | --impor | --impo | --imp | --im | --i )
912 --update | --updat | --upda | --upd | --up | --u )
915 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
918 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
919 mode=create-megatestdir
921 --test | --tes | --te | --t )
924 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
928 mode=`echo "X$1" | sed -e 's/^X--//'`
930 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
936 func_fatal_error "missing argument for --dir"
941 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
946 func_fatal_error "missing argument for --local-dir"
951 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
953 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
956 --no-cache-modules | --no-cache-module | --no-cache-modul | --no-cache-modu | --no-cache-mod | --no-cache-mo | --no-cache-m | --no-cache- | --no-cache | --no-cach | --no-cac | --no-ca )
959 --verbose | --verbos | --verbo | --verb )
960 verbose=`expr $verbose + 1`
962 --quiet | --quie | --qui | --qu | --q )
963 verbose=`expr $verbose - 1`
968 func_fatal_error "missing argument for --lib"
971 supplied_libname=true
974 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
975 supplied_libname=true
980 func_fatal_error "missing argument for --source-base"
985 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
990 func_fatal_error "missing argument for --m4-base"
995 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1000 func_fatal_error "missing argument for --po-base"
1005 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1009 if test $# = 0; then
1010 func_fatal_error "missing argument for --doc-base"
1015 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1019 if test $# = 0; then
1020 func_fatal_error "missing argument for --tests-base"
1025 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1029 if test $# = 0; then
1030 func_fatal_error "missing argument for --aux-dir"
1035 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1045 if test $# = 0; then
1046 func_fatal_error "missing argument for --avoid"
1048 func_append avoidlist " $1"
1051 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1052 func_append avoidlist " $arg"
1058 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1061 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1067 if test $# = 0; then
1068 func_fatal_error "missing argument for --makefile-name"
1073 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1083 if test $# = 0; then
1084 func_fatal_error "missing argument for --macro-prefix"
1089 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1093 if test $# = 0; then
1094 func_fatal_error "missing argument for --po-domain"
1099 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1107 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1113 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1116 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1119 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1123 --help | --hel | --he | --h )
1126 --version | --versio | --versi | --vers )
1130 # Stop option processing
1134 echo "gnulib-tool: unknown option $1" 1>&2
1135 echo "Try 'gnulib-tool --help' for more information." 1>&2
1142 if test "$mode" = update; then
1143 if test $# != 0; then
1144 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1145 echo "Try 'gnulib-tool --help' for more information." 1>&2
1146 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1147 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1150 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1151 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1152 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1153 || test -n "$inctests" || test -n "$incobsolete" \
1154 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1155 || test -n "$macro_prefix" || test -n "$po_domain" \
1156 || test -n "$vc_files"; then
1157 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1158 echo "Try 'gnulib-tool --help' for more information." 1>&2
1159 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1160 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1165 if test -n "$pobase" && test -z "$po_domain"; then
1166 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1167 echo "Try 'gnulib-tool --help' for more information." 1>&2
1170 if test -z "$pobase" && test -n "$po_domain"; then
1171 func_warning "--po-domain has no effect without a --po-base option"
1174 # Determine the minimum supported autoconf version from the project's
1176 DEFAULT_AUTOCONF_MINVERSION="2.59"
1177 autoconf_minversion=
1179 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1180 if test -f "$destdir"/configure.ac; then
1181 configure_ac="$destdir/configure.ac"
1183 if test -f "$destdir"/configure.in; then
1184 configure_ac="$destdir/configure.in"
1188 if test -f configure.ac; then
1189 configure_ac="configure.ac"
1191 if test -f configure.in; then
1192 configure_ac="configure.in"
1196 if test -n "$configure_ac"; then
1197 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1198 # because when some m4 files are omitted from a CVS repository,
1199 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1200 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1201 # autom4te: m4 failed with exit status: 1
1208 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1210 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1211 if test -n "$prereqs"; then
1212 autoconf_minversion=`
1213 for version in $prereqs; do echo $version; done |
1214 LC_ALL=C sort -nru | sed -e 1q
1218 if test -z "$autoconf_minversion"; then
1219 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1221 case "$autoconf_minversion" in
1222 1.* | 2.[0-4]* | 2.5[0-8]*)
1223 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1226 # Remove trailing slashes from the directory names. This is necessary for
1227 # m4base (to avoid an error in func_import) and optional for the others.
1228 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1229 case "$local_gnulib_dir" in
1230 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1232 case "$sourcebase" in
1233 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1236 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1239 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1242 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1244 case "$testsbase" in
1245 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1248 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1254 trap 'exit_status=$?
1255 if test "$signal" != 0; then
1256 echo "caught signal $signal" >&2
1259 exit $exit_status' 0
1260 for signal in 1 2 3 13 15; do
1261 trap '{ signal='$signal'; func_exit 1; }' $signal
1265 # func_lookup_file file
1266 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1269 # - local_gnulib_dir from --local-dir
1271 # - lookedup_file name of the merged (combined) file
1272 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1276 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1277 lookedup_file="$local_gnulib_dir/$lkfile"
1280 if test -f "$gnulib_dir/$lkfile"; then
1281 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1282 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1283 rm -f "$tmp/$lkbase"
1284 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1285 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1286 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1287 lookedup_file="$tmp/$lkbase"
1290 lookedup_file="$gnulib_dir/$lkfile"
1294 func_fatal_error "file $gnulib_dir/$lkfile not found"
1299 # func_sanitize_modulelist
1300 # receives a list of possible module names on standard input, one per line.
1301 # It removes those which are just file names unrelated to modules, and outputs
1302 # the resulting list to standard output, one per line.
1303 func_sanitize_modulelist ()
1305 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1306 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1307 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1308 -e '/^README$/d' -e '/\/README$/d' \
1309 -e '/^TEMPLATE$/d' \
1310 -e '/^TEMPLATE-EXTENDED$/d' \
1311 -e '/^TEMPLATE-TESTS$/d' \
1318 # - local_gnulib_dir from --local-dir
1321 # Filter out metainformation files like README, which are not modules.
1322 # Filter out unit test modules; they can be retrieved through
1323 # --extract-tests-module if desired.
1325 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1326 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1327 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1330 | func_sanitize_modulelist \
1331 | sed -e '/-tests$/d' \
1335 # func_verify_module
1336 # verifies a module name
1338 # - local_gnulib_dir from --local-dir
1339 # - module module name argument
1340 func_verify_module ()
1342 if { test -f "$gnulib_dir/modules/$module" \
1343 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1344 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1345 && test "CVS" != "$module" \
1346 && test "ChangeLog" != "$module" \
1347 && test "COPYING" != "$module" \
1348 && test "README" != "$module" \
1349 && test "TEMPLATE" != "$module" \
1350 && test "TEMPLATE-EXTENDED" != "$module" \
1351 && test "TEMPLATE-TESTS" != "$module"; then
1352 # OK, $module is a correct module name.
1353 # Verify that building the module description with 'patch' succeeds.
1354 func_lookup_file "modules/$module"
1356 func_warning "module $module doesn't exist"
1361 # func_verify_nontests_module
1362 # verifies a module name, excluding tests modules
1364 # - local_gnulib_dir from --local-dir
1365 # - module module name argument
1366 func_verify_nontests_module ()
1369 *-tests ) module= ;;
1370 * ) func_verify_module ;;
1374 # func_verify_tests_module
1375 # verifies a module name, considering only tests modules
1377 # - local_gnulib_dir from --local-dir
1378 # - module module name argument
1379 func_verify_tests_module ()
1382 *-tests ) func_verify_module ;;
1387 # Suffix of a sed expression that extracts a particular field from a
1388 # module description.
1389 # A field starts with a line that contains a keyword, such as 'Description',
1390 # followed by a colon and optional whitespace. All following lines, up to
1391 # the next field (or end of file if there is none) form the contents of the
1393 # An absent field is equivalent to a field with empty contents.
1394 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1395 sed_extract_prog=':[ ]*$/ {
1398 s/^Description:[ ]*$//
1401 s/^Applicability:[ ]*$//
1403 s/^Depends-on:[ ]*$//
1404 s/^configure\.ac-early:[ ]*$//
1405 s/^configure\.ac:[ ]*$//
1406 s/^Makefile\.am:[ ]*$//
1410 s/^Maintainer:[ ]*$//
1417 # Piece of a sed expression that converts a field header line to a shell
1419 # NOTE: Keep this in sync with sed_extract_prog above!
1420 sed_extract_field_header='
1421 s/^Description:[ ]*$/description/
1422 s/^Status:[ ]*$/status/
1423 s/^Notice:[ ]*$/notice/
1424 s/^Applicability:[ ]*$/applicability/
1425 s/^Files:[ ]*$/files/
1426 s/^Depends-on:[ ]*$/dependson/
1427 s/^configure\.ac-early:[ ]*$/configureac_early/
1428 s/^configure\.ac:[ ]*$/configureac/
1429 s/^Makefile\.am:[ ]*$/makefile/
1430 s/^Include:[ ]*$/include/
1432 s/^License:[ ]*$/license/
1433 s/^Maintainer:[ ]*$/maintainer/'
1437 # Note: The 'eval' silences stderr output in dash.
1438 if declare -A x 2>/dev/null && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }; then
1439 # Zsh 4 and Bash 4 have associative arrays.
1440 have_associative=true
1442 # For other shells, use 'eval' with computed shell variable names.
1443 have_associative=false
1446 if $have_associative; then
1448 # Declare the associative arrays.
1449 declare -A modcache_cached
1450 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1451 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1452 eval "$declare_script"
1456 # func_cache_var module
1457 # computes the cache variable name corresponding to $module.
1458 # Note: This computation can map different module names to the same
1459 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1460 # to protect against this case.
1462 # - cachevar a shell variable name
1463 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1464 # Bash 2.0 and newer, ksh, and zsh support the syntax
1465 # ${param//pattern/replacement}
1466 # as a shorthand for
1467 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1468 # Note: The 'eval' above silences stderr output in dash.
1471 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1478 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1487 # func_init_sed_convert_to_cache_statements
1489 # - modcachevar_assignment
1491 # - sed_convert_to_cache_statements
1492 func_init_sed_convert_to_cache_statements ()
1494 # 'sed' script that turns a module description into shell script
1495 # assignments, suitable to be eval'ed. All active characters are escaped.
1498 # Some module's description
1503 # modcache_description[$1]=\
1504 # 'Some module'"'"'s description
1506 # modcache_files[$1]=\
1509 # c_MODULE_description_set=set; c_MODULE_description=\
1510 # 'Some module'"'"'s description
1512 # c_MODULE_files_set=set; c_MODULE_files=\
1514 # The script consists of two parts:
1515 # 1) Ignore the lines before the first field header.
1516 # 2) A loop, treating non-field-header lines by escaping single quotes
1517 # and adding a closing quote in the last line,
1518 sed_convert_to_cache_statements="
1520 # Here we have not yet seen a field header.
1522 # See if the current line contains a field header.
1525 ${sed_extract_field_header}
1528 # No field header. Ignore the line.
1530 # Read the next line. Upon EOF, just exit.
1535 # The current line contains a field header.
1537 # Turn it into the beginning of an assignment.
1538 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1540 # Move it to the hold space. Don't print it yet,
1541 # because we want no assignment if the field is empty.
1544 # Read the next line.
1545 # Upon EOF, the field was empty. Print no assignment. Just exit.
1548 # See if the current line contains a field header.
1551 ${sed_extract_field_header}
1552 # If it is, the previous field was empty. Print no assignment.
1555 # Not a field header.
1557 # Print the previous line, held in the hold space.
1562 # Transform single quotes.
1565 # Prepend a single quote.
1570 # Move it to the hold space.
1573 # Read the next line.
1580 # See if the current line contains a field header.
1583 ${sed_extract_field_header}
1586 # Print the previous line, held in the hold space.
1591 # Transform single quotes.
1598 # Print the previous line, held in the hold space, with a single quote
1599 # to end the assignment.
1609 # Print the previous line, held in the hold space, with a single quote
1610 # to end the assignment.
1617 if ! $sed_comments; then
1619 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1620 | sed -e 's/^ *//' -e 's/^#.*//'`
1624 if $have_associative; then
1625 # sed_convert_to_cache_statements does not depend on the module.
1626 modcachevar_assignment='modcache_\1[$1]='
1627 func_init_sed_convert_to_cache_statements
1630 # func_cache_lookup_module module
1632 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1633 # of its relevant data in a cache in the memory of the processing shell. If
1634 # already cached, it does not look it up again, thus saving file access time.
1636 # - module non-empty string
1637 # Output if $have_associative:
1638 # - modcache_cached[$module] set to yes
1639 # - modcache_description[$module] ==
1640 # - modcache_status[$module] \ set to the field's value, minus the
1641 # - ... / final newline,
1642 # - modcache_maintainer[$module] == or unset if the field's value is empty
1643 # Output if ! $have_associative:
1644 # - cachevar a shell variable name
1645 # - ${cachevar}_cached set to $module
1646 # - ${cachevar}_description ==
1647 # - ${cachevar}_status \ set to the field's value, minus the
1648 # - ... / final newline,
1649 # - ${cachevar}_maintainer == or unset if the field's value is empty
1650 # - ${cachevar}_description_set ==
1651 # - ${cachevar}_status_set \ set to non-empty if the field's value
1652 # - ... / is non-empty,
1653 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1654 func_cache_lookup_module ()
1656 if $have_associative; then
1657 cached=${modcache_cached[$1]}
1660 eval "cached=\"\$${cachevar}_cached\""
1662 if test -z "$cached"; then
1663 # Not found in cache. Look it up on the file system.
1664 func_lookup_file "modules/$1"
1665 if $have_associative; then
1666 modcache_cached[$1]=yes
1668 eval "${cachevar}_cached=\"\$1\""
1670 if ! $have_associative; then
1671 # sed_convert_to_cache_statements depends on the module.
1672 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1673 func_init_sed_convert_to_cache_statements
1675 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1676 eval "$cache_statements"
1678 if ! $have_associative; then
1679 if test "$1" != "$cached"; then
1680 func_fatal_error "cache variable collision between $1 and $cached"
1688 # func_get_description module
1690 # - local_gnulib_dir from --local-dir
1691 # - modcache true or false, from --cache-modules/--no-cache-modules
1692 func_get_description ()
1694 if ! $modcache; then
1695 func_lookup_file "modules/$1"
1696 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1698 func_cache_lookup_module "$1"
1699 # Output the field's value, including the final newline (if any).
1700 if $have_associative; then
1701 if test -n "${modcache_description[$1]+set}"; then
1702 echo "${modcache_description[$1]}"
1705 eval "field_set=\"\$${cachevar}_description_set\""
1706 if test -n "$field_set"; then
1707 eval "field_value=\"\$${cachevar}_description\""
1708 echo "${field_value}"
1714 # func_get_status module
1716 # - local_gnulib_dir from --local-dir
1717 # - modcache true or false, from --cache-modules/--no-cache-modules
1720 if ! $modcache; then
1721 func_lookup_file "modules/$1"
1722 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1724 func_cache_lookup_module "$1"
1725 # Output the field's value, including the final newline (if any).
1726 if $have_associative; then
1727 if test -n "${modcache_status[$1]+set}"; then
1728 echo "${modcache_status[$1]}"
1731 eval "field_set=\"\$${cachevar}_status_set\""
1732 if test -n "$field_set"; then
1733 eval "field_value=\"\$${cachevar}_status\""
1734 echo "${field_value}"
1740 # func_get_notice module
1742 # - local_gnulib_dir from --local-dir
1743 # - modcache true or false, from --cache-modules/--no-cache-modules
1746 if ! $modcache; then
1747 func_lookup_file "modules/$1"
1748 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1750 func_cache_lookup_module "$1"
1751 # Output the field's value, including the final newline (if any).
1752 if $have_associative; then
1753 if test -n "${modcache_notice[$1]+set}"; then
1754 echo "${modcache_notice[$1]}"
1757 eval "field_set=\"\$${cachevar}_notice_set\""
1758 if test -n "$field_set"; then
1759 eval "field_value=\"\$${cachevar}_notice\""
1760 echo "${field_value}"
1766 # func_get_applicability module
1768 # - local_gnulib_dir from --local-dir
1769 # - modcache true or false, from --cache-modules/--no-cache-modules
1770 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1771 func_get_applicability ()
1773 if ! $modcache; then
1774 func_lookup_file "modules/$1"
1775 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1777 func_cache_lookup_module "$1"
1778 # Get the field's value, without the final newline.
1779 if $have_associative; then
1780 my_applicability="${modcache_applicability[$1]}"
1782 eval "my_applicability=\"\$${cachevar}_applicability\""
1785 if test -n "$my_applicability"; then
1786 echo $my_applicability
1788 # The default is 'main' or 'tests', depending on the module's name.
1790 *-tests) echo "tests";;
1796 # func_get_filelist module
1798 # - local_gnulib_dir from --local-dir
1799 # - modcache true or false, from --cache-modules/--no-cache-modules
1800 func_get_filelist ()
1802 if ! $modcache; then
1803 func_lookup_file "modules/$1"
1804 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1806 func_cache_lookup_module "$1"
1807 # Output the field's value, including the final newline (if any).
1808 if $have_associative; then
1809 if test -n "${modcache_files[$1]+set}"; then
1810 echo "${modcache_files[$1]}"
1813 eval "field_set=\"\$${cachevar}_files_set\""
1814 if test -n "$field_set"; then
1815 eval "field_value=\"\$${cachevar}_files\""
1816 echo "${field_value}"
1821 echo m4/gnulib-common.m4
1822 case "$autoconf_minversion" in
1829 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1830 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1831 # elements starting with prefix and ending with suffix are considered.
1832 # Processing: removed_prefix and removed_suffix are removed from each element,
1833 # added_prefix and added_suffix are added to each element.
1834 # prefix, suffix should not contain shell-special characters.
1835 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1836 # added_prefix, added_suffix should not contain the characters \|&.
1837 func_filter_filelist ()
1839 if test "$2" != "$nl" \
1840 || { $fast_func_append \
1841 && { test -z "$6" || $fast_func_remove_prefix; } \
1842 && { test -z "$7" || $fast_func_remove_suffix; }; \
1846 # Do not quote possibly-empty parameters in case patterns,
1847 # AIX and HP-UX ksh won't match them if they are empty.
1850 if test -n "$6"; then
1851 func_remove_prefix fff "$6"
1853 if test -n "$7"; then
1854 func_remove_suffix fff "$7"
1857 if test -z "$ffflist"; then
1860 func_append ffflist "$2${fff}"
1866 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1867 ffflist=`for fff in $3; do
1869 $4*$5) echo "$fff" ;;
1871 done | sed -e "$sed_fff_filter"`
1873 eval "$1=\"\$ffflist\""
1876 # func_get_dependencies module
1878 # - local_gnulib_dir from --local-dir
1879 # - modcache true or false, from --cache-modules/--no-cache-modules
1880 func_get_dependencies ()
1882 # ${module}-tests always implicitly depends on ${module}.
1886 func_remove_suffix fgd1 '-tests'
1890 # Then the explicit dependencies listed in the module description.
1891 if ! $modcache; then
1892 func_lookup_file "modules/$1"
1893 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1895 func_cache_lookup_module "$1"
1896 # Output the field's value, including the final newline (if any).
1897 if $have_associative; then
1898 if test -n "${modcache_dependson[$1]+set}"; then
1899 echo "${modcache_dependson[$1]}"
1902 eval "field_set=\"\$${cachevar}_dependson_set\""
1903 if test -n "$field_set"; then
1904 eval "field_value=\"\$${cachevar}_dependson\""
1905 echo "${field_value}"
1911 # func_get_autoconf_early_snippet module
1913 # - local_gnulib_dir from --local-dir
1914 # - modcache true or false, from --cache-modules/--no-cache-modules
1915 func_get_autoconf_early_snippet ()
1917 if ! $modcache; then
1918 func_lookup_file "modules/$1"
1919 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1921 func_cache_lookup_module "$1"
1922 # Output the field's value, including the final newline (if any).
1923 if $have_associative; then
1924 if test -n "${modcache_configureac_early[$1]+set}"; then
1925 echo "${modcache_configureac_early[$1]}"
1928 eval "field_set=\"\$${cachevar}_configureac_early_set\""
1929 if test -n "$field_set"; then
1930 eval "field_value=\"\$${cachevar}_configureac_early\""
1931 echo "${field_value}"
1937 # func_get_autoconf_snippet module
1939 # - local_gnulib_dir from --local-dir
1940 # - modcache true or false, from --cache-modules/--no-cache-modules
1941 func_get_autoconf_snippet ()
1943 if ! $modcache; then
1944 func_lookup_file "modules/$1"
1945 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1947 func_cache_lookup_module "$1"
1948 # Output the field's value, including the final newline (if any).
1949 if $have_associative; then
1950 if test -n "${modcache_configureac[$1]+set}"; then
1951 echo "${modcache_configureac[$1]}"
1954 eval "field_set=\"\$${cachevar}_configureac_set\""
1955 if test -n "$field_set"; then
1956 eval "field_value=\"\$${cachevar}_configureac\""
1957 echo "${field_value}"
1963 # func_get_automake_snippet module
1965 # - local_gnulib_dir from --local-dir
1966 # - modcache true or false, from --cache-modules/--no-cache-modules
1967 func_get_automake_snippet ()
1969 if ! $modcache; then
1970 func_lookup_file "modules/$1"
1971 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1973 func_cache_lookup_module "$1"
1974 # Output the field's value, including the final newline (if any).
1975 if $have_associative; then
1976 if test -n "${modcache_makefile[$1]+set}"; then
1977 echo "${modcache_makefile[$1]}"
1980 eval "field_set=\"\$${cachevar}_makefile_set\""
1981 if test -n "$field_set"; then
1982 eval "field_value=\"\$${cachevar}_makefile\""
1983 echo "${field_value}"
1989 # *-tests module live in tests/, not lib/.
1990 # Synthesize an EXTRA_DIST augmentation.
1991 all_files=`func_get_filelist $1`
1992 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1993 extra_files="$tests_files"
1994 if test -n "$extra_files"; then
1995 echo "EXTRA_DIST +=" $extra_files
2000 # Synthesize an EXTRA_DIST augmentation.
2001 sed_combine_lines='/\\$/{
2008 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2009 already_mentioned_files=` \
2010 { if ! $modcache; then
2011 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2013 if $have_associative; then
2014 if test -n "${modcache_makefile[$1]+set}"; then
2015 echo "${modcache_makefile[$1]}"
2018 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2019 if test -n "$field_set"; then
2020 eval 'field_value="$'"${cachevar}"'_makefile"'
2021 echo "${field_value}"
2026 | sed -e "$sed_combine_lines" \
2027 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2028 all_files=`func_get_filelist $1`
2029 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2030 # Remove $already_mentioned_files from $lib_files.
2031 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2032 extra_files=`func_reset_sigpipe; \
2033 for f in $already_mentioned_files; do echo $f; done \
2034 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2035 if test -n "$extra_files"; then
2036 echo "EXTRA_DIST +=" $extra_files
2039 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2040 # This is necessary so that automake can generate the right list of
2042 # A possible approach would be to use autom4te --trace of the redefined
2043 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2044 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2045 # inside autoconf's built-in macros are not missed).
2046 # But it's simpler and more robust to do it here, based on the file list.
2047 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2048 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2049 # automake will generate a useless dependency; this is harmless.
2051 relocatable-prog-wrapper) ;;
2053 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2054 if test -n "$extra_files"; then
2055 echo "EXTRA_lib_SOURCES +=" $extra_files
2060 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2061 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2062 if test -n "$buildaux_files"; then
2063 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2064 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2067 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2068 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2069 if test -n "$top_files"; then
2070 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2071 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2078 # func_get_include_directive module
2080 # - local_gnulib_dir from --local-dir
2081 # - modcache true or false, from --cache-modules/--no-cache-modules
2082 func_get_include_directive ()
2085 if ! $modcache; then
2086 func_lookup_file "modules/$1"
2087 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2089 func_cache_lookup_module "$1"
2090 # Output the field's value, including the final newline (if any).
2091 if $have_associative; then
2092 if test -n "${modcache_include[$1]+set}"; then
2093 echo "${modcache_include[$1]}"
2096 eval "field_set=\"\$${cachevar}_include_set\""
2097 if test -n "$field_set"; then
2098 eval "field_value=\"\$${cachevar}_include\""
2099 echo "${field_value}"
2103 } | sed -e 's/^\(["<]\)/#include \1/'
2106 # func_get_link_directive module
2108 # - local_gnulib_dir from --local-dir
2109 # - modcache true or false, from --cache-modules/--no-cache-modules
2110 func_get_link_directive ()
2112 if ! $modcache; then
2113 func_lookup_file "modules/$1"
2114 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2116 func_cache_lookup_module "$1"
2117 # Output the field's value, including the final newline (if any).
2118 if $have_associative; then
2119 if test -n "${modcache_link[$1]+set}"; then
2120 echo "${modcache_link[$1]}"
2123 eval "field_set=\"\$${cachevar}_link_set\""
2124 if test -n "$field_set"; then
2125 eval "field_value=\"\$${cachevar}_link\""
2126 echo "${field_value}"
2132 # func_get_license module
2134 # - local_gnulib_dir from --local-dir
2135 # - modcache true or false, from --cache-modules/--no-cache-modules
2139 if ! $modcache; then
2140 func_lookup_file "modules/$1"
2141 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2143 func_cache_lookup_module "$1"
2144 # Output the field's value, including the final newline (if any).
2145 if $have_associative; then
2146 if test -n "${modcache_license[$1]+set}"; then
2147 echo "${modcache_license[$1]}"
2150 eval "field_set=\"\$${cachevar}_license_set\""
2151 if test -n "$field_set"; then
2152 eval "field_value=\"\$${cachevar}_license\""
2153 echo "${field_value}"
2157 # The default is GPL.
2159 } | sed -e 's,^ *$,,' | sed -e 1q
2162 # func_get_maintainer module
2164 # - local_gnulib_dir from --local-dir
2165 # - modcache true or false, from --cache-modules/--no-cache-modules
2166 func_get_maintainer ()
2168 if ! $modcache; then
2169 func_lookup_file "modules/$1"
2170 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2172 func_cache_lookup_module "$1"
2173 # Output the field's value, including the final newline (if any).
2174 if $have_associative; then
2175 if test -n "${modcache_maintainer[$1]+set}"; then
2176 echo "${modcache_maintainer[$1]}"
2179 eval "field_set=\"\$${cachevar}_maintainer_set\""
2180 if test -n "$field_set"; then
2181 eval "field_value=\"\$${cachevar}_maintainer\""
2182 echo "${field_value}"
2188 # func_get_tests_module module
2190 # - local_gnulib_dir from --local-dir
2191 func_get_tests_module ()
2193 # The naming convention for tests modules is hardwired: ${module}-tests.
2194 if test -f "$gnulib_dir/modules/$1"-tests \
2195 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2196 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2201 # func_acceptable module
2202 # tests whether a module is acceptable.
2204 # - avoidlist list of modules to avoid
2207 for avoid in $avoidlist; do
2208 if test "$avoid" = "$1"; then
2215 # func_modules_transitive_closure
2217 # - local_gnulib_dir from --local-dir
2218 # - modcache true or false, from --cache-modules/--no-cache-modules
2219 # - modules list of specified modules
2220 # - inctests true if tests should be included, blank otherwise
2221 # - incobsolete true if obsolete modules among dependencies should be
2222 # included, blank otherwise
2223 # - avoidlist list of modules to avoid
2224 # - tmp pathname of a temporary directory
2226 # - modules list of modules, including dependencies
2227 func_modules_transitive_closure ()
2229 # In order to process every module only once (for speed), process an "input
2230 # list" of modules, producing an "output list" of modules. During each round,
2231 # more modules can be queued in the input list. Once a module on the input
2232 # list has been processed, it is added to the "handled list", so we can avoid
2233 # to process it again.
2235 inmodules="$modules"
2237 while test -n "$inmodules"; do
2238 inmodules_this_round="$inmodules"
2239 inmodules= # Accumulator, queue for next round
2240 for module in $inmodules_this_round; do
2242 if test -n "$module"; then
2243 if func_acceptable $module; then
2244 func_append outmodules " $module"
2245 deps=`func_get_dependencies $module`
2246 # Duplicate dependencies are harmless, but Jim wants a warning.
2247 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2248 if test -n "$duplicated_deps"; then
2249 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2251 for dep in $deps; do
2252 if test -n "$incobsolete" \
2253 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
2254 func_append inmodules " $dep"
2257 if test -n "$inctests"; then
2258 testsmodule=`func_get_tests_module $module`
2259 if test -n "$testsmodule"; then
2260 func_append inmodules " $testsmodule"
2266 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2267 # Remove $handledmodules from $inmodules.
2268 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2269 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2271 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2272 rm -f "$tmp"/queued-modules
2275 # func_modules_add_dummy
2277 # - local_gnulib_dir from --local-dir
2278 # - modcache true or false, from --cache-modules/--no-cache-modules
2279 # - modules list of modules, including dependencies
2281 # - modules list of modules, including 'dummy' if needed
2282 func_modules_add_dummy ()
2284 # Determine whether any module provides a lib_SOURCES augmentation.
2286 sed_remove_backslash_newline=':a
2293 for module in $modules; do
2294 func_verify_nontests_module
2295 if test -n "$module"; then
2296 # Extract the value of "lib_SOURCES += ...".
2297 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2298 # Ignore .h files since they are not compiled.
2302 have_lib_SOURCES=yes
2309 # Add the dummy module, to make sure the library will be non-empty.
2310 if test -z "$have_lib_SOURCES"; then
2311 if func_acceptable "dummy"; then
2312 func_append modules " dummy"
2317 # func_modules_notice
2319 # - local_gnulib_dir from --local-dir
2320 # - modcache true or false, from --cache-modules/--no-cache-modules
2321 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2322 # - modules list of modules, including dependencies
2323 func_modules_notice ()
2325 if test $verbose -ge -1; then
2326 for module in $modules; do
2328 if test -n "$module"; then
2329 msg=`func_get_notice $module`
2330 if test -n "$msg"; then
2331 echo "Notice from module $module:"
2332 echo "$msg" | sed -e 's/^/ /'
2339 # func_modules_to_filelist
2341 # - local_gnulib_dir from --local-dir
2342 # - modcache true or false, from --cache-modules/--no-cache-modules
2343 # - modules list of modules, including dependencies
2345 # - files list of files
2346 func_modules_to_filelist ()
2349 for module in $modules; do
2351 if test -n "$module"; then
2352 fs=`func_get_filelist $module`
2353 func_append files " $fs"
2356 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2359 # func_execute_command command [args...]
2360 # Executes a command.
2361 # Uses also the variables
2362 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2363 func_execute_command ()
2365 if test $verbose -ge 0; then
2369 # Commands like automake produce output to stderr even when they succeed.
2370 # Turn this output off if the command succeeds.
2371 "$@" > "$tmp"/cmdout 2>&1
2373 if test $cmdret = 0; then
2377 cat "$tmp"/cmdout 1>&2
2384 # func_dest_tmpfilename file
2385 # determines the name of a temporary file (file is relative to destdir).
2387 # - destdir target directory
2388 # - doit : if actions shall be executed, false if only to be printed
2389 # - tmp pathname of a temporary directory
2391 # - tmpfile absolute filename of the temporary file
2392 func_dest_tmpfilename ()
2395 # Put the new contents of $file in a file in the same directory (needed
2396 # to guarantee that an 'mv' to "$destdir/$file" works).
2397 tmpfile="$destdir/$1.tmp"
2399 # Put the new contents of $file in a file in a temporary directory
2400 # (because the directory of "$file" might not exist).
2401 tmpfile="$tmp"/`basename "$1"`.tmp
2406 # copies a file from gnulib into the destination directory. The destination
2407 # is known to not exist.
2409 # - destdir target directory
2410 # - local_gnulib_dir from --local-dir
2411 # - modcache true or false, from --cache-modules/--no-cache-modules
2412 # - f the original file name
2413 # - lookedup_file name of the merged (combined) file
2414 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2415 # - g the rewritten file name
2416 # - tmpfile absolute filename of the temporary file
2417 # - doit : if actions shall be executed, false if only to be printed
2418 # - symbolic true if files should be symlinked, copied otherwise
2419 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2424 echo "Copying file $g"
2425 if { test -n "$symbolic" \
2426 || { test -n "$lsymbolic" \
2427 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2428 && test -z "$lookedup_tmp" \
2429 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2430 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2432 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2440 # copies a file from gnulib into the destination directory. The destination
2441 # is known to exist.
2443 # - destdir target directory
2444 # - local_gnulib_dir from --local-dir
2445 # - modcache true or false, from --cache-modules/--no-cache-modules
2446 # - f the original file name
2447 # - lookedup_file name of the merged (combined) file
2448 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2449 # - g the rewritten file name
2450 # - tmpfile absolute filename of the temporary file
2451 # - doit : if actions shall be executed, false if only to be printed
2452 # - symbolic true if files should be symlinked, copied otherwise
2453 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2455 # - already_present nonempty if the file should already exist, empty otherwise
2458 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2459 : # The file has not changed.
2463 if test -n "$already_present"; then
2464 echo "Updating file $g (backup in ${g}~)"
2466 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2468 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2469 if { test -n "$symbolic" \
2470 || { test -n "$lsymbolic" \
2471 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2472 && test -z "$lookedup_tmp" \
2473 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2474 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2476 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2479 if test -n "$already_present"; then
2480 echo "Update file $g (backup in ${g}~)"
2482 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2488 # func_emit_lib_Makefile_am
2489 # emits the contents of library makefile to standard output.
2491 # - local_gnulib_dir from --local-dir
2492 # - modcache true or false, from --cache-modules/--no-cache-modules
2493 # - modules list of modules, including dependencies
2494 # - libname library name
2495 # - pobase directory relative to destdir where to place *.po files
2496 # - auxdir directory relative to destdir where to place build aux files
2497 # - makefile_name from --makefile-name
2498 # - libtool true if libtool will be used, false or blank otherwise
2499 # - macro_prefix prefix of gl_LIBOBJS macros to use
2500 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2501 # - actioncmd (optional) command that will reproduce this invocation
2502 # - for_test true if creating a package for testing, false otherwise
2503 # - destfile filename relative to destdir of makefile being generated
2505 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2506 # list of edits to be done to Makefile.am variables
2508 # - uses_subdirs nonempty if object files in subdirs exist
2509 func_emit_lib_Makefile_am ()
2511 # When creating an includable Makefile.am snippet, augment variables with
2512 # += instead of assigning them.
2513 if test -n "$makefile_name"; then
2518 if test "$libtool" = true; then
2521 sed_eliminate_LDFLAGS="$sed_noop"
2525 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2528 # When creating a package for testing: Attempt to provoke failures,
2529 # especially link errors, already during "make" rather than during
2530 # "make check", because "make check" is not possible in a cross-compiling
2531 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2532 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2534 sed_transform_check_PROGRAMS="$sed_noop"
2536 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2537 echo "## Process this file with automake to produce Makefile.in."
2538 func_emit_copyright_notice
2539 if test -n "$actioncmd"; then
2540 # The maximum line length (excluding the terminating newline) of any file
2541 # that is to be preprocessed by config.status is 3070. config.status uses
2542 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2543 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2544 len=`echo "$actioncmd" | wc -c`
2545 if test -n "$len" && test "$len" -le 3000; then
2546 echo "# Reproduce by: $actioncmd"
2552 for module in $modules; do
2553 func_verify_nontests_module
2554 if test -n "$module"; then
2556 func_get_automake_snippet "$module" |
2557 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2558 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2559 -e "$sed_eliminate_LDFLAGS" \
2560 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2561 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2562 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2563 -e "$sed_transform_check_PROGRAMS"
2564 if test "$module" = 'alloca'; then
2565 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2566 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2568 } > "$tmp"/amsnippet
2569 # Skip the contents if it's entirely empty.
2570 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2571 echo "## begin gnulib module $module"
2573 cat "$tmp"/amsnippet
2574 echo "## end gnulib module $module"
2577 rm -f "$tmp"/amsnippet
2578 # Test whether there are some source files in subdirectories.
2579 for f in `func_get_filelist "$module"`; do
2589 } > "$tmp"/allsnippets
2590 if test -z "$makefile_name"; then
2591 # If there are source files in subdirectories, prevent collision of the
2592 # object files (example: hash.c and libxml/hash.c).
2594 if test -n "$uses_subdirs"; then
2595 subdir_options=' subdir-objects'
2597 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2600 if test -z "$makefile_name"; then
2602 echo "noinst_HEADERS ="
2603 echo "noinst_LIBRARIES ="
2604 echo "noinst_LTLIBRARIES ="
2605 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2606 # if you specify pkgdata_DATA to empty. This is a workaround.
2607 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2608 echo "pkgdata_DATA ="
2611 echo "BUILT_SOURCES ="
2614 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2615 if test -z "$makefile_name"; then
2616 echo "MOSTLYCLEANDIRS ="
2618 echo "DISTCLEANFILES ="
2619 echo "MAINTAINERCLEANFILES ="
2621 # Execute edits that apply to the Makefile.am being generated.
2623 while test $edit != $makefile_am_edits; do
2624 edit=`expr $edit + 1`
2625 eval dir=\"\$makefile_am_edit${edit}_dir\"
2626 eval var=\"\$makefile_am_edit${edit}_var\"
2627 eval val=\"\$makefile_am_edit${edit}_val\"
2628 if test -n "$var"; then
2629 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2630 echo "${var} += ${val}"
2631 eval "makefile_am_edit${edit}_var="
2635 if test -z "$makefile_name"; then
2637 echo "AM_CPPFLAGS ="
2641 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2642 || { test -n "$makefile_name" \
2643 && test -f "$sourcebase/Makefile.am" \
2644 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2646 # One of the snippets or the user's Makefile.am already specifies an
2647 # installation location for the library. Don't confuse automake by saying
2648 # it should not be installed.
2651 # By default, the generated library should not be installed.
2652 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2655 echo "${libname}_${libext}_SOURCES ="
2656 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2657 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2658 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2659 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2660 echo "EXTRA_${libname}_${libext}_SOURCES ="
2661 if test "$libtool" = true; then
2662 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2665 if test -n "$pobase"; then
2666 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2669 cat "$tmp"/allsnippets \
2670 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2672 echo "mostlyclean-local: mostlyclean-generic"
2673 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2674 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2675 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2679 rm -f "$tmp"/allsnippets
2682 # func_emit_po_Makevars
2683 # emits the contents of po/ makefile parameterization to standard output.
2685 # - local_gnulib_dir from --local-dir
2686 # - modcache true or false, from --cache-modules/--no-cache-modules
2687 # - sourcebase directory relative to destdir where to place source code
2688 # - pobase directory relative to destdir where to place *.po files
2689 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2690 func_emit_po_Makevars ()
2692 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2693 func_emit_copyright_notice
2695 echo "# Usually the message domain is the same as the package name."
2696 echo "# But here it has a '-gnulib' suffix."
2697 echo "DOMAIN = ${po_domain}-gnulib"
2699 echo "# These two variables depend on the location of this directory."
2700 echo "subdir = ${pobase}"
2701 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2704 # These options get passed to xgettext.
2705 XGETTEXT_OPTIONS = \
2706 --keyword=_ --flag=_:1:pass-c-format \
2707 --keyword=N_ --flag=N_:1:pass-c-format \
2708 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2709 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2710 --flag=error:3:c-format --flag=error_at_line:5:c-format
2712 # This is the copyright holder that gets inserted into the header of the
2713 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2714 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2716 # This is the email address or URL to which the translators shall report
2717 # bugs in the untranslated strings:
2718 # - Strings which are not entire sentences, see the maintainer guidelines
2719 # in the GNU gettext documentation, section 'Preparing Strings'.
2720 # - Strings which use unclear terms or require additional context to be
2722 # - Strings which make invalid assumptions about notation of date, time or
2724 # - Pluralisation problems.
2725 # - Incorrect English spelling.
2726 # - Incorrect formatting.
2727 # It can be your email address, or a mailing list address where translators
2728 # can write to without being subscribed, or the URL of a web page through
2729 # which the translators can contact you.
2730 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2732 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2733 # message catalogs shall be used. It is usually empty.
2734 EXTRA_LOCALE_CATEGORIES =
2736 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2737 # context. Possible values are "yes" and "no". Set this to yes if the
2738 # package uses functions taking also a message context, like pgettext(), or
2739 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2744 # func_emit_po_POTFILES_in
2745 # emits the file list to be passed to xgettext to standard output.
2747 # - local_gnulib_dir from --local-dir
2748 # - modcache true or false, from --cache-modules/--no-cache-modules
2749 # - sourcebase directory relative to destdir where to place source code
2750 # - files list of new files
2751 func_emit_po_POTFILES_in ()
2753 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2754 func_emit_copyright_notice
2756 echo "# List of files which contain translatable strings."
2757 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2760 # func_emit_tests_Makefile_am
2761 # emits the contents of tests makefile to standard output.
2763 # - local_gnulib_dir from --local-dir
2764 # - modcache true or false, from --cache-modules/--no-cache-modules
2765 # - modules list of modules, including dependencies
2766 # - libname library name
2767 # - auxdir directory relative to destdir where to place build aux files
2768 # - makefile_name from --makefile-name
2769 # - libtool true if libtool will be used, false or blank otherwise
2770 # - sourcebase relative directory containing lib source code
2771 # - m4base relative directory containing autoconf macros
2772 # - testsbase relative directory containing unit test code
2773 # - macro_prefix prefix of gl_LIBOBJS macros to use
2774 # - for_test true if creating a package for testing, false otherwise
2775 # - use_libtests true if a libtests.a should be built, false otherwise
2776 # - destfile filename relative to destdir of makefile being generated
2778 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2779 # list of edits to be done to Makefile.am variables
2781 # - uses_subdirs nonempty if object files in subdirs exist
2782 func_emit_tests_Makefile_am ()
2784 if test "$libtool" = true; then
2786 sed_eliminate_LDFLAGS="$sed_noop"
2789 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2792 # When creating a package for testing: Attempt to provoke failures,
2793 # especially link errors, already during "make" rather than during
2794 # "make check", because "make check" is not possible in a cross-compiling
2795 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2796 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2798 sed_transform_check_PROGRAMS="$sed_noop"
2800 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2801 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2802 echo "## Process this file with automake to produce Makefile.in."
2803 func_emit_copyright_notice
2807 for module in $modules; do
2809 func_verify_tests_module
2813 if test -n "$module"; then
2815 func_get_automake_snippet "$module" |
2816 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2817 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2818 -e "$sed_eliminate_LDFLAGS" \
2819 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2820 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2821 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2822 -e "$sed_transform_check_PROGRAMS"
2823 if $use_libtests && test "$module" = 'alloca'; then
2824 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2825 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2827 } > "$tmp"/amsnippet
2828 # Skip the contents if it's entirely empty.
2829 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2830 echo "## begin gnulib module $module"
2832 cat "$tmp"/amsnippet
2833 echo "## end gnulib module $module"
2836 rm -f "$tmp"/amsnippet
2837 # Test whether there are some source files in subdirectories.
2838 for f in `func_get_filelist "$module"`; do
2840 lib/*/*.c | tests/*/*.c)
2848 } > "$tmp"/allsnippets
2849 # Generate dependencies here, since it eases the debugging of test failures.
2850 # If there are source files in subdirectories, prevent collision of the
2851 # object files (example: hash.c and libxml/hash.c).
2853 if test -n "$uses_subdirs"; then
2854 subdir_options=' subdir-objects'
2856 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2859 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2862 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2863 # variable is needed to avoid an error from automake:
2864 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2867 echo "XFAIL_TESTS ="
2868 echo "TESTS_ENVIRONMENT ="
2869 echo "noinst_PROGRAMS ="
2870 if ! $for_test; then
2871 echo "check_PROGRAMS ="
2873 echo "noinst_HEADERS ="
2874 echo "noinst_LIBRARIES ="
2875 if $use_libtests; then
2877 echo "noinst_LIBRARIES += libtests.a"
2879 echo "check_LIBRARIES = libtests.a"
2882 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2883 # if you specify pkgdata_DATA to empty. This is a workaround.
2884 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2885 echo "pkgdata_DATA ="
2888 echo "BUILT_SOURCES ="
2890 echo "MOSTLYCLEANFILES = core *.stackdump"
2891 echo "MOSTLYCLEANDIRS ="
2893 echo "DISTCLEANFILES ="
2894 echo "MAINTAINERCLEANFILES ="
2895 # Execute edits that apply to the Makefile.am being generated.
2897 while test $edit != $makefile_am_edits; do
2898 edit=`expr $edit + 1`
2899 eval dir=\"\$makefile_am_edit${edit}_dir\"
2900 eval var=\"\$makefile_am_edit${edit}_var\"
2901 eval val=\"\$makefile_am_edit${edit}_val\"
2902 if test -n "$var"; then
2903 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2904 echo "${var} += ${val}"
2905 eval "makefile_am_edit${edit}_var="
2910 echo "AM_CPPFLAGS = \\"
2911 echo " -I. -I\$(srcdir) \\"
2912 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2913 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2915 local_ldadd_before=''
2916 local_ldadd_after=''
2917 if $use_libtests; then
2918 # All test programs need to be linked with libtests.a.
2919 # It needs to be passed to the linker before ${libname}.${libext}, since
2920 # the tests-related modules depend on the main modules.
2921 # It also needs to be passed to the linker after ${libname}.${libext}
2922 # because the latter might contain incomplete modules (such as the 'error'
2923 # module whose dependency to 'progname' is voluntarily omitted).
2924 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2926 local_ldadd_before=' libtests.a'
2927 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2929 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2931 if $use_libtests; then
2932 echo "libtests_a_SOURCES ="
2933 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2934 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2935 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2936 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2937 echo "EXTRA_libtests_a_SOURCES ="
2938 # The circular dependency in LDADD requires this.
2939 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2942 # Many test scripts use ${EXEEXT} or ${srcdir}.
2943 # EXEEXT is defined by AC_PROG_CC through autoconf.
2944 # srcdir is defined by autoconf and automake.
2945 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
2947 cat "$tmp"/allsnippets \
2948 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2949 echo "# Clean up after Solaris cc."
2951 echo " rm -rf SunWS_cache"
2953 echo "mostlyclean-local: mostlyclean-generic"
2954 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2955 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2956 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2960 rm -f "$tmp"/allsnippets
2963 # func_emit_initmacro_start macro_prefix
2964 # emits the first few statements of the gl_INIT macro to standard output.
2965 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2966 func_emit_initmacro_start ()
2968 macro_prefix_arg="$1"
2969 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2970 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2971 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2972 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2974 # Furthermore it avoids an automake error like this when a Makefile.am
2975 # that uses pieces of gnulib also uses $(LIBOBJ):
2976 # automatically discovered file `error.c' should not be explicitly mentioned
2977 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2978 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2979 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2980 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2981 # automatically discovered file `error.c' should not be explicitly mentioned
2982 # We let automake know about the files to be distributed through the
2983 # EXTRA_lib_SOURCES variable.
2984 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2985 # Create data variables for checking the presence of files that are mentioned
2986 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2987 # because we want the check to happen when the configure file is created,
2988 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2989 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2990 # in which to expect them.
2991 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2992 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2996 # func_emit_initmacro_end macro_prefix
2997 # emits the last few statements of the gl_INIT macro to standard output.
2998 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2999 func_emit_initmacro_end ()
3001 macro_prefix_arg="$1"
3002 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3003 # The check is performed only when autoconf is run from the directory where
3004 # the configure.ac resides; if it is run from a different directory, the
3006 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3007 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3008 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3009 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3010 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3014 echo " m4_if(m4_sysval, [0], [],"
3015 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3017 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3018 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3019 echo " m4_popdef([AC_LIBSOURCES])"
3020 echo " m4_popdef([AC_REPLACE_FUNCS])"
3021 echo " m4_popdef([AC_LIBOBJ])"
3022 echo " AC_CONFIG_COMMANDS_PRE(["
3023 echo " ${macro_prefix_arg}_libobjs="
3024 echo " ${macro_prefix_arg}_ltlibobjs="
3025 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3026 echo " # Remove the extension."
3027 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3028 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3029 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3030 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3033 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3034 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3038 # func_emit_initmacro_done macro_prefix sourcebase
3039 # emits a few statements after the gl_INIT macro to standard output.
3040 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3041 # - sourcebase directory relative to destdir where to place source code
3042 func_emit_initmacro_done ()
3044 macro_prefix_arg="$1"
3047 echo "# Like AC_LIBOBJ, except that the module name goes"
3048 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3049 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3050 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3051 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3054 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3055 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3056 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3057 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3058 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3061 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3062 echo "# expected is derived from the gnulib-tool parameterization,"
3063 echo "# and alloca is special cased (for the alloca-opt module)."
3064 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3065 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3066 echo " m4_foreach([_gl_NAME], [\$1], ["
3067 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3068 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3069 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3075 # func_import modules
3076 # Uses also the variables
3077 # - destdir target directory
3078 # - local_gnulib_dir from --local-dir
3079 # - modcache true or false, from --cache-modules/--no-cache-modules
3080 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3081 # - libname library name
3082 # - sourcebase directory relative to destdir where to place source code
3083 # - m4base directory relative to destdir where to place *.m4 macros
3084 # - pobase directory relative to destdir where to place *.po files
3085 # - docbase directory relative to destdir where to place doc files
3086 # - testsbase directory relative to destdir where to place unit test code
3087 # - auxdir directory relative to destdir where to place build aux files
3088 # - inctests true if --with-tests was given, blank otherwise
3089 # - incobsolete true if --with-obsolete was given, blank otherwise
3090 # - avoidlist list of modules to avoid, from --avoid
3091 # - lgpl yes or a number if library's license shall be LGPL,
3093 # - makefile_name from --makefile-name
3094 # - libtool true if --libtool was given, false if --no-libtool was
3095 # given, blank otherwise
3096 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3097 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3098 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3099 # - vc_files true if --vc-files was given, false if --no-vc-files was
3100 # given, blank otherwise
3101 # - autoconf_minversion minimum supported autoconf version
3102 # - doit : if actions shall be executed, false if only to be printed
3103 # - symbolic true if files should be symlinked, copied otherwise
3104 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3106 # - do_copyrights true if copyright notices in files should be replaced,
3110 # Get the cached settings.
3111 cached_local_gnulib_dir=
3112 cached_specified_modules=
3123 cached_makefile_name=
3125 cached_macro_prefix=
3129 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3130 cached_libtool=false
3136 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3146 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3148 /gl_WITH_OBSOLETE/ {
3149 s,^.*$,cached_incobsolete=true,p
3152 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3155 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3158 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3161 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3164 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3167 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3170 s,^.*$,cached_inctests=true,p
3173 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3176 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3179 s,^.*$,cached_lgpl=yes,p
3181 /gl_MAKEFILE_NAME(/ {
3182 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3185 s,^.*$,cached_libtool=true,p
3187 /gl_MACRO_PREFIX(/ {
3188 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3191 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3194 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3196 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3197 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3202 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3203 s,^.*$,cached_files=",p
3216 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3220 # Merge the cached settings with the specified ones.
3221 # The m4base must be the same as expected from the pathname.
3222 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3223 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3225 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3226 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3227 if test -z "$local_gnulib_dir"; then
3228 if test -n "$cached_local_gnulib_dir"; then
3231 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3233 case "$cached_local_gnulib_dir" in
3235 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3237 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3238 local_gnulib_dir="$relconcat" ;;
3243 # Append the cached and the specified module names. So that
3244 # "gnulib-tool --import foo" means to add the module foo.
3245 specified_modules="$cached_specified_modules $1"
3246 # Included obsolete modules among the dependencies if specified either way.
3247 if test -z "$incobsolete"; then
3248 incobsolete="$cached_incobsolete"
3250 # Append the cached and the specified avoidlist. This is probably better
3251 # than dropping the cached one when --avoid is specified at least once.
3252 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3253 avoidlist=`echo $avoidlist`
3255 # The sourcebase defaults to the cached one.
3256 if test -z "$sourcebase"; then
3257 sourcebase="$cached_sourcebase"
3258 if test -z "$sourcebase"; then
3259 func_fatal_error "missing --source-base option"
3262 # The pobase defaults to the cached one.
3263 if test -z "$pobase"; then
3264 pobase="$cached_pobase"
3266 # The docbase defaults to the cached one.
3267 if test -z "$docbase"; then
3268 docbase="$cached_docbase"
3269 if test -z "$docbase"; then
3270 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."
3273 # The testsbase defaults to the cached one.
3274 if test -z "$testsbase"; then
3275 testsbase="$cached_testsbase"
3276 if test -z "$testsbase"; then
3277 func_fatal_error "missing --tests-base option"
3280 # Require the tests if specified either way.
3281 if test -z "$inctests"; then
3282 inctests="$cached_inctests"
3284 # The libname defaults to the cached one.
3285 if test -z "$supplied_libname"; then
3286 libname="$cached_libname"
3287 if test -z "$libname"; then
3288 func_fatal_error "missing --lib option"
3291 # Require LGPL if specified either way.
3292 if test -z "$lgpl"; then
3295 # The makefile_name defaults to the cached one.
3296 if test -z "$makefile_name"; then
3297 makefile_name="$cached_makefile_name"
3299 # Use libtool if specified either way, or if guessed.
3300 if test -z "$libtool"; then
3301 if test -n "$cached_m4base"; then
3302 libtool="$cached_libtool"
3304 libtool="$guessed_libtool"
3307 # The macro_prefix defaults to the cached one.
3308 if test -z "$macro_prefix"; then
3309 macro_prefix="$cached_macro_prefix"
3310 if test -z "$macro_prefix"; then
3311 func_fatal_error "missing --macro-prefix option"
3314 # The po_domain defaults to the cached one.
3315 if test -z "$po_domain"; then
3316 po_domain="$cached_po_domain"
3318 # The vc_files defaults to the cached one.
3319 if test -z "$vc_files"; then
3320 vc_files="$cached_vc_files"
3323 # Canonicalize the list of specified modules.
3324 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3326 # Determine final module list.
3327 modules="$specified_modules"
3328 func_modules_transitive_closure
3329 if test $verbose -ge 0; then
3330 echo "Module list with included dependencies:"
3331 echo "$modules" | sed -e 's/^/ /'
3333 final_modules="$modules"
3335 # Determine main module list and tests-related module list separately.
3336 # The main module list is the transitive closure of the specified modules,
3337 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3338 # is specified, it will consist only of LGPLed source.
3339 # The tests-related module list is the transitive closure of the specified
3340 # modules, including tests modules, minus the main module list excluding
3341 # modules of applicability 'all'. Its lib/* sources (brought in through
3342 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3343 # source, even if --lgpl is specified.
3344 # Determine main module list.
3345 saved_inctests="$inctests"
3347 modules="$specified_modules"
3348 func_modules_transitive_closure
3349 main_modules="$modules"
3350 inctests="$saved_inctests"
3351 if test $verbose -ge 1; then
3352 echo "Main module list:"
3353 echo "$main_modules" | sed -e 's/^/ /'
3355 # Determine tests-related module list.
3356 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3357 testsrelated_modules=`func_reset_sigpipe
3358 for module in $main_modules; do
3359 if test \`func_get_applicability $module\` = main; then
3363 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3364 if test $verbose -ge 1; then
3365 echo "Tests-related module list:"
3366 echo "$testsrelated_modules" | sed -e 's/^/ /'
3369 # Add the dummy module to the main module list if needed.
3370 modules="$main_modules"
3371 func_modules_add_dummy
3372 main_modules="$modules"
3374 # Determine whether a $testsbase/libtests.a is needed.
3376 for module in $testsrelated_modules; do
3377 func_verify_nontests_module
3378 if test -n "$module"; then
3379 all_files=`func_get_filelist $module`
3380 # Test whether some file in $all_files lies in lib/.
3381 for f in $all_files; do
3392 # Add the dummy module to the tests-related module list if needed.
3393 if $use_libtests; then
3394 modules="$testsrelated_modules"
3395 func_modules_add_dummy
3396 testsrelated_modules="$modules"
3399 # If --lgpl, verify that the licenses of modules are compatible.
3400 if test -n "$lgpl"; then
3401 license_incompatibilities=
3402 for module in $main_modules; do
3403 license=`func_get_license $module`
3405 'GPLed build tool') ;;
3406 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3411 LGPL | LGPLv2+ | LGPLv3+) ;;
3412 *) func_append license_incompatibilities "$module $license$nl" ;;
3418 *) func_append license_incompatibilities "$module $license$nl" ;;
3421 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3426 if test -n "$license_incompatibilities"; then
3427 # Format the license incompatibilities as a table.
3428 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3429 s,^\(.................................................[^ ]*\) *, \1 ,'
3430 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3431 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3435 # Show banner notice of every module.
3436 modules="$main_modules"
3439 # Determine script to apply to imported library files.
3440 sed_transform_lib_file=
3441 for module in $main_modules; do
3442 if test $module = config-h; then
3443 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3444 sed_transform_lib_file=$sed_transform_lib_file'
3445 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3450 sed_transform_main_lib_file="$sed_transform_lib_file"
3451 if test -n "$do_copyrights"; then
3452 if test -n "$lgpl"; then
3456 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3457 s/GNU General/GNU Lesser General/g
3461 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3462 s/GNU General/GNU Lesser General/g
3463 s/version [23]\([ ,]\)/version 2.1\1/g
3466 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3470 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3471 s/GNU Lesser General/GNU General/g
3472 s/GNU Library General/GNU General/g
3473 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3478 # Determine script to apply to auxiliary files that go into $auxdir/.
3479 sed_transform_build_aux_file=
3480 if test -n "$do_copyrights"; then
3482 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3483 s/GNU Lesser General/GNU General/g
3484 s/GNU Library General/GNU General/g
3485 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3489 # Determine script to apply to library files that go into $testsbase/.
3490 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3491 if test -n "$do_copyrights"; then
3493 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3494 s/GNU Lesser General/GNU General/g
3495 s/GNU Library General/GNU General/g
3496 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3500 # Determine the final file lists.
3501 # They must be computed separately, because files in lib/* go into
3502 # $sourcebase/ if they are in the main file list but into $testsbase/
3503 # if they are in the tests-related file list. Furthermore lib/dummy.c
3505 # Determine final main file list.
3506 modules="$main_modules"
3507 func_modules_to_filelist
3509 # Determine final tests-related file list.
3510 modules="$testsrelated_modules"
3511 func_modules_to_filelist
3512 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3513 # Merge both file lists.
3514 sed_remove_empty_lines='/^$/d'
3515 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3516 if test $verbose -ge 0; then
3518 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3519 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3523 || func_fatal_error "refusing to do nothing"
3525 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3526 new_files="$files m4/gnulib-tool.m4"
3527 old_files="$cached_files"
3528 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3529 func_append old_files " m4/gnulib-tool.m4"
3532 rewritten='%REWRITTEN%'
3533 sed_rewrite_old_files="\
3534 s,^build-aux/,$rewritten$auxdir/,
3535 s,^doc/,$rewritten$cached_docbase/,
3536 s,^lib/,$rewritten$cached_sourcebase/,
3537 s,^m4/,$rewritten$cached_m4base/,
3538 s,^tests/,$rewritten$cached_testsbase/,
3539 s,^tests=lib/,$rewritten$cached_testsbase/,
3542 sed_rewrite_new_files="\
3543 s,^build-aux/,$rewritten$auxdir/,
3544 s,^doc/,$rewritten$docbase/,
3545 s,^lib/,$rewritten$sourcebase/,
3546 s,^m4/,$rewritten$m4base/,
3547 s,^tests/,$rewritten$testsbase/,
3548 s,^tests=lib/,$rewritten$testsbase/,
3552 # Create directories.
3553 { echo "$sourcebase"
3555 if test -n "$pobase"; then
3558 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3559 if test -n "$docfiles"; then
3562 if test -n "$inctests"; then
3566 for f in $files; do echo $f; done \
3567 | sed -e "$sed_rewrite_new_files" \
3568 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3571 { # Rearrange file descriptors. Needed because "while ... done < ..."
3572 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3573 exec 5<&0 < "$tmp"/dirs
3575 if test ! -d "$destdir/$d"; then
3577 echo "Creating directory $destdir/$d"
3578 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3580 echo "Create directory $destdir/$d"
3587 # Copy files or make symbolic links. Remove obsolete files.
3591 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3592 # representing the files according to the last gnulib-tool invocation.
3593 for f in $old_files; do echo $f; done \
3594 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3597 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3598 # representing the files after this gnulib-tool invocation.
3599 for f in $new_files; do echo $f; done \
3600 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3603 # First the files that are in old-files, but not in new-files:
3604 sed_take_first_column='s,'"$delimiter"'.*,,'
3605 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3606 # Remove the file. Do nothing if the user already removed it.
3607 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3609 echo "Removing file $g (backup in ${g}~)"
3610 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3612 echo "Remove file $g (backup in ${g}~)"
3614 func_append removed_files "$g$nl"
3617 # func_add_or_update handles a file that ought to be present afterwards.
3619 # - f the original file name
3620 # - g the rewritten file name
3621 # - already_present nonempty if the file should already exist, empty
3623 func_add_or_update ()
3627 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3629 func_dest_tmpfilename "$g"
3630 func_lookup_file "$f"
3631 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3632 if test -n "$sed_transform_main_lib_file"; then
3635 sed -e "$sed_transform_main_lib_file" \
3636 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3640 if test -n "$sed_transform_build_aux_file"; then
3643 sed -e "$sed_transform_build_aux_file" \
3644 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3648 if test -n "$sed_transform_testsrelated_lib_file"; then
3651 sed -e "$sed_transform_testsrelated_lib_file" \
3652 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3656 if test -f "$destdir/$g"; then
3657 # The file already exists.
3661 # Don't protest if the file should be there but isn't: it happens
3662 # frequently that developers don't put autogenerated files into CVS.
3664 func_append added_files "$g$nl"
3668 # Then the files that are in new-files, but not in old-files:
3669 sed_take_last_column='s,^.*'"$delimiter"',,'
3671 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3672 | sed -e "$sed_take_last_column" \
3673 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3674 { # Rearrange file descriptors. Needed because "while ... done < ..."
3675 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3676 exec 5<&0 < "$tmp"/added-files
3682 # Then the files that are in new-files and in old-files:
3683 already_present=true
3684 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3685 | sed -e "$sed_take_last_column" \
3686 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3687 { # Rearrange file descriptors. Needed because "while ... done < ..."
3688 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3689 exec 5<&0 < "$tmp"/kept-files
3696 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3697 actioncmd="gnulib-tool --import"
3698 func_append actioncmd " --dir=$destdir"
3699 if test -n "$local_gnulib_dir"; then
3700 func_append actioncmd " --local-dir=$local_gnulib_dir"
3702 func_append actioncmd " --lib=$libname"
3703 func_append actioncmd " --source-base=$sourcebase"
3704 func_append actioncmd " --m4-base=$m4base"
3705 if test -n "$pobase"; then
3706 func_append actioncmd " --po-base=$pobase"
3708 func_append actioncmd " --doc-base=$docbase"
3709 func_append actioncmd " --tests-base=$testsbase"
3710 func_append actioncmd " --aux-dir=$auxdir"
3711 if test -n "$inctests"; then
3712 func_append actioncmd " --with-tests"
3714 if test -n "$incobsolete"; then
3715 func_append actioncmd " --with-obsolete"
3717 for module in $avoidlist; do
3718 func_append actioncmd " --avoid=$module"
3720 if test -n "$lgpl"; then
3721 if test "$lgpl" = yes; then
3722 func_append actioncmd " --lgpl"
3724 func_append actioncmd " --lgpl=$lgpl"
3727 if test -n "$makefile_name"; then
3728 func_append actioncmd " --makefile-name=$makefile_name"
3730 if test "$libtool" = true; then
3731 func_append actioncmd " --libtool"
3733 func_append actioncmd " --no-libtool"
3735 func_append actioncmd " --macro-prefix=$macro_prefix"
3736 if test -n "$po_domain"; then
3737 func_append actioncmd " --po-domain=$po_domain"
3739 if test -n "$vc_files"; then
3740 if test "$vc_files" = true; then
3741 func_append actioncmd " --vc-files"
3743 func_append actioncmd " --no-vc-files"
3746 func_append actioncmd " `echo $specified_modules`"
3748 # Default the makefile name to Makefile.am.
3749 if test -n "$makefile_name"; then
3750 makefile_am=$makefile_name
3752 makefile_am=Makefile.am
3755 # Create normal Makefile.ams.
3758 # Setup list of Makefile.am edits that are to be performed afterwards.
3759 # Some of these edits apply to files that we will generate; others are
3760 # under the responsibility of the developer.
3762 # func_note_Makefile_am_edit dir var value
3763 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3765 func_note_Makefile_am_edit ()
3767 makefile_am_edits=`expr $makefile_am_edits + 1`
3768 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3769 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3770 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3772 if test "$makefile_am" = Makefile.am; then
3773 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3774 sourcebase_base=`basename "$sourcebase"`
3775 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3777 if test -n "$pobase"; then
3778 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3779 pobase_base=`basename "$pobase"`
3780 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3782 if test -n "$inctests"; then
3783 if test "$makefile_am" = Makefile.am; then
3784 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3785 testsbase_base=`basename "$testsbase"`
3786 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3789 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3791 # Find the first parent directory of $m4base that contains or will contain
3793 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3795 sed_butlast='s,[^/][^/]*//*$,,'
3796 dir1="${m4base}/"; dir2=""
3797 while test -n "$dir1" \
3798 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3799 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3800 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3801 || { test -n "$inctests" \
3802 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3803 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3804 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3805 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3807 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3810 # Create library makefile.
3811 func_dest_tmpfilename $sourcebase/$makefile_am
3812 destfile="$sourcebase/$makefile_am"
3813 modules="$main_modules"
3814 func_emit_lib_Makefile_am > "$tmpfile"
3815 if test -f "$destdir"/$sourcebase/$makefile_am; then
3816 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3820 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3821 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3822 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3824 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3830 echo "Creating $sourcebase/$makefile_am"
3831 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3833 echo "Create $sourcebase/$makefile_am"
3836 func_append added_files "$sourcebase/$makefile_am$nl"
3839 # Create po/ directory.
3840 if test -n "$pobase"; then
3841 # Create po makefile and auxiliary files.
3842 for file in Makefile.in.in remove-potcdate.sin; do
3843 func_dest_tmpfilename $pobase/$file
3844 func_lookup_file build-aux/po/$file
3845 cat "$lookedup_file" > "$tmpfile"
3846 if test -f "$destdir"/$pobase/$file; then
3847 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3851 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3852 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3853 mv -f "$tmpfile" "$destdir"/$pobase/$file
3855 echo "Update $pobase/$file (backup in $pobase/$file~)"
3861 echo "Creating $pobase/$file"
3862 mv -f "$tmpfile" "$destdir"/$pobase/$file
3864 echo "Create $pobase/$file"
3867 func_append added_files "$pobase/$file$nl"
3870 # Create po makefile parameterization, part 1.
3871 func_dest_tmpfilename $pobase/Makevars
3872 func_emit_po_Makevars > "$tmpfile"
3873 if test -f "$destdir"/$pobase/Makevars; then
3874 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3878 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3879 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3880 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3882 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3888 echo "Creating $pobase/Makevars"
3889 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3891 echo "Create $pobase/Makevars"
3894 func_append added_files "$pobase/Makevars$nl"
3896 # Create po makefile parameterization, part 2.
3897 func_dest_tmpfilename $pobase/POTFILES.in
3898 func_emit_po_POTFILES_in > "$tmpfile"
3899 if test -f "$destdir"/$pobase/POTFILES.in; then
3900 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3904 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3905 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3906 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3908 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3914 echo "Creating $pobase/POTFILES.in"
3915 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3917 echo "Create $pobase/POTFILES.in"
3920 func_append added_files "$pobase/POTFILES.in$nl"
3923 TP_URL="http://translationproject.org/latest/"
3924 TP_RSYNC_URI="translationproject.org::tp/latest/"
3926 echo "Fetching gnulib PO files from $TP_URL"
3927 (cd "$destdir"/$pobase \
3928 && { # Prefer rsync over wget if it is available, since it consumes
3929 # less network bandwidth, due to compression.
3930 if type rsync 2>/dev/null | grep / > /dev/null; then
3931 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3933 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3938 echo "Fetch gnulib PO files from $TP_URL"
3940 # Create po/LINGUAS.
3942 func_dest_tmpfilename $pobase/LINGUAS
3943 (cd "$destdir"/$pobase \
3944 && { echo '# Set of available languages.'
3945 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3948 if test -f "$destdir"/$pobase/LINGUAS; then
3949 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3952 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3953 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3954 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3957 echo "Creating $pobase/LINGUAS"
3958 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3959 func_append added_files "$pobase/LINGUAS$nl"
3962 if test -f "$destdir"/$pobase/LINGUAS; then
3963 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3965 echo "Create $pobase/LINGUAS"
3970 # Create m4/gnulib-cache.m4.
3971 func_dest_tmpfilename $m4base/gnulib-cache.m4
3973 func_emit_copyright_notice
3975 echo "# This file represents the specification of how gnulib-tool is used."
3976 echo "# It acts as a cache: It is written and read by gnulib-tool."
3977 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3978 echo "# like the configure.ac and various Makefile.am files."
3981 echo "# Specification in the form of a command-line invocation:"
3984 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3985 # Store the local_gnulib_dir relative to destdir.
3986 case "$local_gnulib_dir" in
3988 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3991 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3993 # destdir, local_gnulib_dir are both relative.
3994 func_relativize "$destdir" "$local_gnulib_dir"
3995 relative_local_gnulib_dir="$reldir" ;;
3998 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4000 echo "$specified_modules" | sed -e 's/^/ /g'
4002 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4003 echo "gl_AVOID([$avoidlist])"
4004 echo "gl_SOURCE_BASE([$sourcebase])"
4005 echo "gl_M4_BASE([$m4base])"
4006 echo "gl_PO_BASE([$pobase])"
4007 echo "gl_DOC_BASE([$docbase])"
4008 echo "gl_TESTS_BASE([$testsbase])"
4009 test -z "$inctests" || echo "gl_WITH_TESTS"
4010 echo "gl_LIB([$libname])"
4011 if test -n "$lgpl"; then
4012 if test "$lgpl" = yes; then
4015 echo "gl_LGPL([$lgpl])"
4018 echo "gl_MAKEFILE_NAME([$makefile_name])"
4019 if test "$libtool" = true; then
4022 echo "gl_MACRO_PREFIX([$macro_prefix])"
4023 echo "gl_PO_DOMAIN([$po_domain])"
4024 if test -n "$vc_files"; then
4025 echo "gl_VC_FILES([$vc_files])"
4028 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4029 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4033 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4034 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4035 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4037 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4041 echo "# gnulib-cache.m4 ends here"
4048 echo "Creating $m4base/gnulib-cache.m4"
4049 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4051 echo "Create $m4base/gnulib-cache.m4"
4057 # Create m4/gnulib-comp.m4.
4058 func_dest_tmpfilename $m4base/gnulib-comp.m4
4060 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4061 func_emit_copyright_notice
4063 echo "# This file represents the compiled summary of the specification in"
4064 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4065 echo "# to be invoked from configure.ac."
4066 echo "# In projects using CVS, this file can be treated like other built files."
4069 echo "# This macro should be invoked from $configure_ac, in the section"
4070 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4071 echo "# any checks for libraries, header files, types and library functions."
4072 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4074 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4075 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4076 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4077 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4078 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4079 if test -n "$uses_subdirs"; then
4080 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4082 for module in $final_modules; do
4084 if test -n "$module"; then
4085 func_get_autoconf_early_snippet "$module"
4088 | sed -e '/^$/d;' -e 's/^/ /'
4091 echo "# This macro should be invoked from $configure_ac, in the section"
4092 echo "# \"Check for header files, types and library functions\"."
4093 echo "AC_DEFUN([${macro_prefix}_INIT],"
4095 if test "$libtool" = true; then
4096 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4097 echo " gl_cond_libtool=true"
4099 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4100 echo " gl_cond_libtool=false"
4102 echo " gl_ltlibdeps="
4104 if test "$auxdir" != "build-aux"; then
4105 sed_replace_build_aux='
4107 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4108 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4112 sed_replace_build_aux="$sed_noop"
4114 func_emit_initmacro_start $macro_prefix
4115 echo " gl_source_base='$sourcebase'"
4116 for module in $main_modules; do
4118 if test -n "$module"; then
4119 func_get_autoconf_snippet "$module" \
4120 | sed -e '/^$/d;' -e 's/^/ /' \
4121 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4122 -e "$sed_replace_build_aux"
4123 if test "$module" = 'alloca' && test "$libtool" = true; then
4124 echo 'changequote(,)dnl'
4125 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4126 echo 'changequote([, ])dnl'
4127 echo 'AC_SUBST([LTALLOCA])'
4131 func_emit_initmacro_end $macro_prefix
4132 echo " gltests_libdeps="
4133 echo " gltests_ltlibdeps="
4134 func_emit_initmacro_start ${macro_prefix}tests
4135 echo " gl_source_base='$testsbase'"
4136 for module in $testsrelated_modules; do
4138 if test -n "$module"; then
4139 func_get_autoconf_snippet "$module" \
4140 | sed -e '/^$/d;' -e 's/^/ /' \
4141 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4142 -e "$sed_replace_build_aux" \
4143 -e 's/\$gl_cond_libtool/false/g' \
4144 -e 's/gl_libdeps/gltests_libdeps/g' \
4145 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4148 func_emit_initmacro_end ${macro_prefix}tests
4149 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4150 # created using libtool, because libtool already handles the dependencies.
4151 if test "$libtool" != true; then
4152 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4153 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4154 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4155 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4156 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4158 if $use_libtests; then
4159 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4160 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4163 func_emit_initmacro_done $macro_prefix $sourcebase
4164 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4166 echo "# This macro records the list of files which have been installed by"
4167 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4168 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4169 echo "$files" | sed -e 's,^, ,'
4172 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4173 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4177 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4178 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4179 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4181 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4185 echo "# gnulib-comp.m4 ends here"
4192 echo "Creating $m4base/gnulib-comp.m4"
4193 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4195 echo "Create $m4base/gnulib-comp.m4"
4201 if test -n "$inctests"; then
4202 # Create tests makefile.
4203 func_dest_tmpfilename $testsbase/$makefile_am
4204 destfile="$testsbase/$makefile_am"
4205 modules="$testsrelated_modules"
4206 func_emit_tests_Makefile_am > "$tmpfile"
4207 if test -f "$destdir"/$testsbase/$makefile_am; then
4208 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4212 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4213 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4214 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4216 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4222 echo "Creating $testsbase/$makefile_am"
4223 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4225 echo "Create $testsbase/$makefile_am"
4228 func_append added_files "$testsbase/$makefile_am$nl"
4232 if test "$vc_files" != false; then
4233 # Update the .cvsignore and .gitignore files.
4234 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4235 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4236 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4237 echo "$m4base/|A|gnulib-comp.m4"
4238 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4239 { # Rearrange file descriptors. Needed because "while ... done < ..."
4240 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4241 exec 5<&0 < "$tmp"/fileset-changes
4242 func_update_ignorelist ()
4245 if test "$ignore" = .gitignore; then
4246 # In a .gitignore file, "foo" applies to the current directory and all
4247 # subdirectories, whereas "/foo" applies to the current directory only.
4250 doubly_escaped_anchor='\\/'
4254 doubly_escaped_anchor=''
4256 if test -f "$destdir/$dir$ignore"; then
4257 if test -n "$dir_added" || test -n "$dir_removed"; then
4258 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4260 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4261 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4262 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4263 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4265 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4267 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4268 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4269 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4270 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4271 } > "$tmp"/sed-ignore-removed
4272 { cat "$destdir/$dir$ignore"~
4273 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4274 } | sed -f "$tmp"/sed-ignore-removed \
4275 > "$destdir/$dir$ignore"
4277 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4282 if test -n "$dir_added"; then
4284 echo "Creating $destdir/$dir$ignore"
4286 if test "$ignore" = .cvsignore; then
4288 # Automake generates Makefile rules that create .dirstamp files.
4291 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4292 } > "$destdir/$dir$ignore"
4294 echo "Create $destdir/$dir$ignore"
4304 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4305 func_update_ignorelist .cvsignore
4307 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4308 func_update_ignorelist .gitignore
4315 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4316 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4317 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4318 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4319 if test "$next_dir" != "$last_dir"; then
4320 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4321 last_dir="$next_dir"
4326 A) func_append last_dir_added "$file$nl";;
4327 R) func_append last_dir_removed "$file$nl";;
4330 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4337 echo "You may need to add #include directives for the following .h files."
4338 # Intersect $specified_modules and $main_modules
4339 # (since $specified_modules is not necessarily of subset of $main_modules
4340 # - some may have been skipped through --avoid, and since the elements of
4341 # $main_modules but not in $specified_modules can go away without explicit
4342 # notice - through changes in the module dependencies).
4343 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4344 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4345 # First the #include <...> directives without #ifs, sorted for convenience,
4346 # then the #include "..." directives without #ifs, sorted for convenience,
4347 # then the #include directives that are surrounded by #ifs. Not sorted.
4348 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4349 include_directive=`func_get_include_directive "$module"`
4350 case "$nl$include_directive" in
4352 echo "$include_directive" 1>&5
4355 echo "$include_directive" | grep -v 'include "' 1>&6
4356 echo "$include_directive" | grep 'include "' 1>&7
4359 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4361 LC_ALL=C sort -u "$tmp"/include-angles
4362 LC_ALL=C sort -u "$tmp"/include-quotes
4363 cat "$tmp"/include-if
4364 ) | sed -e '/^$/d' -e 's/^/ /'
4365 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4367 for module in $main_modules; do
4368 func_get_link_directive "$module"
4370 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4371 if test `wc -l < "$tmp"/link` != 0; then
4373 echo "You may need to use the following Makefile variables when linking."
4374 echo "Use them in <program>_LDADD when linking a program, or"
4375 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4381 echo "Don't forget to"
4382 if test "$makefile_am" = Makefile.am; then
4383 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4385 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4387 if test -n "$pobase"; then
4388 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4390 if test -n "$inctests"; then
4391 if test "$makefile_am" = Makefile.am; then
4392 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4394 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4398 while test $edit != $makefile_am_edits; do
4399 edit=`expr $edit + 1`
4400 eval dir=\"\$makefile_am_edit${edit}_dir\"
4401 eval var=\"\$makefile_am_edit${edit}_var\"
4402 eval val=\"\$makefile_am_edit${edit}_val\"
4403 if test -n "$var"; then
4404 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4407 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4408 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4411 # func_create_testdir testdir modules
4413 # - local_gnulib_dir from --local-dir
4414 # - modcache true or false, from --cache-modules/--no-cache-modules
4415 # - auxdir directory relative to destdir where to place build aux files
4416 func_create_testdir ()
4420 if test -z "$modules"; then
4421 # All modules together.
4422 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4423 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4424 modules=`func_all_modules`
4425 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist) ;; *) echo $m;; esac; done`
4427 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
4429 # Check that the license of every module is consistent with the license of
4431 saved_modules="$modules"
4432 saved_inctests="$inctests"
4433 # When computing transitive closures, don't consider $module to depend on
4434 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4435 # on GPL modules - therefore we don't want a warning in this case.
4437 for requested_module in $saved_modules; do
4438 requested_license=`func_get_license "$requested_module"`
4439 if test "$requested_license" != GPL; then
4440 # Here we use func_modules_transitive_closure, not just
4441 # func_get_dependencies, so that we also detect weird situations like
4442 # an LGPL module which depends on a GPLed build tool module which depends
4444 modules="$requested_module"
4445 func_modules_transitive_closure
4446 for module in $modules; do
4447 license=`func_get_license "$module"`
4449 'GPLed build tool') ;;
4450 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4452 case "$requested_license" in
4455 GPLv2+ | LGPLv2+) ;;
4456 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4462 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4468 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4477 modules="$saved_modules"
4478 inctests="$saved_inctests"
4480 # Subdirectory names.
4490 # Determine final module list.
4491 func_modules_transitive_closure
4492 if test $verbose -ge 0; then
4493 echo "Module list with included dependencies:"
4494 echo "$modules" | sed -e 's/^/ /'
4497 # Add the dummy module if needed.
4498 func_modules_add_dummy
4500 # Show banner notice of every module.
4503 # Determine final file list.
4504 func_modules_to_filelist
4505 if test $verbose -ge 0; then
4507 echo "$files" | sed -e 's/^/ /'
4510 rewritten='%REWRITTEN%'
4511 sed_rewrite_files="\
4512 s,^build-aux/,$rewritten$auxdir/,
4513 s,^doc/,$rewritten$docbase/,
4514 s,^lib/,$rewritten$sourcebase/,
4515 s,^m4/,$rewritten$m4base/,
4516 s,^tests/,$rewritten$testsbase/,
4520 # Create directories.
4521 for f in $files; do echo $f; done \
4522 | sed -e "$sed_rewrite_files" \
4523 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4524 | LC_ALL=C sort -u \
4526 { # Rearrange file descriptors. Needed because "while ... done < ..."
4527 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4528 exec 5<&0 < "$tmp"/dirs
4530 mkdir -p "$testdir/$d"
4535 # Copy files or make symbolic links.
4537 for f in $files; do echo $f; done \
4538 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4541 { # Rearrange file descriptors. Needed because "while ... done < ..."
4542 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4543 exec 5<&0 < "$tmp"/files
4545 func_lookup_file "$f"
4546 if test -n "$lookedup_tmp"; then
4547 cp -p "$lookedup_file" "$testdir/$g"
4549 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4550 if { test -n "$symbolic" \
4551 || { test -n "$lsymbolic" \
4552 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4553 func_ln "$lookedup_file" "$testdir/$g"
4555 cp -p "$lookedup_file" "$testdir/$g"
4562 # Create Makefile.ams that are for testing.
4565 # No special edits are needed.
4568 # Create $sourcebase/Makefile.am.
4569 mkdir -p "$testdir/$sourcebase"
4570 destfile="$sourcebase/Makefile.am"
4571 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4572 any_uses_subdirs="$uses_subdirs"
4574 # Create $m4base/Makefile.am.
4575 mkdir -p "$testdir/$m4base"
4576 (echo "## Process this file with automake to produce Makefile.in."
4582 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4585 ) > "$testdir/$m4base/Makefile.am"
4587 subdirs="$sourcebase $m4base"
4588 subdirs_with_configure_ac=""
4590 if false && test -f "$testdir"/$m4base/gettext.m4; then
4591 # Avoid stupid error message from automake:
4592 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4593 mkdir -p "$testdir/po"
4594 (echo "## Process this file with automake to produce Makefile.in."
4595 ) > "$testdir/po/Makefile.am"
4596 func_append subdirs " po"
4599 if test -n "$inctests"; then
4600 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4601 # Viewed from the $testsbase subdirectory, $auxdir is different.
4602 saved_auxdir="$auxdir"
4603 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4604 # Create $testsbase/Makefile.am.
4606 destfile="$testsbase/Makefile.am"
4607 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
4608 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4609 # Create $testsbase/configure.ac.
4610 (echo "# Process this file with autoconf to produce a configure script."
4611 echo "AC_INIT([dummy], [0])"
4612 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4613 echo "AM_INIT_AUTOMAKE"
4615 echo "AC_CONFIG_HEADERS([config.h])"
4618 echo "AC_PROG_INSTALL"
4619 echo "AC_PROG_MAKE_SET"
4620 echo "AC_PROG_RANLIB"
4622 if test -n "$uses_subdirs"; then
4623 echo "AM_PROG_CC_C_O"
4626 for module in $modules; do
4628 if test -n "$module"; then
4630 gnumakefile | maintainer-makefile)
4631 # These modules are meant to be used only in the top-level directory.
4634 func_get_autoconf_early_snippet "$module"
4639 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4640 if test "$libtool" = true; then
4641 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4642 echo "gl_cond_libtool=true"
4644 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4645 echo "gl_cond_libtool=false"
4647 echo "gl_ltlibdeps="
4649 # Wrap the set of autoconf snippets into an autoconf macro that is then
4650 # invoked. This is needed because autoconf does not support AC_REQUIRE
4652 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4653 # but we want the AC_REQUIRE to have its normal meaning (provide one
4654 # expansion of the required macro before the current point, and only one
4656 echo "AC_DEFUN([gl_INIT], ["
4657 sed_replace_build_aux='
4659 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4660 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4663 func_emit_initmacro_start $macro_prefix
4664 # We don't have explicit ordering constraints between the various
4665 # autoconf snippets. It's cleanest to put those of the library before
4666 # those of the tests.
4667 echo "gl_source_base='../$sourcebase'"
4668 for module in $modules; do
4669 func_verify_nontests_module
4670 if test -n "$module"; then
4672 gnumakefile | maintainer-makefile)
4673 # These modules are meant to be used only in the top-level directory.
4676 func_get_autoconf_snippet "$module" \
4677 | sed -e "$sed_replace_build_aux"
4682 echo "gl_source_base='.'"
4683 for module in $modules; do
4684 func_verify_tests_module
4685 if test -n "$module"; then
4686 func_get_autoconf_snippet "$module" \
4687 | sed -e "$sed_replace_build_aux"
4690 func_emit_initmacro_end $macro_prefix
4691 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4692 # created using libtool, because libtool already handles the dependencies.
4693 if test "$libtool" != true; then
4694 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4695 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4696 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4697 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4698 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4701 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4705 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4706 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4707 echo "AH_TOP([#include \"../config.h\"])"
4709 echo "AC_CONFIG_FILES([Makefile])"
4711 ) > "$testdir/$testsbase/configure.ac"
4712 auxdir="$saved_auxdir"
4713 func_append subdirs " $testsbase"
4714 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4717 # Create Makefile.am.
4718 (echo "## Process this file with automake to produce Makefile.in."
4720 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4722 echo "SUBDIRS = $subdirs"
4724 echo "ACLOCAL_AMFLAGS = -I $m4base"
4725 ) > "$testdir/Makefile.am"
4727 # Create configure.ac.
4728 (echo "# Process this file with autoconf to produce a configure script."
4729 echo "AC_INIT([dummy], [0])"
4730 if test "$auxdir" != "."; then
4731 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4733 echo "AM_INIT_AUTOMAKE"
4735 echo "AC_CONFIG_HEADERS([config.h])"
4738 echo "AC_PROG_INSTALL"
4739 echo "AC_PROG_MAKE_SET"
4741 echo "# For autobuild."
4742 echo "AC_CANONICAL_BUILD"
4743 echo "AC_CANONICAL_HOST"
4745 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4746 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4747 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4748 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4750 echo "AC_PROG_RANLIB"
4752 if test -n "$any_uses_subdirs"; then
4753 echo "AM_PROG_CC_C_O"
4756 for module in $modules; do
4757 func_verify_nontests_module
4758 if test -n "$module"; then
4759 func_get_autoconf_early_snippet "$module"
4762 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4763 if test "$libtool" = true; then
4764 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4765 echo "gl_cond_libtool=true"
4767 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4768 echo "gl_cond_libtool=false"
4770 echo "gl_ltlibdeps="
4772 # Wrap the set of autoconf snippets into an autoconf macro that is then
4773 # invoked. This is needed because autoconf does not support AC_REQUIRE
4775 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4776 # but we want the AC_REQUIRE to have its normal meaning (provide one
4777 # expansion of the required macro before the current point, and only one
4779 echo "AC_DEFUN([gl_INIT], ["
4780 if test "$auxdir" != "build-aux"; then
4781 sed_replace_build_aux='
4783 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4784 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4788 sed_replace_build_aux="$sed_noop"
4790 func_emit_initmacro_start $macro_prefix
4791 echo "gl_source_base='$sourcebase'"
4792 for module in $modules; do
4793 func_verify_nontests_module
4794 if test -n "$module"; then
4795 func_get_autoconf_snippet "$module" \
4796 | sed -e "$sed_replace_build_aux"
4799 func_emit_initmacro_end $macro_prefix
4800 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4801 # created using libtool, because libtool already handles the dependencies.
4802 if test "$libtool" != true; then
4803 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4804 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4805 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4806 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4807 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4810 func_emit_initmacro_done $macro_prefix $sourcebase
4814 if test -n "$subdirs_with_configure_ac"; then
4815 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4817 makefiles="Makefile"
4818 for d in $subdirs; do
4819 # For subdirs that have a configure.ac by their own, it's the subdir's
4820 # configure.ac which creates the subdir's Makefile.am, not this one.
4821 case " $subdirs_with_configure_ac " in
4823 *) func_append makefiles " $d/Makefile" ;;
4826 echo "AC_CONFIG_FILES([$makefiles])"
4828 ) > "$testdir/configure.ac"
4830 # Create autogenerated files.
4832 # Do not use "${AUTORECONF} --force --install", because it may invoke
4833 # autopoint, which brings in older versions of some of our .m4 files.
4834 if test -f $m4base/gettext.m4; then
4835 func_execute_command ${AUTOPOINT} --force || func_exit 1
4836 for f in $m4base/*.m4~; do
4838 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4842 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4843 if ! test -d build-aux; then
4844 func_execute_command mkdir build-aux || func_exit 1
4846 func_execute_command ${AUTOCONF} || func_exit 1
4847 func_execute_command ${AUTOHEADER} || func_exit 1
4848 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4850 if test -n "$inctests"; then
4851 # Create autogenerated files.
4852 (cd "$testdir/$testsbase" || func_exit 1
4853 # Do not use "${AUTORECONF} --force --install", because it may invoke
4854 # autopoint, which brings in older versions of some of our .m4 files.
4855 if test -f ../$m4base/gettext.m4; then
4856 func_execute_command ${AUTOPOINT} --force || func_exit 1
4857 for f in ../$m4base/*.m4~; do
4859 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4863 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4864 if ! test -d ../build-aux; then
4865 func_execute_command mkdir ../build-aux
4867 func_execute_command ${AUTOCONF} || func_exit 1
4868 func_execute_command ${AUTOHEADER} || func_exit 1
4869 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4872 # Need to run configure and make once, to create built files that are to be
4873 # distributed (such as getdate.c).
4874 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4875 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4876 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4877 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4878 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4879 # such $(FOO_H) because they don't refer to distributed files.
4880 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4881 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4882 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4883 | sed -e "$sed_remove_make_variables"`
4884 distributed_built_sources=`for file in $built_sources; do
4885 case "$cleaned_files" in
4890 if test -n "$distributed_built_sources"; then
4892 ./configure || func_exit 1
4894 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4895 $MAKE built_sources || func_exit 1
4897 $MAKE distclean || func_exit 1
4902 # func_create_megatestdir megatestdir allmodules
4904 # - local_gnulib_dir from --local-dir
4905 # - modcache true or false, from --cache-modules/--no-cache-modules
4906 # - auxdir directory relative to destdir where to place build aux files
4907 func_create_megatestdir ()
4911 if test -z "$allmodules"; then
4912 allmodules=`func_all_modules`
4916 # First, all modules one by one.
4917 for onemodule in $allmodules; do
4918 func_create_testdir "$megatestdir/$onemodule" $onemodule
4919 func_append megasubdirs "$onemodule "
4921 # Then, all modules all together.
4922 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4923 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
4924 func_create_testdir "$megatestdir/ALL" "$allmodules"
4925 func_append megasubdirs "ALL"
4928 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4929 vc_witness="$gnulib_dir/CVS/Entries"; \
4931 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4933 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4934 | sed -e 's,January,01,' -e 's,Jan,01,' \
4935 -e 's,February,02,' -e 's,Feb,02,' \
4936 -e 's,March,03,' -e 's,Mar,03,' \
4937 -e 's,April,04,' -e 's,Apr,04,' \
4939 -e 's,June,06,' -e 's,Jun,06,' \
4940 -e 's,July,07,' -e 's,Jul,07,' \
4941 -e 's,August,08,' -e 's,Aug,08,' \
4942 -e 's,September,09,' -e 's,Sep,09,' \
4943 -e 's,October,10,' -e 's,Oct,10,' \
4944 -e 's,November,11,' -e 's,Nov,11,' \
4945 -e 's,December,12,' -e 's,Dec,12,' \
4946 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4947 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4949 echo "CVSDATE=$cvsdate"
4950 echo ": \${MAKE=make}"
4951 echo "test -d logs || mkdir logs"
4952 echo "for module in $megasubdirs; do"
4953 echo " echo \"Working on module \$module...\""
4954 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4955 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4958 echo " : autobuild project... \$module"
4959 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4960 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4961 echo " : autobuild hostname... \`hostname\`"
4962 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
4964 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4966 ) > "$megatestdir/do-autobuild"
4967 chmod a+x "$megatestdir/do-autobuild"
4969 # Create Makefile.am.
4970 (echo "## Process this file with automake to produce Makefile.in."
4972 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4974 echo "SUBDIRS = $megasubdirs"
4976 echo "EXTRA_DIST = do-autobuild"
4977 ) > "$megatestdir/Makefile.am"
4979 # Create configure.ac.
4980 (echo "# Process this file with autoconf to produce a configure script."
4981 echo "AC_INIT([dummy], [0])"
4982 if test "$auxdir" != "."; then
4983 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4985 echo "AM_INIT_AUTOMAKE"
4987 echo "AC_PROG_MAKE_SET"
4989 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4990 echo "AC_CONFIG_FILES([Makefile])"
4992 ) > "$megatestdir/configure.ac"
4994 # Create autogenerated files.
4996 # Do not use "${AUTORECONF} --install", because autoreconf operates
4997 # recursively, but the subdirectories are already finished, therefore
4998 # calling autoreconf here would only waste lots of CPU time.
4999 func_execute_command ${ACLOCAL} || func_exit 1
5000 func_execute_command mkdir build-aux
5001 func_execute_command ${AUTOCONF} || func_exit 1
5002 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5008 func_fatal_error "no mode specified" ;;
5015 # sed expression that converts a literal to a basic regular expression.
5016 # Needs to handle . [ \ * ^ $.
5017 sed_literal_to_basic_regex='s/\\/\\\\/g
5023 if test -f "$gnulib_dir/$filename" \
5024 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5025 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5026 filename_line_regex='^'"$filename_anywhere_regex"'$'
5029 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5030 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5031 (cd "$local_gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_anywhere_regex" /dev/null | sed -e 's,^modules/,,' -e 's,\.diff$,,')
5034 | func_sanitize_modulelist \
5037 for module in $module_candidates; do
5038 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5043 func_warning "file $filename does not exist"
5051 if test -z "$destdir"; then
5054 test -d "$destdir" \
5055 || func_fatal_error "destination directory does not exist: $destdir"
5057 # Prefer configure.ac to configure.in.
5058 if test -f "$destdir"/configure.ac; then
5059 configure_ac="$destdir/configure.ac"
5061 if test -f "$destdir"/configure.in; then
5062 configure_ac="$destdir/configure.in"
5064 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5068 # Analyze configure.ac.
5070 guessed_libtool=false
5075 /AC_CONFIG_AUX_DIR/ {
5076 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5078 /A[CM]_PROG_LIBTOOL/ {
5079 s,^.*$,guessed_libtool=true,p
5081 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5083 if test -z "$auxdir"; then
5084 auxdir="$guessed_auxdir"
5087 # Determine where to apply func_import.
5088 if test -n "$m4base"; then
5089 # Apply func_import to a particular gnulib directory.
5090 # Any number of additional modules can be given.
5091 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5092 # First use of gnulib in the given m4base.
5093 test -n "$supplied_libname" || supplied_libname=true
5094 test -n "$sourcebase" || sourcebase="lib"
5095 test -n "$docbase" || docbase="doc"
5096 test -n "$testsbase" || testsbase="tests"
5097 test -n "$macro_prefix" || macro_prefix="gl"
5101 # Apply func_import to all gnulib directories.
5102 # To get this list of directories, look at Makefile.am. (Not at
5103 # configure, because it may be omitted from CVS. Also, don't run
5104 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5107 if test -f "$destdir"/Makefile.am; then
5108 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5110 for arg in $aclocal_amflags; do
5111 if test -n "$m4dir_is_next"; then
5112 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5116 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5117 func_append m4dirs " $arg"
5118 m4dirs_count=`expr $m4dirs_count + 1`
5124 if test "X$arg" = "X-I"; then
5132 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5133 if test -f "$destdir"/aclocal.m4; then
5134 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5135 sedexpr2='s,^[^/]*$,.,'
5136 sedexpr3='s,/[^/]*$,,'
5137 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5138 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5141 if test $m4dirs_count = 0; then
5142 # First use of gnulib in a package.
5143 # Any number of additional modules can be given.
5144 test -n "$supplied_libname" || supplied_libname=true
5145 test -n "$sourcebase" || sourcebase="lib"
5147 test -n "$docbase" || docbase="doc"
5148 test -n "$testsbase" || testsbase="tests"
5149 test -n "$macro_prefix" || macro_prefix="gl"
5152 if test $m4dirs_count = 1; then
5153 # There's only one use of gnulib here. Assume the user means it.
5154 # Any number of additional modules can be given.
5155 for m4base in $m4dirs; do
5159 # Ambiguous - guess what the user meant.
5160 if test $# = 0; then
5161 # No further arguments. Guess the user wants to update all of them.
5162 for m4base in $m4dirs; do
5163 # Perform func_import in a subshell, so that variable values
5165 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
5166 # pobase, docbase, testsbase, inctests, libname, lgpl,
5167 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5168 # don't propagate from one directory to another.
5169 (func_import) || func_exit 1
5173 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5181 if test -z "$destdir"; then
5182 func_fatal_error "please specify --dir option"
5185 test -d "$destdir" \
5186 || func_fatal_error "could not create destination directory"
5187 test -n "$auxdir" || auxdir="build-aux"
5188 func_create_testdir "$destdir" "$*"
5191 create-megatestdir )
5192 if test -z "$destdir"; then
5193 func_fatal_error "please specify --dir option"
5195 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5196 test -n "$auxdir" || auxdir="build-aux"
5197 func_create_megatestdir "$destdir" "$*"
5201 test -n "$destdir" || destdir=testdir$$
5202 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5203 test -n "$auxdir" || auxdir="build-aux"
5204 func_create_testdir "$destdir" "$*"
5208 ../configure || func_exit 1
5209 $MAKE || func_exit 1
5210 $MAKE check || func_exit 1
5211 $MAKE distclean || func_exit 1
5212 remaining=`find . -type f -print`
5213 if test -n "$remaining"; then
5214 echo "Remaining files:" $remaining 1>&2
5215 echo "gnulib-tool: *** Stop." 1>&2
5224 test -n "$destdir" || destdir=testdir$$
5225 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5226 test -n "$auxdir" || auxdir="build-aux"
5227 func_create_megatestdir "$destdir" "$*"
5235 remaining=`find . -type f -print`
5236 if test -n "$remaining"; then
5237 echo "Remaining files:" $remaining 1>&2
5238 echo "gnulib-tool: *** Stop." 1>&2
5246 extract-description )
5250 if test -n "$module"; then
5251 func_get_description "$module"
5260 if test -n "$module"; then
5261 func_get_status "$module"
5270 if test -n "$module"; then
5271 func_get_notice "$module"
5276 extract-applicability )
5280 if test -n "$module"; then
5281 func_get_applicability "$module"
5290 if test -n "$module"; then
5291 func_get_filelist "$module"
5296 extract-dependencies )
5300 if test -n "$module"; then
5301 func_get_dependencies "$module"
5306 extract-autoconf-snippet )
5310 if test -n "$module"; then
5311 func_get_autoconf_snippet "$module"
5316 extract-automake-snippet )
5320 if test -n "$module"; then
5321 func_get_automake_snippet "$module"
5326 extract-include-directive )
5330 if test -n "$module"; then
5331 func_get_include_directive "$module"
5336 extract-link-directive )
5340 if test -n "$module"; then
5341 func_get_link_directive "$module"
5350 if test -n "$module"; then
5351 func_get_license "$module"
5356 extract-maintainer )
5360 if test -n "$module"; then
5361 func_get_maintainer "$module"
5366 extract-tests-module )
5370 if test -n "$module"; then
5371 func_get_tests_module "$module"
5377 # Verify the number of arguments.
5378 if test $# -lt 1 || test $# -gt 2; then
5379 func_fatal_error "invalid number of arguments for --$mode"
5382 # The first argument is the file to be copied.
5384 # Verify the file exists.
5385 func_lookup_file "$f"
5387 # The second argument is the destination; either a directory ot a file.
5388 # It defaults to the current directory.
5390 test -n "$dest" || dest='.'
5391 test -n "$sourcebase" || sourcebase="lib"
5392 test -n "$m4base" || m4base="m4"
5393 test -n "$docbase" || docbase="doc"
5394 test -n "$testsbase" || testsbase="tests"
5395 test -n "$auxdir" || auxdir="build-aux"
5396 rewritten='%REWRITTEN%'
5397 sed_rewrite_files="\
5398 s,^build-aux/,$rewritten$auxdir/,
5399 s,^doc/,$rewritten$docbase/,
5400 s,^lib/,$rewritten$sourcebase/,
5401 s,^m4/,$rewritten$m4base/,
5402 s,^tests/,$rewritten$testsbase/,
5405 if test -d "$dest"; then
5407 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5409 destdir=`dirname "$dest"`
5410 g=`basename "$dest"`
5413 # Create the directory for destfile.
5414 d=`dirname "$destdir/$g"`
5416 if test -n "$d" && test ! -d "$d"; then
5417 mkdir -p "$d" || func_fatal_error "failed"
5421 func_dest_tmpfilename "$g"
5422 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5423 already_present=true
5424 if test -f "$destdir/$g"; then
5425 # The file already exists.
5429 # Don't protest if the file should be there but isn't: it happens
5430 # frequently that developers don't put autogenerated files into CVS.
5437 func_fatal_error "unknown operation mode --$mode" ;;
5441 # Undo the effect of the previous 'trap' command. Some shellology:
5442 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5443 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5444 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5445 # 128 + signal number and is set before the trap-registered command is run.
5447 trap 'func_exit $?' 1 2 3 13 15
5452 # indent-tabs-mode: nil
5453 # whitespace-check-buffer-indent: nil