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
664 # Ensure an 'echo' command
665 # 1. does not interpret backslashes and
666 # 2. does not print an error message "broken pipe" when writing into a pipe
669 # Test cases for problem 1:
670 # echo '\n' | wc -l prints 1 when OK, 2 when KO
671 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
672 # Test cases for problem 2:
673 # echo hi | true frequently prints
674 # "bash: echo: write error: Broken pipe"
675 # to standard error in bash 3.2.
677 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
678 # BSD echo interprets '-n' as an option, which is also not desirable).
679 # Nowadays the problem occurs in 4 situations:
680 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
681 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
682 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
683 # - in zsh, when sh-emulation is not set,
684 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
685 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
686 # - in Solaris /bin/sh and OSF/1 /bin/sh.
687 # We try the following workarounds:
688 # - for all: respawn using $CONFIG_SHELL if that is set and works.
689 # - for bash >= 2.04: unset the shell option xpg_echo.
690 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
691 # - for bash < 2.0: define echo to a function that uses cat of a here document.
692 # - for zsh: turn sh-emulation on.
693 # - for ksh: alias echo to 'print -r'.
694 # - for ksh: alias echo to a function that uses cat of a here document.
695 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
696 # the ksh workaround.
697 # - otherwise: respawn using /bin/sh and rely on the workarounds.
698 # When respawning, we pass --no-reexec as first argument, so as to avoid
699 # turning this script into a fork bomb in unlucky situations.
701 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
702 # the 'printf' built-in. See
703 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
704 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
705 # The workaround is: define echo to a function that uses the printf built-in.
707 if echo '\t' | grep t > /dev/null; then
708 have_echo=yes # Lucky!
710 # Try the workarounds.
711 # Respawn using $CONFIG_SHELL if that is set and works.
712 if test -z "$have_echo" \
713 && test "X$1" != "X--no-reexec" \
714 && test -n "$CONFIG_SHELL" \
715 && test -f "$CONFIG_SHELL" \
716 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
717 exec $CONFIG_SHELL "$0" --no-reexec "$@"
720 # For bash >= 2.04: unset the shell option xpg_echo.
721 if test -z "$have_echo" \
722 && test -n "$BASH_VERSION" \
723 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
727 # For bash >= 2.0: define echo to a function that uses the printf built-in.
728 # For bash < 2.0: define echo to a function that uses cat of a here document.
729 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
730 if test -z "$have_echo" \
731 && test -n "$BASH_VERSION"; then \
732 if type printf 2>/dev/null | grep / > /dev/null; then
733 # 'printf' is not a shell built-in.
741 # 'printf' is a shell built-in.
747 if echo '\t' | grep t > /dev/null; then
751 # For zsh: turn sh-emulation on.
752 if test -z "$have_echo" \
753 && test -n "$ZSH_VERSION" \
754 && (emulate sh) >/dev/null 2>&1; then
757 # For ksh: alias echo to 'print -r'.
758 if test -z "$have_echo" \
759 && (type print) >/dev/null 2>&1; then
760 # A 'print' command exists.
761 if type print 2>/dev/null | grep / > /dev/null; then
764 # 'print' is a shell built-in.
765 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
766 # 'print' is the ksh shell built-in.
767 alias echo='print -r'
771 if test -z "$have_echo" \
772 && echo '\t' | grep t > /dev/null; then
775 # For ksh: alias echo to a function that uses cat of a here document.
776 # The ksh manual page says:
777 # "Aliasing is performed when scripts are read, not while they are executed.
778 # Therefore, for an alias to take effect, the alias definition command has
779 # to be executed before the command which references the alias is read."
780 # Because of this, we have to play strange tricks with have_echo, to ensure
781 # that the top-level statement containing the test starts after the 'alias'
783 if test -z "$have_echo"; then
790 alias echo=bsd_echo 2>/dev/null
792 if test -z "$have_echo" \
793 && echo '\t' | grep t > /dev/null; then
796 if test -z "$have_echo"; then
797 unalias echo 2>/dev/null
799 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
800 if test -z "$have_echo" \
801 && test "X$1" != "X--no-reexec" \
802 && test -f /bin/ksh; then
803 exec /bin/ksh "$0" --no-reexec "$@"
806 # Otherwise: respawn using /bin/sh.
807 if test -z "$have_echo" \
808 && test "X$1" != "X--no-reexec" \
809 && test -f /bin/sh; then
810 exec /bin/sh "$0" --no-reexec "$@"
813 # Now handle problem 2, specific to bash 3.2.
814 case "$BASH_VERSION" in
822 if test -z "$have_echo"; then
823 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
825 if echo '\t' | grep t > /dev/null; then
828 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
830 if test "X$1" = "X--no-reexec"; then
834 # Command-line option processing.
835 # Removes the OPTIONS from the arguments. Sets the variables:
836 # - mode list or import or create-testdir or create-megatestdir
837 # - destdir from --dir
838 # - local_gnulib_dir from --local-dir
839 # - modcache true or false, from --cache-modules/--no-cache-modules
840 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
841 # - libname, supplied_libname from --lib
842 # - sourcebase from --source-base
843 # - m4base from --m4-base
844 # - pobase from --po-base
845 # - docbase from --doc-base
846 # - testsbase from --tests-base
847 # - auxdir from --aux-dir
848 # - inctests true if --with-tests was given, blank otherwise
849 # - incobsolete true if --with-obsolete was given, blank otherwise
850 # - avoidlist list of modules to avoid, from --avoid
851 # - lgpl yes or a number if --lgpl was given, blank otherwise
852 # - makefile_name from --makefile-name
853 # - libtool true if --libtool was given, false if --no-libtool was
854 # given, blank otherwise
855 # - macro_prefix from --macro-prefix
856 # - po_domain from --po-domain
857 # - vc_files true if --vc-files was given, false if --no-vc-files was
858 # given, blank otherwise
859 # - autoconf_minversion minimum supported autoconf version
860 # - do_changelog false if --no-changelog was given, : otherwise
861 # - doit : if actions shall be executed, false if only to be printed
862 # - symbolic true if --symlink or --more-symlinks was given, blank
864 # - lsymbolic true if --local-symlink was given, blank otherwise
865 # - do_copyrights blank if --more-symlinks was given, true otherwise
897 while test $# -gt 0; do
902 --find | --fin | --fi | --f )
905 --import | --impor | --impo | --imp | --im | --i )
908 --update | --updat | --upda | --upd | --up | --u )
911 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
914 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
915 mode=create-megatestdir
917 --test | --tes | --te | --t )
920 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
924 mode=`echo "X$1" | sed -e 's/^X--//'`
926 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
932 func_fatal_error "missing argument for --dir"
937 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
942 func_fatal_error "missing argument for --local-dir"
947 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
949 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
952 --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 )
955 --verbose | --verbos | --verbo | --verb )
956 verbose=`expr $verbose + 1`
958 --quiet | --quie | --qui | --qu | --q )
959 verbose=`expr $verbose - 1`
964 func_fatal_error "missing argument for --lib"
967 supplied_libname=true
970 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
971 supplied_libname=true
976 func_fatal_error "missing argument for --source-base"
981 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
986 func_fatal_error "missing argument for --m4-base"
991 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
996 func_fatal_error "missing argument for --po-base"
1001 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1005 if test $# = 0; then
1006 func_fatal_error "missing argument for --doc-base"
1011 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1015 if test $# = 0; then
1016 func_fatal_error "missing argument for --tests-base"
1021 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1025 if test $# = 0; then
1026 func_fatal_error "missing argument for --aux-dir"
1031 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1041 if test $# = 0; then
1042 func_fatal_error "missing argument for --avoid"
1044 func_append avoidlist " $1"
1047 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1048 func_append avoidlist " $arg"
1054 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1057 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1063 if test $# = 0; then
1064 func_fatal_error "missing argument for --makefile-name"
1069 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1079 if test $# = 0; then
1080 func_fatal_error "missing argument for --macro-prefix"
1085 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1089 if test $# = 0; then
1090 func_fatal_error "missing argument for --po-domain"
1095 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1103 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1109 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1112 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1115 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1119 --help | --hel | --he | --h )
1122 --version | --versio | --versi | --vers )
1126 # Stop option processing
1130 echo "gnulib-tool: unknown option $1" 1>&2
1131 echo "Try 'gnulib-tool --help' for more information." 1>&2
1138 if test "$mode" = update; then
1139 if test $# != 0; then
1140 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1141 echo "Try 'gnulib-tool --help' for more information." 1>&2
1142 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1143 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1146 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1147 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1148 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1149 || test -n "$inctests" || test -n "$incobsolete" \
1150 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1151 || test -n "$macro_prefix" || test -n "$po_domain" \
1152 || test -n "$vc_files"; then
1153 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1154 echo "Try 'gnulib-tool --help' for more information." 1>&2
1155 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1156 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1161 if test -n "$pobase" && test -z "$po_domain"; then
1162 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1163 echo "Try 'gnulib-tool --help' for more information." 1>&2
1166 if test -z "$pobase" && test -n "$po_domain"; then
1167 func_warning "--po-domain has no effect without a --po-base option"
1170 # Determine the minimum supported autoconf version from the project's
1172 DEFAULT_AUTOCONF_MINVERSION="2.59"
1173 autoconf_minversion=
1175 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1176 if test -f "$destdir"/configure.ac; then
1177 configure_ac="$destdir/configure.ac"
1179 if test -f "$destdir"/configure.in; then
1180 configure_ac="$destdir/configure.in"
1184 if test -f configure.ac; then
1185 configure_ac="configure.ac"
1187 if test -f configure.in; then
1188 configure_ac="configure.in"
1192 if test -n "$configure_ac"; then
1193 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1194 # because when some m4 files are omitted from a CVS repository,
1195 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1196 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1197 # autom4te: m4 failed with exit status: 1
1204 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1206 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1207 if test -n "$prereqs"; then
1208 autoconf_minversion=`
1209 for version in $prereqs; do echo $version; done |
1210 LC_ALL=C sort -nru | sed -e 1q
1214 if test -z "$autoconf_minversion"; then
1215 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1217 case "$autoconf_minversion" in
1218 1.* | 2.[0-4]* | 2.5[0-8]*)
1219 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1222 # Remove trailing slashes from the directory names. This is necessary for
1223 # m4base (to avoid an error in func_import) and optional for the others.
1224 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1225 case "$local_gnulib_dir" in
1226 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1228 case "$sourcebase" in
1229 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1232 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1235 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1238 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1240 case "$testsbase" in
1241 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1244 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1250 trap 'exit_status=$?
1251 if test "$signal" != 0; then
1252 echo "caught signal $signal" >&2
1255 exit $exit_status' 0
1256 for signal in 1 2 3 13 15; do
1257 trap '{ signal='$signal'; func_exit 1; }' $signal
1261 # func_lookup_file file
1262 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1265 # - local_gnulib_dir from --local-dir
1267 # - lookedup_file name of the merged (combined) file
1268 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1272 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1273 lookedup_file="$local_gnulib_dir/$lkfile"
1276 if test -f "$gnulib_dir/$lkfile"; then
1277 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1278 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1279 rm -f "$tmp/$lkbase"
1280 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1281 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1282 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1283 lookedup_file="$tmp/$lkbase"
1286 lookedup_file="$gnulib_dir/$lkfile"
1290 func_fatal_error "file $gnulib_dir/$lkfile not found"
1295 # func_sanitize_modulelist
1296 # receives a list of possible module names on standard input, one per line.
1297 # It removes those which are just file names unrelated to modules, and outputs
1298 # the resulting list to standard output, one per line.
1299 func_sanitize_modulelist ()
1301 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1302 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1303 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1304 -e '/^README$/d' -e '/\/README$/d' \
1305 -e '/^TEMPLATE$/d' \
1306 -e '/^TEMPLATE-EXTENDED$/d' \
1307 -e '/^TEMPLATE-TESTS$/d' \
1314 # - local_gnulib_dir from --local-dir
1317 # Filter out metainformation files like README, which are not modules.
1318 # Filter out unit test modules; they can be retrieved through
1319 # --extract-tests-module if desired.
1321 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1322 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1323 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1326 | func_sanitize_modulelist \
1327 | sed -e '/-tests$/d' \
1331 # func_verify_module
1332 # verifies a module name
1334 # - local_gnulib_dir from --local-dir
1335 # - module module name argument
1336 func_verify_module ()
1338 if { test -f "$gnulib_dir/modules/$module" \
1339 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1340 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1341 && test "CVS" != "$module" \
1342 && test "ChangeLog" != "$module" \
1343 && test "COPYING" != "$module" \
1344 && test "README" != "$module" \
1345 && test "TEMPLATE" != "$module" \
1346 && test "TEMPLATE-EXTENDED" != "$module" \
1347 && test "TEMPLATE-TESTS" != "$module"; then
1348 # OK, $module is a correct module name.
1349 # Verify that building the module description with 'patch' succeeds.
1350 func_lookup_file "modules/$module"
1352 func_warning "module $module doesn't exist"
1357 # func_verify_nontests_module
1358 # verifies a module name, excluding tests modules
1360 # - local_gnulib_dir from --local-dir
1361 # - module module name argument
1362 func_verify_nontests_module ()
1365 *-tests ) module= ;;
1366 * ) func_verify_module ;;
1370 # func_verify_tests_module
1371 # verifies a module name, considering only tests modules
1373 # - local_gnulib_dir from --local-dir
1374 # - module module name argument
1375 func_verify_tests_module ()
1378 *-tests ) func_verify_module ;;
1383 # Suffix of a sed expression that extracts a particular field from a
1384 # module description.
1385 # A field starts with a line that contains a keyword, such as 'Description',
1386 # followed by a colon and optional whitespace. All following lines, up to
1387 # the next field (or end of file if there is none) form the contents of the
1389 # An absent field is equivalent to a field with empty contents.
1390 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1391 sed_extract_prog=':[ ]*$/ {
1394 s/^Description:[ ]*$//
1397 s/^Applicability:[ ]*$//
1399 s/^Depends-on:[ ]*$//
1400 s/^configure\.ac-early:[ ]*$//
1401 s/^configure\.ac:[ ]*$//
1402 s/^Makefile\.am:[ ]*$//
1406 s/^Maintainer:[ ]*$//
1413 # Piece of a sed expression that converts a field header line to a shell
1415 # NOTE: Keep this in sync with sed_extract_prog above!
1416 sed_extract_field_header='
1417 s/^Description:[ ]*$/description/
1418 s/^Status:[ ]*$/status/
1419 s/^Notice:[ ]*$/notice/
1420 s/^Applicability:[ ]*$/applicability/
1421 s/^Files:[ ]*$/files/
1422 s/^Depends-on:[ ]*$/dependson/
1423 s/^configure\.ac-early:[ ]*$/configureac_early/
1424 s/^configure\.ac:[ ]*$/configureac/
1425 s/^Makefile\.am:[ ]*$/makefile/
1426 s/^Include:[ ]*$/include/
1428 s/^License:[ ]*$/license/
1429 s/^Maintainer:[ ]*$/maintainer/'
1433 # Note: The 'eval' silences stderr output in dash.
1434 if declare -A x 2>/dev/null && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }; then
1435 # Zsh 4 and Bash 4 have associative arrays.
1436 have_associative=true
1438 # For other shells, use 'eval' with computed shell variable names.
1439 have_associative=false
1442 if $have_associative; then
1444 # Declare the associative arrays.
1445 declare -A modcache_cached
1446 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1447 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1448 eval "$declare_script"
1452 # func_cache_var module
1453 # computes the cache variable name corresponding to $module.
1454 # Note: This computation can map different module names to the same
1455 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1456 # to protect against this case.
1458 # - cachevar a shell variable name
1459 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1460 # Bash 2.0 and newer, ksh, and zsh support the syntax
1461 # ${param//pattern/replacement}
1462 # as a shorthand for
1463 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1464 # Note: The 'eval' above silences stderr output in dash.
1467 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1474 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1483 # func_init_sed_convert_to_cache_statements
1485 # - modcachevar_assignment
1487 # - sed_convert_to_cache_statements
1488 func_init_sed_convert_to_cache_statements ()
1490 # 'sed' script that turns a module description into shell script
1491 # assignments, suitable to be eval'ed. All active characters are escaped.
1494 # Some module's description
1499 # modcache_description[$1]=\
1500 # 'Some module'"'"'s description
1502 # modcache_files[$1]=\
1505 # c_MODULE_description_set=set; c_MODULE_description=\
1506 # 'Some module'"'"'s description
1508 # c_MODULE_files_set=set; c_MODULE_files=\
1510 # The script consists of two parts:
1511 # 1) Ignore the lines before the first field header.
1512 # 2) A loop, treating non-field-header lines by escaping single quotes
1513 # and adding a closing quote in the last line,
1514 sed_convert_to_cache_statements="
1516 # Here we have not yet seen a field header.
1518 # See if the current line contains a field header.
1521 ${sed_extract_field_header}
1524 # No field header. Ignore the line.
1526 # Read the next line. Upon EOF, just exit.
1531 # The current line contains a field header.
1533 # Turn it into the beginning of an assignment.
1534 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1536 # Move it to the hold space. Don't print it yet,
1537 # because we want no assignment if the field is empty.
1540 # Read the next line.
1541 # Upon EOF, the field was empty. Print no assignment. Just exit.
1544 # See if the current line contains a field header.
1547 ${sed_extract_field_header}
1548 # If it is, the previous field was empty. Print no assignment.
1551 # Not a field header.
1553 # Print the previous line, held in the hold space.
1558 # Transform single quotes.
1561 # Prepend a single quote.
1566 # Move it to the hold space.
1569 # Read the next line.
1576 # See if the current line contains a field header.
1579 ${sed_extract_field_header}
1582 # Print the previous line, held in the hold space.
1587 # Transform single quotes.
1594 # Print the previous line, held in the hold space, with a single quote
1595 # to end the assignment.
1605 # Print the previous line, held in the hold space, with a single quote
1606 # to end the assignment.
1613 if ! $sed_comments; then
1615 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1616 | sed -e 's/^ *//' -e 's/^#.*//'`
1620 if $have_associative; then
1621 # sed_convert_to_cache_statements does not depend on the module.
1622 modcachevar_assignment='modcache_\1[$1]='
1623 func_init_sed_convert_to_cache_statements
1626 # func_cache_lookup_module module
1628 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1629 # of its relevant data in a cache in the memory of the processing shell. If
1630 # already cached, it does not look it up again, thus saving file access time.
1632 # - module non-empty string
1633 # Output if $have_associative:
1634 # - modcache_cached[$module] set to yes
1635 # - modcache_description[$module] ==
1636 # - modcache_status[$module] \ set to the field's value, minus the
1637 # - ... / final newline,
1638 # - modcache_maintainer[$module] == or unset if the field's value is empty
1639 # Output if ! $have_associative:
1640 # - cachevar a shell variable name
1641 # - ${cachevar}_cached set to $module
1642 # - ${cachevar}_description ==
1643 # - ${cachevar}_status \ set to the field's value, minus the
1644 # - ... / final newline,
1645 # - ${cachevar}_maintainer == or unset if the field's value is empty
1646 # - ${cachevar}_description_set ==
1647 # - ${cachevar}_status_set \ set to non-empty if the field's value
1648 # - ... / is non-empty,
1649 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1650 func_cache_lookup_module ()
1652 if $have_associative; then
1653 cached=${modcache_cached[$1]}
1656 eval "cached=\"\$${cachevar}_cached\""
1658 if test -z "$cached"; then
1659 # Not found in cache. Look it up on the file system.
1660 func_lookup_file "modules/$1"
1661 if $have_associative; then
1662 modcache_cached[$1]=yes
1664 eval "${cachevar}_cached=\"\$1\""
1666 if ! $have_associative; then
1667 # sed_convert_to_cache_statements depends on the module.
1668 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1669 func_init_sed_convert_to_cache_statements
1671 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1672 eval "$cache_statements"
1674 if ! $have_associative; then
1675 if test "$1" != "$cached"; then
1676 func_fatal_error "cache variable collision between $1 and $cached"
1684 # func_get_description module
1686 # - local_gnulib_dir from --local-dir
1687 # - modcache true or false, from --cache-modules/--no-cache-modules
1688 func_get_description ()
1690 if ! $modcache; then
1691 func_lookup_file "modules/$1"
1692 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1694 func_cache_lookup_module "$1"
1695 # Output the field's value, including the final newline (if any).
1696 if $have_associative; then
1697 if test -n "${modcache_description[$1]+set}"; then
1698 echo "${modcache_description[$1]}"
1701 eval "field_set=\"\$${cachevar}_description_set\""
1702 if test -n "$field_set"; then
1703 eval "field_value=\"\$${cachevar}_description\""
1704 echo "${field_value}"
1710 # func_get_status module
1712 # - local_gnulib_dir from --local-dir
1713 # - modcache true or false, from --cache-modules/--no-cache-modules
1716 if ! $modcache; then
1717 func_lookup_file "modules/$1"
1718 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1720 func_cache_lookup_module "$1"
1721 # Output the field's value, including the final newline (if any).
1722 if $have_associative; then
1723 if test -n "${modcache_status[$1]+set}"; then
1724 echo "${modcache_status[$1]}"
1727 eval "field_set=\"\$${cachevar}_status_set\""
1728 if test -n "$field_set"; then
1729 eval "field_value=\"\$${cachevar}_status\""
1730 echo "${field_value}"
1736 # func_get_notice module
1738 # - local_gnulib_dir from --local-dir
1739 # - modcache true or false, from --cache-modules/--no-cache-modules
1742 if ! $modcache; then
1743 func_lookup_file "modules/$1"
1744 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1746 func_cache_lookup_module "$1"
1747 # Output the field's value, including the final newline (if any).
1748 if $have_associative; then
1749 if test -n "${modcache_notice[$1]+set}"; then
1750 echo "${modcache_notice[$1]}"
1753 eval "field_set=\"\$${cachevar}_notice_set\""
1754 if test -n "$field_set"; then
1755 eval "field_value=\"\$${cachevar}_notice\""
1756 echo "${field_value}"
1762 # func_get_applicability module
1764 # - local_gnulib_dir from --local-dir
1765 # - modcache true or false, from --cache-modules/--no-cache-modules
1766 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1767 func_get_applicability ()
1769 if ! $modcache; then
1770 func_lookup_file "modules/$1"
1771 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1773 func_cache_lookup_module "$1"
1774 # Get the field's value, without the final newline.
1775 if $have_associative; then
1776 my_applicability="${modcache_applicability[$1]}"
1778 eval "my_applicability=\"\$${cachevar}_applicability\""
1781 if test -n "$my_applicability"; then
1782 echo $my_applicability
1784 # The default is 'main' or 'tests', depending on the module's name.
1786 *-tests) echo "tests";;
1792 # func_get_filelist module
1794 # - local_gnulib_dir from --local-dir
1795 # - modcache true or false, from --cache-modules/--no-cache-modules
1796 func_get_filelist ()
1798 if ! $modcache; then
1799 func_lookup_file "modules/$1"
1800 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1802 func_cache_lookup_module "$1"
1803 # Output the field's value, including the final newline (if any).
1804 if $have_associative; then
1805 if test -n "${modcache_files[$1]+set}"; then
1806 echo "${modcache_files[$1]}"
1809 eval "field_set=\"\$${cachevar}_files_set\""
1810 if test -n "$field_set"; then
1811 eval "field_value=\"\$${cachevar}_files\""
1812 echo "${field_value}"
1817 echo m4/gnulib-common.m4
1818 case "$autoconf_minversion" in
1825 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1826 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1827 # elements starting with prefix and ending with suffix are considered.
1828 # Processing: removed_prefix and removed_suffix are removed from each element,
1829 # added_prefix and added_suffix are added to each element.
1830 # prefix, suffix should not contain shell-special characters.
1831 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1832 # added_prefix, added_suffix should not contain the characters \|&.
1833 func_filter_filelist ()
1835 if test "$2" != "$nl" \
1836 || { $fast_func_append \
1837 && { test -z "$6" || $fast_func_remove_prefix; } \
1838 && { test -z "$7" || $fast_func_remove_suffix; }; \
1842 # Do not quote possibly-empty parameters in case patterns,
1843 # AIX and HP-UX ksh won't match them if they are empty.
1846 if test -n "$6"; then
1847 func_remove_prefix fff "$6"
1849 if test -n "$7"; then
1850 func_remove_suffix fff "$7"
1853 if test -z "$ffflist"; then
1856 func_append ffflist "$2${fff}"
1862 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1863 ffflist=`for fff in $3; do
1865 $4*$5) echo "$fff" ;;
1867 done | sed -e "$sed_fff_filter"`
1869 eval "$1=\"\$ffflist\""
1872 # func_get_dependencies module
1874 # - local_gnulib_dir from --local-dir
1875 # - modcache true or false, from --cache-modules/--no-cache-modules
1876 func_get_dependencies ()
1878 # ${module}-tests always implicitly depends on ${module}.
1882 func_remove_suffix fgd1 '-tests'
1886 # Then the explicit dependencies listed in the module description.
1887 if ! $modcache; then
1888 func_lookup_file "modules/$1"
1889 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1891 func_cache_lookup_module "$1"
1892 # Output the field's value, including the final newline (if any).
1893 if $have_associative; then
1894 if test -n "${modcache_dependson[$1]+set}"; then
1895 echo "${modcache_dependson[$1]}"
1898 eval "field_set=\"\$${cachevar}_dependson_set\""
1899 if test -n "$field_set"; then
1900 eval "field_value=\"\$${cachevar}_dependson\""
1901 echo "${field_value}"
1907 # func_get_autoconf_early_snippet module
1909 # - local_gnulib_dir from --local-dir
1910 # - modcache true or false, from --cache-modules/--no-cache-modules
1911 func_get_autoconf_early_snippet ()
1913 if ! $modcache; then
1914 func_lookup_file "modules/$1"
1915 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1917 func_cache_lookup_module "$1"
1918 # Output the field's value, including the final newline (if any).
1919 if $have_associative; then
1920 if test -n "${modcache_configureac_early[$1]+set}"; then
1921 echo "${modcache_configureac_early[$1]}"
1924 eval "field_set=\"\$${cachevar}_configureac_early_set\""
1925 if test -n "$field_set"; then
1926 eval "field_value=\"\$${cachevar}_configureac_early\""
1927 echo "${field_value}"
1933 # func_get_autoconf_snippet module
1935 # - local_gnulib_dir from --local-dir
1936 # - modcache true or false, from --cache-modules/--no-cache-modules
1937 func_get_autoconf_snippet ()
1939 if ! $modcache; then
1940 func_lookup_file "modules/$1"
1941 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1943 func_cache_lookup_module "$1"
1944 # Output the field's value, including the final newline (if any).
1945 if $have_associative; then
1946 if test -n "${modcache_configureac[$1]+set}"; then
1947 echo "${modcache_configureac[$1]}"
1950 eval "field_set=\"\$${cachevar}_configureac_set\""
1951 if test -n "$field_set"; then
1952 eval "field_value=\"\$${cachevar}_configureac\""
1953 echo "${field_value}"
1959 # func_get_automake_snippet module
1961 # - local_gnulib_dir from --local-dir
1962 # - modcache true or false, from --cache-modules/--no-cache-modules
1963 func_get_automake_snippet ()
1965 if ! $modcache; then
1966 func_lookup_file "modules/$1"
1967 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1969 func_cache_lookup_module "$1"
1970 # Output the field's value, including the final newline (if any).
1971 if $have_associative; then
1972 if test -n "${modcache_makefile[$1]+set}"; then
1973 echo "${modcache_makefile[$1]}"
1976 eval "field_set=\"\$${cachevar}_makefile_set\""
1977 if test -n "$field_set"; then
1978 eval "field_value=\"\$${cachevar}_makefile\""
1979 echo "${field_value}"
1985 # *-tests module live in tests/, not lib/.
1986 # Synthesize an EXTRA_DIST augmentation.
1987 all_files=`func_get_filelist $1`
1988 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1989 extra_files="$tests_files"
1990 if test -n "$extra_files"; then
1991 echo "EXTRA_DIST +=" $extra_files
1996 # Synthesize an EXTRA_DIST augmentation.
1997 sed_combine_lines='/\\$/{
2004 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2005 already_mentioned_files=` \
2006 { if ! $modcache; then
2007 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2009 if $have_associative; then
2010 if test -n "${modcache_makefile[$1]+set}"; then
2011 echo "${modcache_makefile[$1]}"
2014 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2015 if test -n "$field_set"; then
2016 eval 'field_value="$'"${cachevar}"'_makefile"'
2017 echo "${field_value}"
2022 | sed -e "$sed_combine_lines" \
2023 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2024 all_files=`func_get_filelist $1`
2025 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2026 # Remove $already_mentioned_files from $lib_files.
2027 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2028 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2029 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2030 if test -n "$extra_files"; then
2031 echo "EXTRA_DIST +=" $extra_files
2034 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2035 # This is necessary so that automake can generate the right list of
2037 # A possible approach would be to use autom4te --trace of the redefined
2038 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2039 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2040 # inside autoconf's built-in macros are not missed).
2041 # But it's simpler and more robust to do it here, based on the file list.
2042 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2043 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2044 # automake will generate a useless dependency; this is harmless.
2046 relocatable-prog-wrapper) ;;
2048 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2049 if test -n "$extra_files"; then
2050 echo "EXTRA_lib_SOURCES +=" $extra_files
2055 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2056 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2057 if test -n "$buildaux_files"; then
2058 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2059 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2062 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2063 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2064 if test -n "$top_files"; then
2065 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2066 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2073 # func_get_include_directive module
2075 # - local_gnulib_dir from --local-dir
2076 # - modcache true or false, from --cache-modules/--no-cache-modules
2077 func_get_include_directive ()
2080 if ! $modcache; then
2081 func_lookup_file "modules/$1"
2082 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2084 func_cache_lookup_module "$1"
2085 # Output the field's value, including the final newline (if any).
2086 if $have_associative; then
2087 if test -n "${modcache_include[$1]+set}"; then
2088 echo "${modcache_include[$1]}"
2091 eval "field_set=\"\$${cachevar}_include_set\""
2092 if test -n "$field_set"; then
2093 eval "field_value=\"\$${cachevar}_include\""
2094 echo "${field_value}"
2098 } | sed -e 's/^\(["<]\)/#include \1/'
2101 # func_get_link_directive module
2103 # - local_gnulib_dir from --local-dir
2104 # - modcache true or false, from --cache-modules/--no-cache-modules
2105 func_get_link_directive ()
2107 if ! $modcache; then
2108 func_lookup_file "modules/$1"
2109 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2111 func_cache_lookup_module "$1"
2112 # Output the field's value, including the final newline (if any).
2113 if $have_associative; then
2114 if test -n "${modcache_link[$1]+set}"; then
2115 echo "${modcache_link[$1]}"
2118 eval "field_set=\"\$${cachevar}_link_set\""
2119 if test -n "$field_set"; then
2120 eval "field_value=\"\$${cachevar}_link\""
2121 echo "${field_value}"
2127 # func_get_license module
2129 # - local_gnulib_dir from --local-dir
2130 # - modcache true or false, from --cache-modules/--no-cache-modules
2134 if ! $modcache; then
2135 func_lookup_file "modules/$1"
2136 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2138 func_cache_lookup_module "$1"
2139 # Output the field's value, including the final newline (if any).
2140 if $have_associative; then
2141 if test -n "${modcache_license[$1]+set}"; then
2142 echo "${modcache_license[$1]}"
2145 eval "field_set=\"\$${cachevar}_license_set\""
2146 if test -n "$field_set"; then
2147 eval "field_value=\"\$${cachevar}_license\""
2148 echo "${field_value}"
2152 # The default is GPL.
2154 } | sed -e 's,^ *$,,' | sed -e 1q
2157 # func_get_maintainer module
2159 # - local_gnulib_dir from --local-dir
2160 # - modcache true or false, from --cache-modules/--no-cache-modules
2161 func_get_maintainer ()
2163 if ! $modcache; then
2164 func_lookup_file "modules/$1"
2165 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2167 func_cache_lookup_module "$1"
2168 # Output the field's value, including the final newline (if any).
2169 if $have_associative; then
2170 if test -n "${modcache_maintainer[$1]+set}"; then
2171 echo "${modcache_maintainer[$1]}"
2174 eval "field_set=\"\$${cachevar}_maintainer_set\""
2175 if test -n "$field_set"; then
2176 eval "field_value=\"\$${cachevar}_maintainer\""
2177 echo "${field_value}"
2183 # func_get_tests_module module
2185 # - local_gnulib_dir from --local-dir
2186 func_get_tests_module ()
2188 # The naming convention for tests modules is hardwired: ${module}-tests.
2189 if test -f "$gnulib_dir/modules/$1"-tests \
2190 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2191 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2196 # func_acceptable module
2197 # tests whether a module is acceptable.
2199 # - avoidlist list of modules to avoid
2202 for avoid in $avoidlist; do
2203 if test "$avoid" = "$1"; then
2210 # func_modules_transitive_closure
2212 # - local_gnulib_dir from --local-dir
2213 # - modcache true or false, from --cache-modules/--no-cache-modules
2214 # - modules list of specified modules
2215 # - inctests true if tests should be included, blank otherwise
2216 # - incobsolete true if obsolete modules among dependencies should be
2217 # included, blank otherwise
2218 # - avoidlist list of modules to avoid
2219 # - tmp pathname of a temporary directory
2221 # - modules list of modules, including dependencies
2222 func_modules_transitive_closure ()
2224 # In order to process every module only once (for speed), process an "input
2225 # list" of modules, producing an "output list" of modules. During each round,
2226 # more modules can be queued in the input list. Once a module on the input
2227 # list has been processed, it is added to the "handled list", so we can avoid
2228 # to process it again.
2230 inmodules="$modules"
2232 while test -n "$inmodules"; do
2233 inmodules_this_round="$inmodules"
2234 inmodules= # Accumulator, queue for next round
2235 for module in $inmodules_this_round; do
2237 if test -n "$module"; then
2238 if func_acceptable $module; then
2239 func_append outmodules " $module"
2240 deps=`func_get_dependencies $module`
2241 # Duplicate dependencies are harmless, but Jim wants a warning.
2242 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2243 if test -n "$duplicated_deps"; then
2244 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2246 for dep in $deps; do
2247 if test -n "$incobsolete" \
2248 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
2249 func_append inmodules " $dep"
2252 if test -n "$inctests"; then
2253 testsmodule=`func_get_tests_module $module`
2254 if test -n "$testsmodule"; then
2255 func_append inmodules " $testsmodule"
2261 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2262 # Remove $handledmodules from $inmodules.
2263 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2264 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2266 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2267 rm -f "$tmp"/queued-modules
2270 # func_modules_add_dummy
2272 # - local_gnulib_dir from --local-dir
2273 # - modcache true or false, from --cache-modules/--no-cache-modules
2274 # - modules list of modules, including dependencies
2276 # - modules list of modules, including 'dummy' if needed
2277 func_modules_add_dummy ()
2279 # Determine whether any module provides a lib_SOURCES augmentation.
2281 sed_remove_backslash_newline=':a
2288 for module in $modules; do
2289 func_verify_nontests_module
2290 if test -n "$module"; then
2291 # Extract the value of "lib_SOURCES += ...".
2292 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2293 # Ignore .h files since they are not compiled.
2297 have_lib_SOURCES=yes
2304 # Add the dummy module, to make sure the library will be non-empty.
2305 if test -z "$have_lib_SOURCES"; then
2306 if func_acceptable "dummy"; then
2307 func_append modules " dummy"
2312 # func_modules_notice
2314 # - local_gnulib_dir from --local-dir
2315 # - modcache true or false, from --cache-modules/--no-cache-modules
2316 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2317 # - modules list of modules, including dependencies
2318 func_modules_notice ()
2320 if test $verbose -ge -1; then
2321 for module in $modules; do
2323 if test -n "$module"; then
2324 msg=`func_get_notice $module`
2325 if test -n "$msg"; then
2326 echo "Notice from module $module:"
2327 echo "$msg" | sed -e 's/^/ /'
2334 # func_modules_to_filelist
2336 # - local_gnulib_dir from --local-dir
2337 # - modcache true or false, from --cache-modules/--no-cache-modules
2338 # - modules list of modules, including dependencies
2340 # - files list of files
2341 func_modules_to_filelist ()
2344 for module in $modules; do
2346 if test -n "$module"; then
2347 fs=`func_get_filelist $module`
2348 func_append files " $fs"
2351 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2354 # func_execute_command command [args...]
2355 # Executes a command.
2356 # Uses also the variables
2357 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2358 func_execute_command ()
2360 if test $verbose -ge 0; then
2364 # Commands like automake produce output to stderr even when they succeed.
2365 # Turn this output off if the command succeeds.
2366 "$@" > "$tmp"/cmdout 2>&1
2368 if test $cmdret = 0; then
2372 cat "$tmp"/cmdout 1>&2
2379 # func_dest_tmpfilename file
2380 # determines the name of a temporary file (file is relative to destdir).
2382 # - destdir target directory
2383 # - doit : if actions shall be executed, false if only to be printed
2384 # - tmp pathname of a temporary directory
2386 # - tmpfile absolute filename of the temporary file
2387 func_dest_tmpfilename ()
2390 # Put the new contents of $file in a file in the same directory (needed
2391 # to guarantee that an 'mv' to "$destdir/$file" works).
2392 tmpfile="$destdir/$1.tmp"
2394 # Put the new contents of $file in a file in a temporary directory
2395 # (because the directory of "$file" might not exist).
2396 tmpfile="$tmp"/`basename "$1"`.tmp
2401 # copies a file from gnulib into the destination directory. The destination
2402 # is known to not exist.
2404 # - destdir target directory
2405 # - local_gnulib_dir from --local-dir
2406 # - modcache true or false, from --cache-modules/--no-cache-modules
2407 # - f the original file name
2408 # - lookedup_file name of the merged (combined) file
2409 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2410 # - g the rewritten file name
2411 # - tmpfile absolute filename of the temporary file
2412 # - doit : if actions shall be executed, false if only to be printed
2413 # - symbolic true if files should be symlinked, copied otherwise
2414 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2419 echo "Copying file $g"
2420 if { test -n "$symbolic" \
2421 || { test -n "$lsymbolic" \
2422 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2423 && test -z "$lookedup_tmp" \
2424 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2425 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2427 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2435 # copies a file from gnulib into the destination directory. The destination
2436 # is known to exist.
2438 # - destdir target directory
2439 # - local_gnulib_dir from --local-dir
2440 # - modcache true or false, from --cache-modules/--no-cache-modules
2441 # - f the original file name
2442 # - lookedup_file name of the merged (combined) file
2443 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2444 # - g the rewritten file name
2445 # - tmpfile absolute filename of the temporary file
2446 # - doit : if actions shall be executed, false if only to be printed
2447 # - symbolic true if files should be symlinked, copied otherwise
2448 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2450 # - already_present nonempty if the file should already exist, empty otherwise
2453 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2454 : # The file has not changed.
2458 if test -n "$already_present"; then
2459 echo "Updating file $g (backup in ${g}~)"
2461 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2463 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2464 if { test -n "$symbolic" \
2465 || { test -n "$lsymbolic" \
2466 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2467 && test -z "$lookedup_tmp" \
2468 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2469 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2471 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2474 if test -n "$already_present"; then
2475 echo "Update file $g (backup in ${g}~)"
2477 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2483 # func_emit_lib_Makefile_am
2484 # emits the contents of library makefile to standard output.
2486 # - local_gnulib_dir from --local-dir
2487 # - modcache true or false, from --cache-modules/--no-cache-modules
2488 # - modules list of modules, including dependencies
2489 # - libname library name
2490 # - pobase directory relative to destdir where to place *.po files
2491 # - auxdir directory relative to destdir where to place build aux files
2492 # - makefile_name from --makefile-name
2493 # - libtool true if libtool will be used, false or blank otherwise
2494 # - macro_prefix prefix of gl_LIBOBJS macros to use
2495 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2496 # - actioncmd (optional) command that will reproduce this invocation
2497 # - for_test true if creating a package for testing, false otherwise
2498 # - destfile filename relative to destdir of makefile being generated
2500 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2501 # list of edits to be done to Makefile.am variables
2503 # - uses_subdirs nonempty if object files in subdirs exist
2504 func_emit_lib_Makefile_am ()
2506 # When creating an includable Makefile.am snippet, augment variables with
2507 # += instead of assigning them.
2508 if test -n "$makefile_name"; then
2513 if test "$libtool" = true; then
2516 sed_eliminate_LDFLAGS="$sed_noop"
2520 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2523 # When creating a package for testing: Attempt to provoke failures,
2524 # especially link errors, already during "make" rather than during
2525 # "make check", because "make check" is not possible in a cross-compiling
2526 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2527 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2529 sed_transform_check_PROGRAMS="$sed_noop"
2531 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2532 echo "## Process this file with automake to produce Makefile.in."
2533 func_emit_copyright_notice
2534 if test -n "$actioncmd"; then
2535 # The maximum line length (excluding the terminating newline) of any file
2536 # that is to be preprocessed by config.status is 3070. config.status uses
2537 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2538 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2539 len=`echo "$actioncmd" | wc -c`
2540 if test -n "$len" && test "$len" -le 3000; then
2541 echo "# Reproduce by: $actioncmd"
2547 for module in $modules; do
2548 func_verify_nontests_module
2549 if test -n "$module"; then
2551 func_get_automake_snippet "$module" |
2552 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2553 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2554 -e "$sed_eliminate_LDFLAGS" \
2555 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2556 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2557 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2558 -e "$sed_transform_check_PROGRAMS"
2559 if test "$module" = 'alloca'; then
2560 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2561 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2563 } > "$tmp"/amsnippet
2564 # Skip the contents if it's entirely empty.
2565 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2566 echo "## begin gnulib module $module"
2568 cat "$tmp"/amsnippet
2569 echo "## end gnulib module $module"
2572 rm -f "$tmp"/amsnippet
2573 # Test whether there are some source files in subdirectories.
2574 for f in `func_get_filelist "$module"`; do
2584 } > "$tmp"/allsnippets
2585 if test -z "$makefile_name"; then
2586 # If there are source files in subdirectories, prevent collision of the
2587 # object files (example: hash.c and libxml/hash.c).
2589 if test -n "$uses_subdirs"; then
2590 subdir_options=' subdir-objects'
2592 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2595 if test -z "$makefile_name"; then
2597 echo "noinst_HEADERS ="
2598 echo "noinst_LIBRARIES ="
2599 echo "noinst_LTLIBRARIES ="
2600 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2601 # if you specify pkgdata_DATA to empty. This is a workaround.
2602 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2603 echo "pkgdata_DATA ="
2606 echo "BUILT_SOURCES ="
2609 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2610 if test -z "$makefile_name"; then
2611 echo "MOSTLYCLEANDIRS ="
2613 echo "DISTCLEANFILES ="
2614 echo "MAINTAINERCLEANFILES ="
2616 # Execute edits that apply to the Makefile.am being generated.
2618 while test $edit != $makefile_am_edits; do
2619 edit=`expr $edit + 1`
2620 eval dir=\"\$makefile_am_edit${edit}_dir\"
2621 eval var=\"\$makefile_am_edit${edit}_var\"
2622 eval val=\"\$makefile_am_edit${edit}_val\"
2623 if test -n "$var"; then
2624 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2625 echo "${var} += ${val}"
2626 eval "makefile_am_edit${edit}_var="
2630 if test -z "$makefile_name"; then
2632 echo "AM_CPPFLAGS ="
2636 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2637 || { test -n "$makefile_name" \
2638 && test -f "$sourcebase/Makefile.am" \
2639 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2641 # One of the snippets or the user's Makefile.am already specifies an
2642 # installation location for the library. Don't confuse automake by saying
2643 # it should not be installed.
2646 # By default, the generated library should not be installed.
2647 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2650 echo "${libname}_${libext}_SOURCES ="
2651 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2652 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2653 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2654 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2655 echo "EXTRA_${libname}_${libext}_SOURCES ="
2656 if test "$libtool" = true; then
2657 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2660 if test -n "$pobase"; then
2661 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2664 cat "$tmp"/allsnippets \
2665 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2667 echo "mostlyclean-local: mostlyclean-generic"
2668 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2669 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2670 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2674 rm -f "$tmp"/allsnippets
2677 # func_emit_po_Makevars
2678 # emits the contents of po/ makefile parameterization to standard output.
2680 # - local_gnulib_dir from --local-dir
2681 # - modcache true or false, from --cache-modules/--no-cache-modules
2682 # - sourcebase directory relative to destdir where to place source code
2683 # - pobase directory relative to destdir where to place *.po files
2684 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2685 func_emit_po_Makevars ()
2687 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2688 func_emit_copyright_notice
2690 echo "# Usually the message domain is the same as the package name."
2691 echo "# But here it has a '-gnulib' suffix."
2692 echo "DOMAIN = ${po_domain}-gnulib"
2694 echo "# These two variables depend on the location of this directory."
2695 echo "subdir = ${pobase}"
2696 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2699 # These options get passed to xgettext.
2700 XGETTEXT_OPTIONS = \
2701 --keyword=_ --flag=_:1:pass-c-format \
2702 --keyword=N_ --flag=N_:1:pass-c-format \
2703 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2704 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2705 --flag=error:3:c-format --flag=error_at_line:5:c-format
2707 # This is the copyright holder that gets inserted into the header of the
2708 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2709 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2711 # This is the email address or URL to which the translators shall report
2712 # bugs in the untranslated strings:
2713 # - Strings which are not entire sentences, see the maintainer guidelines
2714 # in the GNU gettext documentation, section 'Preparing Strings'.
2715 # - Strings which use unclear terms or require additional context to be
2717 # - Strings which make invalid assumptions about notation of date, time or
2719 # - Pluralisation problems.
2720 # - Incorrect English spelling.
2721 # - Incorrect formatting.
2722 # It can be your email address, or a mailing list address where translators
2723 # can write to without being subscribed, or the URL of a web page through
2724 # which the translators can contact you.
2725 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2727 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2728 # message catalogs shall be used. It is usually empty.
2729 EXTRA_LOCALE_CATEGORIES =
2731 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2732 # context. Possible values are "yes" and "no". Set this to yes if the
2733 # package uses functions taking also a message context, like pgettext(), or
2734 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2739 # func_emit_po_POTFILES_in
2740 # emits the file list to be passed to xgettext to standard output.
2742 # - local_gnulib_dir from --local-dir
2743 # - modcache true or false, from --cache-modules/--no-cache-modules
2744 # - sourcebase directory relative to destdir where to place source code
2745 # - files list of new files
2746 func_emit_po_POTFILES_in ()
2748 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2749 func_emit_copyright_notice
2751 echo "# List of files which contain translatable strings."
2752 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2755 # func_emit_tests_Makefile_am
2756 # emits the contents of tests makefile to standard output.
2758 # - local_gnulib_dir from --local-dir
2759 # - modcache true or false, from --cache-modules/--no-cache-modules
2760 # - modules list of modules, including dependencies
2761 # - libname library name
2762 # - auxdir directory relative to destdir where to place build aux files
2763 # - makefile_name from --makefile-name
2764 # - libtool true if libtool will be used, false or blank otherwise
2765 # - sourcebase relative directory containing lib source code
2766 # - m4base relative directory containing autoconf macros
2767 # - testsbase relative directory containing unit test code
2768 # - macro_prefix prefix of gl_LIBOBJS macros to use
2769 # - for_test true if creating a package for testing, false otherwise
2770 # - use_libtests true if a libtests.a should be built, false otherwise
2771 # - destfile filename relative to destdir of makefile being generated
2773 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2774 # list of edits to be done to Makefile.am variables
2776 # - uses_subdirs nonempty if object files in subdirs exist
2777 func_emit_tests_Makefile_am ()
2779 if test "$libtool" = true; then
2781 sed_eliminate_LDFLAGS="$sed_noop"
2784 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2787 # When creating a package for testing: Attempt to provoke failures,
2788 # especially link errors, already during "make" rather than during
2789 # "make check", because "make check" is not possible in a cross-compiling
2790 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2791 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2793 sed_transform_check_PROGRAMS="$sed_noop"
2795 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2796 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2797 echo "## Process this file with automake to produce Makefile.in."
2798 func_emit_copyright_notice
2802 for module in $modules; do
2804 func_verify_tests_module
2808 if test -n "$module"; then
2810 func_get_automake_snippet "$module" |
2811 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2812 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2813 -e "$sed_eliminate_LDFLAGS" \
2814 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2815 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2816 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2817 -e "$sed_transform_check_PROGRAMS"
2818 if $use_libtests && test "$module" = 'alloca'; then
2819 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2820 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2822 } > "$tmp"/amsnippet
2823 # Skip the contents if it's entirely empty.
2824 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2825 echo "## begin gnulib module $module"
2827 cat "$tmp"/amsnippet
2828 echo "## end gnulib module $module"
2831 rm -f "$tmp"/amsnippet
2832 # Test whether there are some source files in subdirectories.
2833 for f in `func_get_filelist "$module"`; do
2835 lib/*/*.c | tests/*/*.c)
2843 } > "$tmp"/allsnippets
2844 # Generate dependencies here, since it eases the debugging of test failures.
2845 # If there are source files in subdirectories, prevent collision of the
2846 # object files (example: hash.c and libxml/hash.c).
2848 if test -n "$uses_subdirs"; then
2849 subdir_options=' subdir-objects'
2851 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2854 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2857 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2858 # variable is needed to avoid an error from automake:
2859 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2862 echo "XFAIL_TESTS ="
2863 echo "TESTS_ENVIRONMENT ="
2864 echo "noinst_PROGRAMS ="
2865 if ! $for_test; then
2866 echo "check_PROGRAMS ="
2868 echo "noinst_HEADERS ="
2869 echo "noinst_LIBRARIES ="
2870 if $use_libtests; then
2872 echo "noinst_LIBRARIES += libtests.a"
2874 echo "check_LIBRARIES = libtests.a"
2877 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2878 # if you specify pkgdata_DATA to empty. This is a workaround.
2879 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2880 echo "pkgdata_DATA ="
2883 echo "BUILT_SOURCES ="
2885 echo "MOSTLYCLEANFILES = core *.stackdump"
2886 echo "MOSTLYCLEANDIRS ="
2888 echo "DISTCLEANFILES ="
2889 echo "MAINTAINERCLEANFILES ="
2890 # Execute edits that apply to the Makefile.am being generated.
2892 while test $edit != $makefile_am_edits; do
2893 edit=`expr $edit + 1`
2894 eval dir=\"\$makefile_am_edit${edit}_dir\"
2895 eval var=\"\$makefile_am_edit${edit}_var\"
2896 eval val=\"\$makefile_am_edit${edit}_val\"
2897 if test -n "$var"; then
2898 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2899 echo "${var} += ${val}"
2900 eval "makefile_am_edit${edit}_var="
2905 echo "AM_CPPFLAGS = \\"
2906 echo " -I. -I\$(srcdir) \\"
2907 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2908 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2910 local_ldadd_before=''
2911 local_ldadd_after=''
2912 if $use_libtests; then
2913 # All test programs need to be linked with libtests.a.
2914 # It needs to be passed to the linker before ${libname}.${libext}, since
2915 # the tests-related modules depend on the main modules.
2916 # It also needs to be passed to the linker after ${libname}.${libext}
2917 # because the latter might contain incomplete modules (such as the 'error'
2918 # module whose dependency to 'progname' is voluntarily omitted).
2919 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2921 local_ldadd_before=' libtests.a'
2922 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2924 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2926 if $use_libtests; then
2927 echo "libtests_a_SOURCES ="
2928 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2929 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2930 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2931 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2932 echo "EXTRA_libtests_a_SOURCES ="
2933 # The circular dependency in LDADD requires this.
2934 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2937 # Many test scripts use ${EXEEXT} or ${srcdir}.
2938 # EXEEXT is defined by AC_PROG_CC through autoconf.
2939 # srcdir is defined by autoconf and automake.
2940 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
2942 cat "$tmp"/allsnippets \
2943 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2944 echo "# Clean up after Solaris cc."
2946 echo " rm -rf SunWS_cache"
2948 echo "mostlyclean-local: mostlyclean-generic"
2949 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2950 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2951 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2955 rm -f "$tmp"/allsnippets
2958 # func_emit_initmacro_start macro_prefix
2959 # emits the first few statements of the gl_INIT macro to standard output.
2960 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2961 func_emit_initmacro_start ()
2963 macro_prefix_arg="$1"
2964 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2965 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2966 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2967 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2969 # Furthermore it avoids an automake error like this when a Makefile.am
2970 # that uses pieces of gnulib also uses $(LIBOBJ):
2971 # automatically discovered file `error.c' should not be explicitly mentioned
2972 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2973 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2974 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2975 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2976 # automatically discovered file `error.c' should not be explicitly mentioned
2977 # We let automake know about the files to be distributed through the
2978 # EXTRA_lib_SOURCES variable.
2979 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2980 # Create data variables for checking the presence of files that are mentioned
2981 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2982 # because we want the check to happen when the configure file is created,
2983 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2984 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2985 # in which to expect them.
2986 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2987 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2991 # func_emit_initmacro_end macro_prefix
2992 # emits the last few statements of the gl_INIT macro to standard output.
2993 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2994 func_emit_initmacro_end ()
2996 macro_prefix_arg="$1"
2997 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2998 # The check is performed only when autoconf is run from the directory where
2999 # the configure.ac resides; if it is run from a different directory, the
3001 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3002 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3003 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3004 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3005 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3009 echo " m4_if(m4_sysval, [0], [],"
3010 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3012 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3013 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3014 echo " m4_popdef([AC_LIBSOURCES])"
3015 echo " m4_popdef([AC_REPLACE_FUNCS])"
3016 echo " m4_popdef([AC_LIBOBJ])"
3017 echo " AC_CONFIG_COMMANDS_PRE(["
3018 echo " ${macro_prefix_arg}_libobjs="
3019 echo " ${macro_prefix_arg}_ltlibobjs="
3020 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3021 echo " # Remove the extension."
3022 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3023 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3024 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3025 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3028 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3029 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3033 # func_emit_initmacro_done macro_prefix sourcebase
3034 # emits a few statements after the gl_INIT macro to standard output.
3035 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3036 # - sourcebase directory relative to destdir where to place source code
3037 func_emit_initmacro_done ()
3039 macro_prefix_arg="$1"
3042 echo "# Like AC_LIBOBJ, except that the module name goes"
3043 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3044 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3045 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3046 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3049 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3050 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3051 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3052 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3053 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3056 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3057 echo "# expected is derived from the gnulib-tool parameterization,"
3058 echo "# and alloca is special cased (for the alloca-opt module)."
3059 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3060 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3061 echo " m4_foreach([_gl_NAME], [\$1], ["
3062 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3063 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3064 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3070 # func_import modules
3071 # Uses also the variables
3072 # - destdir target directory
3073 # - local_gnulib_dir from --local-dir
3074 # - modcache true or false, from --cache-modules/--no-cache-modules
3075 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3076 # - libname library name
3077 # - sourcebase directory relative to destdir where to place source code
3078 # - m4base directory relative to destdir where to place *.m4 macros
3079 # - pobase directory relative to destdir where to place *.po files
3080 # - docbase directory relative to destdir where to place doc files
3081 # - testsbase directory relative to destdir where to place unit test code
3082 # - auxdir directory relative to destdir where to place build aux files
3083 # - inctests true if --with-tests was given, blank otherwise
3084 # - incobsolete true if --with-obsolete was given, blank otherwise
3085 # - avoidlist list of modules to avoid, from --avoid
3086 # - lgpl yes or a number if library's license shall be LGPL,
3088 # - makefile_name from --makefile-name
3089 # - libtool true if --libtool was given, false if --no-libtool was
3090 # given, blank otherwise
3091 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3092 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3093 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3094 # - vc_files true if --vc-files was given, false if --no-vc-files was
3095 # given, blank otherwise
3096 # - autoconf_minversion minimum supported autoconf version
3097 # - doit : if actions shall be executed, false if only to be printed
3098 # - symbolic true if files should be symlinked, copied otherwise
3099 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3101 # - do_copyrights true if copyright notices in files should be replaced,
3105 # Get the cached settings.
3106 cached_local_gnulib_dir=
3107 cached_specified_modules=
3118 cached_makefile_name=
3120 cached_macro_prefix=
3124 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3125 cached_libtool=false
3131 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3141 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3143 /gl_WITH_OBSOLETE/ {
3144 s,^.*$,cached_incobsolete=true,p
3147 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3150 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3153 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3156 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3159 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3162 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3165 s,^.*$,cached_inctests=true,p
3168 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3171 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3174 s,^.*$,cached_lgpl=yes,p
3176 /gl_MAKEFILE_NAME(/ {
3177 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3180 s,^.*$,cached_libtool=true,p
3182 /gl_MACRO_PREFIX(/ {
3183 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3186 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3189 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3191 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3192 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3197 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3198 s,^.*$,cached_files=",p
3211 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3215 # Merge the cached settings with the specified ones.
3216 # The m4base must be the same as expected from the pathname.
3217 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3218 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3220 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3221 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3222 if test -z "$local_gnulib_dir"; then
3223 if test -n "$cached_local_gnulib_dir"; then
3226 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3228 case "$cached_local_gnulib_dir" in
3230 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3232 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3233 local_gnulib_dir="$relconcat" ;;
3238 # Append the cached and the specified module names. So that
3239 # "gnulib-tool --import foo" means to add the module foo.
3240 specified_modules="$cached_specified_modules $1"
3241 # Included obsolete modules among the dependencies if specified either way.
3242 if test -z "$incobsolete"; then
3243 incobsolete="$cached_incobsolete"
3245 # Append the cached and the specified avoidlist. This is probably better
3246 # than dropping the cached one when --avoid is specified at least once.
3247 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3248 avoidlist=`echo $avoidlist`
3250 # The sourcebase defaults to the cached one.
3251 if test -z "$sourcebase"; then
3252 sourcebase="$cached_sourcebase"
3253 if test -z "$sourcebase"; then
3254 func_fatal_error "missing --source-base option"
3257 # The pobase defaults to the cached one.
3258 if test -z "$pobase"; then
3259 pobase="$cached_pobase"
3261 # The docbase defaults to the cached one.
3262 if test -z "$docbase"; then
3263 docbase="$cached_docbase"
3264 if test -z "$docbase"; then
3265 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."
3268 # The testsbase defaults to the cached one.
3269 if test -z "$testsbase"; then
3270 testsbase="$cached_testsbase"
3271 if test -z "$testsbase"; then
3272 func_fatal_error "missing --tests-base option"
3275 # Require the tests if specified either way.
3276 if test -z "$inctests"; then
3277 inctests="$cached_inctests"
3279 # The libname defaults to the cached one.
3280 if test -z "$supplied_libname"; then
3281 libname="$cached_libname"
3282 if test -z "$libname"; then
3283 func_fatal_error "missing --lib option"
3286 # Require LGPL if specified either way.
3287 if test -z "$lgpl"; then
3290 # The makefile_name defaults to the cached one.
3291 if test -z "$makefile_name"; then
3292 makefile_name="$cached_makefile_name"
3294 # Use libtool if specified either way, or if guessed.
3295 if test -z "$libtool"; then
3296 if test -n "$cached_m4base"; then
3297 libtool="$cached_libtool"
3299 libtool="$guessed_libtool"
3302 # The macro_prefix defaults to the cached one.
3303 if test -z "$macro_prefix"; then
3304 macro_prefix="$cached_macro_prefix"
3305 if test -z "$macro_prefix"; then
3306 func_fatal_error "missing --macro-prefix option"
3309 # The po_domain defaults to the cached one.
3310 if test -z "$po_domain"; then
3311 po_domain="$cached_po_domain"
3313 # The vc_files defaults to the cached one.
3314 if test -z "$vc_files"; then
3315 vc_files="$cached_vc_files"
3318 # Canonicalize the list of specified modules.
3319 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3321 # Determine final module list.
3322 modules="$specified_modules"
3323 func_modules_transitive_closure
3324 if test $verbose -ge 0; then
3325 echo "Module list with included dependencies:"
3326 echo "$modules" | sed -e 's/^/ /'
3328 final_modules="$modules"
3330 # Determine main module list and tests-related module list separately.
3331 # The main module list is the transitive closure of the specified modules,
3332 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3333 # is specified, it will consist only of LGPLed source.
3334 # The tests-related module list is the transitive closure of the specified
3335 # modules, including tests modules, minus the main module list excluding
3336 # modules of applicability 'all'. Its lib/* sources (brought in through
3337 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3338 # source, even if --lgpl is specified.
3339 # Determine main module list.
3340 saved_inctests="$inctests"
3342 modules="$specified_modules"
3343 func_modules_transitive_closure
3344 main_modules="$modules"
3345 inctests="$saved_inctests"
3346 if test $verbose -ge 1; then
3347 echo "Main module list:"
3348 echo "$main_modules" | sed -e 's/^/ /'
3350 # Determine tests-related module list.
3351 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3352 testsrelated_modules=`for module in $main_modules; do
3353 if test \`func_get_applicability $module\` = main; then
3357 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3358 if test $verbose -ge 1; then
3359 echo "Tests-related module list:"
3360 echo "$testsrelated_modules" | sed -e 's/^/ /'
3363 # Add the dummy module to the main module list if needed.
3364 modules="$main_modules"
3365 func_modules_add_dummy
3366 main_modules="$modules"
3368 # Determine whether a $testsbase/libtests.a is needed.
3370 for module in $testsrelated_modules; do
3371 func_verify_nontests_module
3372 if test -n "$module"; then
3373 all_files=`func_get_filelist $module`
3374 # Test whether some file in $all_files lies in lib/.
3375 for f in $all_files; do
3386 # Add the dummy module to the tests-related module list if needed.
3387 if $use_libtests; then
3388 modules="$testsrelated_modules"
3389 func_modules_add_dummy
3390 testsrelated_modules="$modules"
3393 # If --lgpl, verify that the licenses of modules are compatible.
3394 if test -n "$lgpl"; then
3395 license_incompatibilities=
3396 for module in $main_modules; do
3397 license=`func_get_license $module`
3399 'GPLed build tool') ;;
3400 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3405 LGPL | LGPLv2+ | LGPLv3+) ;;
3406 *) func_append license_incompatibilities "$module $license$nl" ;;
3412 *) func_append license_incompatibilities "$module $license$nl" ;;
3415 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3420 if test -n "$license_incompatibilities"; then
3421 # Format the license incompatibilities as a table.
3422 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3423 s,^\(.................................................[^ ]*\) *, \1 ,'
3424 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3425 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3429 # Show banner notice of every module.
3430 modules="$main_modules"
3433 # Determine script to apply to imported library files.
3434 sed_transform_lib_file=
3435 for module in $main_modules; do
3436 if test $module = config-h; then
3437 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3438 sed_transform_lib_file=$sed_transform_lib_file'
3439 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3444 sed_transform_main_lib_file="$sed_transform_lib_file"
3445 if test -n "$do_copyrights"; then
3446 if test -n "$lgpl"; then
3450 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3451 s/GNU General/GNU Lesser General/g
3455 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3456 s/GNU General/GNU Lesser General/g
3457 s/version [23]\([ ,]\)/version 2.1\1/g
3460 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3464 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3465 s/GNU Lesser General/GNU General/g
3466 s/GNU Library General/GNU General/g
3467 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3472 # Determine script to apply to auxiliary files that go into $auxdir/.
3473 sed_transform_build_aux_file=
3474 if test -n "$do_copyrights"; then
3476 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3477 s/GNU Lesser General/GNU General/g
3478 s/GNU Library General/GNU General/g
3479 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3483 # Determine script to apply to library files that go into $testsbase/.
3484 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3485 if test -n "$do_copyrights"; then
3487 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3488 s/GNU Lesser General/GNU General/g
3489 s/GNU Library General/GNU General/g
3490 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3494 # Determine the final file lists.
3495 # They must be computed separately, because files in lib/* go into
3496 # $sourcebase/ if they are in the main file list but into $testsbase/
3497 # if they are in the tests-related file list. Furthermore lib/dummy.c
3499 # Determine final main file list.
3500 modules="$main_modules"
3501 func_modules_to_filelist
3503 # Determine final tests-related file list.
3504 modules="$testsrelated_modules"
3505 func_modules_to_filelist
3506 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3507 # Merge both file lists.
3508 sed_remove_empty_lines='/^$/d'
3509 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3510 if test $verbose -ge 0; then
3512 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3513 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3517 || func_fatal_error "refusing to do nothing"
3519 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3520 new_files="$files m4/gnulib-tool.m4"
3521 old_files="$cached_files"
3522 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3523 func_append old_files " m4/gnulib-tool.m4"
3526 rewritten='%REWRITTEN%'
3527 sed_rewrite_old_files="\
3528 s,^build-aux/,$rewritten$auxdir/,
3529 s,^doc/,$rewritten$cached_docbase/,
3530 s,^lib/,$rewritten$cached_sourcebase/,
3531 s,^m4/,$rewritten$cached_m4base/,
3532 s,^tests/,$rewritten$cached_testsbase/,
3533 s,^tests=lib/,$rewritten$cached_testsbase/,
3536 sed_rewrite_new_files="\
3537 s,^build-aux/,$rewritten$auxdir/,
3538 s,^doc/,$rewritten$docbase/,
3539 s,^lib/,$rewritten$sourcebase/,
3540 s,^m4/,$rewritten$m4base/,
3541 s,^tests/,$rewritten$testsbase/,
3542 s,^tests=lib/,$rewritten$testsbase/,
3546 # Create directories.
3547 { echo "$sourcebase"
3549 if test -n "$pobase"; then
3552 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3553 if test -n "$docfiles"; then
3556 if test -n "$inctests"; then
3560 for f in $files; do echo $f; done \
3561 | sed -e "$sed_rewrite_new_files" \
3562 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3565 { # Rearrange file descriptors. Needed because "while ... done < ..."
3566 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3567 exec 5<&0 < "$tmp"/dirs
3569 if test ! -d "$destdir/$d"; then
3571 echo "Creating directory $destdir/$d"
3572 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3574 echo "Create directory $destdir/$d"
3581 # Copy files or make symbolic links. Remove obsolete files.
3585 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3586 # representing the files according to the last gnulib-tool invocation.
3587 for f in $old_files; do echo $f; done \
3588 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3591 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3592 # representing the files after this gnulib-tool invocation.
3593 for f in $new_files; do echo $f; done \
3594 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3597 # First the files that are in old-files, but not in new-files:
3598 sed_take_first_column='s,'"$delimiter"'.*,,'
3599 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3600 # Remove the file. Do nothing if the user already removed it.
3601 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3603 echo "Removing file $g (backup in ${g}~)"
3604 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3606 echo "Remove file $g (backup in ${g}~)"
3608 func_append removed_files "$g$nl"
3611 # func_add_or_update handles a file that ought to be present afterwards.
3613 # - f the original file name
3614 # - g the rewritten file name
3615 # - already_present nonempty if the file should already exist, empty
3617 func_add_or_update ()
3621 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3623 func_dest_tmpfilename "$g"
3624 func_lookup_file "$f"
3625 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3626 if test -n "$sed_transform_main_lib_file"; then
3629 sed -e "$sed_transform_main_lib_file" \
3630 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3634 if test -n "$sed_transform_build_aux_file"; then
3637 sed -e "$sed_transform_build_aux_file" \
3638 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3642 if test -n "$sed_transform_testsrelated_lib_file"; then
3645 sed -e "$sed_transform_testsrelated_lib_file" \
3646 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3650 if test -f "$destdir/$g"; then
3651 # The file already exists.
3655 # Don't protest if the file should be there but isn't: it happens
3656 # frequently that developers don't put autogenerated files into CVS.
3658 func_append added_files "$g$nl"
3662 # Then the files that are in new-files, but not in old-files:
3663 sed_take_last_column='s,^.*'"$delimiter"',,'
3665 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3666 | sed -e "$sed_take_last_column" \
3667 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3668 { # Rearrange file descriptors. Needed because "while ... done < ..."
3669 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3670 exec 5<&0 < "$tmp"/added-files
3676 # Then the files that are in new-files and in old-files:
3677 already_present=true
3678 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3679 | sed -e "$sed_take_last_column" \
3680 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3681 { # Rearrange file descriptors. Needed because "while ... done < ..."
3682 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3683 exec 5<&0 < "$tmp"/kept-files
3690 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3691 actioncmd="gnulib-tool --import"
3692 func_append actioncmd " --dir=$destdir"
3693 if test -n "$local_gnulib_dir"; then
3694 func_append actioncmd " --local-dir=$local_gnulib_dir"
3696 func_append actioncmd " --lib=$libname"
3697 func_append actioncmd " --source-base=$sourcebase"
3698 func_append actioncmd " --m4-base=$m4base"
3699 if test -n "$pobase"; then
3700 func_append actioncmd " --po-base=$pobase"
3702 func_append actioncmd " --doc-base=$docbase"
3703 func_append actioncmd " --tests-base=$testsbase"
3704 func_append actioncmd " --aux-dir=$auxdir"
3705 if test -n "$inctests"; then
3706 func_append actioncmd " --with-tests"
3708 if test -n "$incobsolete"; then
3709 func_append actioncmd " --with-obsolete"
3711 for module in $avoidlist; do
3712 func_append actioncmd " --avoid=$module"
3714 if test -n "$lgpl"; then
3715 if test "$lgpl" = yes; then
3716 func_append actioncmd " --lgpl"
3718 func_append actioncmd " --lgpl=$lgpl"
3721 if test -n "$makefile_name"; then
3722 func_append actioncmd " --makefile-name=$makefile_name"
3724 if test "$libtool" = true; then
3725 func_append actioncmd " --libtool"
3727 func_append actioncmd " --no-libtool"
3729 func_append actioncmd " --macro-prefix=$macro_prefix"
3730 if test -n "$po_domain"; then
3731 func_append actioncmd " --po-domain=$po_domain"
3733 if test -n "$vc_files"; then
3734 if test "$vc_files" = true; then
3735 func_append actioncmd " --vc-files"
3737 func_append actioncmd " --no-vc-files"
3740 func_append actioncmd " `echo $specified_modules`"
3742 # Default the makefile name to Makefile.am.
3743 if test -n "$makefile_name"; then
3744 makefile_am=$makefile_name
3746 makefile_am=Makefile.am
3749 # Create normal Makefile.ams.
3752 # Setup list of Makefile.am edits that are to be performed afterwards.
3753 # Some of these edits apply to files that we will generate; others are
3754 # under the responsibility of the developer.
3756 # func_note_Makefile_am_edit dir var value
3757 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3759 func_note_Makefile_am_edit ()
3761 makefile_am_edits=`expr $makefile_am_edits + 1`
3762 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3763 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3764 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3766 if test "$makefile_am" = Makefile.am; then
3767 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3768 sourcebase_base=`basename "$sourcebase"`
3769 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3771 if test -n "$pobase"; then
3772 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3773 pobase_base=`basename "$pobase"`
3774 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3776 if test -n "$inctests"; then
3777 if test "$makefile_am" = Makefile.am; then
3778 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3779 testsbase_base=`basename "$testsbase"`
3780 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3783 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3785 # Find the first parent directory of $m4base that contains or will contain
3787 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3789 sed_butlast='s,[^/][^/]*//*$,,'
3790 dir1="${m4base}/"; dir2=""
3791 while test -n "$dir1" \
3792 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3793 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3794 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3795 || { test -n "$inctests" \
3796 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3797 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3798 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3799 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3801 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3804 # Create library makefile.
3805 func_dest_tmpfilename $sourcebase/$makefile_am
3806 destfile="$sourcebase/$makefile_am"
3807 modules="$main_modules"
3808 func_emit_lib_Makefile_am > "$tmpfile"
3809 if test -f "$destdir"/$sourcebase/$makefile_am; then
3810 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3814 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3815 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3816 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3818 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3824 echo "Creating $sourcebase/$makefile_am"
3825 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3827 echo "Create $sourcebase/$makefile_am"
3830 func_append added_files "$sourcebase/$makefile_am$nl"
3833 # Create po/ directory.
3834 if test -n "$pobase"; then
3835 # Create po makefile and auxiliary files.
3836 for file in Makefile.in.in remove-potcdate.sin; do
3837 func_dest_tmpfilename $pobase/$file
3838 func_lookup_file build-aux/po/$file
3839 cat "$lookedup_file" > "$tmpfile"
3840 if test -f "$destdir"/$pobase/$file; then
3841 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3845 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3846 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3847 mv -f "$tmpfile" "$destdir"/$pobase/$file
3849 echo "Update $pobase/$file (backup in $pobase/$file~)"
3855 echo "Creating $pobase/$file"
3856 mv -f "$tmpfile" "$destdir"/$pobase/$file
3858 echo "Create $pobase/$file"
3861 func_append added_files "$pobase/$file$nl"
3864 # Create po makefile parameterization, part 1.
3865 func_dest_tmpfilename $pobase/Makevars
3866 func_emit_po_Makevars > "$tmpfile"
3867 if test -f "$destdir"/$pobase/Makevars; then
3868 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3872 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3873 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3874 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3876 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3882 echo "Creating $pobase/Makevars"
3883 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3885 echo "Create $pobase/Makevars"
3888 func_append added_files "$pobase/Makevars$nl"
3890 # Create po makefile parameterization, part 2.
3891 func_dest_tmpfilename $pobase/POTFILES.in
3892 func_emit_po_POTFILES_in > "$tmpfile"
3893 if test -f "$destdir"/$pobase/POTFILES.in; then
3894 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3898 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3899 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3900 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3902 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3908 echo "Creating $pobase/POTFILES.in"
3909 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3911 echo "Create $pobase/POTFILES.in"
3914 func_append added_files "$pobase/POTFILES.in$nl"
3917 TP_URL="http://translationproject.org/latest/"
3918 TP_RSYNC_URI="translationproject.org::tp/latest/"
3920 echo "Fetching gnulib PO files from $TP_URL"
3921 (cd "$destdir"/$pobase \
3922 && { # Prefer rsync over wget if it is available, since it consumes
3923 # less network bandwidth, due to compression.
3924 if type rsync 2>/dev/null | grep / > /dev/null; then
3925 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3927 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3932 echo "Fetch gnulib PO files from $TP_URL"
3934 # Create po/LINGUAS.
3936 func_dest_tmpfilename $pobase/LINGUAS
3937 (cd "$destdir"/$pobase \
3938 && { echo '# Set of available languages.'
3939 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3942 if test -f "$destdir"/$pobase/LINGUAS; then
3943 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3946 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3947 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3948 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3951 echo "Creating $pobase/LINGUAS"
3952 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3953 func_append added_files "$pobase/LINGUAS$nl"
3956 if test -f "$destdir"/$pobase/LINGUAS; then
3957 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3959 echo "Create $pobase/LINGUAS"
3964 # Create m4/gnulib-cache.m4.
3965 func_dest_tmpfilename $m4base/gnulib-cache.m4
3967 func_emit_copyright_notice
3969 echo "# This file represents the specification of how gnulib-tool is used."
3970 echo "# It acts as a cache: It is written and read by gnulib-tool."
3971 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3972 echo "# like the configure.ac and various Makefile.am files."
3975 echo "# Specification in the form of a command-line invocation:"
3978 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3979 # Store the local_gnulib_dir relative to destdir.
3980 case "$local_gnulib_dir" in
3982 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3985 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3987 # destdir, local_gnulib_dir are both relative.
3988 func_relativize "$destdir" "$local_gnulib_dir"
3989 relative_local_gnulib_dir="$reldir" ;;
3992 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3994 echo "$specified_modules" | sed -e 's/^/ /g'
3996 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3997 echo "gl_AVOID([$avoidlist])"
3998 echo "gl_SOURCE_BASE([$sourcebase])"
3999 echo "gl_M4_BASE([$m4base])"
4000 echo "gl_PO_BASE([$pobase])"
4001 echo "gl_DOC_BASE([$docbase])"
4002 echo "gl_TESTS_BASE([$testsbase])"
4003 test -z "$inctests" || echo "gl_WITH_TESTS"
4004 echo "gl_LIB([$libname])"
4005 if test -n "$lgpl"; then
4006 if test "$lgpl" = yes; then
4009 echo "gl_LGPL([$lgpl])"
4012 echo "gl_MAKEFILE_NAME([$makefile_name])"
4013 if test "$libtool" = true; then
4016 echo "gl_MACRO_PREFIX([$macro_prefix])"
4017 echo "gl_PO_DOMAIN([$po_domain])"
4018 if test -n "$vc_files"; then
4019 echo "gl_VC_FILES([$vc_files])"
4022 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4023 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4027 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4028 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4029 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4031 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4035 echo "# gnulib-cache.m4 ends here"
4042 echo "Creating $m4base/gnulib-cache.m4"
4043 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4045 echo "Create $m4base/gnulib-cache.m4"
4051 # Create m4/gnulib-comp.m4.
4052 func_dest_tmpfilename $m4base/gnulib-comp.m4
4054 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4055 func_emit_copyright_notice
4057 echo "# This file represents the compiled summary of the specification in"
4058 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4059 echo "# to be invoked from configure.ac."
4060 echo "# In projects using CVS, this file can be treated like other built files."
4063 echo "# This macro should be invoked from $configure_ac, in the section"
4064 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4065 echo "# any checks for libraries, header files, types and library functions."
4066 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4068 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4069 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4070 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4071 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4072 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4073 if test -n "$uses_subdirs"; then
4074 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4076 for module in $final_modules; do
4078 if test -n "$module"; then
4079 func_get_autoconf_early_snippet "$module"
4082 | sed -e '/^$/d;' -e 's/^/ /'
4085 echo "# This macro should be invoked from $configure_ac, in the section"
4086 echo "# \"Check for header files, types and library functions\"."
4087 echo "AC_DEFUN([${macro_prefix}_INIT],"
4089 if test "$libtool" = true; then
4090 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4091 echo " gl_cond_libtool=true"
4093 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4094 echo " gl_cond_libtool=false"
4096 echo " gl_ltlibdeps="
4098 if test "$auxdir" != "build-aux"; then
4099 sed_replace_build_aux='
4101 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4102 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4106 sed_replace_build_aux="$sed_noop"
4108 func_emit_initmacro_start $macro_prefix
4109 echo " gl_source_base='$sourcebase'"
4110 for module in $main_modules; do
4112 if test -n "$module"; then
4113 func_get_autoconf_snippet "$module" \
4114 | sed -e '/^$/d;' -e 's/^/ /' \
4115 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4116 -e "$sed_replace_build_aux"
4117 if test "$module" = 'alloca' && test "$libtool" = true; then
4118 echo 'changequote(,)dnl'
4119 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4120 echo 'changequote([, ])dnl'
4121 echo 'AC_SUBST([LTALLOCA])'
4125 func_emit_initmacro_end $macro_prefix
4126 echo " gltests_libdeps="
4127 echo " gltests_ltlibdeps="
4128 func_emit_initmacro_start ${macro_prefix}tests
4129 echo " gl_source_base='$testsbase'"
4130 for module in $testsrelated_modules; do
4132 if test -n "$module"; then
4133 func_get_autoconf_snippet "$module" \
4134 | sed -e '/^$/d;' -e 's/^/ /' \
4135 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4136 -e "$sed_replace_build_aux" \
4137 -e 's/\$gl_cond_libtool/false/g' \
4138 -e 's/gl_libdeps/gltests_libdeps/g' \
4139 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4142 func_emit_initmacro_end ${macro_prefix}tests
4143 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4144 # created using libtool, because libtool already handles the dependencies.
4145 if test "$libtool" != true; then
4146 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4147 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4148 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4149 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4150 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4152 if $use_libtests; then
4153 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4154 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4157 func_emit_initmacro_done $macro_prefix $sourcebase
4158 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4160 echo "# This macro records the list of files which have been installed by"
4161 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4162 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4163 echo "$files" | sed -e 's,^, ,'
4166 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4167 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4171 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4172 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4173 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4175 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4179 echo "# gnulib-comp.m4 ends here"
4186 echo "Creating $m4base/gnulib-comp.m4"
4187 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4189 echo "Create $m4base/gnulib-comp.m4"
4195 if test -n "$inctests"; then
4196 # Create tests makefile.
4197 func_dest_tmpfilename $testsbase/$makefile_am
4198 destfile="$testsbase/$makefile_am"
4199 modules="$testsrelated_modules"
4200 func_emit_tests_Makefile_am > "$tmpfile"
4201 if test -f "$destdir"/$testsbase/$makefile_am; then
4202 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4206 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4207 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4208 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4210 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4216 echo "Creating $testsbase/$makefile_am"
4217 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4219 echo "Create $testsbase/$makefile_am"
4222 func_append added_files "$testsbase/$makefile_am$nl"
4226 if test "$vc_files" != false; then
4227 # Update the .cvsignore and .gitignore files.
4228 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4229 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4230 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4231 echo "$m4base/|A|gnulib-comp.m4"
4232 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4233 { # Rearrange file descriptors. Needed because "while ... done < ..."
4234 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4235 exec 5<&0 < "$tmp"/fileset-changes
4236 func_update_ignorelist ()
4239 if test "$ignore" = .gitignore; then
4240 # In a .gitignore file, "foo" applies to the current directory and all
4241 # subdirectories, whereas "/foo" applies to the current directory only.
4244 doubly_escaped_anchor='\\/'
4248 doubly_escaped_anchor=''
4250 if test -f "$destdir/$dir$ignore"; then
4251 if test -n "$dir_added" || test -n "$dir_removed"; then
4252 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4253 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4254 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4255 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4256 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4258 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4260 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4261 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4262 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4263 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4264 } > "$tmp"/sed-ignore-removed
4265 { cat "$destdir/$dir$ignore"~
4266 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4267 } | sed -f "$tmp"/sed-ignore-removed \
4268 > "$destdir/$dir$ignore"
4270 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4275 if test -n "$dir_added"; then
4277 echo "Creating $destdir/$dir$ignore"
4279 if test "$ignore" = .cvsignore; then
4281 # Automake generates Makefile rules that create .dirstamp files.
4284 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4285 } > "$destdir/$dir$ignore"
4287 echo "Create $destdir/$dir$ignore"
4297 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4298 func_update_ignorelist .cvsignore
4300 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4301 func_update_ignorelist .gitignore
4308 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4309 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4310 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4311 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4312 if test "$next_dir" != "$last_dir"; then
4313 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4314 last_dir="$next_dir"
4319 A) func_append last_dir_added "$file$nl";;
4320 R) func_append last_dir_removed "$file$nl";;
4323 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4330 echo "You may need to add #include directives for the following .h files."
4331 # Intersect $specified_modules and $main_modules
4332 # (since $specified_modules is not necessarily of subset of $main_modules
4333 # - some may have been skipped through --avoid, and since the elements of
4334 # $main_modules but not in $specified_modules can go away without explicit
4335 # notice - through changes in the module dependencies).
4336 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4337 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4338 # First the #include <...> directives without #ifs, sorted for convenience,
4339 # then the #include "..." directives without #ifs, sorted for convenience,
4340 # then the #include directives that are surrounded by #ifs. Not sorted.
4341 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4342 include_directive=`func_get_include_directive "$module"`
4343 case "$nl$include_directive" in
4345 echo "$include_directive" 1>&5
4348 echo "$include_directive" | grep -v 'include "' 1>&6
4349 echo "$include_directive" | grep 'include "' 1>&7
4352 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4354 LC_ALL=C sort -u "$tmp"/include-angles
4355 LC_ALL=C sort -u "$tmp"/include-quotes
4356 cat "$tmp"/include-if
4357 ) | sed -e '/^$/d' -e 's/^/ /'
4358 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4360 for module in $main_modules; do
4361 func_get_link_directive "$module"
4363 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4364 if test `wc -l < "$tmp"/link` != 0; then
4366 echo "You may need to use the following Makefile variables when linking."
4367 echo "Use them in <program>_LDADD when linking a program, or"
4368 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4374 echo "Don't forget to"
4375 if test "$makefile_am" = Makefile.am; then
4376 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4378 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4380 if test -n "$pobase"; then
4381 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4383 if test -n "$inctests"; then
4384 if test "$makefile_am" = Makefile.am; then
4385 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4387 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4391 while test $edit != $makefile_am_edits; do
4392 edit=`expr $edit + 1`
4393 eval dir=\"\$makefile_am_edit${edit}_dir\"
4394 eval var=\"\$makefile_am_edit${edit}_var\"
4395 eval val=\"\$makefile_am_edit${edit}_val\"
4396 if test -n "$var"; then
4397 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4400 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4401 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4404 # func_create_testdir testdir modules
4406 # - local_gnulib_dir from --local-dir
4407 # - modcache true or false, from --cache-modules/--no-cache-modules
4408 # - auxdir directory relative to destdir where to place build aux files
4409 func_create_testdir ()
4413 if test -z "$modules"; then
4414 # All modules together.
4415 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4416 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4417 modules=`func_all_modules`
4418 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist) ;; *) echo $m;; esac; done`
4420 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
4422 # Check that the license of every module is consistent with the license of
4424 saved_modules="$modules"
4425 saved_inctests="$inctests"
4426 # When computing transitive closures, don't consider $module to depend on
4427 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4428 # on GPL modules - therefore we don't want a warning in this case.
4430 for requested_module in $saved_modules; do
4431 requested_license=`func_get_license "$requested_module"`
4432 if test "$requested_license" != GPL; then
4433 # Here we use func_modules_transitive_closure, not just
4434 # func_get_dependencies, so that we also detect weird situations like
4435 # an LGPL module which depends on a GPLed build tool module which depends
4437 modules="$requested_module"
4438 func_modules_transitive_closure
4439 for module in $modules; do
4440 license=`func_get_license "$module"`
4442 'GPLed build tool') ;;
4443 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4445 case "$requested_license" in
4448 GPLv2+ | LGPLv2+) ;;
4449 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4455 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4461 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4470 modules="$saved_modules"
4471 inctests="$saved_inctests"
4473 # Subdirectory names.
4483 # Determine final module list.
4484 func_modules_transitive_closure
4485 if test $verbose -ge 0; then
4486 echo "Module list with included dependencies:"
4487 echo "$modules" | sed -e 's/^/ /'
4490 # Add the dummy module if needed.
4491 func_modules_add_dummy
4493 # Show banner notice of every module.
4496 # Determine final file list.
4497 func_modules_to_filelist
4498 if test $verbose -ge 0; then
4500 echo "$files" | sed -e 's/^/ /'
4503 rewritten='%REWRITTEN%'
4504 sed_rewrite_files="\
4505 s,^build-aux/,$rewritten$auxdir/,
4506 s,^doc/,$rewritten$docbase/,
4507 s,^lib/,$rewritten$sourcebase/,
4508 s,^m4/,$rewritten$m4base/,
4509 s,^tests/,$rewritten$testsbase/,
4513 # Create directories.
4514 for f in $files; do echo $f; done \
4515 | sed -e "$sed_rewrite_files" \
4516 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4517 | LC_ALL=C sort -u \
4519 { # Rearrange file descriptors. Needed because "while ... done < ..."
4520 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4521 exec 5<&0 < "$tmp"/dirs
4523 mkdir -p "$testdir/$d"
4528 # Copy files or make symbolic links.
4530 for f in $files; do echo $f; done \
4531 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4534 { # Rearrange file descriptors. Needed because "while ... done < ..."
4535 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4536 exec 5<&0 < "$tmp"/files
4538 func_lookup_file "$f"
4539 if test -n "$lookedup_tmp"; then
4540 cp -p "$lookedup_file" "$testdir/$g"
4542 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4543 if { test -n "$symbolic" \
4544 || { test -n "$lsymbolic" \
4545 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4546 func_ln "$lookedup_file" "$testdir/$g"
4548 cp -p "$lookedup_file" "$testdir/$g"
4555 # Create Makefile.ams that are for testing.
4558 # No special edits are needed.
4561 # Create $sourcebase/Makefile.am.
4562 mkdir -p "$testdir/$sourcebase"
4563 destfile="$sourcebase/Makefile.am"
4564 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4565 any_uses_subdirs="$uses_subdirs"
4567 # Create $m4base/Makefile.am.
4568 mkdir -p "$testdir/$m4base"
4569 (echo "## Process this file with automake to produce Makefile.in."
4575 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4578 ) > "$testdir/$m4base/Makefile.am"
4580 subdirs="$sourcebase $m4base"
4581 subdirs_with_configure_ac=""
4583 if false && test -f "$testdir"/$m4base/gettext.m4; then
4584 # Avoid stupid error message from automake:
4585 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4586 mkdir -p "$testdir/po"
4587 (echo "## Process this file with automake to produce Makefile.in."
4588 ) > "$testdir/po/Makefile.am"
4589 func_append subdirs " po"
4592 if test -n "$inctests"; then
4593 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4594 # Viewed from the $testsbase subdirectory, $auxdir is different.
4595 saved_auxdir="$auxdir"
4596 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4597 # Create $testsbase/Makefile.am.
4599 destfile="$testsbase/Makefile.am"
4600 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
4601 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4602 # Create $testsbase/configure.ac.
4603 (echo "# Process this file with autoconf to produce a configure script."
4604 echo "AC_INIT([dummy], [0])"
4605 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4606 echo "AM_INIT_AUTOMAKE"
4608 echo "AC_CONFIG_HEADERS([config.h])"
4611 echo "AC_PROG_INSTALL"
4612 echo "AC_PROG_MAKE_SET"
4613 echo "AC_PROG_RANLIB"
4615 if test -n "$uses_subdirs"; then
4616 echo "AM_PROG_CC_C_O"
4619 for module in $modules; do
4621 if test -n "$module"; then
4623 gnumakefile | maintainer-makefile)
4624 # These modules are meant to be used only in the top-level directory.
4627 func_get_autoconf_early_snippet "$module"
4632 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4633 if test "$libtool" = true; then
4634 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4635 echo "gl_cond_libtool=true"
4637 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4638 echo "gl_cond_libtool=false"
4640 echo "gl_ltlibdeps="
4642 # Wrap the set of autoconf snippets into an autoconf macro that is then
4643 # invoked. This is needed because autoconf does not support AC_REQUIRE
4645 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4646 # but we want the AC_REQUIRE to have its normal meaning (provide one
4647 # expansion of the required macro before the current point, and only one
4649 echo "AC_DEFUN([gl_INIT], ["
4650 sed_replace_build_aux='
4652 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4653 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4656 func_emit_initmacro_start $macro_prefix
4657 # We don't have explicit ordering constraints between the various
4658 # autoconf snippets. It's cleanest to put those of the library before
4659 # those of the tests.
4660 echo "gl_source_base='../$sourcebase'"
4661 for module in $modules; do
4662 func_verify_nontests_module
4663 if test -n "$module"; then
4665 gnumakefile | maintainer-makefile)
4666 # These modules are meant to be used only in the top-level directory.
4669 func_get_autoconf_snippet "$module" \
4670 | sed -e "$sed_replace_build_aux"
4675 echo "gl_source_base='.'"
4676 for module in $modules; do
4677 func_verify_tests_module
4678 if test -n "$module"; then
4679 func_get_autoconf_snippet "$module" \
4680 | sed -e "$sed_replace_build_aux"
4683 func_emit_initmacro_end $macro_prefix
4684 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4685 # created using libtool, because libtool already handles the dependencies.
4686 if test "$libtool" != true; then
4687 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4688 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4689 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4690 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4691 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4694 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4698 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4699 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4700 echo "AH_TOP([#include \"../config.h\"])"
4702 echo "AC_CONFIG_FILES([Makefile])"
4704 ) > "$testdir/$testsbase/configure.ac"
4705 auxdir="$saved_auxdir"
4706 func_append subdirs " $testsbase"
4707 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4710 # Create Makefile.am.
4711 (echo "## Process this file with automake to produce Makefile.in."
4713 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4715 echo "SUBDIRS = $subdirs"
4717 echo "ACLOCAL_AMFLAGS = -I $m4base"
4718 ) > "$testdir/Makefile.am"
4720 # Create configure.ac.
4721 (echo "# Process this file with autoconf to produce a configure script."
4722 echo "AC_INIT([dummy], [0])"
4723 if test "$auxdir" != "."; then
4724 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4726 echo "AM_INIT_AUTOMAKE"
4728 echo "AC_CONFIG_HEADERS([config.h])"
4731 echo "AC_PROG_INSTALL"
4732 echo "AC_PROG_MAKE_SET"
4734 echo "# For autobuild."
4735 echo "AC_CANONICAL_BUILD"
4736 echo "AC_CANONICAL_HOST"
4738 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4739 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4740 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4741 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4743 echo "AC_PROG_RANLIB"
4745 if test -n "$any_uses_subdirs"; then
4746 echo "AM_PROG_CC_C_O"
4749 for module in $modules; do
4750 func_verify_nontests_module
4751 if test -n "$module"; then
4752 func_get_autoconf_early_snippet "$module"
4755 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4756 if test "$libtool" = true; then
4757 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4758 echo "gl_cond_libtool=true"
4760 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4761 echo "gl_cond_libtool=false"
4763 echo "gl_ltlibdeps="
4765 # Wrap the set of autoconf snippets into an autoconf macro that is then
4766 # invoked. This is needed because autoconf does not support AC_REQUIRE
4768 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4769 # but we want the AC_REQUIRE to have its normal meaning (provide one
4770 # expansion of the required macro before the current point, and only one
4772 echo "AC_DEFUN([gl_INIT], ["
4773 if test "$auxdir" != "build-aux"; then
4774 sed_replace_build_aux='
4776 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4777 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4781 sed_replace_build_aux="$sed_noop"
4783 func_emit_initmacro_start $macro_prefix
4784 echo "gl_source_base='$sourcebase'"
4785 for module in $modules; do
4786 func_verify_nontests_module
4787 if test -n "$module"; then
4788 func_get_autoconf_snippet "$module" \
4789 | sed -e "$sed_replace_build_aux"
4792 func_emit_initmacro_end $macro_prefix
4793 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4794 # created using libtool, because libtool already handles the dependencies.
4795 if test "$libtool" != true; then
4796 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4797 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4798 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4799 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4800 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4803 func_emit_initmacro_done $macro_prefix $sourcebase
4807 if test -n "$subdirs_with_configure_ac"; then
4808 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4810 makefiles="Makefile"
4811 for d in $subdirs; do
4812 # For subdirs that have a configure.ac by their own, it's the subdir's
4813 # configure.ac which creates the subdir's Makefile.am, not this one.
4814 case " $subdirs_with_configure_ac " in
4816 *) func_append makefiles " $d/Makefile" ;;
4819 echo "AC_CONFIG_FILES([$makefiles])"
4821 ) > "$testdir/configure.ac"
4823 # Create autogenerated files.
4825 # Do not use "${AUTORECONF} --force --install", because it may invoke
4826 # autopoint, which brings in older versions of some of our .m4 files.
4827 if test -f $m4base/gettext.m4; then
4828 func_execute_command ${AUTOPOINT} --force || func_exit 1
4829 for f in $m4base/*.m4~; do
4831 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4835 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4836 if ! test -d build-aux; then
4837 func_execute_command mkdir build-aux || func_exit 1
4839 func_execute_command ${AUTOCONF} || func_exit 1
4840 func_execute_command ${AUTOHEADER} || func_exit 1
4841 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4843 if test -n "$inctests"; then
4844 # Create autogenerated files.
4845 (cd "$testdir/$testsbase" || func_exit 1
4846 # Do not use "${AUTORECONF} --force --install", because it may invoke
4847 # autopoint, which brings in older versions of some of our .m4 files.
4848 if test -f ../$m4base/gettext.m4; then
4849 func_execute_command ${AUTOPOINT} --force || func_exit 1
4850 for f in ../$m4base/*.m4~; do
4852 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4856 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4857 if ! test -d ../build-aux; then
4858 func_execute_command mkdir ../build-aux
4860 func_execute_command ${AUTOCONF} || func_exit 1
4861 func_execute_command ${AUTOHEADER} || func_exit 1
4862 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4865 # Need to run configure and make once, to create built files that are to be
4866 # distributed (such as getdate.c).
4867 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4868 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4869 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4870 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4871 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4872 # such $(FOO_H) because they don't refer to distributed files.
4873 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4874 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4875 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4876 | sed -e "$sed_remove_make_variables"`
4877 distributed_built_sources=`for file in $built_sources; do
4878 case "$cleaned_files" in
4883 if test -n "$distributed_built_sources"; then
4885 ./configure || func_exit 1
4887 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4888 $MAKE built_sources || func_exit 1
4890 $MAKE distclean || func_exit 1
4895 # func_create_megatestdir megatestdir allmodules
4897 # - local_gnulib_dir from --local-dir
4898 # - modcache true or false, from --cache-modules/--no-cache-modules
4899 # - auxdir directory relative to destdir where to place build aux files
4900 func_create_megatestdir ()
4904 if test -z "$allmodules"; then
4905 allmodules=`func_all_modules`
4909 # First, all modules one by one.
4910 for onemodule in $allmodules; do
4911 func_create_testdir "$megatestdir/$onemodule" $onemodule
4912 func_append megasubdirs "$onemodule "
4914 # Then, all modules all together.
4915 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4916 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
4917 func_create_testdir "$megatestdir/ALL" "$allmodules"
4918 func_append megasubdirs "ALL"
4921 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4922 vc_witness="$gnulib_dir/CVS/Entries"; \
4924 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4926 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4927 | sed -e 's,January,01,' -e 's,Jan,01,' \
4928 -e 's,February,02,' -e 's,Feb,02,' \
4929 -e 's,March,03,' -e 's,Mar,03,' \
4930 -e 's,April,04,' -e 's,Apr,04,' \
4932 -e 's,June,06,' -e 's,Jun,06,' \
4933 -e 's,July,07,' -e 's,Jul,07,' \
4934 -e 's,August,08,' -e 's,Aug,08,' \
4935 -e 's,September,09,' -e 's,Sep,09,' \
4936 -e 's,October,10,' -e 's,Oct,10,' \
4937 -e 's,November,11,' -e 's,Nov,11,' \
4938 -e 's,December,12,' -e 's,Dec,12,' \
4939 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4940 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4942 echo "CVSDATE=$cvsdate"
4943 echo ": \${MAKE=make}"
4944 echo "test -d logs || mkdir logs"
4945 echo "for module in $megasubdirs; do"
4946 echo " echo \"Working on module \$module...\""
4947 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4948 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4951 echo " : autobuild project... \$module"
4952 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4953 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4954 echo " : autobuild hostname... \`hostname\`"
4955 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
4957 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4959 ) > "$megatestdir/do-autobuild"
4960 chmod a+x "$megatestdir/do-autobuild"
4962 # Create Makefile.am.
4963 (echo "## Process this file with automake to produce Makefile.in."
4965 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4967 echo "SUBDIRS = $megasubdirs"
4969 echo "EXTRA_DIST = do-autobuild"
4970 ) > "$megatestdir/Makefile.am"
4972 # Create configure.ac.
4973 (echo "# Process this file with autoconf to produce a configure script."
4974 echo "AC_INIT([dummy], [0])"
4975 if test "$auxdir" != "."; then
4976 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4978 echo "AM_INIT_AUTOMAKE"
4980 echo "AC_PROG_MAKE_SET"
4982 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4983 echo "AC_CONFIG_FILES([Makefile])"
4985 ) > "$megatestdir/configure.ac"
4987 # Create autogenerated files.
4989 # Do not use "${AUTORECONF} --install", because autoreconf operates
4990 # recursively, but the subdirectories are already finished, therefore
4991 # calling autoreconf here would only waste lots of CPU time.
4992 func_execute_command ${ACLOCAL} || func_exit 1
4993 func_execute_command mkdir build-aux
4994 func_execute_command ${AUTOCONF} || func_exit 1
4995 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5001 func_fatal_error "no mode specified" ;;
5008 # sed expression that converts a literal to a basic regular expression.
5009 # Needs to handle . [ \ * ^ $.
5010 sed_literal_to_basic_regex='s/\\/\\\\/g
5016 if test -f "$gnulib_dir/$filename" \
5017 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5018 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5019 filename_line_regex='^'"$filename_anywhere_regex"'$'
5022 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5023 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5024 (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$,,')
5027 | func_sanitize_modulelist \
5030 for module in $module_candidates; do
5031 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5036 func_warning "file $filename does not exist"
5044 if test -z "$destdir"; then
5047 test -d "$destdir" \
5048 || func_fatal_error "destination directory does not exist: $destdir"
5050 # Prefer configure.ac to configure.in.
5051 if test -f "$destdir"/configure.ac; then
5052 configure_ac="$destdir/configure.ac"
5054 if test -f "$destdir"/configure.in; then
5055 configure_ac="$destdir/configure.in"
5057 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5061 # Analyze configure.ac.
5063 guessed_libtool=false
5068 /AC_CONFIG_AUX_DIR/ {
5069 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5071 /A[CM]_PROG_LIBTOOL/ {
5072 s,^.*$,guessed_libtool=true,p
5074 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5076 if test -z "$auxdir"; then
5077 auxdir="$guessed_auxdir"
5080 # Determine where to apply func_import.
5081 if test -n "$m4base"; then
5082 # Apply func_import to a particular gnulib directory.
5083 # Any number of additional modules can be given.
5084 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5085 # First use of gnulib in the given m4base.
5086 test -n "$supplied_libname" || supplied_libname=true
5087 test -n "$sourcebase" || sourcebase="lib"
5088 test -n "$docbase" || docbase="doc"
5089 test -n "$testsbase" || testsbase="tests"
5090 test -n "$macro_prefix" || macro_prefix="gl"
5094 # Apply func_import to all gnulib directories.
5095 # To get this list of directories, look at Makefile.am. (Not at
5096 # configure, because it may be omitted from CVS. Also, don't run
5097 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5100 if test -f "$destdir"/Makefile.am; then
5101 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5103 for arg in $aclocal_amflags; do
5104 if test -n "$m4dir_is_next"; then
5105 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5109 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5110 func_append m4dirs " $arg"
5111 m4dirs_count=`expr $m4dirs_count + 1`
5117 if test "X$arg" = "X-I"; then
5125 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5126 if test -f "$destdir"/aclocal.m4; then
5127 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5128 sedexpr2='s,^[^/]*$,.,'
5129 sedexpr3='s,/[^/]*$,,'
5130 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5131 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5134 if test $m4dirs_count = 0; then
5135 # First use of gnulib in a package.
5136 # Any number of additional modules can be given.
5137 test -n "$supplied_libname" || supplied_libname=true
5138 test -n "$sourcebase" || sourcebase="lib"
5140 test -n "$docbase" || docbase="doc"
5141 test -n "$testsbase" || testsbase="tests"
5142 test -n "$macro_prefix" || macro_prefix="gl"
5145 if test $m4dirs_count = 1; then
5146 # There's only one use of gnulib here. Assume the user means it.
5147 # Any number of additional modules can be given.
5148 for m4base in $m4dirs; do
5152 # Ambiguous - guess what the user meant.
5153 if test $# = 0; then
5154 # No further arguments. Guess the user wants to update all of them.
5155 for m4base in $m4dirs; do
5156 # Perform func_import in a subshell, so that variable values
5158 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
5159 # pobase, docbase, testsbase, inctests, libname, lgpl,
5160 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5161 # don't propagate from one directory to another.
5162 (func_import) || func_exit 1
5166 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5174 if test -z "$destdir"; then
5175 func_fatal_error "please specify --dir option"
5178 test -d "$destdir" \
5179 || func_fatal_error "could not create destination directory"
5180 test -n "$auxdir" || auxdir="build-aux"
5181 func_create_testdir "$destdir" "$*"
5184 create-megatestdir )
5185 if test -z "$destdir"; then
5186 func_fatal_error "please specify --dir option"
5188 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5189 test -n "$auxdir" || auxdir="build-aux"
5190 func_create_megatestdir "$destdir" "$*"
5194 test -n "$destdir" || destdir=testdir$$
5195 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5196 test -n "$auxdir" || auxdir="build-aux"
5197 func_create_testdir "$destdir" "$*"
5201 ../configure || func_exit 1
5202 $MAKE || func_exit 1
5203 $MAKE check || func_exit 1
5204 $MAKE distclean || func_exit 1
5205 remaining=`find . -type f -print`
5206 if test -n "$remaining"; then
5207 echo "Remaining files:" $remaining 1>&2
5208 echo "gnulib-tool: *** Stop." 1>&2
5217 test -n "$destdir" || destdir=testdir$$
5218 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5219 test -n "$auxdir" || auxdir="build-aux"
5220 func_create_megatestdir "$destdir" "$*"
5228 remaining=`find . -type f -print`
5229 if test -n "$remaining"; then
5230 echo "Remaining files:" $remaining 1>&2
5231 echo "gnulib-tool: *** Stop." 1>&2
5239 extract-description )
5243 if test -n "$module"; then
5244 func_get_description "$module"
5253 if test -n "$module"; then
5254 func_get_status "$module"
5263 if test -n "$module"; then
5264 func_get_notice "$module"
5269 extract-applicability )
5273 if test -n "$module"; then
5274 func_get_applicability "$module"
5283 if test -n "$module"; then
5284 func_get_filelist "$module"
5289 extract-dependencies )
5293 if test -n "$module"; then
5294 func_get_dependencies "$module"
5299 extract-autoconf-snippet )
5303 if test -n "$module"; then
5304 func_get_autoconf_snippet "$module"
5309 extract-automake-snippet )
5313 if test -n "$module"; then
5314 func_get_automake_snippet "$module"
5319 extract-include-directive )
5323 if test -n "$module"; then
5324 func_get_include_directive "$module"
5329 extract-link-directive )
5333 if test -n "$module"; then
5334 func_get_link_directive "$module"
5343 if test -n "$module"; then
5344 func_get_license "$module"
5349 extract-maintainer )
5353 if test -n "$module"; then
5354 func_get_maintainer "$module"
5359 extract-tests-module )
5363 if test -n "$module"; then
5364 func_get_tests_module "$module"
5370 # Verify the number of arguments.
5371 if test $# -lt 1 || test $# -gt 2; then
5372 func_fatal_error "invalid number of arguments for --$mode"
5375 # The first argument is the file to be copied.
5377 # Verify the file exists.
5378 func_lookup_file "$f"
5380 # The second argument is the destination; either a directory ot a file.
5381 # It defaults to the current directory.
5383 test -n "$dest" || dest='.'
5384 test -n "$sourcebase" || sourcebase="lib"
5385 test -n "$m4base" || m4base="m4"
5386 test -n "$docbase" || docbase="doc"
5387 test -n "$testsbase" || testsbase="tests"
5388 test -n "$auxdir" || auxdir="build-aux"
5389 rewritten='%REWRITTEN%'
5390 sed_rewrite_files="\
5391 s,^build-aux/,$rewritten$auxdir/,
5392 s,^doc/,$rewritten$docbase/,
5393 s,^lib/,$rewritten$sourcebase/,
5394 s,^m4/,$rewritten$m4base/,
5395 s,^tests/,$rewritten$testsbase/,
5398 if test -d "$dest"; then
5400 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5402 destdir=`dirname "$dest"`
5403 g=`basename "$dest"`
5406 # Create the directory for destfile.
5407 d=`dirname "$destdir/$g"`
5409 if test -n "$d" && test ! -d "$d"; then
5410 mkdir -p "$d" || func_fatal_error "failed"
5414 func_dest_tmpfilename "$g"
5415 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5416 already_present=true
5417 if test -f "$destdir/$g"; then
5418 # The file already exists.
5422 # Don't protest if the file should be there but isn't: it happens
5423 # frequently that developers don't put autogenerated files into CVS.
5430 func_fatal_error "unknown operation mode --$mode" ;;
5434 # Undo the effect of the previous 'trap' command. Some shellology:
5435 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5436 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5437 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5438 # 128 + signal number and is set before the trap-registered command is run.
5440 trap 'func_exit $?' 1 2 3 13 15
5445 # indent-tabs-mode: nil
5446 # whitespace-check-buffer-indent: nil