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 that
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 # Also handle problem 2, specific to bash 3.2, here.
731 if { test -z "$have_echo" \
732 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
734 && test -n "$BASH_VERSION"; then \
735 if type printf 2>/dev/null | grep / > /dev/null; then
736 # 'printf' is not a shell built-in.
744 # 'printf' is a shell built-in.
750 if echo '\t' | grep t > /dev/null; then
754 # For zsh: turn sh-emulation on.
755 if test -z "$have_echo" \
756 && test -n "$ZSH_VERSION" \
757 && (emulate sh) >/dev/null 2>&1; then
760 # For ksh: alias echo to 'print -r'.
761 if test -z "$have_echo" \
762 && (type print) >/dev/null 2>&1; then
763 # A 'print' command exists.
764 if type print 2>/dev/null | grep / > /dev/null; then
767 # 'print' is a shell built-in.
768 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
769 # 'print' is the ksh shell built-in.
770 alias echo='print -r'
774 if test -z "$have_echo" \
775 && echo '\t' | grep t > /dev/null; then
778 # For ksh: alias echo to a function that uses cat of a here document.
779 # The ksh manual page says:
780 # "Aliasing is performed when scripts are read, not while they are executed.
781 # Therefore, for an alias to take effect, the alias definition command has
782 # to be executed before the command which references the alias is read."
783 # Because of this, we have to play strange tricks with have_echo, to ensure
784 # that the top-level statement containing the test starts after the 'alias'
786 if test -z "$have_echo"; then
793 alias echo=bsd_echo 2>/dev/null
795 if test -z "$have_echo" \
796 && echo '\t' | grep t > /dev/null; then
799 if test -z "$have_echo"; then
800 unalias echo 2>/dev/null
802 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
803 if test -z "$have_echo" \
804 && test "X$1" != "X--no-reexec" \
805 && test -f /bin/ksh; then
806 exec /bin/ksh "$0" --no-reexec "$@"
809 # Otherwise: respawn using /bin/sh.
810 if test -z "$have_echo" \
811 && test "X$1" != "X--no-reexec" \
812 && test -f /bin/sh; then
813 exec /bin/sh "$0" --no-reexec "$@"
816 if test -z "$have_echo"; then
817 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
819 if echo '\t' | grep t > /dev/null; then
822 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
824 if test "X$1" = "X--no-reexec"; then
828 # Command-line option processing.
829 # Removes the OPTIONS from the arguments. Sets the variables:
830 # - mode list or import or create-testdir or create-megatestdir
831 # - destdir from --dir
832 # - local_gnulib_dir from --local-dir
833 # - modcache true or false, from --cache-modules/--no-cache-modules
834 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
835 # - libname, supplied_libname from --lib
836 # - sourcebase from --source-base
837 # - m4base from --m4-base
838 # - pobase from --po-base
839 # - docbase from --doc-base
840 # - testsbase from --tests-base
841 # - auxdir from --aux-dir
842 # - inctests true if --with-tests was given, blank otherwise
843 # - incobsolete true if --with-obsolete was given, blank otherwise
844 # - avoidlist list of modules to avoid, from --avoid
845 # - lgpl yes or a number if --lgpl was given, blank otherwise
846 # - makefile_name from --makefile-name
847 # - libtool true if --libtool was given, false if --no-libtool was
848 # given, blank otherwise
849 # - macro_prefix from --macro-prefix
850 # - po_domain from --po-domain
851 # - vc_files true if --vc-files was given, false if --no-vc-files was
852 # given, blank otherwise
853 # - autoconf_minversion minimum supported autoconf version
854 # - do_changelog false if --no-changelog was given, : otherwise
855 # - doit : if actions shall be executed, false if only to be printed
856 # - symbolic true if --symlink or --more-symlinks was given, blank
858 # - lsymbolic true if --local-symlink was given, blank otherwise
859 # - do_copyrights blank if --more-symlinks was given, true otherwise
891 while test $# -gt 0; do
896 --find | --fin | --fi | --f )
899 --import | --impor | --impo | --imp | --im | --i )
902 --update | --updat | --upda | --upd | --up | --u )
905 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
908 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
909 mode=create-megatestdir
911 --test | --tes | --te | --t )
914 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
918 mode=`echo "X$1" | sed -e 's/^X--//'`
920 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
926 func_fatal_error "missing argument for --dir"
931 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
936 func_fatal_error "missing argument for --local-dir"
941 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
943 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
946 --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 )
949 --verbose | --verbos | --verbo | --verb )
950 verbose=`expr $verbose + 1`
952 --quiet | --quie | --qui | --qu | --q )
953 verbose=`expr $verbose - 1`
958 func_fatal_error "missing argument for --lib"
961 supplied_libname=true
964 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
965 supplied_libname=true
970 func_fatal_error "missing argument for --source-base"
975 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
980 func_fatal_error "missing argument for --m4-base"
985 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
990 func_fatal_error "missing argument for --po-base"
995 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1000 func_fatal_error "missing argument for --doc-base"
1005 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1009 if test $# = 0; then
1010 func_fatal_error "missing argument for --tests-base"
1015 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1019 if test $# = 0; then
1020 func_fatal_error "missing argument for --aux-dir"
1025 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1035 if test $# = 0; then
1036 func_fatal_error "missing argument for --avoid"
1038 func_append avoidlist " $1"
1041 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1042 func_append avoidlist " $arg"
1048 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1051 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1057 if test $# = 0; then
1058 func_fatal_error "missing argument for --makefile-name"
1063 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1073 if test $# = 0; then
1074 func_fatal_error "missing argument for --macro-prefix"
1079 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1083 if test $# = 0; then
1084 func_fatal_error "missing argument for --po-domain"
1089 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1097 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1103 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1106 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1109 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1113 --help | --hel | --he | --h )
1116 --version | --versio | --versi | --vers )
1120 # Stop option processing
1124 echo "gnulib-tool: unknown option $1" 1>&2
1125 echo "Try 'gnulib-tool --help' for more information." 1>&2
1132 if test "$mode" = update; then
1133 if test $# != 0; then
1134 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1135 echo "Try 'gnulib-tool --help' for more information." 1>&2
1136 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1137 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1140 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1141 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1142 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1143 || test -n "$inctests" || test -n "$incobsolete" \
1144 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1145 || test -n "$macro_prefix" || test -n "$po_domain" \
1146 || test -n "$vc_files"; then
1147 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1148 echo "Try 'gnulib-tool --help' for more information." 1>&2
1149 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1150 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1155 if test -n "$pobase" && test -z "$po_domain"; then
1156 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1157 echo "Try 'gnulib-tool --help' for more information." 1>&2
1160 if test -z "$pobase" && test -n "$po_domain"; then
1161 func_warning "--po-domain has no effect without a --po-base option"
1164 # Determine the minimum supported autoconf version from the project's
1166 DEFAULT_AUTOCONF_MINVERSION="2.59"
1167 autoconf_minversion=
1169 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1170 if test -f "$destdir"/configure.ac; then
1171 configure_ac="$destdir/configure.ac"
1173 if test -f "$destdir"/configure.in; then
1174 configure_ac="$destdir/configure.in"
1178 if test -f configure.ac; then
1179 configure_ac="configure.ac"
1181 if test -f configure.in; then
1182 configure_ac="configure.in"
1186 if test -n "$configure_ac"; then
1187 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1188 # because when some m4 files are omitted from a CVS repository,
1189 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1190 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1191 # autom4te: m4 failed with exit status: 1
1198 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1200 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1201 if test -n "$prereqs"; then
1202 autoconf_minversion=`
1203 for version in $prereqs; do echo $version; done |
1204 LC_ALL=C sort -nru | sed -e 1q
1208 if test -z "$autoconf_minversion"; then
1209 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1211 case "$autoconf_minversion" in
1212 1.* | 2.[0-4]* | 2.5[0-8]*)
1213 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1216 # Remove trailing slashes from the directory names. This is necessary for
1217 # m4base (to avoid an error in func_import) and optional for the others.
1218 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1219 case "$local_gnulib_dir" in
1220 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1222 case "$sourcebase" in
1223 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1226 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1229 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1232 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1234 case "$testsbase" in
1235 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1238 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1244 trap 'exit_status=$?
1245 if test "$signal" != 0; then
1246 echo "caught signal $signal" >&2
1249 exit $exit_status' 0
1250 for signal in 1 2 3 13 15; do
1251 trap '{ signal='$signal'; func_exit 1; }' $signal
1255 # func_lookup_file file
1256 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1259 # - local_gnulib_dir from --local-dir
1261 # - lookedup_file name of the merged (combined) file
1262 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1266 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1267 lookedup_file="$local_gnulib_dir/$lkfile"
1270 if test -f "$gnulib_dir/$lkfile"; then
1271 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1272 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1273 rm -f "$tmp/$lkbase"
1274 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1275 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1276 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1277 lookedup_file="$tmp/$lkbase"
1280 lookedup_file="$gnulib_dir/$lkfile"
1284 func_fatal_error "file $gnulib_dir/$lkfile not found"
1289 # func_sanitize_modulelist
1290 # receives a list of possible module names on standard input, one per line.
1291 # It removes those which are just file names unrelated to modules, and outputs
1292 # the resulting list to standard output, one per line.
1293 func_sanitize_modulelist ()
1295 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1296 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1297 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1298 -e '/^README$/d' -e '/\/README$/d' \
1299 -e '/^TEMPLATE$/d' \
1300 -e '/^TEMPLATE-EXTENDED$/d' \
1301 -e '/^TEMPLATE-TESTS$/d' \
1308 # - local_gnulib_dir from --local-dir
1311 # Filter out metainformation files like README, which are not modules.
1312 # Filter out unit test modules; they can be retrieved through
1313 # --extract-tests-module if desired.
1315 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1316 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1317 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1320 | func_sanitize_modulelist \
1321 | sed -e '/-tests$/d' \
1325 # func_verify_module
1326 # verifies a module name
1328 # - local_gnulib_dir from --local-dir
1329 # - module module name argument
1330 func_verify_module ()
1332 if { test -f "$gnulib_dir/modules/$module" \
1333 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1334 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1335 && test "CVS" != "$module" \
1336 && test "ChangeLog" != "$module" \
1337 && test "COPYING" != "$module" \
1338 && test "README" != "$module" \
1339 && test "TEMPLATE" != "$module" \
1340 && test "TEMPLATE-EXTENDED" != "$module" \
1341 && test "TEMPLATE-TESTS" != "$module"; then
1342 # OK, $module is a correct module name.
1343 # Verify that building the module description with 'patch' succeeds.
1344 func_lookup_file "modules/$module"
1346 func_warning "module $module doesn't exist"
1351 # func_verify_nontests_module
1352 # verifies a module name, excluding tests modules
1354 # - local_gnulib_dir from --local-dir
1355 # - module module name argument
1356 func_verify_nontests_module ()
1359 *-tests ) module= ;;
1360 * ) func_verify_module ;;
1364 # func_verify_tests_module
1365 # verifies a module name, considering only tests modules
1367 # - local_gnulib_dir from --local-dir
1368 # - module module name argument
1369 func_verify_tests_module ()
1372 *-tests ) func_verify_module ;;
1377 # Suffix of a sed expression that extracts a particular field from a
1378 # module description.
1379 # A field starts with a line that contains a keyword, such as 'Description',
1380 # followed by a colon and optional whitespace. All following lines, up to
1381 # the next field (or end of file if there is none) form the contents of the
1383 # An absent field is equivalent to a field with empty contents.
1384 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1385 sed_extract_prog=':[ ]*$/ {
1388 s/^Description:[ ]*$//
1391 s/^Applicability:[ ]*$//
1393 s/^Depends-on:[ ]*$//
1394 s/^configure\.ac-early:[ ]*$//
1395 s/^configure\.ac:[ ]*$//
1396 s/^Makefile\.am:[ ]*$//
1400 s/^Maintainer:[ ]*$//
1407 # Piece of a sed expression that converts a field header line to a shell
1409 # NOTE: Keep this in sync with sed_extract_prog above!
1410 sed_extract_field_header='
1411 s/^Description:[ ]*$/description/
1412 s/^Status:[ ]*$/status/
1413 s/^Notice:[ ]*$/notice/
1414 s/^Applicability:[ ]*$/applicability/
1415 s/^Files:[ ]*$/files/
1416 s/^Depends-on:[ ]*$/dependson/
1417 s/^configure\.ac-early:[ ]*$/configureac_early/
1418 s/^configure\.ac:[ ]*$/configureac/
1419 s/^Makefile\.am:[ ]*$/makefile/
1420 s/^Include:[ ]*$/include/
1422 s/^License:[ ]*$/license/
1423 s/^Maintainer:[ ]*$/maintainer/'
1427 # Note: The 'eval' silences stderr output in dash.
1428 if declare -A x 2>/dev/null && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }; then
1429 # Zsh 4 and Bash 4 have associative arrays.
1430 have_associative=true
1432 # For other shells, use 'eval' with computed shell variable names.
1433 have_associative=false
1436 if $have_associative; then
1438 # Declare the associative arrays.
1439 declare -A modcache_cached
1440 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1441 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1442 eval "$declare_script"
1446 # func_cache_var module
1447 # computes the cache variable name corresponding to $module.
1448 # Note: This computation can map different module names to the same
1449 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1450 # to protect against this case.
1452 # - cachevar a shell variable name
1453 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1454 # Bash 2.0 and newer, ksh, and zsh support the syntax
1455 # ${param//pattern/replacement}
1456 # as a shorthand for
1457 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1458 # Note: The 'eval' above silences stderr output in dash.
1461 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1468 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1477 # func_init_sed_convert_to_cache_statements
1479 # - modcachevar_assignment
1481 # - sed_convert_to_cache_statements
1482 func_init_sed_convert_to_cache_statements ()
1484 # 'sed' script that turns a module description into shell script
1485 # assignments, suitable to be eval'ed. All active characters are escaped.
1488 # Some module's description
1493 # modcache_description[$1]=\
1494 # 'Some module'"'"'s description
1496 # modcache_files[$1]=\
1499 # c_MODULE_description_set=set; c_MODULE_description=\
1500 # 'Some module'"'"'s description
1502 # c_MODULE_files_set=set; c_MODULE_files=\
1504 # The script consists of two parts:
1505 # 1) Ignore the lines before the first field header.
1506 # 2) A loop, treating non-field-header lines by escaping single quotes
1507 # and adding a closing quote in the last line,
1508 sed_convert_to_cache_statements="
1510 # Here we have not yet seen a field header.
1512 # See if the current line contains a field header.
1515 ${sed_extract_field_header}
1518 # No field header. Ignore the line.
1520 # Read the next line. Upon EOF, just exit.
1525 # The current line contains a field header.
1527 # Turn it into the beginning of an assignment.
1528 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1530 # Move it to the hold space. Don't print it yet,
1531 # because we want no assignment if the field is empty.
1534 # Read the next line.
1535 # Upon EOF, the field was empty. Print no assignment. Just exit.
1538 # See if the current line contains a field header.
1541 ${sed_extract_field_header}
1542 # If it is, the previous field was empty. Print no assignment.
1545 # Not a field header.
1547 # Print the previous line, held in the hold space.
1552 # Transform single quotes.
1555 # Prepend a single quote.
1560 # Move it to the hold space.
1563 # Read the next line.
1570 # See if the current line contains a field header.
1573 ${sed_extract_field_header}
1576 # Print the previous line, held in the hold space.
1581 # Transform single quotes.
1588 # Print the previous line, held in the hold space, with a single quote
1589 # to end the assignment.
1599 # Print the previous line, held in the hold space, with a single quote
1600 # to end the assignment.
1607 if ! $sed_comments; then
1609 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1610 | sed -e 's/^ *//' -e 's/^#.*//'`
1614 if $have_associative; then
1615 # sed_convert_to_cache_statements does not depend on the module.
1616 modcachevar_assignment='modcache_\1[$1]='
1617 func_init_sed_convert_to_cache_statements
1620 # func_cache_lookup_module module
1622 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1623 # of its relevant data in a cache in the memory of the processing shell. If
1624 # already cached, it does not look it up again, thus saving file access time.
1626 # - module non-empty string
1627 # Output if $have_associative:
1628 # - modcache_cached[$module] set to yes
1629 # - modcache_description[$module] ==
1630 # - modcache_status[$module] \ set to the field's value, minus the
1631 # - ... / final newline,
1632 # - modcache_maintainer[$module] == or unset if the field's value is empty
1633 # Output if ! $have_associative:
1634 # - cachevar a shell variable name
1635 # - ${cachevar}_cached set to $module
1636 # - ${cachevar}_description ==
1637 # - ${cachevar}_status \ set to the field's value, minus the
1638 # - ... / final newline,
1639 # - ${cachevar}_maintainer == or unset if the field's value is empty
1640 # - ${cachevar}_description_set ==
1641 # - ${cachevar}_status_set \ set to non-empty if the field's value
1642 # - ... / is non-empty,
1643 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1644 func_cache_lookup_module ()
1646 if $have_associative; then
1647 cached=${modcache_cached[$1]}
1650 eval "cached=\"\$${cachevar}_cached\""
1652 if test -z "$cached"; then
1653 # Not found in cache. Look it up on the file system.
1654 func_lookup_file "modules/$1"
1655 if $have_associative; then
1656 modcache_cached[$1]=yes
1658 eval "${cachevar}_cached=\"\$1\""
1660 if ! $have_associative; then
1661 # sed_convert_to_cache_statements depends on the module.
1662 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1663 func_init_sed_convert_to_cache_statements
1665 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1666 eval "$cache_statements"
1668 if ! $have_associative; then
1669 if test "$1" != "$cached"; then
1670 func_fatal_error "cache variable collision between $1 and $cached"
1678 # func_get_description module
1680 # - local_gnulib_dir from --local-dir
1681 # - modcache true or false, from --cache-modules/--no-cache-modules
1682 func_get_description ()
1684 if ! $modcache; then
1685 func_lookup_file "modules/$1"
1686 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1688 func_cache_lookup_module "$1"
1689 # Output the field's value, including the final newline (if any).
1690 if $have_associative; then
1691 if test -n "${modcache_description[$1]+set}"; then
1692 echo "${modcache_description[$1]}"
1695 eval "field_set=\"\$${cachevar}_description_set\""
1696 if test -n "$field_set"; then
1697 eval "field_value=\"\$${cachevar}_description\""
1698 echo "${field_value}"
1704 # func_get_status module
1706 # - local_gnulib_dir from --local-dir
1707 # - modcache true or false, from --cache-modules/--no-cache-modules
1710 if ! $modcache; then
1711 func_lookup_file "modules/$1"
1712 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1714 func_cache_lookup_module "$1"
1715 # Output the field's value, including the final newline (if any).
1716 if $have_associative; then
1717 if test -n "${modcache_status[$1]+set}"; then
1718 echo "${modcache_status[$1]}"
1721 eval "field_set=\"\$${cachevar}_status_set\""
1722 if test -n "$field_set"; then
1723 eval "field_value=\"\$${cachevar}_status\""
1724 echo "${field_value}"
1730 # func_get_notice module
1732 # - local_gnulib_dir from --local-dir
1733 # - modcache true or false, from --cache-modules/--no-cache-modules
1736 if ! $modcache; then
1737 func_lookup_file "modules/$1"
1738 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1740 func_cache_lookup_module "$1"
1741 # Output the field's value, including the final newline (if any).
1742 if $have_associative; then
1743 if test -n "${modcache_notice[$1]+set}"; then
1744 echo "${modcache_notice[$1]}"
1747 eval "field_set=\"\$${cachevar}_notice_set\""
1748 if test -n "$field_set"; then
1749 eval "field_value=\"\$${cachevar}_notice\""
1750 echo "${field_value}"
1756 # func_get_applicability module
1758 # - local_gnulib_dir from --local-dir
1759 # - modcache true or false, from --cache-modules/--no-cache-modules
1760 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1761 func_get_applicability ()
1763 if ! $modcache; then
1764 func_lookup_file "modules/$1"
1765 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1767 func_cache_lookup_module "$1"
1768 # Get the field's value, without the final newline.
1769 if $have_associative; then
1770 my_applicability="${modcache_applicability[$1]}"
1772 eval "my_applicability=\"\$${cachevar}_applicability\""
1775 if test -n "$my_applicability"; then
1776 echo $my_applicability
1778 # The default is 'main' or 'tests', depending on the module's name.
1780 *-tests) echo "tests";;
1786 # func_get_filelist module
1788 # - local_gnulib_dir from --local-dir
1789 # - modcache true or false, from --cache-modules/--no-cache-modules
1790 func_get_filelist ()
1792 if ! $modcache; then
1793 func_lookup_file "modules/$1"
1794 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1796 func_cache_lookup_module "$1"
1797 # Output the field's value, including the final newline (if any).
1798 if $have_associative; then
1799 if test -n "${modcache_files[$1]+set}"; then
1800 echo "${modcache_files[$1]}"
1803 eval "field_set=\"\$${cachevar}_files_set\""
1804 if test -n "$field_set"; then
1805 eval "field_value=\"\$${cachevar}_files\""
1806 echo "${field_value}"
1811 echo m4/gnulib-common.m4
1812 case "$autoconf_minversion" in
1819 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1820 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1821 # elements starting with prefix and ending with suffix are considered.
1822 # Processing: removed_prefix and removed_suffix are removed from each element,
1823 # added_prefix and added_suffix are added to each element.
1824 # prefix, suffix should not contain shell-special characters.
1825 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1826 # added_prefix, added_suffix should not contain the characters \|&.
1827 func_filter_filelist ()
1829 if test "$2" != "$nl" \
1830 || { $fast_func_append \
1831 && { test -z "$6" || $fast_func_remove_prefix; } \
1832 && { test -z "$7" || $fast_func_remove_suffix; }; \
1836 # Do not quote possibly-empty parameters in case patterns,
1837 # AIX and HP-UX ksh won't match them if they are empty.
1840 if test -n "$6"; then
1841 func_remove_prefix fff "$6"
1843 if test -n "$7"; then
1844 func_remove_suffix fff "$7"
1847 if test -z "$ffflist"; then
1850 func_append ffflist "$2${fff}"
1856 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1857 ffflist=`for fff in $3; do
1859 $4*$5) echo "$fff" ;;
1861 done | sed -e "$sed_fff_filter"`
1863 eval "$1=\"\$ffflist\""
1866 # func_get_dependencies module
1868 # - local_gnulib_dir from --local-dir
1869 # - modcache true or false, from --cache-modules/--no-cache-modules
1870 func_get_dependencies ()
1872 # ${module}-tests always implicitly depends on ${module}.
1876 func_remove_suffix fgd1 '-tests'
1880 # Then the explicit dependencies listed in the module description.
1881 if ! $modcache; then
1882 func_lookup_file "modules/$1"
1883 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1885 func_cache_lookup_module "$1"
1886 # Output the field's value, including the final newline (if any).
1887 if $have_associative; then
1888 if test -n "${modcache_dependson[$1]+set}"; then
1889 echo "${modcache_dependson[$1]}"
1892 eval "field_set=\"\$${cachevar}_dependson_set\""
1893 if test -n "$field_set"; then
1894 eval "field_value=\"\$${cachevar}_dependson\""
1895 echo "${field_value}"
1901 # func_get_autoconf_early_snippet module
1903 # - local_gnulib_dir from --local-dir
1904 # - modcache true or false, from --cache-modules/--no-cache-modules
1905 func_get_autoconf_early_snippet ()
1907 if ! $modcache; then
1908 func_lookup_file "modules/$1"
1909 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1911 func_cache_lookup_module "$1"
1912 # Output the field's value, including the final newline (if any).
1913 if $have_associative; then
1914 if test -n "${modcache_configureac_early[$1]+set}"; then
1915 echo "${modcache_configureac_early[$1]}"
1918 eval "field_set=\"\$${cachevar}_configureac_early_set\""
1919 if test -n "$field_set"; then
1920 eval "field_value=\"\$${cachevar}_configureac_early\""
1921 echo "${field_value}"
1927 # func_get_autoconf_snippet module
1929 # - local_gnulib_dir from --local-dir
1930 # - modcache true or false, from --cache-modules/--no-cache-modules
1931 func_get_autoconf_snippet ()
1933 if ! $modcache; then
1934 func_lookup_file "modules/$1"
1935 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1937 func_cache_lookup_module "$1"
1938 # Output the field's value, including the final newline (if any).
1939 if $have_associative; then
1940 if test -n "${modcache_configureac[$1]+set}"; then
1941 echo "${modcache_configureac[$1]}"
1944 eval "field_set=\"\$${cachevar}_configureac_set\""
1945 if test -n "$field_set"; then
1946 eval "field_value=\"\$${cachevar}_configureac\""
1947 echo "${field_value}"
1953 # func_get_automake_snippet module
1955 # - local_gnulib_dir from --local-dir
1956 # - modcache true or false, from --cache-modules/--no-cache-modules
1957 func_get_automake_snippet ()
1959 if ! $modcache; then
1960 func_lookup_file "modules/$1"
1961 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1963 func_cache_lookup_module "$1"
1964 # Output the field's value, including the final newline (if any).
1965 if $have_associative; then
1966 if test -n "${modcache_makefile[$1]+set}"; then
1967 echo "${modcache_makefile[$1]}"
1970 eval "field_set=\"\$${cachevar}_makefile_set\""
1971 if test -n "$field_set"; then
1972 eval "field_value=\"\$${cachevar}_makefile\""
1973 echo "${field_value}"
1979 # *-tests module live in tests/, not lib/.
1980 # Synthesize an EXTRA_DIST augmentation.
1981 all_files=`func_get_filelist $1`
1982 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1983 extra_files="$tests_files"
1984 if test -n "$extra_files"; then
1985 echo "EXTRA_DIST +=" $extra_files
1990 # Synthesize an EXTRA_DIST augmentation.
1991 sed_combine_lines='/\\$/{
1998 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1999 already_mentioned_files=` \
2000 { if ! $modcache; then
2001 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2003 if $have_associative; then
2004 if test -n "${modcache_makefile[$1]+set}"; then
2005 echo "${modcache_makefile[$1]}"
2008 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2009 if test -n "$field_set"; then
2010 eval 'field_value="$'"${cachevar}"'_makefile"'
2011 echo "${field_value}"
2016 | sed -e "$sed_combine_lines" \
2017 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2018 all_files=`func_get_filelist $1`
2019 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2020 # Remove $already_mentioned_files from $lib_files.
2021 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2022 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2023 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2024 if test -n "$extra_files"; then
2025 echo "EXTRA_DIST +=" $extra_files
2028 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2029 # This is necessary so that automake can generate the right list of
2031 # A possible approach would be to use autom4te --trace of the redefined
2032 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2033 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2034 # inside autoconf's built-in macros are not missed).
2035 # But it's simpler and more robust to do it here, based on the file list.
2036 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2037 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2038 # automake will generate a useless dependency; this is harmless.
2040 relocatable-prog-wrapper) ;;
2042 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2043 if test -n "$extra_files"; then
2044 echo "EXTRA_lib_SOURCES +=" $extra_files
2049 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2050 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2051 if test -n "$buildaux_files"; then
2052 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2053 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2056 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2057 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2058 if test -n "$top_files"; then
2059 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2060 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2067 # func_get_include_directive module
2069 # - local_gnulib_dir from --local-dir
2070 # - modcache true or false, from --cache-modules/--no-cache-modules
2071 func_get_include_directive ()
2074 if ! $modcache; then
2075 func_lookup_file "modules/$1"
2076 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2078 func_cache_lookup_module "$1"
2079 # Output the field's value, including the final newline (if any).
2080 if $have_associative; then
2081 if test -n "${modcache_include[$1]+set}"; then
2082 echo "${modcache_include[$1]}"
2085 eval "field_set=\"\$${cachevar}_include_set\""
2086 if test -n "$field_set"; then
2087 eval "field_value=\"\$${cachevar}_include\""
2088 echo "${field_value}"
2092 } | sed -e 's/^\(["<]\)/#include \1/'
2095 # func_get_link_directive module
2097 # - local_gnulib_dir from --local-dir
2098 # - modcache true or false, from --cache-modules/--no-cache-modules
2099 func_get_link_directive ()
2101 if ! $modcache; then
2102 func_lookup_file "modules/$1"
2103 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2105 func_cache_lookup_module "$1"
2106 # Output the field's value, including the final newline (if any).
2107 if $have_associative; then
2108 if test -n "${modcache_link[$1]+set}"; then
2109 echo "${modcache_link[$1]}"
2112 eval "field_set=\"\$${cachevar}_link_set\""
2113 if test -n "$field_set"; then
2114 eval "field_value=\"\$${cachevar}_link\""
2115 echo "${field_value}"
2121 # func_get_license module
2123 # - local_gnulib_dir from --local-dir
2124 # - modcache true or false, from --cache-modules/--no-cache-modules
2128 if ! $modcache; then
2129 func_lookup_file "modules/$1"
2130 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2132 func_cache_lookup_module "$1"
2133 # Output the field's value, including the final newline (if any).
2134 if $have_associative; then
2135 if test -n "${modcache_license[$1]+set}"; then
2136 echo "${modcache_license[$1]}"
2139 eval "field_set=\"\$${cachevar}_license_set\""
2140 if test -n "$field_set"; then
2141 eval "field_value=\"\$${cachevar}_license\""
2142 echo "${field_value}"
2146 # The default is GPL.
2148 } | sed -e 's,^ *$,,' | sed -e 1q
2151 # func_get_maintainer module
2153 # - local_gnulib_dir from --local-dir
2154 # - modcache true or false, from --cache-modules/--no-cache-modules
2155 func_get_maintainer ()
2157 if ! $modcache; then
2158 func_lookup_file "modules/$1"
2159 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2161 func_cache_lookup_module "$1"
2162 # Output the field's value, including the final newline (if any).
2163 if $have_associative; then
2164 if test -n "${modcache_maintainer[$1]+set}"; then
2165 echo "${modcache_maintainer[$1]}"
2168 eval "field_set=\"\$${cachevar}_maintainer_set\""
2169 if test -n "$field_set"; then
2170 eval "field_value=\"\$${cachevar}_maintainer\""
2171 echo "${field_value}"
2177 # func_get_tests_module module
2179 # - local_gnulib_dir from --local-dir
2180 func_get_tests_module ()
2182 # The naming convention for tests modules is hardwired: ${module}-tests.
2183 if test -f "$gnulib_dir/modules/$1"-tests \
2184 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2185 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2190 # func_acceptable module
2191 # tests whether a module is acceptable.
2193 # - avoidlist list of modules to avoid
2196 for avoid in $avoidlist; do
2197 if test "$avoid" = "$1"; then
2204 # func_modules_transitive_closure
2206 # - local_gnulib_dir from --local-dir
2207 # - modcache true or false, from --cache-modules/--no-cache-modules
2208 # - modules list of specified modules
2209 # - inctests true if tests should be included, blank otherwise
2210 # - incobsolete true if obsolete modules among dependencies should be
2211 # included, blank otherwise
2212 # - avoidlist list of modules to avoid
2213 # - tmp pathname of a temporary directory
2215 # - modules list of modules, including dependencies
2216 func_modules_transitive_closure ()
2218 # In order to process every module only once (for speed), process an "input
2219 # list" of modules, producing an "output list" of modules. During each round,
2220 # more modules can be queued in the input list. Once a module on the input
2221 # list has been processed, it is added to the "handled list", so we can avoid
2222 # to process it again.
2224 inmodules="$modules"
2226 while test -n "$inmodules"; do
2227 inmodules_this_round="$inmodules"
2228 inmodules= # Accumulator, queue for next round
2229 for module in $inmodules_this_round; do
2231 if test -n "$module"; then
2232 if func_acceptable $module; then
2233 func_append outmodules " $module"
2234 deps=`func_get_dependencies $module`
2235 # Duplicate dependencies are harmless, but Jim wants a warning.
2236 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2237 if test -n "$duplicated_deps"; then
2238 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2240 for dep in $deps; do
2241 if test -n "$incobsolete" \
2242 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
2243 func_append inmodules " $dep"
2246 if test -n "$inctests"; then
2247 testsmodule=`func_get_tests_module $module`
2248 if test -n "$testsmodule"; then
2249 func_append inmodules " $testsmodule"
2255 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2256 # Remove $handledmodules from $inmodules.
2257 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2258 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2260 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2261 rm -f "$tmp"/queued-modules
2264 # func_modules_add_dummy
2266 # - local_gnulib_dir from --local-dir
2267 # - modcache true or false, from --cache-modules/--no-cache-modules
2268 # - modules list of modules, including dependencies
2270 # - modules list of modules, including 'dummy' if needed
2271 func_modules_add_dummy ()
2273 # Determine whether any module provides a lib_SOURCES augmentation.
2275 sed_remove_backslash_newline=':a
2282 for module in $modules; do
2283 func_verify_nontests_module
2284 if test -n "$module"; then
2285 # Extract the value of "lib_SOURCES += ...".
2286 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2287 # Ignore .h files since they are not compiled.
2291 have_lib_SOURCES=yes
2298 # Add the dummy module, to make sure the library will be non-empty.
2299 if test -z "$have_lib_SOURCES"; then
2300 if func_acceptable "dummy"; then
2301 func_append modules " dummy"
2306 # func_modules_notice
2308 # - local_gnulib_dir from --local-dir
2309 # - modcache true or false, from --cache-modules/--no-cache-modules
2310 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2311 # - modules list of modules, including dependencies
2312 func_modules_notice ()
2314 if test $verbose -ge -1; then
2315 for module in $modules; do
2317 if test -n "$module"; then
2318 msg=`func_get_notice $module`
2319 if test -n "$msg"; then
2320 echo "Notice from module $module:"
2321 echo "$msg" | sed -e 's/^/ /'
2328 # func_modules_to_filelist
2330 # - local_gnulib_dir from --local-dir
2331 # - modcache true or false, from --cache-modules/--no-cache-modules
2332 # - modules list of modules, including dependencies
2334 # - files list of files
2335 func_modules_to_filelist ()
2338 for module in $modules; do
2340 if test -n "$module"; then
2341 fs=`func_get_filelist $module`
2342 func_append files " $fs"
2345 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2348 # func_execute_command command [args...]
2349 # Executes a command.
2350 # Uses also the variables
2351 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2352 func_execute_command ()
2354 if test $verbose -ge 0; then
2358 # Commands like automake produce output to stderr even when they succeed.
2359 # Turn this output off if the command succeeds.
2360 "$@" > "$tmp"/cmdout 2>&1
2362 if test $cmdret = 0; then
2366 cat "$tmp"/cmdout 1>&2
2373 # func_dest_tmpfilename file
2374 # determines the name of a temporary file (file is relative to destdir).
2376 # - destdir target directory
2377 # - doit : if actions shall be executed, false if only to be printed
2378 # - tmp pathname of a temporary directory
2380 # - tmpfile absolute filename of the temporary file
2381 func_dest_tmpfilename ()
2384 # Put the new contents of $file in a file in the same directory (needed
2385 # to guarantee that an 'mv' to "$destdir/$file" works).
2386 tmpfile="$destdir/$1.tmp"
2388 # Put the new contents of $file in a file in a temporary directory
2389 # (because the directory of "$file" might not exist).
2390 tmpfile="$tmp"/`basename "$1"`.tmp
2395 # copies a file from gnulib into the destination directory. The destination
2396 # is known to not exist.
2398 # - destdir target directory
2399 # - local_gnulib_dir from --local-dir
2400 # - modcache true or false, from --cache-modules/--no-cache-modules
2401 # - f the original file name
2402 # - lookedup_file name of the merged (combined) file
2403 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2404 # - g the rewritten file name
2405 # - tmpfile absolute filename of the temporary file
2406 # - doit : if actions shall be executed, false if only to be printed
2407 # - symbolic true if files should be symlinked, copied otherwise
2408 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2413 echo "Copying file $g"
2414 if { test -n "$symbolic" \
2415 || { test -n "$lsymbolic" \
2416 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2417 && test -z "$lookedup_tmp" \
2418 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2419 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2421 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2429 # copies a file from gnulib into the destination directory. The destination
2430 # is known to exist.
2432 # - destdir target directory
2433 # - local_gnulib_dir from --local-dir
2434 # - modcache true or false, from --cache-modules/--no-cache-modules
2435 # - f the original file name
2436 # - lookedup_file name of the merged (combined) file
2437 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2438 # - g the rewritten file name
2439 # - tmpfile absolute filename of the temporary file
2440 # - doit : if actions shall be executed, false if only to be printed
2441 # - symbolic true if files should be symlinked, copied otherwise
2442 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2444 # - already_present nonempty if the file should already exist, empty otherwise
2447 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2448 : # The file has not changed.
2452 if test -n "$already_present"; then
2453 echo "Updating file $g (backup in ${g}~)"
2455 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2457 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2458 if { test -n "$symbolic" \
2459 || { test -n "$lsymbolic" \
2460 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2461 && test -z "$lookedup_tmp" \
2462 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2463 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2465 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2468 if test -n "$already_present"; then
2469 echo "Update file $g (backup in ${g}~)"
2471 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2477 # func_emit_lib_Makefile_am
2478 # emits the contents of library makefile to standard output.
2480 # - local_gnulib_dir from --local-dir
2481 # - modcache true or false, from --cache-modules/--no-cache-modules
2482 # - modules list of modules, including dependencies
2483 # - libname library name
2484 # - pobase directory relative to destdir where to place *.po files
2485 # - auxdir directory relative to destdir where to place build aux files
2486 # - makefile_name from --makefile-name
2487 # - libtool true if libtool will be used, false or blank otherwise
2488 # - macro_prefix prefix of gl_LIBOBJS macros to use
2489 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2490 # - actioncmd (optional) command that will reproduce this invocation
2491 # - for_test true if creating a package for testing, false otherwise
2492 # - destfile filename relative to destdir of makefile being generated
2494 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2495 # list of edits to be done to Makefile.am variables
2497 # - uses_subdirs nonempty if object files in subdirs exist
2498 func_emit_lib_Makefile_am ()
2500 # When creating an includable Makefile.am snippet, augment variables with
2501 # += instead of assigning them.
2502 if test -n "$makefile_name"; then
2507 if test "$libtool" = true; then
2510 sed_eliminate_LDFLAGS="$sed_noop"
2514 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2517 # When creating a package for testing: Attempt to provoke failures,
2518 # especially link errors, already during "make" rather than during
2519 # "make check", because "make check" is not possible in a cross-compiling
2520 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2521 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2523 sed_transform_check_PROGRAMS="$sed_noop"
2525 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2526 echo "## Process this file with automake to produce Makefile.in."
2527 func_emit_copyright_notice
2528 if test -n "$actioncmd"; then
2529 # The maximum line length (excluding the terminating newline) of any file
2530 # that is to be preprocessed by config.status is 3070. config.status uses
2531 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2532 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2533 len=`echo "$actioncmd" | wc -c`
2534 if test -n "$len" && test "$len" -le 3000; then
2535 echo "# Reproduce by: $actioncmd"
2541 for module in $modules; do
2542 func_verify_nontests_module
2543 if test -n "$module"; then
2545 func_get_automake_snippet "$module" |
2547 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2548 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2549 -e "$sed_eliminate_LDFLAGS" \
2550 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2551 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2552 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2553 -e "$sed_transform_check_PROGRAMS"
2554 if test "$module" = 'alloca'; then
2555 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2556 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2558 } > "$tmp"/amsnippet
2559 # Skip the contents if it's entirely empty.
2560 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2561 echo "## begin gnulib module $module"
2563 cat "$tmp"/amsnippet
2564 echo "## end gnulib module $module"
2567 rm -f "$tmp"/amsnippet
2568 # Test whether there are some source files in subdirectories.
2569 for f in `func_get_filelist "$module"`; do
2579 } > "$tmp"/allsnippets
2580 if test -z "$makefile_name"; then
2581 # If there are source files in subdirectories, prevent collision of the
2582 # object files (example: hash.c and libxml/hash.c).
2584 if test -n "$uses_subdirs"; then
2585 subdir_options=' subdir-objects'
2587 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2590 if test -z "$makefile_name"; then
2592 echo "noinst_HEADERS ="
2593 echo "noinst_LIBRARIES ="
2594 echo "noinst_LTLIBRARIES ="
2595 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2596 # if you specify pkgdata_DATA to empty. This is a workaround.
2597 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2598 echo "pkgdata_DATA ="
2601 echo "BUILT_SOURCES ="
2604 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2605 if test -z "$makefile_name"; then
2606 echo "MOSTLYCLEANDIRS ="
2608 echo "DISTCLEANFILES ="
2609 echo "MAINTAINERCLEANFILES ="
2611 # Execute edits that apply to the Makefile.am being generated.
2613 while test $edit != $makefile_am_edits; do
2614 edit=`expr $edit + 1`
2615 eval dir=\"\$makefile_am_edit${edit}_dir\"
2616 eval var=\"\$makefile_am_edit${edit}_var\"
2617 eval val=\"\$makefile_am_edit${edit}_val\"
2618 if test -n "$var"; then
2619 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2620 echo "${var} += ${val}"
2621 eval "makefile_am_edit${edit}_var="
2625 if test -z "$makefile_name"; then
2627 echo "AM_CPPFLAGS ="
2631 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2632 || { test -n "$makefile_name" \
2633 && test -f "$sourcebase/Makefile.am" \
2634 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2636 # One of the snippets or the user's Makefile.am already specifies an
2637 # installation location for the library. Don't confuse automake by saying
2638 # it should not be installed.
2641 # By default, the generated library should not be installed.
2642 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2645 echo "${libname}_${libext}_SOURCES ="
2646 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2647 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2648 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2649 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2650 echo "EXTRA_${libname}_${libext}_SOURCES ="
2651 if test "$libtool" = true; then
2652 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2655 if test -n "$pobase"; then
2656 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2659 cat "$tmp"/allsnippets \
2660 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2662 echo "mostlyclean-local: mostlyclean-generic"
2663 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2664 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2665 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2669 rm -f "$tmp"/allsnippets
2672 # func_emit_po_Makevars
2673 # emits the contents of po/ makefile parameterization to standard output.
2675 # - local_gnulib_dir from --local-dir
2676 # - modcache true or false, from --cache-modules/--no-cache-modules
2677 # - sourcebase directory relative to destdir where to place source code
2678 # - pobase directory relative to destdir where to place *.po files
2679 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2680 func_emit_po_Makevars ()
2682 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2683 func_emit_copyright_notice
2685 echo "# Usually the message domain is the same as the package name."
2686 echo "# But here it has a '-gnulib' suffix."
2687 echo "DOMAIN = ${po_domain}-gnulib"
2689 echo "# These two variables depend on the location of this directory."
2690 echo "subdir = ${pobase}"
2691 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2694 # These options get passed to xgettext.
2695 XGETTEXT_OPTIONS = \
2696 --keyword=_ --flag=_:1:pass-c-format \
2697 --keyword=N_ --flag=N_:1:pass-c-format \
2698 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2699 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2700 --flag=error:3:c-format --flag=error_at_line:5:c-format
2702 # This is the copyright holder that gets inserted into the header of the
2703 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2704 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2706 # This is the email address or URL to which the translators shall report
2707 # bugs in the untranslated strings:
2708 # - Strings which are not entire sentences, see the maintainer guidelines
2709 # in the GNU gettext documentation, section 'Preparing Strings'.
2710 # - Strings which use unclear terms or require additional context to be
2712 # - Strings which make invalid assumptions about notation of date, time or
2714 # - Pluralisation problems.
2715 # - Incorrect English spelling.
2716 # - Incorrect formatting.
2717 # It can be your email address, or a mailing list address where translators
2718 # can write to without being subscribed, or the URL of a web page through
2719 # which the translators can contact you.
2720 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2722 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2723 # message catalogs shall be used. It is usually empty.
2724 EXTRA_LOCALE_CATEGORIES =
2726 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2727 # context. Possible values are "yes" and "no". Set this to yes if the
2728 # package uses functions taking also a message context, like pgettext(), or
2729 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2734 # func_emit_po_POTFILES_in
2735 # emits the file list to be passed to xgettext to standard output.
2737 # - local_gnulib_dir from --local-dir
2738 # - modcache true or false, from --cache-modules/--no-cache-modules
2739 # - sourcebase directory relative to destdir where to place source code
2740 # - files list of new files
2741 func_emit_po_POTFILES_in ()
2743 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2744 func_emit_copyright_notice
2746 echo "# List of files which contain translatable strings."
2747 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2750 # func_emit_tests_Makefile_am
2751 # emits the contents of tests makefile to standard output.
2753 # - local_gnulib_dir from --local-dir
2754 # - modcache true or false, from --cache-modules/--no-cache-modules
2755 # - modules list of modules, including dependencies
2756 # - libname library name
2757 # - auxdir directory relative to destdir where to place build aux files
2758 # - makefile_name from --makefile-name
2759 # - libtool true if libtool will be used, false or blank otherwise
2760 # - sourcebase relative directory containing lib source code
2761 # - m4base relative directory containing autoconf macros
2762 # - testsbase relative directory containing unit test code
2763 # - macro_prefix prefix of gl_LIBOBJS macros to use
2764 # - for_test true if creating a package for testing, false otherwise
2765 # - use_libtests true if a libtests.a should be built, false otherwise
2766 # - destfile filename relative to destdir of makefile being generated
2768 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2769 # list of edits to be done to Makefile.am variables
2771 # - uses_subdirs nonempty if object files in subdirs exist
2772 func_emit_tests_Makefile_am ()
2774 if test "$libtool" = true; then
2776 sed_eliminate_LDFLAGS="$sed_noop"
2779 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2782 # When creating a package for testing: Attempt to provoke failures,
2783 # especially link errors, already during "make" rather than during
2784 # "make check", because "make check" is not possible in a cross-compiling
2785 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2786 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2788 sed_transform_check_PROGRAMS="$sed_noop"
2790 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2791 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2792 echo "## Process this file with automake to produce Makefile.in."
2793 func_emit_copyright_notice
2797 for module in $modules; do
2799 func_verify_tests_module
2803 if test -n "$module"; then
2805 func_get_automake_snippet "$module" |
2807 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2808 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2809 -e "$sed_eliminate_LDFLAGS" \
2810 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2811 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2812 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2813 -e "$sed_transform_check_PROGRAMS"
2814 if $use_libtests && test "$module" = 'alloca'; then
2815 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2816 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2818 } > "$tmp"/amsnippet
2819 # Skip the contents if it's entirely empty.
2820 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2821 echo "## begin gnulib module $module"
2823 cat "$tmp"/amsnippet
2824 echo "## end gnulib module $module"
2827 rm -f "$tmp"/amsnippet
2828 # Test whether there are some source files in subdirectories.
2829 for f in `func_get_filelist "$module"`; do
2831 lib/*/*.c | tests/*/*.c)
2839 } > "$tmp"/allsnippets
2840 # Generate dependencies here, since it eases the debugging of test failures.
2841 # If there are source files in subdirectories, prevent collision of the
2842 # object files (example: hash.c and libxml/hash.c).
2844 if test -n "$uses_subdirs"; then
2845 subdir_options=' subdir-objects'
2847 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2850 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2853 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2854 # variable is needed to avoid an error from automake:
2855 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2858 echo "XFAIL_TESTS ="
2859 echo "TESTS_ENVIRONMENT ="
2860 echo "noinst_PROGRAMS ="
2861 if ! $for_test; then
2862 echo "check_PROGRAMS ="
2864 echo "noinst_HEADERS ="
2865 echo "noinst_LIBRARIES ="
2866 if $use_libtests; then
2868 echo "noinst_LIBRARIES += libtests.a"
2870 echo "check_LIBRARIES = libtests.a"
2873 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2874 # if you specify pkgdata_DATA to empty. This is a workaround.
2875 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2876 echo "pkgdata_DATA ="
2879 echo "BUILT_SOURCES ="
2881 echo "MOSTLYCLEANFILES = core *.stackdump"
2882 echo "MOSTLYCLEANDIRS ="
2884 echo "DISTCLEANFILES ="
2885 echo "MAINTAINERCLEANFILES ="
2886 # Execute edits that apply to the Makefile.am being generated.
2888 while test $edit != $makefile_am_edits; do
2889 edit=`expr $edit + 1`
2890 eval dir=\"\$makefile_am_edit${edit}_dir\"
2891 eval var=\"\$makefile_am_edit${edit}_var\"
2892 eval val=\"\$makefile_am_edit${edit}_val\"
2893 if test -n "$var"; then
2894 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2895 echo "${var} += ${val}"
2896 eval "makefile_am_edit${edit}_var="
2901 echo "AM_CPPFLAGS = \\"
2902 echo " -I. -I\$(srcdir) \\"
2903 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2904 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2906 local_ldadd_before=''
2907 local_ldadd_after=''
2908 if $use_libtests; then
2909 # All test programs need to be linked with libtests.a.
2910 # It needs to be passed to the linker before ${libname}.${libext}, since
2911 # the tests-related modules depend on the main modules.
2912 # It also needs to be passed to the linker after ${libname}.${libext}
2913 # because the latter might contain incomplete modules (such as the 'error'
2914 # module whose dependency to 'progname' is voluntarily omitted).
2915 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2917 local_ldadd_before=' libtests.a'
2918 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2920 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2922 if $use_libtests; then
2923 echo "libtests_a_SOURCES ="
2924 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2925 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2926 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2927 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2928 echo "EXTRA_libtests_a_SOURCES ="
2929 # The circular dependency in LDADD requires this.
2930 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2933 # Many test scripts use ${EXEEXT} or ${srcdir}.
2934 # EXEEXT is defined by AC_PROG_CC through autoconf.
2935 # srcdir is defined by autoconf and automake.
2936 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
2938 cat "$tmp"/allsnippets \
2939 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2940 echo "# Clean up after Solaris cc."
2942 echo " rm -rf SunWS_cache"
2944 echo "mostlyclean-local: mostlyclean-generic"
2945 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2946 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2947 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2951 rm -f "$tmp"/allsnippets
2954 # func_emit_initmacro_start macro_prefix
2955 # emits the first few statements of the gl_INIT macro to standard output.
2956 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2957 func_emit_initmacro_start ()
2959 macro_prefix_arg="$1"
2960 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2961 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2962 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2963 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2965 # Furthermore it avoids an automake error like this when a Makefile.am
2966 # that uses pieces of gnulib also uses $(LIBOBJ):
2967 # automatically discovered file `error.c' should not be explicitly mentioned
2968 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2969 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2970 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2971 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2972 # automatically discovered file `error.c' should not be explicitly mentioned
2973 # We let automake know about the files to be distributed through the
2974 # EXTRA_lib_SOURCES variable.
2975 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2976 # Create data variables for checking the presence of files that are mentioned
2977 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2978 # because we want the check to happen when the configure file is created,
2979 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2980 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2981 # in which to expect them.
2982 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2983 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2987 # func_emit_initmacro_end macro_prefix
2988 # emits the last few statements of the gl_INIT macro to standard output.
2989 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2990 func_emit_initmacro_end ()
2992 macro_prefix_arg="$1"
2993 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2994 # The check is performed only when autoconf is run from the directory where
2995 # the configure.ac resides; if it is run from a different directory, the
2997 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2998 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2999 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3000 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3001 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3005 echo " m4_if(m4_sysval, [0], [],"
3006 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3008 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3009 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3010 echo " m4_popdef([AC_LIBSOURCES])"
3011 echo " m4_popdef([AC_REPLACE_FUNCS])"
3012 echo " m4_popdef([AC_LIBOBJ])"
3013 echo " AC_CONFIG_COMMANDS_PRE(["
3014 echo " ${macro_prefix_arg}_libobjs="
3015 echo " ${macro_prefix_arg}_ltlibobjs="
3016 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3017 echo " # Remove the extension."
3018 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3019 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3020 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3021 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3024 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3025 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3029 # func_emit_initmacro_done macro_prefix sourcebase
3030 # emits a few statements after the gl_INIT macro to standard output.
3031 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3032 # - sourcebase directory relative to destdir where to place source code
3033 func_emit_initmacro_done ()
3035 macro_prefix_arg="$1"
3038 echo "# Like AC_LIBOBJ, except that the module name goes"
3039 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3040 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3041 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3042 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3045 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3046 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3047 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3048 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3049 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3052 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3053 echo "# expected is derived from the gnulib-tool parameterization,"
3054 echo "# and alloca is special cased (for the alloca-opt module)."
3055 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3056 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3057 echo " m4_foreach([_gl_NAME], [\$1], ["
3058 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3059 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3060 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3066 # func_import modules
3067 # Uses also the variables
3068 # - destdir target directory
3069 # - local_gnulib_dir from --local-dir
3070 # - modcache true or false, from --cache-modules/--no-cache-modules
3071 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3072 # - libname library name
3073 # - sourcebase directory relative to destdir where to place source code
3074 # - m4base directory relative to destdir where to place *.m4 macros
3075 # - pobase directory relative to destdir where to place *.po files
3076 # - docbase directory relative to destdir where to place doc files
3077 # - testsbase directory relative to destdir where to place unit test code
3078 # - auxdir directory relative to destdir where to place build aux files
3079 # - inctests true if --with-tests was given, blank otherwise
3080 # - incobsolete true if --with-obsolete was given, blank otherwise
3081 # - avoidlist list of modules to avoid, from --avoid
3082 # - lgpl yes or a number if library's license shall be LGPL,
3084 # - makefile_name from --makefile-name
3085 # - libtool true if --libtool was given, false if --no-libtool was
3086 # given, blank otherwise
3087 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3088 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3089 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3090 # - vc_files true if --vc-files was given, false if --no-vc-files was
3091 # given, blank otherwise
3092 # - autoconf_minversion minimum supported autoconf version
3093 # - doit : if actions shall be executed, false if only to be printed
3094 # - symbolic true if files should be symlinked, copied otherwise
3095 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3097 # - do_copyrights true if copyright notices in files should be replaced,
3101 # Get the cached settings.
3102 cached_local_gnulib_dir=
3103 cached_specified_modules=
3114 cached_makefile_name=
3116 cached_macro_prefix=
3120 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3121 cached_libtool=false
3127 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3137 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3139 /gl_WITH_OBSOLETE/ {
3140 s,^.*$,cached_incobsolete=true,p
3143 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3146 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3149 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3152 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3155 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3158 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3161 s,^.*$,cached_inctests=true,p
3164 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3167 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3170 s,^.*$,cached_lgpl=yes,p
3172 /gl_MAKEFILE_NAME(/ {
3173 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3176 s,^.*$,cached_libtool=true,p
3178 /gl_MACRO_PREFIX(/ {
3179 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3182 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3185 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3187 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3188 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3193 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3194 s,^.*$,cached_files=",p
3207 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3211 # Merge the cached settings with the specified ones.
3212 # The m4base must be the same as expected from the pathname.
3213 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3214 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3216 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3217 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3218 if test -z "$local_gnulib_dir"; then
3219 if test -n "$cached_local_gnulib_dir"; then
3222 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3224 case "$cached_local_gnulib_dir" in
3226 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3228 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3229 local_gnulib_dir="$relconcat" ;;
3234 # Append the cached and the specified module names. So that
3235 # "gnulib-tool --import foo" means to add the module foo.
3236 specified_modules="$cached_specified_modules $1"
3237 # Included obsolete modules among the dependencies if specified either way.
3238 if test -z "$incobsolete"; then
3239 incobsolete="$cached_incobsolete"
3241 # Append the cached and the specified avoidlist. This is probably better
3242 # than dropping the cached one when --avoid is specified at least once.
3243 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3244 avoidlist=`echo $avoidlist`
3246 # The sourcebase defaults to the cached one.
3247 if test -z "$sourcebase"; then
3248 sourcebase="$cached_sourcebase"
3249 if test -z "$sourcebase"; then
3250 func_fatal_error "missing --source-base option"
3253 # The pobase defaults to the cached one.
3254 if test -z "$pobase"; then
3255 pobase="$cached_pobase"
3257 # The docbase defaults to the cached one.
3258 if test -z "$docbase"; then
3259 docbase="$cached_docbase"
3260 if test -z "$docbase"; then
3261 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."
3264 # The testsbase defaults to the cached one.
3265 if test -z "$testsbase"; then
3266 testsbase="$cached_testsbase"
3267 if test -z "$testsbase"; then
3268 func_fatal_error "missing --tests-base option"
3271 # Require the tests if specified either way.
3272 if test -z "$inctests"; then
3273 inctests="$cached_inctests"
3275 # The libname defaults to the cached one.
3276 if test -z "$supplied_libname"; then
3277 libname="$cached_libname"
3278 if test -z "$libname"; then
3279 func_fatal_error "missing --lib option"
3282 # Require LGPL if specified either way.
3283 if test -z "$lgpl"; then
3286 # The makefile_name defaults to the cached one.
3287 if test -z "$makefile_name"; then
3288 makefile_name="$cached_makefile_name"
3290 # Use libtool if specified either way, or if guessed.
3291 if test -z "$libtool"; then
3292 if test -n "$cached_m4base"; then
3293 libtool="$cached_libtool"
3295 libtool="$guessed_libtool"
3298 # The macro_prefix defaults to the cached one.
3299 if test -z "$macro_prefix"; then
3300 macro_prefix="$cached_macro_prefix"
3301 if test -z "$macro_prefix"; then
3302 func_fatal_error "missing --macro-prefix option"
3305 # The po_domain defaults to the cached one.
3306 if test -z "$po_domain"; then
3307 po_domain="$cached_po_domain"
3309 # The vc_files defaults to the cached one.
3310 if test -z "$vc_files"; then
3311 vc_files="$cached_vc_files"
3314 # Canonicalize the list of specified modules.
3315 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3317 # Determine final module list.
3318 modules="$specified_modules"
3319 func_modules_transitive_closure
3320 if test $verbose -ge 0; then
3321 echo "Module list with included dependencies:"
3322 echo "$modules" | sed -e 's/^/ /'
3324 final_modules="$modules"
3326 # Determine main module list and tests-related module list separately.
3327 # The main module list is the transitive closure of the specified modules,
3328 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3329 # is specified, it will consist only of LGPLed source.
3330 # The tests-related module list is the transitive closure of the specified
3331 # modules, including tests modules, minus the main module list excluding
3332 # modules of applicability 'all'. Its lib/* sources (brought in through
3333 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3334 # source, even if --lgpl is specified.
3335 # Determine main module list.
3336 saved_inctests="$inctests"
3338 modules="$specified_modules"
3339 func_modules_transitive_closure
3340 main_modules="$modules"
3341 inctests="$saved_inctests"
3342 if test $verbose -ge 1; then
3343 echo "Main module list:"
3344 echo "$main_modules" | sed -e 's/^/ /'
3346 # Determine tests-related module list.
3347 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3348 testsrelated_modules=`for module in $main_modules; do
3349 if test \`func_get_applicability $module\` = main; then
3353 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3354 if test $verbose -ge 1; then
3355 echo "Tests-related module list:"
3356 echo "$testsrelated_modules" | sed -e 's/^/ /'
3359 # Add the dummy module to the main module list if needed.
3360 modules="$main_modules"
3361 func_modules_add_dummy
3362 main_modules="$modules"
3364 # Determine whether a $testsbase/libtests.a is needed.
3366 for module in $testsrelated_modules; do
3367 func_verify_nontests_module
3368 if test -n "$module"; then
3369 all_files=`func_get_filelist $module`
3370 # Test whether some file in $all_files lies in lib/.
3371 for f in $all_files; do
3382 # Add the dummy module to the tests-related module list if needed.
3383 if $use_libtests; then
3384 modules="$testsrelated_modules"
3385 func_modules_add_dummy
3386 testsrelated_modules="$modules"
3389 # If --lgpl, verify that the licenses of modules are compatible.
3390 if test -n "$lgpl"; then
3391 license_incompatibilities=
3392 for module in $main_modules; do
3393 license=`func_get_license $module`
3395 'GPLed build tool') ;;
3396 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3401 LGPL | LGPLv2+ | LGPLv3+) ;;
3402 *) func_append license_incompatibilities "$module $license$nl" ;;
3408 *) func_append license_incompatibilities "$module $license$nl" ;;
3411 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3416 if test -n "$license_incompatibilities"; then
3417 # Format the license incompatibilities as a table.
3418 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3419 s,^\(.................................................[^ ]*\) *, \1 ,'
3420 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3421 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3425 # Show banner notice of every module.
3426 modules="$main_modules"
3429 # Determine script to apply to imported library files.
3430 sed_transform_lib_file=
3431 for module in $main_modules; do
3432 if test $module = config-h; then
3433 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3434 sed_transform_lib_file=$sed_transform_lib_file'
3435 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3440 sed_transform_main_lib_file="$sed_transform_lib_file"
3441 if test -n "$do_copyrights"; then
3442 if test -n "$lgpl"; then
3446 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3447 s/GNU General/GNU Lesser General/g
3451 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3452 s/GNU General/GNU Lesser General/g
3453 s/version [23]\([ ,]\)/version 2.1\1/g
3456 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3460 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3461 s/GNU Lesser General/GNU General/g
3462 s/GNU Library General/GNU General/g
3463 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3468 # Determine script to apply to auxiliary files that go into $auxdir/.
3469 sed_transform_build_aux_file=
3470 if test -n "$do_copyrights"; then
3472 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3473 s/GNU Lesser General/GNU General/g
3474 s/GNU Library General/GNU General/g
3475 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3479 # Determine script to apply to library files that go into $testsbase/.
3480 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3481 if test -n "$do_copyrights"; then
3483 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3484 s/GNU Lesser General/GNU General/g
3485 s/GNU Library General/GNU General/g
3486 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3490 # Determine the final file lists.
3491 # They must be computed separately, because files in lib/* go into
3492 # $sourcebase/ if they are in the main file list but into $testsbase/
3493 # if they are in the tests-related file list. Furthermore lib/dummy.c
3495 # Determine final main file list.
3496 modules="$main_modules"
3497 func_modules_to_filelist
3499 # Determine final tests-related file list.
3500 modules="$testsrelated_modules"
3501 func_modules_to_filelist
3502 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3503 # Merge both file lists.
3504 sed_remove_empty_lines='/^$/d'
3505 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3506 if test $verbose -ge 0; then
3508 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3509 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3513 || func_fatal_error "refusing to do nothing"
3515 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3516 new_files="$files m4/gnulib-tool.m4"
3517 old_files="$cached_files"
3518 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3519 func_append old_files " m4/gnulib-tool.m4"
3522 rewritten='%REWRITTEN%'
3523 sed_rewrite_old_files="\
3524 s,^build-aux/,$rewritten$auxdir/,
3525 s,^doc/,$rewritten$cached_docbase/,
3526 s,^lib/,$rewritten$cached_sourcebase/,
3527 s,^m4/,$rewritten$cached_m4base/,
3528 s,^tests/,$rewritten$cached_testsbase/,
3529 s,^tests=lib/,$rewritten$cached_testsbase/,
3532 sed_rewrite_new_files="\
3533 s,^build-aux/,$rewritten$auxdir/,
3534 s,^doc/,$rewritten$docbase/,
3535 s,^lib/,$rewritten$sourcebase/,
3536 s,^m4/,$rewritten$m4base/,
3537 s,^tests/,$rewritten$testsbase/,
3538 s,^tests=lib/,$rewritten$testsbase/,
3542 # Create directories.
3543 { echo "$sourcebase"
3545 if test -n "$pobase"; then
3548 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3549 if test -n "$docfiles"; then
3552 if test -n "$inctests"; then
3556 for f in $files; do echo $f; done \
3557 | sed -e "$sed_rewrite_new_files" \
3558 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3561 { # Rearrange file descriptors. Needed because "while ... done < ..."
3562 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3563 exec 5<&0 < "$tmp"/dirs
3565 if test ! -d "$destdir/$d"; then
3567 echo "Creating directory $destdir/$d"
3568 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3570 echo "Create directory $destdir/$d"
3577 # Copy files or make symbolic links. Remove obsolete files.
3581 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3582 # representing the files according to the last gnulib-tool invocation.
3583 for f in $old_files; do echo $f; done \
3584 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3587 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3588 # representing the files after this gnulib-tool invocation.
3589 for f in $new_files; do echo $f; done \
3590 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3593 # First the files that are in old-files, but not in new-files:
3594 sed_take_first_column='s,'"$delimiter"'.*,,'
3595 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3596 # Remove the file. Do nothing if the user already removed it.
3597 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3599 echo "Removing file $g (backup in ${g}~)"
3600 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3602 echo "Remove file $g (backup in ${g}~)"
3604 func_append removed_files "$g$nl"
3607 # func_add_or_update handles a file that ought to be present afterwards.
3609 # - f the original file name
3610 # - g the rewritten file name
3611 # - already_present nonempty if the file should already exist, empty
3613 func_add_or_update ()
3617 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3619 func_dest_tmpfilename "$g"
3620 func_lookup_file "$f"
3621 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3622 if test -n "$sed_transform_main_lib_file"; then
3625 sed -e "$sed_transform_main_lib_file" \
3626 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3630 if test -n "$sed_transform_build_aux_file"; then
3633 sed -e "$sed_transform_build_aux_file" \
3634 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3638 if test -n "$sed_transform_testsrelated_lib_file"; then
3641 sed -e "$sed_transform_testsrelated_lib_file" \
3642 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3646 if test -f "$destdir/$g"; then
3647 # The file already exists.
3651 # Don't protest if the file should be there but isn't: it happens
3652 # frequently that developers don't put autogenerated files into CVS.
3654 func_append added_files "$g$nl"
3658 # Then the files that are in new-files, but not in old-files:
3659 sed_take_last_column='s,^.*'"$delimiter"',,'
3661 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3662 | sed -e "$sed_take_last_column" \
3663 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3664 { # Rearrange file descriptors. Needed because "while ... done < ..."
3665 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3666 exec 5<&0 < "$tmp"/added-files
3672 # Then the files that are in new-files and in old-files:
3673 already_present=true
3674 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3675 | sed -e "$sed_take_last_column" \
3676 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3677 { # Rearrange file descriptors. Needed because "while ... done < ..."
3678 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3679 exec 5<&0 < "$tmp"/kept-files
3686 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3687 actioncmd="gnulib-tool --import"
3688 func_append actioncmd " --dir=$destdir"
3689 if test -n "$local_gnulib_dir"; then
3690 func_append actioncmd " --local-dir=$local_gnulib_dir"
3692 func_append actioncmd " --lib=$libname"
3693 func_append actioncmd " --source-base=$sourcebase"
3694 func_append actioncmd " --m4-base=$m4base"
3695 if test -n "$pobase"; then
3696 func_append actioncmd " --po-base=$pobase"
3698 func_append actioncmd " --doc-base=$docbase"
3699 func_append actioncmd " --tests-base=$testsbase"
3700 func_append actioncmd " --aux-dir=$auxdir"
3701 if test -n "$inctests"; then
3702 func_append actioncmd " --with-tests"
3704 if test -n "$incobsolete"; then
3705 func_append actioncmd " --with-obsolete"
3707 for module in $avoidlist; do
3708 func_append actioncmd " --avoid=$module"
3710 if test -n "$lgpl"; then
3711 if test "$lgpl" = yes; then
3712 func_append actioncmd " --lgpl"
3714 func_append actioncmd " --lgpl=$lgpl"
3717 if test -n "$makefile_name"; then
3718 func_append actioncmd " --makefile-name=$makefile_name"
3720 if test "$libtool" = true; then
3721 func_append actioncmd " --libtool"
3723 func_append actioncmd " --no-libtool"
3725 func_append actioncmd " --macro-prefix=$macro_prefix"
3726 if test -n "$po_domain"; then
3727 func_append actioncmd " --po-domain=$po_domain"
3729 if test -n "$vc_files"; then
3730 if test "$vc_files" = true; then
3731 func_append actioncmd " --vc-files"
3733 func_append actioncmd " --no-vc-files"
3736 func_append actioncmd " `echo $specified_modules`"
3738 # Default the makefile name to Makefile.am.
3739 if test -n "$makefile_name"; then
3740 makefile_am=$makefile_name
3742 makefile_am=Makefile.am
3745 # Create normal Makefile.ams.
3748 # Setup list of Makefile.am edits that are to be performed afterwards.
3749 # Some of these edits apply to files that we will generate; others are
3750 # under the responsibility of the developer.
3752 # func_note_Makefile_am_edit dir var value
3753 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3755 func_note_Makefile_am_edit ()
3757 makefile_am_edits=`expr $makefile_am_edits + 1`
3758 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3759 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3760 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3762 if test "$makefile_am" = Makefile.am; then
3763 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3764 sourcebase_base=`basename "$sourcebase"`
3765 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3767 if test -n "$pobase"; then
3768 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3769 pobase_base=`basename "$pobase"`
3770 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3772 if test -n "$inctests"; then
3773 if test "$makefile_am" = Makefile.am; then
3774 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3775 testsbase_base=`basename "$testsbase"`
3776 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3779 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3781 # Find the first parent directory of $m4base that contains or will contain
3783 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3785 sed_butlast='s,[^/][^/]*//*$,,'
3786 dir1="${m4base}/"; dir2=""
3787 while test -n "$dir1" \
3788 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3789 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3790 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3791 || { test -n "$inctests" \
3792 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3793 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3794 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3795 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3797 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3800 # Create library makefile.
3801 func_dest_tmpfilename $sourcebase/$makefile_am
3802 destfile="$sourcebase/$makefile_am"
3803 modules="$main_modules"
3804 func_emit_lib_Makefile_am > "$tmpfile"
3805 if test -f "$destdir"/$sourcebase/$makefile_am; then
3806 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3810 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3811 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3812 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3814 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3820 echo "Creating $sourcebase/$makefile_am"
3821 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3823 echo "Create $sourcebase/$makefile_am"
3826 func_append added_files "$sourcebase/$makefile_am$nl"
3829 # Create po/ directory.
3830 if test -n "$pobase"; then
3831 # Create po makefile and auxiliary files.
3832 for file in Makefile.in.in remove-potcdate.sin; do
3833 func_dest_tmpfilename $pobase/$file
3834 func_lookup_file build-aux/po/$file
3835 cat "$lookedup_file" > "$tmpfile"
3836 if test -f "$destdir"/$pobase/$file; then
3837 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3841 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3842 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3843 mv -f "$tmpfile" "$destdir"/$pobase/$file
3845 echo "Update $pobase/$file (backup in $pobase/$file~)"
3851 echo "Creating $pobase/$file"
3852 mv -f "$tmpfile" "$destdir"/$pobase/$file
3854 echo "Create $pobase/$file"
3857 func_append added_files "$pobase/$file$nl"
3860 # Create po makefile parameterization, part 1.
3861 func_dest_tmpfilename $pobase/Makevars
3862 func_emit_po_Makevars > "$tmpfile"
3863 if test -f "$destdir"/$pobase/Makevars; then
3864 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3868 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3869 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3870 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3872 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3878 echo "Creating $pobase/Makevars"
3879 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3881 echo "Create $pobase/Makevars"
3884 func_append added_files "$pobase/Makevars$nl"
3886 # Create po makefile parameterization, part 2.
3887 func_dest_tmpfilename $pobase/POTFILES.in
3888 func_emit_po_POTFILES_in > "$tmpfile"
3889 if test -f "$destdir"/$pobase/POTFILES.in; then
3890 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3894 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3895 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3896 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3898 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3904 echo "Creating $pobase/POTFILES.in"
3905 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3907 echo "Create $pobase/POTFILES.in"
3910 func_append added_files "$pobase/POTFILES.in$nl"
3913 TP_URL="http://translationproject.org/latest/"
3914 TP_RSYNC_URI="translationproject.org::tp/latest/"
3916 echo "Fetching gnulib PO files from $TP_URL"
3917 (cd "$destdir"/$pobase \
3918 && { # Prefer rsync over wget if it is available, since it consumes
3919 # less network bandwidth, due to compression.
3920 if type rsync 2>/dev/null | grep / > /dev/null; then
3921 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3923 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3928 echo "Fetch gnulib PO files from $TP_URL"
3930 # Create po/LINGUAS.
3932 func_dest_tmpfilename $pobase/LINGUAS
3933 (cd "$destdir"/$pobase \
3934 && { echo '# Set of available languages.'
3935 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3938 if test -f "$destdir"/$pobase/LINGUAS; then
3939 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3942 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3943 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3944 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3947 echo "Creating $pobase/LINGUAS"
3948 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3949 func_append added_files "$pobase/LINGUAS$nl"
3952 if test -f "$destdir"/$pobase/LINGUAS; then
3953 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3955 echo "Create $pobase/LINGUAS"
3960 # Create m4/gnulib-cache.m4.
3961 func_dest_tmpfilename $m4base/gnulib-cache.m4
3963 func_emit_copyright_notice
3965 echo "# This file represents the specification of how gnulib-tool is used."
3966 echo "# It acts as a cache: It is written and read by gnulib-tool."
3967 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3968 echo "# like the configure.ac and various Makefile.am files."
3971 echo "# Specification in the form of a command-line invocation:"
3974 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3975 # Store the local_gnulib_dir relative to destdir.
3976 case "$local_gnulib_dir" in
3978 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3981 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3983 # destdir, local_gnulib_dir are both relative.
3984 func_relativize "$destdir" "$local_gnulib_dir"
3985 relative_local_gnulib_dir="$reldir" ;;
3988 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3990 echo "$specified_modules" | sed -e 's/^/ /g'
3992 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3993 echo "gl_AVOID([$avoidlist])"
3994 echo "gl_SOURCE_BASE([$sourcebase])"
3995 echo "gl_M4_BASE([$m4base])"
3996 echo "gl_PO_BASE([$pobase])"
3997 echo "gl_DOC_BASE([$docbase])"
3998 echo "gl_TESTS_BASE([$testsbase])"
3999 test -z "$inctests" || echo "gl_WITH_TESTS"
4000 echo "gl_LIB([$libname])"
4001 if test -n "$lgpl"; then
4002 if test "$lgpl" = yes; then
4005 echo "gl_LGPL([$lgpl])"
4008 echo "gl_MAKEFILE_NAME([$makefile_name])"
4009 if test "$libtool" = true; then
4012 echo "gl_MACRO_PREFIX([$macro_prefix])"
4013 echo "gl_PO_DOMAIN([$po_domain])"
4014 if test -n "$vc_files"; then
4015 echo "gl_VC_FILES([$vc_files])"
4018 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4019 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4023 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4024 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4025 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4027 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4031 echo "# gnulib-cache.m4 ends here"
4038 echo "Creating $m4base/gnulib-cache.m4"
4039 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4041 echo "Create $m4base/gnulib-cache.m4"
4047 # Create m4/gnulib-comp.m4.
4048 func_dest_tmpfilename $m4base/gnulib-comp.m4
4050 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4051 func_emit_copyright_notice
4053 echo "# This file represents the compiled summary of the specification in"
4054 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4055 echo "# to be invoked from configure.ac."
4056 echo "# In projects using CVS, this file can be treated like other built files."
4059 echo "# This macro should be invoked from $configure_ac, in the section"
4060 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4061 echo "# any checks for libraries, header files, types and library functions."
4062 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4064 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4065 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4066 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4067 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4068 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4069 if test -n "$uses_subdirs"; then
4070 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4072 for module in $final_modules; do
4074 if test -n "$module"; then
4075 func_get_autoconf_early_snippet "$module"
4078 | sed -e '/^$/d;' -e 's/^/ /'
4081 echo "# This macro should be invoked from $configure_ac, in the section"
4082 echo "# \"Check for header files, types and library functions\"."
4083 echo "AC_DEFUN([${macro_prefix}_INIT],"
4085 if test "$libtool" = true; then
4086 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4087 echo " gl_cond_libtool=true"
4089 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4090 echo " gl_cond_libtool=false"
4092 echo " gl_ltlibdeps="
4094 if test "$auxdir" != "build-aux"; then
4095 sed_replace_build_aux='
4097 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4098 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4102 sed_replace_build_aux="$sed_noop"
4104 func_emit_initmacro_start $macro_prefix
4105 echo " gl_source_base='$sourcebase'"
4106 for module in $main_modules; do
4108 if test -n "$module"; then
4109 func_get_autoconf_snippet "$module" \
4110 | sed -e '/^$/d;' -e 's/^/ /' \
4111 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4112 -e "$sed_replace_build_aux"
4113 if test "$module" = 'alloca' && test "$libtool" = true; then
4114 echo 'changequote(,)dnl'
4115 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4116 echo 'changequote([, ])dnl'
4117 echo 'AC_SUBST([LTALLOCA])'
4121 func_emit_initmacro_end $macro_prefix
4122 echo " gltests_libdeps="
4123 echo " gltests_ltlibdeps="
4124 func_emit_initmacro_start ${macro_prefix}tests
4125 echo " gl_source_base='$testsbase'"
4126 for module in $testsrelated_modules; do
4128 if test -n "$module"; then
4129 func_get_autoconf_snippet "$module" \
4130 | sed -e '/^$/d;' -e 's/^/ /' \
4131 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4132 -e "$sed_replace_build_aux" \
4133 -e 's/\$gl_cond_libtool/false/g' \
4134 -e 's/gl_libdeps/gltests_libdeps/g' \
4135 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4138 func_emit_initmacro_end ${macro_prefix}tests
4139 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4140 # created using libtool, because libtool already handles the dependencies.
4141 if test "$libtool" != true; then
4142 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4143 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4144 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4145 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4146 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4148 if $use_libtests; then
4149 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4150 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4153 func_emit_initmacro_done $macro_prefix $sourcebase
4154 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4156 echo "# This macro records the list of files which have been installed by"
4157 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4158 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4159 echo "$files" | sed -e 's,^, ,'
4162 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4163 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4167 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4168 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4169 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4171 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4175 echo "# gnulib-comp.m4 ends here"
4182 echo "Creating $m4base/gnulib-comp.m4"
4183 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4185 echo "Create $m4base/gnulib-comp.m4"
4191 if test -n "$inctests"; then
4192 # Create tests makefile.
4193 func_dest_tmpfilename $testsbase/$makefile_am
4194 destfile="$testsbase/$makefile_am"
4195 modules="$testsrelated_modules"
4196 func_emit_tests_Makefile_am > "$tmpfile"
4197 if test -f "$destdir"/$testsbase/$makefile_am; then
4198 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4202 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4203 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4204 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4206 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4212 echo "Creating $testsbase/$makefile_am"
4213 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4215 echo "Create $testsbase/$makefile_am"
4218 func_append added_files "$testsbase/$makefile_am$nl"
4222 if test "$vc_files" != false; then
4223 # Update the .cvsignore and .gitignore files.
4224 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4225 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4226 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4227 echo "$m4base/|A|gnulib-comp.m4"
4228 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4229 { # Rearrange file descriptors. Needed because "while ... done < ..."
4230 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4231 exec 5<&0 < "$tmp"/fileset-changes
4232 func_update_ignorelist ()
4235 if test "$ignore" = .gitignore; then
4236 # In a .gitignore file, "foo" applies to the current directory and all
4237 # subdirectories, whereas "/foo" applies to the current directory only.
4240 doubly_escaped_anchor='\\/'
4244 doubly_escaped_anchor=''
4246 if test -f "$destdir/$dir$ignore"; then
4247 if test -n "$dir_added" || test -n "$dir_removed"; then
4248 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4249 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4250 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4251 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4252 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4254 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4256 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4257 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4258 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4259 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4260 } > "$tmp"/sed-ignore-removed
4261 { cat "$destdir/$dir$ignore"~
4262 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4263 } | sed -f "$tmp"/sed-ignore-removed \
4264 > "$destdir/$dir$ignore"
4266 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4271 if test -n "$dir_added"; then
4273 echo "Creating $destdir/$dir$ignore"
4275 if test "$ignore" = .cvsignore; then
4277 # Automake generates Makefile rules that create .dirstamp files.
4280 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4281 } > "$destdir/$dir$ignore"
4283 echo "Create $destdir/$dir$ignore"
4293 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4294 func_update_ignorelist .cvsignore
4296 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4297 func_update_ignorelist .gitignore
4304 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4305 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4306 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4307 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4308 if test "$next_dir" != "$last_dir"; then
4309 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4310 last_dir="$next_dir"
4315 A) func_append last_dir_added "$file$nl";;
4316 R) func_append last_dir_removed "$file$nl";;
4319 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4326 echo "You may need to add #include directives for the following .h files."
4327 # Intersect $specified_modules and $main_modules
4328 # (since $specified_modules is not necessarily of subset of $main_modules
4329 # - some may have been skipped through --avoid, and since the elements of
4330 # $main_modules but not in $specified_modules can go away without explicit
4331 # notice - through changes in the module dependencies).
4332 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4333 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4334 # First the #include <...> directives without #ifs, sorted for convenience,
4335 # then the #include "..." directives without #ifs, sorted for convenience,
4336 # then the #include directives that are surrounded by #ifs. Not sorted.
4337 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4338 include_directive=`func_get_include_directive "$module"`
4339 case "$nl$include_directive" in
4341 echo "$include_directive" 1>&5
4344 echo "$include_directive" | grep -v 'include "' 1>&6
4345 echo "$include_directive" | grep 'include "' 1>&7
4348 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4350 LC_ALL=C sort -u "$tmp"/include-angles
4351 LC_ALL=C sort -u "$tmp"/include-quotes
4352 cat "$tmp"/include-if
4353 ) | sed -e '/^$/d' -e 's/^/ /'
4354 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4356 for module in $main_modules; do
4357 func_get_link_directive "$module"
4359 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4360 if test `wc -l < "$tmp"/link` != 0; then
4362 echo "You may need to use the following Makefile variables when linking."
4363 echo "Use them in <program>_LDADD when linking a program, or"
4364 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4370 echo "Don't forget to"
4371 if test "$makefile_am" = Makefile.am; then
4372 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4374 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4376 if test -n "$pobase"; then
4377 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4379 if test -n "$inctests"; then
4380 if test "$makefile_am" = Makefile.am; then
4381 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4383 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4387 while test $edit != $makefile_am_edits; do
4388 edit=`expr $edit + 1`
4389 eval dir=\"\$makefile_am_edit${edit}_dir\"
4390 eval var=\"\$makefile_am_edit${edit}_var\"
4391 eval val=\"\$makefile_am_edit${edit}_val\"
4392 if test -n "$var"; then
4393 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4396 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4397 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4400 # func_create_testdir testdir modules
4402 # - local_gnulib_dir from --local-dir
4403 # - modcache true or false, from --cache-modules/--no-cache-modules
4404 # - auxdir directory relative to destdir where to place build aux files
4405 func_create_testdir ()
4409 if test -z "$modules"; then
4410 # All modules together.
4411 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4412 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4413 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4414 modules=`func_all_modules`
4415 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4417 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
4419 # Check that the license of every module is consistent with the license of
4421 saved_modules="$modules"
4422 saved_inctests="$inctests"
4423 # When computing transitive closures, don't consider $module to depend on
4424 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4425 # on GPL modules - therefore we don't want a warning in this case.
4427 for requested_module in $saved_modules; do
4428 requested_license=`func_get_license "$requested_module"`
4429 if test "$requested_license" != GPL; then
4430 # Here we use func_modules_transitive_closure, not just
4431 # func_get_dependencies, so that we also detect weird situations like
4432 # an LGPL module which depends on a GPLed build tool module which depends
4434 modules="$requested_module"
4435 func_modules_transitive_closure
4436 for module in $modules; do
4437 license=`func_get_license "$module"`
4439 'GPLed build tool') ;;
4440 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4442 case "$requested_license" in
4445 GPLv2+ | LGPLv2+) ;;
4446 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4452 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4458 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4467 modules="$saved_modules"
4468 inctests="$saved_inctests"
4470 # Subdirectory names.
4480 # Determine final module list.
4481 func_modules_transitive_closure
4482 if test $verbose -ge 0; then
4483 echo "Module list with included dependencies:"
4484 echo "$modules" | sed -e 's/^/ /'
4487 # Add the dummy module if needed.
4488 func_modules_add_dummy
4490 # Show banner notice of every module.
4493 # Determine final file list.
4494 func_modules_to_filelist
4495 if test $verbose -ge 0; then
4497 echo "$files" | sed -e 's/^/ /'
4500 rewritten='%REWRITTEN%'
4501 sed_rewrite_files="\
4502 s,^build-aux/,$rewritten$auxdir/,
4503 s,^doc/,$rewritten$docbase/,
4504 s,^lib/,$rewritten$sourcebase/,
4505 s,^m4/,$rewritten$m4base/,
4506 s,^tests/,$rewritten$testsbase/,
4510 # Create directories.
4511 for f in $files; do echo $f; done \
4512 | sed -e "$sed_rewrite_files" \
4513 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4514 | LC_ALL=C sort -u \
4516 { # Rearrange file descriptors. Needed because "while ... done < ..."
4517 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4518 exec 5<&0 < "$tmp"/dirs
4520 mkdir -p "$testdir/$d"
4525 # Copy files or make symbolic links.
4527 for f in $files; do echo $f; done \
4528 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4531 { # Rearrange file descriptors. Needed because "while ... done < ..."
4532 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4533 exec 5<&0 < "$tmp"/files
4535 func_lookup_file "$f"
4536 if test -n "$lookedup_tmp"; then
4537 cp -p "$lookedup_file" "$testdir/$g"
4539 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4540 if { test -n "$symbolic" \
4541 || { test -n "$lsymbolic" \
4542 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4543 func_ln "$lookedup_file" "$testdir/$g"
4545 cp -p "$lookedup_file" "$testdir/$g"
4552 # Create Makefile.ams that are for testing.
4555 # No special edits are needed.
4558 # Create $sourcebase/Makefile.am.
4559 mkdir -p "$testdir/$sourcebase"
4560 destfile="$sourcebase/Makefile.am"
4561 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4562 any_uses_subdirs="$uses_subdirs"
4564 # Create $m4base/Makefile.am.
4565 mkdir -p "$testdir/$m4base"
4566 (echo "## Process this file with automake to produce Makefile.in."
4572 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4575 ) > "$testdir/$m4base/Makefile.am"
4577 subdirs="$sourcebase $m4base"
4578 subdirs_with_configure_ac=""
4580 if false && test -f "$testdir"/$m4base/gettext.m4; then
4581 # Avoid stupid error message from automake:
4582 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4583 mkdir -p "$testdir/po"
4584 (echo "## Process this file with automake to produce Makefile.in."
4585 ) > "$testdir/po/Makefile.am"
4586 func_append subdirs " po"
4589 if test -n "$inctests"; then
4590 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4591 # Viewed from the $testsbase subdirectory, $auxdir is different.
4592 saved_auxdir="$auxdir"
4593 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4594 # Create $testsbase/Makefile.am.
4596 destfile="$testsbase/Makefile.am"
4597 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
4598 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4599 # Create $testsbase/configure.ac.
4600 (echo "# Process this file with autoconf to produce a configure script."
4601 echo "AC_INIT([dummy], [0])"
4602 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4603 echo "AM_INIT_AUTOMAKE"
4605 echo "AC_CONFIG_HEADERS([config.h])"
4608 echo "AC_PROG_INSTALL"
4609 echo "AC_PROG_MAKE_SET"
4610 echo "AC_PROG_RANLIB"
4612 if test -n "$uses_subdirs"; then
4613 echo "AM_PROG_CC_C_O"
4616 for module in $modules; do
4618 if test -n "$module"; then
4620 gnumakefile | maintainer-makefile)
4621 # These modules are meant to be used only in the top-level directory.
4624 func_get_autoconf_early_snippet "$module"
4629 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4630 if test "$libtool" = true; then
4631 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4632 echo "gl_cond_libtool=true"
4634 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4635 echo "gl_cond_libtool=false"
4637 echo "gl_ltlibdeps="
4639 # Wrap the set of autoconf snippets into an autoconf macro that is then
4640 # invoked. This is needed because autoconf does not support AC_REQUIRE
4642 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4643 # but we want the AC_REQUIRE to have its normal meaning (provide one
4644 # expansion of the required macro before the current point, and only one
4646 echo "AC_DEFUN([gl_INIT], ["
4647 sed_replace_build_aux='
4649 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4650 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4653 func_emit_initmacro_start $macro_prefix
4654 # We don't have explicit ordering constraints between the various
4655 # autoconf snippets. It's cleanest to put those of the library before
4656 # those of the tests.
4657 echo "gl_source_base='../$sourcebase'"
4658 for module in $modules; do
4659 func_verify_nontests_module
4660 if test -n "$module"; then
4662 gnumakefile | maintainer-makefile)
4663 # These modules are meant to be used only in the top-level directory.
4666 func_get_autoconf_snippet "$module" \
4667 | sed -e "$sed_replace_build_aux"
4672 echo "gl_source_base='.'"
4673 for module in $modules; do
4674 func_verify_tests_module
4675 if test -n "$module"; then
4676 func_get_autoconf_snippet "$module" \
4677 | sed -e "$sed_replace_build_aux"
4680 func_emit_initmacro_end $macro_prefix
4681 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4682 # created using libtool, because libtool already handles the dependencies.
4683 if test "$libtool" != true; then
4684 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4685 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4686 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4687 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4688 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4691 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4695 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4696 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4697 echo "AH_TOP([#include \"../config.h\"])"
4699 echo "AC_CONFIG_FILES([Makefile])"
4701 ) > "$testdir/$testsbase/configure.ac"
4702 auxdir="$saved_auxdir"
4703 func_append subdirs " $testsbase"
4704 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4707 # Create Makefile.am.
4708 (echo "## Process this file with automake to produce Makefile.in."
4710 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4712 echo "SUBDIRS = $subdirs"
4714 echo "ACLOCAL_AMFLAGS = -I $m4base"
4715 ) > "$testdir/Makefile.am"
4717 # Create configure.ac.
4718 (echo "# Process this file with autoconf to produce a configure script."
4719 echo "AC_INIT([dummy], [0])"
4720 if test "$auxdir" != "."; then
4721 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4723 echo "AM_INIT_AUTOMAKE"
4725 echo "AC_CONFIG_HEADERS([config.h])"
4728 echo "AC_PROG_INSTALL"
4729 echo "AC_PROG_MAKE_SET"
4731 echo "# For autobuild."
4732 echo "AC_CANONICAL_BUILD"
4733 echo "AC_CANONICAL_HOST"
4735 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4736 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4737 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4738 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4740 echo "AC_PROG_RANLIB"
4742 if test -n "$any_uses_subdirs"; then
4743 echo "AM_PROG_CC_C_O"
4746 for module in $modules; do
4747 func_verify_nontests_module
4748 if test -n "$module"; then
4749 func_get_autoconf_early_snippet "$module"
4752 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4753 if test "$libtool" = true; then
4754 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4755 echo "gl_cond_libtool=true"
4757 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4758 echo "gl_cond_libtool=false"
4760 echo "gl_ltlibdeps="
4762 # Wrap the set of autoconf snippets into an autoconf macro that is then
4763 # invoked. This is needed because autoconf does not support AC_REQUIRE
4765 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4766 # but we want the AC_REQUIRE to have its normal meaning (provide one
4767 # expansion of the required macro before the current point, and only one
4769 echo "AC_DEFUN([gl_INIT], ["
4770 if test "$auxdir" != "build-aux"; then
4771 sed_replace_build_aux='
4773 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4774 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4778 sed_replace_build_aux="$sed_noop"
4780 func_emit_initmacro_start $macro_prefix
4781 echo "gl_source_base='$sourcebase'"
4782 for module in $modules; do
4783 func_verify_nontests_module
4784 if test -n "$module"; then
4785 func_get_autoconf_snippet "$module" \
4786 | sed -e "$sed_replace_build_aux"
4789 func_emit_initmacro_end $macro_prefix
4790 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4791 # created using libtool, because libtool already handles the dependencies.
4792 if test "$libtool" != true; then
4793 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4794 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4795 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4796 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4797 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4800 func_emit_initmacro_done $macro_prefix $sourcebase
4804 if test -n "$subdirs_with_configure_ac"; then
4805 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4807 makefiles="Makefile"
4808 for d in $subdirs; do
4809 # For subdirs that have a configure.ac by their own, it's the subdir's
4810 # configure.ac which creates the subdir's Makefile.am, not this one.
4811 case " $subdirs_with_configure_ac " in
4813 *) func_append makefiles " $d/Makefile" ;;
4816 echo "AC_CONFIG_FILES([$makefiles])"
4818 ) > "$testdir/configure.ac"
4820 # Create autogenerated files.
4822 # Do not use "${AUTORECONF} --force --install", because it may invoke
4823 # autopoint, which brings in older versions of some of our .m4 files.
4824 if test -f $m4base/gettext.m4; then
4825 func_execute_command ${AUTOPOINT} --force || func_exit 1
4826 for f in $m4base/*.m4~; do
4828 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4832 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4833 if ! test -d build-aux; then
4834 func_execute_command mkdir build-aux || func_exit 1
4836 func_execute_command ${AUTOCONF} || func_exit 1
4837 func_execute_command ${AUTOHEADER} || func_exit 1
4838 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4840 if test -n "$inctests"; then
4841 # Create autogenerated files.
4842 (cd "$testdir/$testsbase" || func_exit 1
4843 # Do not use "${AUTORECONF} --force --install", because it may invoke
4844 # autopoint, which brings in older versions of some of our .m4 files.
4845 if test -f ../$m4base/gettext.m4; then
4846 func_execute_command ${AUTOPOINT} --force || func_exit 1
4847 for f in ../$m4base/*.m4~; do
4849 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4853 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4854 if ! test -d ../build-aux; then
4855 func_execute_command mkdir ../build-aux
4857 func_execute_command ${AUTOCONF} || func_exit 1
4858 func_execute_command ${AUTOHEADER} || func_exit 1
4859 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4862 # Need to run configure and make once, to create built files that are to be
4863 # distributed (such as getdate.c).
4864 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4865 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4866 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4867 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4868 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4869 # such $(FOO_H) because they don't refer to distributed files.
4870 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4871 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4872 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4873 | sed -e "$sed_remove_make_variables"`
4874 distributed_built_sources=`for file in $built_sources; do
4875 case "$cleaned_files" in
4880 if test -n "$distributed_built_sources"; then
4882 ./configure || func_exit 1
4884 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4885 $MAKE built_sources || func_exit 1
4887 $MAKE distclean || func_exit 1
4892 # func_create_megatestdir megatestdir allmodules
4894 # - local_gnulib_dir from --local-dir
4895 # - modcache true or false, from --cache-modules/--no-cache-modules
4896 # - auxdir directory relative to destdir where to place build aux files
4897 func_create_megatestdir ()
4901 if test -z "$allmodules"; then
4902 allmodules=`func_all_modules`
4906 # First, all modules one by one.
4907 for onemodule in $allmodules; do
4908 func_create_testdir "$megatestdir/$onemodule" $onemodule
4909 func_append megasubdirs "$onemodule "
4911 # Then, all modules all together.
4912 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4913 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
4914 func_create_testdir "$megatestdir/ALL" "$allmodules"
4915 func_append megasubdirs "ALL"
4918 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4919 vc_witness="$gnulib_dir/CVS/Entries"; \
4921 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4923 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4924 | sed -e 's,January,01,' -e 's,Jan,01,' \
4925 -e 's,February,02,' -e 's,Feb,02,' \
4926 -e 's,March,03,' -e 's,Mar,03,' \
4927 -e 's,April,04,' -e 's,Apr,04,' \
4929 -e 's,June,06,' -e 's,Jun,06,' \
4930 -e 's,July,07,' -e 's,Jul,07,' \
4931 -e 's,August,08,' -e 's,Aug,08,' \
4932 -e 's,September,09,' -e 's,Sep,09,' \
4933 -e 's,October,10,' -e 's,Oct,10,' \
4934 -e 's,November,11,' -e 's,Nov,11,' \
4935 -e 's,December,12,' -e 's,Dec,12,' \
4936 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4937 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4939 echo "CVSDATE=$cvsdate"
4940 echo ": \${MAKE=make}"
4941 echo "test -d logs || mkdir logs"
4942 echo "for module in $megasubdirs; do"
4943 echo " echo \"Working on module \$module...\""
4944 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4945 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4948 echo " : autobuild project... \$module"
4949 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4950 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4951 echo " : autobuild hostname... \`hostname\`"
4952 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
4954 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4956 ) > "$megatestdir/do-autobuild"
4957 chmod a+x "$megatestdir/do-autobuild"
4959 # Create Makefile.am.
4960 (echo "## Process this file with automake to produce Makefile.in."
4962 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4964 echo "SUBDIRS = $megasubdirs"
4966 echo "EXTRA_DIST = do-autobuild"
4967 ) > "$megatestdir/Makefile.am"
4969 # Create configure.ac.
4970 (echo "# Process this file with autoconf to produce a configure script."
4971 echo "AC_INIT([dummy], [0])"
4972 if test "$auxdir" != "."; then
4973 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4975 echo "AM_INIT_AUTOMAKE"
4977 echo "AC_PROG_MAKE_SET"
4979 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4980 echo "AC_CONFIG_FILES([Makefile])"
4982 ) > "$megatestdir/configure.ac"
4984 # Create autogenerated files.
4986 # Do not use "${AUTORECONF} --install", because autoreconf operates
4987 # recursively, but the subdirectories are already finished, therefore
4988 # calling autoreconf here would only waste lots of CPU time.
4989 func_execute_command ${ACLOCAL} || func_exit 1
4990 func_execute_command mkdir build-aux
4991 func_execute_command ${AUTOCONF} || func_exit 1
4992 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4998 func_fatal_error "no mode specified" ;;
5005 # sed expression that converts a literal to a basic regular expression.
5006 # Needs to handle . [ \ * ^ $.
5007 sed_literal_to_basic_regex='s/\\/\\\\/g
5013 if test -f "$gnulib_dir/$filename" \
5014 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5015 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5016 filename_line_regex='^'"$filename_anywhere_regex"'$'
5019 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5020 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5021 (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$,,')
5024 | func_sanitize_modulelist \
5027 for module in $module_candidates; do
5028 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5033 func_warning "file $filename does not exist"
5041 if test -z "$destdir"; then
5044 test -d "$destdir" \
5045 || func_fatal_error "destination directory does not exist: $destdir"
5047 # Prefer configure.ac to configure.in.
5048 if test -f "$destdir"/configure.ac; then
5049 configure_ac="$destdir/configure.ac"
5051 if test -f "$destdir"/configure.in; then
5052 configure_ac="$destdir/configure.in"
5054 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5058 # Analyze configure.ac.
5060 guessed_libtool=false
5065 /AC_CONFIG_AUX_DIR/ {
5066 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5068 /A[CM]_PROG_LIBTOOL/ {
5069 s,^.*$,guessed_libtool=true,p
5071 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5073 if test -z "$auxdir"; then
5074 auxdir="$guessed_auxdir"
5077 # Determine where to apply func_import.
5078 if test -n "$m4base"; then
5079 # Apply func_import to a particular gnulib directory.
5080 # Any number of additional modules can be given.
5081 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5082 # First use of gnulib in the given m4base.
5083 test -n "$supplied_libname" || supplied_libname=true
5084 test -n "$sourcebase" || sourcebase="lib"
5085 test -n "$docbase" || docbase="doc"
5086 test -n "$testsbase" || testsbase="tests"
5087 test -n "$macro_prefix" || macro_prefix="gl"
5091 # Apply func_import to all gnulib directories.
5092 # To get this list of directories, look at Makefile.am. (Not at
5093 # configure, because it may be omitted from CVS. Also, don't run
5094 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5097 if test -f "$destdir"/Makefile.am; then
5098 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5100 for arg in $aclocal_amflags; do
5101 if test -n "$m4dir_is_next"; then
5102 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5106 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5107 func_append m4dirs " $arg"
5108 m4dirs_count=`expr $m4dirs_count + 1`
5114 if test "X$arg" = "X-I"; then
5122 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5123 if test -f "$destdir"/aclocal.m4; then
5124 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5125 sedexpr2='s,^[^/]*$,.,'
5126 sedexpr3='s,/[^/]*$,,'
5127 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5128 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5131 if test $m4dirs_count = 0; then
5132 # First use of gnulib in a package.
5133 # Any number of additional modules can be given.
5134 test -n "$supplied_libname" || supplied_libname=true
5135 test -n "$sourcebase" || sourcebase="lib"
5137 test -n "$docbase" || docbase="doc"
5138 test -n "$testsbase" || testsbase="tests"
5139 test -n "$macro_prefix" || macro_prefix="gl"
5142 if test $m4dirs_count = 1; then
5143 # There's only one use of gnulib here. Assume the user means it.
5144 # Any number of additional modules can be given.
5145 for m4base in $m4dirs; do
5149 # Ambiguous - guess what the user meant.
5150 if test $# = 0; then
5151 # No further arguments. Guess the user wants to update all of them.
5152 for m4base in $m4dirs; do
5153 # Perform func_import in a subshell, so that variable values
5155 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
5156 # pobase, docbase, testsbase, inctests, libname, lgpl,
5157 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5158 # don't propagate from one directory to another.
5159 (func_import) || func_exit 1
5163 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5171 if test -z "$destdir"; then
5172 func_fatal_error "please specify --dir option"
5175 test -d "$destdir" \
5176 || func_fatal_error "could not create destination directory"
5177 test -n "$auxdir" || auxdir="build-aux"
5178 func_create_testdir "$destdir" "$*"
5181 create-megatestdir )
5182 if test -z "$destdir"; then
5183 func_fatal_error "please specify --dir option"
5185 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5186 test -n "$auxdir" || auxdir="build-aux"
5187 func_create_megatestdir "$destdir" "$*"
5191 test -n "$destdir" || destdir=testdir$$
5192 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5193 test -n "$auxdir" || auxdir="build-aux"
5194 func_create_testdir "$destdir" "$*"
5198 ../configure || func_exit 1
5199 $MAKE || func_exit 1
5200 $MAKE check || func_exit 1
5201 $MAKE distclean || func_exit 1
5202 remaining=`find . -type f -print`
5203 if test -n "$remaining"; then
5204 echo "Remaining files:" $remaining 1>&2
5205 echo "gnulib-tool: *** Stop." 1>&2
5214 test -n "$destdir" || destdir=testdir$$
5215 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5216 test -n "$auxdir" || auxdir="build-aux"
5217 func_create_megatestdir "$destdir" "$*"
5225 remaining=`find . -type f -print`
5226 if test -n "$remaining"; then
5227 echo "Remaining files:" $remaining 1>&2
5228 echo "gnulib-tool: *** Stop." 1>&2
5236 extract-description )
5240 if test -n "$module"; then
5241 func_get_description "$module"
5250 if test -n "$module"; then
5251 func_get_status "$module"
5260 if test -n "$module"; then
5261 func_get_notice "$module"
5266 extract-applicability )
5270 if test -n "$module"; then
5271 func_get_applicability "$module"
5280 if test -n "$module"; then
5281 func_get_filelist "$module"
5286 extract-dependencies )
5290 if test -n "$module"; then
5291 func_get_dependencies "$module"
5296 extract-autoconf-snippet )
5300 if test -n "$module"; then
5301 func_get_autoconf_snippet "$module"
5306 extract-automake-snippet )
5310 if test -n "$module"; then
5311 func_get_automake_snippet "$module"
5316 extract-include-directive )
5320 if test -n "$module"; then
5321 func_get_include_directive "$module"
5326 extract-link-directive )
5330 if test -n "$module"; then
5331 func_get_link_directive "$module"
5340 if test -n "$module"; then
5341 func_get_license "$module"
5346 extract-maintainer )
5350 if test -n "$module"; then
5351 func_get_maintainer "$module"
5356 extract-tests-module )
5360 if test -n "$module"; then
5361 func_get_tests_module "$module"
5367 # Verify the number of arguments.
5368 if test $# -lt 1 || test $# -gt 2; then
5369 func_fatal_error "invalid number of arguments for --$mode"
5372 # The first argument is the file to be copied.
5374 # Verify the file exists.
5375 func_lookup_file "$f"
5377 # The second argument is the destination; either a directory ot a file.
5378 # It defaults to the current directory.
5380 test -n "$dest" || dest='.'
5381 test -n "$sourcebase" || sourcebase="lib"
5382 test -n "$m4base" || m4base="m4"
5383 test -n "$docbase" || docbase="doc"
5384 test -n "$testsbase" || testsbase="tests"
5385 test -n "$auxdir" || auxdir="build-aux"
5386 rewritten='%REWRITTEN%'
5387 sed_rewrite_files="\
5388 s,^build-aux/,$rewritten$auxdir/,
5389 s,^doc/,$rewritten$docbase/,
5390 s,^lib/,$rewritten$sourcebase/,
5391 s,^m4/,$rewritten$m4base/,
5392 s,^tests/,$rewritten$testsbase/,
5395 if test -d "$dest"; then
5397 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5399 destdir=`dirname "$dest"`
5400 g=`basename "$dest"`
5403 # Create the directory for destfile.
5404 d=`dirname "$destdir/$g"`
5406 if test -n "$d" && test ! -d "$d"; then
5407 mkdir -p "$d" || func_fatal_error "failed"
5411 func_dest_tmpfilename "$g"
5412 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5413 already_present=true
5414 if test -f "$destdir/$g"; then
5415 # The file already exists.
5419 # Don't protest if the file should be there but isn't: it happens
5420 # frequently that developers don't put autogenerated files into CVS.
5427 func_fatal_error "unknown operation mode --$mode" ;;
5431 # Undo the effect of the previous 'trap' command. Some shellology:
5432 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5433 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5434 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5435 # 128 + signal number and is set before the trap-registered command is run.
5437 trap 'func_exit $?' 1 2 3 13 15
5442 # indent-tabs-mode: nil
5443 # whitespace-check-buffer-indent: nil