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 --import [module1 ... moduleN]
122 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
123 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
124 gnulib-tool --test --dir=directory module1 ... moduleN
125 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
126 gnulib-tool --extract-description module
127 gnulib-tool --extract-status module
128 gnulib-tool --extract-notice module
129 gnulib-tool --extract-applicability module
130 gnulib-tool --extract-filelist module
131 gnulib-tool --extract-dependencies module
132 gnulib-tool --extract-autoconf-snippet module
133 gnulib-tool --extract-automake-snippet module
134 gnulib-tool --extract-include-directive module
135 gnulib-tool --extract-link-directive module
136 gnulib-tool --extract-license module
137 gnulib-tool --extract-maintainer module
138 gnulib-tool --extract-tests-module module
139 gnulib-tool --copy-file file [destination]
142 --list print the available module names
143 --import import the given modules into the current package;
144 if no modules are specified, update the current
145 package from the current gnulib
146 --update update the current package, restore files omitted
148 --create-testdir create a scratch package with the given modules
149 --create-megatestdir create a mega scratch package with the given modules
150 one by one and all together
151 --test test the combination of the given modules
152 (recommended to use CC=\"gcc -Wall\" here)
153 --megatest test the given modules one by one and all together
154 (recommended to use CC=\"gcc -Wall\" here)
155 --extract-description extract the description
156 --extract-status extract the status (obsolete or not)
157 --extract-notice extract the notice or banner
158 --extract-filelist extract the list of files
159 --extract-dependencies extract the dependencies
160 --extract-autoconf-snippet extract the snippet for configure.ac
161 --extract-automake-snippet extract the snippet for library makefile
162 --extract-include-directive extract the #include directive
163 --extract-link-directive extract the linker directive
164 --extract-license report the license terms of the source files
166 --extract-maintainer report the maintainer(s) inside gnulib
167 --extract-tests-module report the unit test module, if it exists
168 --copy-file copy a file that is not part of any module
171 --dir=DIRECTORY Specify the target directory.
172 For --import, this specifies where your
173 configure.ac can be found. Defaults to current
175 --local-dir=DIRECTORY Specify a local override directory where to look
176 up files before looking in gnulib's directory.
177 --cache-modules Enable module caching optimization.
178 --no-cache-modules Disable module caching optimization.
179 --verbose Increase verbosity. May be repeated.
180 --quiet Decrease verbosity. May be repeated.
182 Options for --import:
183 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
184 --source-base=DIRECTORY
185 Directory relative to --dir where source code is
186 placed (default \"lib\").
187 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
188 placed (default \"m4\").
189 --po-base=DIRECTORY Directory relative to --dir where *.po files are
190 placed (default \"po\").
191 --doc-base=DIRECTORY Directory relative to --dir where doc files are
192 placed (default \"doc\").
193 --tests-base=DIRECTORY
194 Directory relative to --dir where unit tests are
195 placed (default \"tests\").
196 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
197 tools are placed (default \"build-aux\").
198 --with-tests Include unit tests for the included modules.
199 --with-obsolete Include obsolete modules when they occur among the
200 dependencies. By default, dependencies to obsolete
202 --avoid=MODULE Avoid including the given MODULE. Useful if you
203 have code that provides equivalent functionality.
204 This option can be repeated.
205 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
206 Also modify license template from GPL to LGPL.
207 The version number of the LGPL can be specified;
208 the default is currently LGPLv3.
209 --makefile-name=NAME Name of makefile in automake syntax in the
210 source-base and tests-base directories
211 (default \"Makefile.am\").
212 --libtool Use libtool rules.
213 --no-libtool Don't use libtool rules.
214 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
215 'gl_INIT'. Default is 'gl'.
216 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
217 the package name. A suffix '-gnulib' is appended.
218 --vc-files Update version control related files.
219 --no-vc-files Don't update version control related files
220 (.gitignore and/or .cvsignore).
221 --no-changelog Don't update or create ChangeLog files.
223 Options for --import and --update:
224 --dry-run For --import, only print what would have been done.
225 -s, --symbolic, --symlink Make symbolic links instead of copying files.
226 --local-symlink Make symbolic links instead of copying files, only
227 for files from the local override directory.
228 -S, --more-symlinks Make symbolic links instead of copying files, and
229 don't replace copyright notices.
231 Report bugs to <bug-gnulib@gnu.org>."
235 # outputs to stdout the --version message.
239 if test -d "$gnulib_dir"/.git \
240 && (git --version) >/dev/null 2>/dev/null \
241 && (date --version) >/dev/null 2>/dev/null; then
242 # gnulib checked out from git.
243 sed_extract_first_date='/^Date/{
247 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
248 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
249 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
250 date=`echo "$date" | sed -e "$sed_year_before_time"`
251 # Use GNU date to compute the time in GMT.
252 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
253 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
255 if test -d "$gnulib_dir"/CVS \
256 && (cvs --version) >/dev/null 2>/dev/null; then
257 # gnulib checked out from CVS.
258 sed_extract_first_date='/^date: /{
259 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
262 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
264 # gnulib copy without versioning information.
265 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
269 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
271 gnulib-tool (GNU $package $date)$version
272 Copyright (C) $year Free Software Foundation, Inc.
273 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
274 This is free software: you are free to change and redistribute it.
275 There is NO WARRANTY, to the extent permitted by law.
277 Written by" "Bruno Haible" "and" "Simon Josefsson"
280 # func_emit_copyright_notice
281 # outputs to stdout a header for a generated file.
282 func_emit_copyright_notice ()
284 sed -n -e '/Copyright/ {
287 }' < "$self_abspathname"
289 echo "# This file is free software, distributed under the terms of the GNU"
290 echo "# General Public License. As a special exception to the GNU General"
291 echo "# Public License, this file may be distributed as part of a program"
292 echo "# that contains a configuration script generated by Autoconf, under"
293 echo "# the same distribution terms as the rest of that program."
295 echo "# Generated by gnulib-tool."
299 # exits with a given status.
300 # This function needs to be used, rather than 'exit', when a 'trap' handler is
301 # in effect that refers to $?.
308 # locates the directory where the gnulib repository lives
310 # - progname name of this program
312 # - self_abspathname absolute pathname of gnulib-tool
313 # - gnulib_dir absolute pathname of gnulib repository
317 /*) self_abspathname="$progname" ;;
318 */*) self_abspathname=`pwd`/"$progname" ;;
321 # Iterate through the elements of $PATH.
322 # We use IFS=: instead of
323 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
324 # because the latter does not work when some PATH element contains spaces.
325 # We use a canonicalized $pathx instead of $PATH, because empty PATH
326 # elements are by definition equivalent to '.', however field splitting
327 # according to IFS=: loses empty fields in many shells:
328 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
329 # beginning, at the end, and in the middle),
330 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
331 # at the beginning and at the end,
332 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
333 # Solaris lose empty fields at the end.
334 # The 'case' statement is an optimization, to avoid evaluating the
335 # explicit canonicalization command when $PATH contains no empty fields.
337 if test "${PATH_SEPARATOR+set}" != set; then
339 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
340 chmod +x "$tmp"/conf.sh
341 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
348 if test "$PATH_SEPARATOR" = ";"; then
349 # On Windows, programs are searched in "." before $PATH.
352 # On Unix, we have to convert empty PATH elements to ".".
356 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
361 IFS="$PATH_SEPARATOR"
365 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
366 self_abspathname="$d/$progname"
371 if test -z "$self_abspathname"; then
372 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
376 while test -h "$self_abspathname"; do
377 # Resolve symbolic link.
378 linkval=`func_readlink "$self_abspathname"`
379 test -n "$linkval" || break
381 /* ) self_abspathname="$linkval" ;;
382 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
385 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
389 # creates a temporary directory.
391 # - progname name of this program
393 # - tmp pathname of freshly created temporary directory
396 # Use the environment variable TMPDIR, falling back to /tmp. This allows
397 # users to specify a different temporary directory, for example, if their
398 # /tmp is filled up or too small.
401 # Use the mktemp program if available. If not available, hide the error
403 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
404 test -n "$tmp" && test -d "$tmp"
407 # Use a simple mkdir command. It is guaranteed to fail if the directory
408 # already exists. $RANDOM is bash specific and expands to empty in shells
409 # other than bash, ksh and zsh. Its use does not increase security;
410 # rather, it minimizes the probability of failure in a very cluttered /tmp
412 tmp=$TMPDIR/gl$$-$RANDOM
413 (umask 077 && mkdir "$tmp")
416 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
421 # func_append var value
422 # appends the given value to the shell variable var.
423 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
424 # Use bash's += operator. It reduces complexity of appending repeatedly to
425 # a single variable from O(n^2) to O(n).
430 fast_func_append=true
434 eval "$1=\"\$$1\$2\""
436 fast_func_append=false
439 # func_remove_prefix var prefix
440 # removes the given prefix from the value of the shell variable var.
441 # var should be the name of a shell variable.
442 # Its value should not contain a newline and not start or end with whitespace.
443 # prefix should not contain the characters "$`\{}[]^|.
444 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
445 func_remove_prefix ()
449 fast_func_remove_prefix=true
451 func_remove_prefix ()
453 eval "value=\"\$$1\""
457 sed_escape_dots='s/\([.]\)/\\\1/g'
458 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
461 value=`echo "$value" | sed -e "s|^${prefix}||"`
462 eval "$1=\"\$value\""
464 fast_func_remove_prefix=false
467 # func_remove_suffix var suffix
468 # removes the given suffix from the value of the shell variable var.
469 # var should be the name of a shell variable.
470 # Its value should not contain a newline and not start or end with whitespace.
471 # suffix should not contain the characters "$`\{}[]^|.
472 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
473 func_remove_suffix ()
477 fast_func_remove_suffix=true
479 func_remove_suffix ()
481 eval "value=\"\$$1\""
485 sed_escape_dots='s/\([.]\)/\\\1/g'
486 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
489 value=`echo "$value" | sed -e "s|${suffix}\$||"`
490 eval "$1=\"\$value\""
492 fast_func_remove_suffix=false
495 # func_fatal_error message
496 # outputs to stderr a fatal error message, and terminates the program.
498 # - progname name of this program
501 echo "$progname: *** $1" 1>&2
502 echo "$progname: *** Stop." 1>&2
506 # func_warning message
507 # Outputs to stderr a warning message,
510 echo "gnulib-tool: warning: $1" 1>&2
513 # func_readlink SYMLINK
514 # outputs the target of the given symlink.
515 if (type -p readlink) > /dev/null 2>&1; then
518 # Use the readlink program from GNU coreutils.
524 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
525 # would do the wrong thing if the link target contains " -> ".
526 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
530 # func_relativize DIR1 DIR2
531 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
533 # - DIR1 relative pathname, relative to the current directory
534 # - DIR2 relative pathname, relative to the current directory
536 # - reldir relative pathname of DIR2, relative to DIR1
542 sed_first='s,^\([^/]*\)/.*$,\1,'
543 sed_rest='s,^[^/]*/*,,'
544 sed_last='s,^.*/\([^/]*\)$,\1,'
545 sed_butlast='s,/*[^/]*$,,'
546 while test -n "$dir1"; do
547 first=`echo "$dir1" | sed -e "$sed_first"`
548 if test "$first" != "."; then
549 if test "$first" = ".."; then
550 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
551 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
553 first2=`echo "$dir2" | sed -e "$sed_first"`
554 if test "$first2" = "$first"; then
555 dir2=`echo "$dir2" | sed -e "$sed_rest"`
559 dir0="$dir0"/"$first"
562 dir1=`echo "$dir1" | sed -e "$sed_rest"`
567 # func_relconcat DIR1 DIR2
568 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
570 # - DIR1 relative pathname, relative to the current directory
571 # - DIR2 relative pathname, relative to DIR1
573 # - relconcat DIR1/DIR2, relative to the current directory
578 sed_first='s,^\([^/]*\)/.*$,\1,'
579 sed_rest='s,^[^/]*/*,,'
580 sed_last='s,^.*/\([^/]*\)$,\1,'
581 sed_butlast='s,/*[^/]*$,,'
583 first=`echo "$dir2" | sed -e "$sed_first"`
584 if test "$first" = "."; then
585 dir2=`echo "$dir2" | sed -e "$sed_rest"`
586 if test -z "$dir2"; then
591 last=`echo "$dir1" | sed -e "$sed_last"`
592 while test "$last" = "."; do
593 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
594 last=`echo "$dir1" | sed -e "$sed_last"`
596 if test -z "$dir1"; then
600 if test "$first" = ".."; then
601 if test "$last" = ".."; then
602 relconcat="$dir1/$dir2"
605 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
606 dir2=`echo "$dir2" | sed -e "$sed_rest"`
607 if test -z "$dir1"; then
611 if test -z "$dir2"; then
616 relconcat="$dir1/$dir2"
624 # Like ln -s, except that SRC is given relative to the current directory (or
625 # absolute), not given relative to the directory of DEST.
631 *) # SRC is relative.
634 ln -s "`pwd`/$1" "$2" ;;
635 *) # DEST is relative too.
636 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
637 test -n "$ln_destdir" || ln_destdir="."
638 func_relativize "$ln_destdir" "$1"
646 # func_ln_if_changed SRC DEST
647 # Like func_ln, but avoids munging timestamps if the link is correct.
648 func_ln_if_changed ()
650 if test $# -ne 2; then
651 echo "usage: func_ln_if_changed SRC DEST" >&2
653 ln_target=`func_readlink "$2"`
654 if test -h "$2" && test "$1" = "$ln_target"; then
663 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
664 # writes into a pipe with no readers, i.e. a pipe where all readers have
665 # already closed their file descriptor that read from it or exited entirely.
666 # The default behaviour is to terminate the current process without an error
668 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
669 # terminate the current process with an error message.
670 # This function should be called at the beginning of a command that only
671 # produces output to stdout (i.e. no side effects!), when the command that
672 # will read from this pipe might prematurely exit or close its standard input
674 if test -n "$BASH_VERSION"; then
675 # The problem has only been reported with bash. Probably it occurs only with
676 # bash-3.2. For the reasons, see
677 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
678 # Note that Solaris sh does not understand "trap - SIGPIPE".
679 func_reset_sigpipe ()
684 func_reset_sigpipe ()
690 # Ensure an 'echo' command that does not interpret backslashes.
692 # echo '\n' | wc -l prints 1 when OK, 2 when KO
693 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
694 # This problem is a weird heritage from SVR4. BSD got it right (except that
695 # BSD echo interprets '-n' as an option, which is also not desirable).
696 # Nowadays the problem occurs in 4 situations:
697 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
698 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
699 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
700 # - in zsh, when sh-emulation is not set,
701 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
702 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
703 # - in Solaris /bin/sh and OSF/1 /bin/sh.
704 # We try the following workarounds:
705 # - for all: respawn using $CONFIG_SHELL if that is set and works.
706 # - for bash >= 2.04: unset the shell option xpg_echo.
707 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
708 # - for bash < 2.0: define echo to a function that uses cat of a here document.
709 # - for zsh: turn sh-emulation on.
710 # - for ksh: alias echo to 'print -r'.
711 # - for ksh: alias echo to a function that uses cat of a here document.
712 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
713 # the ksh workaround.
714 # - otherwise: respawn using /bin/sh and rely on the workarounds.
715 # When respawning, we pass --no-reexec as first argument, so as to avoid
716 # turning this script into a fork bomb in unlucky situations.
718 if echo '\t' | grep t > /dev/null; then
719 have_echo=yes # Lucky!
721 # Try the workarounds.
722 # Respawn using $CONFIG_SHELL if that is set and works.
723 if test -z "$have_echo" \
724 && test "X$1" != "X--no-reexec" \
725 && test -n "$CONFIG_SHELL" \
726 && test -f "$CONFIG_SHELL" \
727 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
728 exec $CONFIG_SHELL "$0" --no-reexec "$@"
731 # For bash >= 2.04: unset the shell option xpg_echo.
732 if test -z "$have_echo" \
733 && test -n "$BASH_VERSION" \
734 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
738 # For bash >= 2.0: define echo to a function that uses the printf built-in.
739 # For bash < 2.0: define echo to a function that uses cat of a here document.
740 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
741 if test -z "$have_echo" \
742 && test -n "$BASH_VERSION"; then \
743 if type printf 2>/dev/null | grep / > /dev/null; then
744 # 'printf' is not a shell built-in.
752 # 'printf' is a shell built-in.
758 if echo '\t' | grep t > /dev/null; then
762 # For zsh: turn sh-emulation on.
763 if test -z "$have_echo" \
764 && test -n "$ZSH_VERSION" \
765 && (emulate sh) >/dev/null 2>&1; then
768 # For ksh: alias echo to 'print -r'.
769 if test -z "$have_echo" \
770 && (type print) >/dev/null 2>&1; then
771 # A 'print' command exists.
772 if type print 2>/dev/null | grep / > /dev/null; then
775 # 'print' is a shell built-in.
776 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
777 # 'print' is the ksh shell built-in.
778 alias echo='print -r'
782 if test -z "$have_echo" \
783 && echo '\t' | grep t > /dev/null; then
786 # For ksh: alias echo to a function that uses cat of a here document.
787 # The ksh manual page says:
788 # "Aliasing is performed when scripts are read, not while they are executed.
789 # Therefore, for an alias to take effect, the alias definition command has
790 # to be executed before the command which references the alias is read."
791 # Because of this, we have to play strange tricks with have_echo, to ensure
792 # that the top-level statement containing the test starts after the 'alias'
794 if test -z "$have_echo"; then
801 alias echo=bsd_echo 2>/dev/null
803 if test -z "$have_echo" \
804 && echo '\t' | grep t > /dev/null; then
807 if test -z "$have_echo"; then
808 unalias echo 2>/dev/null
810 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
811 if test -z "$have_echo" \
812 && test "X$1" != "X--no-reexec" \
813 && test -f /bin/ksh; then
814 exec /bin/ksh "$0" --no-reexec "$@"
817 # Otherwise: respawn using /bin/sh.
818 if test -z "$have_echo" \
819 && test "X$1" != "X--no-reexec" \
820 && test -f /bin/sh; then
821 exec /bin/sh "$0" --no-reexec "$@"
824 if test -z "$have_echo"; then
825 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
827 if echo '\t' | grep t > /dev/null; then
830 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
832 if test "X$1" = "X--no-reexec"; then
836 # Command-line option processing.
837 # Removes the OPTIONS from the arguments. Sets the variables:
838 # - mode list or import or create-testdir or create-megatestdir
839 # - destdir from --dir
840 # - local_gnulib_dir from --local-dir
841 # - modcache true or false, from --cache-modules/--no-cache-modules
842 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
843 # - libname, supplied_libname from --lib
844 # - sourcebase from --source-base
845 # - m4base from --m4-base
846 # - pobase from --po-base
847 # - docbase from --doc-base
848 # - testsbase from --tests-base
849 # - auxdir from --aux-dir
850 # - inctests true if --with-tests was given, blank otherwise
851 # - incobsolete true if --with-obsolete was given, blank otherwise
852 # - avoidlist list of modules to avoid, from --avoid
853 # - lgpl yes or a number if --lgpl was given, blank otherwise
854 # - makefile_name from --makefile-name
855 # - libtool true if --libtool was given, false if --no-libtool was
856 # given, blank otherwise
857 # - macro_prefix from --macro-prefix
858 # - po_domain from --po-domain
859 # - vc_files true if --vc-files was given, false if --no-vc-files was
860 # given, blank otherwise
861 # - autoconf_minversion minimum supported autoconf version
862 # - do_changelog false if --no-changelog was given, : otherwise
863 # - doit : if actions shall be executed, false if only to be printed
864 # - symbolic true if --symlink or --more-symlinks was given, blank
866 # - lsymbolic true if --local-symlink was given, blank otherwise
867 # - do_copyrights blank if --more-symlinks was given, true otherwise
899 while test $# -gt 0; do
904 --import | --impor | --impo | --imp | --im | --i )
907 --update | --updat | --upda | --upd | --up | --u )
910 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
913 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
914 mode=create-megatestdir
916 --test | --tes | --te | --t )
919 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
923 mode=`echo "X$1" | sed -e 's/^X--//'`
925 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
931 func_fatal_error "missing argument for --dir"
936 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
941 func_fatal_error "missing argument for --local-dir"
946 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
948 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
951 --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 )
954 --verbose | --verbos | --verbo | --verb )
955 verbose=`expr $verbose + 1`
957 --quiet | --quie | --qui | --qu | --q )
958 verbose=`expr $verbose - 1`
963 func_fatal_error "missing argument for --lib"
966 supplied_libname=true
969 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
970 supplied_libname=true
975 func_fatal_error "missing argument for --source-base"
980 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
985 func_fatal_error "missing argument for --m4-base"
990 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
995 func_fatal_error "missing argument for --po-base"
1000 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1004 if test $# = 0; then
1005 func_fatal_error "missing argument for --doc-base"
1010 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1014 if test $# = 0; then
1015 func_fatal_error "missing argument for --tests-base"
1020 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1024 if test $# = 0; then
1025 func_fatal_error "missing argument for --aux-dir"
1030 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1040 if test $# = 0; then
1041 func_fatal_error "missing argument for --avoid"
1043 func_append avoidlist " $1"
1046 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1047 func_append avoidlist " $arg"
1053 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1056 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1062 if test $# = 0; then
1063 func_fatal_error "missing argument for --makefile-name"
1068 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1078 if test $# = 0; then
1079 func_fatal_error "missing argument for --macro-prefix"
1084 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1088 if test $# = 0; then
1089 func_fatal_error "missing argument for --po-domain"
1094 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1102 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1108 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1111 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1114 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1118 --help | --hel | --he | --h )
1121 --version | --versio | --versi | --vers )
1125 # Stop option processing
1129 echo "gnulib-tool: unknown option $1" 1>&2
1130 echo "Try 'gnulib-tool --help' for more information." 1>&2
1137 if test "$mode" = update; then
1138 if test $# != 0; then
1139 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1140 echo "Try 'gnulib-tool --help' for more information." 1>&2
1141 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1142 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1145 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1146 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1147 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1148 || test -n "$inctests" || test -n "$incobsolete" \
1149 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1150 || test -n "$macro_prefix" || test -n "$po_domain" \
1151 || test -n "$vc_files"; then
1152 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1153 echo "Try 'gnulib-tool --help' for more information." 1>&2
1154 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1155 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1160 if test -n "$pobase" && test -z "$po_domain"; then
1161 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1162 echo "Try 'gnulib-tool --help' for more information." 1>&2
1165 if test -z "$pobase" && test -n "$po_domain"; then
1166 func_warning "--po-domain has no effect without a --po-base option"
1169 # Determine the minimum supported autoconf version from the project's
1171 DEFAULT_AUTOCONF_MINVERSION="2.59"
1172 autoconf_minversion=
1174 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1175 if test -f "$destdir"/configure.ac; then
1176 configure_ac="$destdir/configure.ac"
1178 if test -f "$destdir"/configure.in; then
1179 configure_ac="$destdir/configure.in"
1183 if test -f configure.ac; then
1184 configure_ac="configure.ac"
1186 if test -f configure.in; then
1187 configure_ac="configure.in"
1191 if test -n "$configure_ac"; then
1192 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1193 # because when some m4 files are omitted from a CVS repository,
1194 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1195 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1196 # autom4te: m4 failed with exit status: 1
1203 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1205 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1206 if test -n "$prereqs"; then
1207 autoconf_minversion=`
1208 for version in $prereqs; do echo $version; done |
1209 LC_ALL=C sort -nru | sed -e 1q
1213 if test -z "$autoconf_minversion"; then
1214 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1216 case "$autoconf_minversion" in
1217 1.* | 2.[0-4]* | 2.5[0-8]*)
1218 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1221 # Remove trailing slashes from the directory names. This is necessary for
1222 # m4base (to avoid an error in func_import) and optional for the others.
1223 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1224 case "$local_gnulib_dir" in
1225 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1227 case "$sourcebase" in
1228 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1231 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1234 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1237 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1239 case "$testsbase" in
1240 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1243 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1249 trap 'exit_status=$?
1250 if test "$signal" != 0; then
1251 echo "caught signal $signal" >&2
1254 exit $exit_status' 0
1255 for signal in 1 2 3 13 15; do
1256 trap '{ signal='$signal'; func_exit 1; }' $signal
1260 # func_lookup_file file
1261 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1264 # - local_gnulib_dir from --local-dir
1266 # - lookedup_file name of the merged (combined) file
1267 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1271 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1272 lookedup_file="$local_gnulib_dir/$lkfile"
1275 if test -f "$gnulib_dir/$lkfile"; then
1276 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1277 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1278 rm -f "$tmp/$lkbase"
1279 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1280 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1281 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1282 lookedup_file="$tmp/$lkbase"
1285 lookedup_file="$gnulib_dir/$lkfile"
1289 func_fatal_error "file $gnulib_dir/$lkfile not found"
1296 # - local_gnulib_dir from --local-dir
1299 # Filter out metainformation files like README, which are not modules.
1300 # Filter out unit test modules; they can be retrieved through
1301 # --extract-tests-module if desired.
1303 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1304 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1305 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1308 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1309 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1310 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1311 -e '/^README$/d' -e '/\/README$/d' \
1312 -e '/^TEMPLATE$/d' \
1313 -e '/^TEMPLATE-EXTENDED$/d' \
1314 -e '/^TEMPLATE-TESTS$/d' \
1317 | sed -e '/-tests$/d' \
1321 # func_verify_module
1322 # verifies a module name
1324 # - local_gnulib_dir from --local-dir
1325 # - module module name argument
1326 func_verify_module ()
1328 if { test -f "$gnulib_dir/modules/$module" \
1329 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1330 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1331 && test "CVS" != "$module" \
1332 && test "ChangeLog" != "$module" \
1333 && test "COPYING" != "$module" \
1334 && test "README" != "$module" \
1335 && test "TEMPLATE" != "$module" \
1336 && test "TEMPLATE-EXTENDED" != "$module" \
1337 && test "TEMPLATE-TESTS" != "$module"; then
1338 # OK, $module is a correct module name.
1339 # Verify that building the module description with 'patch' succeeds.
1340 func_lookup_file "modules/$module"
1342 func_warning "module $module doesn't exist"
1347 # func_verify_nontests_module
1348 # verifies a module name, excluding tests modules
1350 # - local_gnulib_dir from --local-dir
1351 # - module module name argument
1352 func_verify_nontests_module ()
1355 *-tests ) module= ;;
1356 * ) func_verify_module ;;
1360 # func_verify_tests_module
1361 # verifies a module name, considering only tests modules
1363 # - local_gnulib_dir from --local-dir
1364 # - module module name argument
1365 func_verify_tests_module ()
1368 *-tests ) func_verify_module ;;
1373 # Suffix of a sed expression that extracts a particular field from a
1374 # module description.
1375 # A field starts with a line that contains a keyword, such as 'Description',
1376 # followed by a colon and optional whitespace. All following lines, up to
1377 # the next field (or end of file if there is none) form the contents of the
1379 # An absent field is equivalent to a field with empty contents.
1380 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1381 sed_extract_prog=':[ ]*$/ {
1384 s/^Description:[ ]*$//
1387 s/^Applicability:[ ]*$//
1389 s/^Depends-on:[ ]*$//
1390 s/^configure\.ac-early:[ ]*$//
1391 s/^configure\.ac:[ ]*$//
1392 s/^Makefile\.am:[ ]*$//
1396 s/^Maintainer:[ ]*$//
1403 # Piece of a sed expression that converts a field header line to a shell
1405 # NOTE: Keep this in sync with sed_extract_prog above!
1406 sed_extract_field_header='
1407 s/^Description:[ ]*$/description/
1408 s/^Status:[ ]*$/status/
1409 s/^Notice:[ ]*$/notice/
1410 s/^Applicability:[ ]*$/applicability/
1411 s/^Files:[ ]*$/files/
1412 s/^Depends-on:[ ]*$/dependson/
1413 s/^configure\.ac-early:[ ]*$/configureac_early/
1414 s/^configure\.ac:[ ]*$/configureac/
1415 s/^Makefile\.am:[ ]*$/makefile/
1416 s/^Include:[ ]*$/include/
1418 s/^License:[ ]*$/license/
1419 s/^Maintainer:[ ]*$/maintainer/'
1423 # Note: The 'eval' silences stderr output in dash.
1424 if declare -A x 2>/dev/null && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }; then
1425 # Zsh 4 and Bash 4 have associative arrays.
1426 have_associative=true
1428 # For other shells, use 'eval' with computed shell variable names.
1429 have_associative=false
1432 if $have_associative; then
1434 # Declare the associative arrays.
1435 declare -A modcache_cached
1436 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1437 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1438 eval "$declare_script"
1442 # func_cache_var module
1443 # computes the cache variable name corresponding to $module.
1444 # Note: This computation can map different module names to the same
1445 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1446 # to protect against this case.
1448 # - cachevar a shell variable name
1449 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1450 # Bash 2.0 and newer, ksh, and zsh support the syntax
1451 # ${param//pattern/replacement}
1452 # as a shorthand for
1453 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1454 # Note: The 'eval' above silences stderr output in dash.
1457 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1464 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1473 # func_init_sed_convert_to_cache_statements
1475 # - modcachevar_assignment
1477 # - sed_convert_to_cache_statements
1478 func_init_sed_convert_to_cache_statements ()
1480 # 'sed' script that turns a module description into shell script
1481 # assignments, suitable to be eval'ed. All active characters are escaped.
1484 # Some module's description
1489 # modcache_description[$1]=\
1490 # 'Some module'"'"'s description
1492 # modcache_files[$1]=\
1495 # c_MODULE_description_set=set; c_MODULE_description=\
1496 # 'Some module'"'"'s description
1498 # c_MODULE_files_set=set; c_MODULE_files=\
1500 # The script consists of two parts:
1501 # 1) Ignore the lines before the first field header.
1502 # 2) A loop, treating non-field-header lines by escaping single quotes
1503 # and adding a closing quote in the last line,
1504 sed_convert_to_cache_statements="
1506 # Here we have not yet seen a field header.
1508 # See if the current line contains a field header.
1511 ${sed_extract_field_header}
1514 # No field header. Ignore the line.
1516 # Read the next line. Upon EOF, just exit.
1521 # The current line contains a field header.
1523 # Turn it into the beginning of an assignment.
1524 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1526 # Move it to the hold space. Don't print it yet,
1527 # because we want no assignment if the field is empty.
1530 # Read the next line.
1531 # Upon EOF, the field was empty. Print no assignment. Just exit.
1534 # See if the current line contains a field header.
1537 ${sed_extract_field_header}
1538 # If it is, the previous field was empty. Print no assignment.
1541 # Not a field header.
1543 # Print the previous line, held in the hold space.
1548 # Transform single quotes.
1551 # Prepend a single quote.
1556 # Move it to the hold space.
1559 # Read the next line.
1566 # See if the current line contains a field header.
1569 ${sed_extract_field_header}
1572 # Print the previous line, held in the hold space.
1577 # Transform single quotes.
1584 # Print the previous line, held in the hold space, with a single quote
1585 # to end the assignment.
1595 # Print the previous line, held in the hold space, with a single quote
1596 # to end the assignment.
1603 if ! $sed_comments; then
1605 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1606 | sed -e 's/^ *//' -e 's/^#.*//'`
1610 if $have_associative; then
1611 # sed_convert_to_cache_statements does not depend on the module.
1612 modcachevar_assignment='modcache_\1[$1]='
1613 func_init_sed_convert_to_cache_statements
1616 # func_cache_lookup_module module
1618 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1619 # of its relevant data in a cache in the memory of the processing shell. If
1620 # already cached, it does not look it up again, thus saving file access time.
1622 # - module non-empty string
1623 # Output if $have_associative:
1624 # - modcache_cached[$module] set to yes
1625 # - modcache_description[$module] ==
1626 # - modcache_status[$module] \ set to the field's value, minus the
1627 # - ... / final newline,
1628 # - modcache_maintainer[$module] == or unset if the field's value is empty
1629 # Output if ! $have_associative:
1630 # - cachevar a shell variable name
1631 # - ${cachevar}_cached set to $module
1632 # - ${cachevar}_description ==
1633 # - ${cachevar}_status \ set to the field's value, minus the
1634 # - ... / final newline,
1635 # - ${cachevar}_maintainer == or unset if the field's value is empty
1636 # - ${cachevar}_description_set ==
1637 # - ${cachevar}_status_set \ set to non-empty if the field's value
1638 # - ... / is non-empty,
1639 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1640 func_cache_lookup_module ()
1642 if $have_associative; then
1643 cached=${modcache_cached[$1]}
1646 eval "cached=\"\$${cachevar}_cached\""
1648 if test -z "$cached"; then
1649 # Not found in cache. Look it up on the file system.
1650 func_lookup_file "modules/$1"
1651 if $have_associative; then
1652 modcache_cached[$1]=yes
1654 eval "${cachevar}_cached=\"\$1\""
1656 if ! $have_associative; then
1657 # sed_convert_to_cache_statements depends on the module.
1658 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1659 func_init_sed_convert_to_cache_statements
1661 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1662 eval "$cache_statements"
1664 if ! $have_associative; then
1665 if test "$1" != "$cached"; then
1666 func_fatal_error "cache variable collision between $1 and $cached"
1674 # func_get_description module
1676 # - local_gnulib_dir from --local-dir
1677 # - modcache true or false, from --cache-modules/--no-cache-modules
1678 func_get_description ()
1680 if ! $modcache; then
1681 func_lookup_file "modules/$1"
1682 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1684 func_cache_lookup_module "$1"
1685 # Output the field's value, including the final newline (if any).
1686 if $have_associative; then
1687 if test -n "${modcache_description[$1]+set}"; then
1688 echo "${modcache_description[$1]}"
1691 eval "field_set=\"\$${cachevar}_description_set\""
1692 if test -n "$field_set"; then
1693 eval "field_value=\"\$${cachevar}_description\""
1694 echo "${field_value}"
1700 # func_get_status module
1702 # - local_gnulib_dir from --local-dir
1703 # - modcache true or false, from --cache-modules/--no-cache-modules
1706 if ! $modcache; then
1707 func_lookup_file "modules/$1"
1708 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1710 func_cache_lookup_module "$1"
1711 # Output the field's value, including the final newline (if any).
1712 if $have_associative; then
1713 if test -n "${modcache_status[$1]+set}"; then
1714 echo "${modcache_status[$1]}"
1717 eval "field_set=\"\$${cachevar}_status_set\""
1718 if test -n "$field_set"; then
1719 eval "field_value=\"\$${cachevar}_status\""
1720 echo "${field_value}"
1726 # func_get_notice module
1728 # - local_gnulib_dir from --local-dir
1729 # - modcache true or false, from --cache-modules/--no-cache-modules
1732 if ! $modcache; then
1733 func_lookup_file "modules/$1"
1734 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1736 func_cache_lookup_module "$1"
1737 # Output the field's value, including the final newline (if any).
1738 if $have_associative; then
1739 if test -n "${modcache_notice[$1]+set}"; then
1740 echo "${modcache_notice[$1]}"
1743 eval "field_set=\"\$${cachevar}_notice_set\""
1744 if test -n "$field_set"; then
1745 eval "field_value=\"\$${cachevar}_notice\""
1746 echo "${field_value}"
1752 # func_get_applicability module
1754 # - local_gnulib_dir from --local-dir
1755 # - modcache true or false, from --cache-modules/--no-cache-modules
1756 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1757 func_get_applicability ()
1759 if ! $modcache; then
1760 func_lookup_file "modules/$1"
1761 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1763 func_cache_lookup_module "$1"
1764 # Get the field's value, without the final newline.
1765 if $have_associative; then
1766 my_applicability="${modcache_applicability[$1]}"
1768 eval "my_applicability=\"\$${cachevar}_applicability\""
1771 if test -n "$my_applicability"; then
1772 echo $my_applicability
1774 # The default is 'main' or 'tests', depending on the module's name.
1776 *-tests) echo "tests";;
1782 # func_get_filelist module
1784 # - local_gnulib_dir from --local-dir
1785 # - modcache true or false, from --cache-modules/--no-cache-modules
1786 func_get_filelist ()
1788 if ! $modcache; then
1789 func_lookup_file "modules/$1"
1790 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1792 func_cache_lookup_module "$1"
1793 # Output the field's value, including the final newline (if any).
1794 if $have_associative; then
1795 if test -n "${modcache_files[$1]+set}"; then
1796 echo "${modcache_files[$1]}"
1799 eval "field_set=\"\$${cachevar}_files_set\""
1800 if test -n "$field_set"; then
1801 eval "field_value=\"\$${cachevar}_files\""
1802 echo "${field_value}"
1807 echo m4/gnulib-common.m4
1808 case "$autoconf_minversion" in
1815 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1816 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1817 # elements starting with prefix and ending with suffix are considered.
1818 # Processing: removed_prefix and removed_suffix are removed from each element,
1819 # added_prefix and added_suffix are added to each element.
1820 # prefix, suffix should not contain shell-special characters.
1821 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1822 # added_prefix, added_suffix should not contain the characters \|&.
1823 func_filter_filelist ()
1825 if test "$2" != "$nl" \
1826 || { $fast_func_append \
1827 && { test -z "$6" || $fast_func_remove_prefix; } \
1828 && { test -z "$7" || $fast_func_remove_suffix; }; \
1832 # Do not quote possibly-empty parameters in case patterns,
1833 # AIX and HP-UX ksh won't match them if they are empty.
1836 if test -n "$6"; then
1837 func_remove_prefix fff "$6"
1839 if test -n "$7"; then
1840 func_remove_suffix fff "$7"
1843 if test -z "$ffflist"; then
1846 func_append ffflist "$2${fff}"
1852 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1853 ffflist=`for fff in $3; do
1855 $4*$5) echo "$fff" ;;
1857 done | sed -e "$sed_fff_filter"`
1859 eval "$1=\"\$ffflist\""
1862 # func_get_dependencies module
1864 # - local_gnulib_dir from --local-dir
1865 # - modcache true or false, from --cache-modules/--no-cache-modules
1866 func_get_dependencies ()
1868 # ${module}-tests always implicitly depends on ${module}.
1872 func_remove_suffix fgd1 '-tests'
1876 # Then the explicit dependencies listed in the module description.
1877 if ! $modcache; then
1878 func_lookup_file "modules/$1"
1879 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1881 func_cache_lookup_module "$1"
1882 # Output the field's value, including the final newline (if any).
1883 if $have_associative; then
1884 if test -n "${modcache_dependson[$1]+set}"; then
1885 echo "${modcache_dependson[$1]}"
1888 eval "field_set=\"\$${cachevar}_dependson_set\""
1889 if test -n "$field_set"; then
1890 eval "field_value=\"\$${cachevar}_dependson\""
1891 echo "${field_value}"
1897 # func_get_autoconf_early_snippet module
1899 # - local_gnulib_dir from --local-dir
1900 # - modcache true or false, from --cache-modules/--no-cache-modules
1901 func_get_autoconf_early_snippet ()
1903 if ! $modcache; then
1904 func_lookup_file "modules/$1"
1905 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1907 func_cache_lookup_module "$1"
1908 # Output the field's value, including the final newline (if any).
1909 if $have_associative; then
1910 if test -n "${modcache_configureac_early[$1]+set}"; then
1911 echo "${modcache_configureac_early[$1]}"
1914 eval "field_set=\"\$${cachevar}_configureac_early_set\""
1915 if test -n "$field_set"; then
1916 eval "field_value=\"\$${cachevar}_configureac_early\""
1917 echo "${field_value}"
1923 # func_get_autoconf_snippet module
1925 # - local_gnulib_dir from --local-dir
1926 # - modcache true or false, from --cache-modules/--no-cache-modules
1927 func_get_autoconf_snippet ()
1929 if ! $modcache; then
1930 func_lookup_file "modules/$1"
1931 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1933 func_cache_lookup_module "$1"
1934 # Output the field's value, including the final newline (if any).
1935 if $have_associative; then
1936 if test -n "${modcache_configureac[$1]+set}"; then
1937 echo "${modcache_configureac[$1]}"
1940 eval "field_set=\"\$${cachevar}_configureac_set\""
1941 if test -n "$field_set"; then
1942 eval "field_value=\"\$${cachevar}_configureac\""
1943 echo "${field_value}"
1949 # func_get_automake_snippet module
1951 # - local_gnulib_dir from --local-dir
1952 # - modcache true or false, from --cache-modules/--no-cache-modules
1953 func_get_automake_snippet ()
1955 if ! $modcache; then
1956 func_lookup_file "modules/$1"
1957 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1959 func_cache_lookup_module "$1"
1960 # Output the field's value, including the final newline (if any).
1961 if $have_associative; then
1962 if test -n "${modcache_makefile[$1]+set}"; then
1963 echo "${modcache_makefile[$1]}"
1966 eval "field_set=\"\$${cachevar}_makefile_set\""
1967 if test -n "$field_set"; then
1968 eval "field_value=\"\$${cachevar}_makefile\""
1969 echo "${field_value}"
1975 # *-tests module live in tests/, not lib/.
1976 # Synthesize an EXTRA_DIST augmentation.
1977 all_files=`func_get_filelist $1`
1978 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1979 extra_files="$tests_files"
1980 if test -n "$extra_files"; then
1981 echo "EXTRA_DIST +=" $extra_files
1986 # Synthesize an EXTRA_DIST augmentation.
1987 sed_combine_lines='/\\$/{
1994 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1995 already_mentioned_files=` \
1996 { if ! $modcache; then
1997 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1999 if $have_associative; then
2000 if test -n "${modcache_makefile[$1]+set}"; then
2001 echo "${modcache_makefile[$1]}"
2004 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2005 if test -n "$field_set"; then
2006 eval 'field_value="$'"${cachevar}"'_makefile"'
2007 echo "${field_value}"
2012 | sed -e "$sed_combine_lines" \
2013 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2014 all_files=`func_get_filelist $1`
2015 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2016 # Remove $already_mentioned_files from $lib_files.
2017 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2018 extra_files=`func_reset_sigpipe; \
2019 for f in $already_mentioned_files; do echo $f; done \
2020 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2021 if test -n "$extra_files"; then
2022 echo "EXTRA_DIST +=" $extra_files
2025 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2026 # This is necessary so that automake can generate the right list of
2028 # A possible approach would be to use autom4te --trace of the redefined
2029 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2030 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2031 # inside autoconf's built-in macros are not missed).
2032 # But it's simpler and more robust to do it here, based on the file list.
2033 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2034 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2035 # automake will generate a useless dependency; this is harmless.
2037 relocatable-prog-wrapper) ;;
2039 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2040 if test -n "$extra_files"; then
2041 echo "EXTRA_lib_SOURCES +=" $extra_files
2046 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2047 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2048 if test -n "$buildaux_files"; then
2049 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2050 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2053 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2054 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2055 if test -n "$top_files"; then
2056 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2057 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2064 # func_get_include_directive module
2066 # - local_gnulib_dir from --local-dir
2067 # - modcache true or false, from --cache-modules/--no-cache-modules
2068 func_get_include_directive ()
2071 if ! $modcache; then
2072 func_lookup_file "modules/$1"
2073 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2075 func_cache_lookup_module "$1"
2076 # Output the field's value, including the final newline (if any).
2077 if $have_associative; then
2078 if test -n "${modcache_include[$1]+set}"; then
2079 echo "${modcache_include[$1]}"
2082 eval "field_set=\"\$${cachevar}_include_set\""
2083 if test -n "$field_set"; then
2084 eval "field_value=\"\$${cachevar}_include\""
2085 echo "${field_value}"
2089 } | sed -e 's/^\(["<]\)/#include \1/'
2092 # func_get_link_directive module
2094 # - local_gnulib_dir from --local-dir
2095 # - modcache true or false, from --cache-modules/--no-cache-modules
2096 func_get_link_directive ()
2098 if ! $modcache; then
2099 func_lookup_file "modules/$1"
2100 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2102 func_cache_lookup_module "$1"
2103 # Output the field's value, including the final newline (if any).
2104 if $have_associative; then
2105 if test -n "${modcache_link[$1]+set}"; then
2106 echo "${modcache_link[$1]}"
2109 eval "field_set=\"\$${cachevar}_link_set\""
2110 if test -n "$field_set"; then
2111 eval "field_value=\"\$${cachevar}_link\""
2112 echo "${field_value}"
2118 # func_get_license module
2120 # - local_gnulib_dir from --local-dir
2121 # - modcache true or false, from --cache-modules/--no-cache-modules
2125 if ! $modcache; then
2126 func_lookup_file "modules/$1"
2127 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2129 func_cache_lookup_module "$1"
2130 # Output the field's value, including the final newline (if any).
2131 if $have_associative; then
2132 if test -n "${modcache_license[$1]+set}"; then
2133 echo "${modcache_license[$1]}"
2136 eval "field_set=\"\$${cachevar}_license_set\""
2137 if test -n "$field_set"; then
2138 eval "field_value=\"\$${cachevar}_license\""
2139 echo "${field_value}"
2143 # The default is GPL.
2145 } | sed -e 's,^ *$,,' | sed -e 1q
2148 # func_get_maintainer module
2150 # - local_gnulib_dir from --local-dir
2151 # - modcache true or false, from --cache-modules/--no-cache-modules
2152 func_get_maintainer ()
2154 if ! $modcache; then
2155 func_lookup_file "modules/$1"
2156 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2158 func_cache_lookup_module "$1"
2159 # Output the field's value, including the final newline (if any).
2160 if $have_associative; then
2161 if test -n "${modcache_maintainer[$1]+set}"; then
2162 echo "${modcache_maintainer[$1]}"
2165 eval "field_set=\"\$${cachevar}_maintainer_set\""
2166 if test -n "$field_set"; then
2167 eval "field_value=\"\$${cachevar}_maintainer\""
2168 echo "${field_value}"
2174 # func_get_tests_module module
2176 # - local_gnulib_dir from --local-dir
2177 func_get_tests_module ()
2179 # The naming convention for tests modules is hardwired: ${module}-tests.
2180 if test -f "$gnulib_dir/modules/$1"-tests \
2181 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2182 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2187 # func_acceptable module
2188 # tests whether a module is acceptable.
2190 # - avoidlist list of modules to avoid
2193 for avoid in $avoidlist; do
2194 if test "$avoid" = "$1"; then
2201 # func_modules_transitive_closure
2203 # - local_gnulib_dir from --local-dir
2204 # - modcache true or false, from --cache-modules/--no-cache-modules
2205 # - modules list of specified modules
2206 # - inctests true if tests should be included, blank otherwise
2207 # - incobsolete true if obsolete modules among dependencies should be
2208 # included, blank otherwise
2209 # - avoidlist list of modules to avoid
2210 # - tmp pathname of a temporary directory
2212 # - modules list of modules, including dependencies
2213 func_modules_transitive_closure ()
2215 # In order to process every module only once (for speed), process an "input
2216 # list" of modules, producing an "output list" of modules. During each round,
2217 # more modules can be queued in the input list. Once a module on the input
2218 # list has been processed, it is added to the "handled list", so we can avoid
2219 # to process it again.
2221 inmodules="$modules"
2223 while test -n "$inmodules"; do
2224 inmodules_this_round="$inmodules"
2225 inmodules= # Accumulator, queue for next round
2226 for module in $inmodules_this_round; do
2228 if test -n "$module"; then
2229 if func_acceptable $module; then
2230 func_append outmodules " $module"
2231 deps=`func_get_dependencies $module`
2232 # Duplicate dependencies are harmless, but Jim wants a warning.
2233 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2234 if test -n "$duplicated_deps"; then
2235 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2237 for dep in $deps; do
2238 if test -n "$incobsolete" \
2239 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
2240 func_append inmodules " $dep"
2243 if test -n "$inctests"; then
2244 testsmodule=`func_get_tests_module $module`
2245 if test -n "$testsmodule"; then
2246 func_append inmodules " $testsmodule"
2252 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2253 # Remove $handledmodules from $inmodules.
2254 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2255 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2257 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2258 rm -f "$tmp"/queued-modules
2261 # func_modules_add_dummy
2263 # - local_gnulib_dir from --local-dir
2264 # - modcache true or false, from --cache-modules/--no-cache-modules
2265 # - modules list of modules, including dependencies
2267 # - modules list of modules, including 'dummy' if needed
2268 func_modules_add_dummy ()
2270 # Determine whether any module provides a lib_SOURCES augmentation.
2272 sed_remove_backslash_newline=':a
2279 for module in $modules; do
2280 func_verify_nontests_module
2281 if test -n "$module"; then
2282 # Extract the value of "lib_SOURCES += ...".
2283 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2284 # Ignore .h files since they are not compiled.
2288 have_lib_SOURCES=yes
2295 # Add the dummy module, to make sure the library will be non-empty.
2296 if test -z "$have_lib_SOURCES"; then
2297 if func_acceptable "dummy"; then
2298 func_append modules " dummy"
2303 # func_modules_notice
2305 # - local_gnulib_dir from --local-dir
2306 # - modcache true or false, from --cache-modules/--no-cache-modules
2307 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2308 # - modules list of modules, including dependencies
2309 func_modules_notice ()
2311 if test $verbose -ge -1; then
2312 for module in $modules; do
2314 if test -n "$module"; then
2315 msg=`func_get_notice $module`
2316 if test -n "$msg"; then
2317 echo "Notice from module $module:"
2318 echo "$msg" | sed -e 's/^/ /'
2325 # func_modules_to_filelist
2327 # - local_gnulib_dir from --local-dir
2328 # - modcache true or false, from --cache-modules/--no-cache-modules
2329 # - modules list of modules, including dependencies
2331 # - files list of files
2332 func_modules_to_filelist ()
2335 for module in $modules; do
2337 if test -n "$module"; then
2338 fs=`func_get_filelist $module`
2339 func_append files " $fs"
2342 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2345 # func_execute_command command [args...]
2346 # Executes a command.
2347 # Uses also the variables
2348 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2349 func_execute_command ()
2351 if test $verbose -ge 0; then
2355 # Commands like automake produce output to stderr even when they succeed.
2356 # Turn this output off if the command succeeds.
2357 "$@" > "$tmp"/cmdout 2>&1
2359 if test $cmdret = 0; then
2363 cat "$tmp"/cmdout 1>&2
2370 # func_dest_tmpfilename file
2371 # determines the name of a temporary file (file is relative to destdir).
2373 # - destdir target directory
2374 # - doit : if actions shall be executed, false if only to be printed
2375 # - tmp pathname of a temporary directory
2377 # - tmpfile absolute filename of the temporary file
2378 func_dest_tmpfilename ()
2381 # Put the new contents of $file in a file in the same directory (needed
2382 # to guarantee that an 'mv' to "$destdir/$file" works).
2383 tmpfile="$destdir/$1.tmp"
2385 # Put the new contents of $file in a file in a temporary directory
2386 # (because the directory of "$file" might not exist).
2387 tmpfile="$tmp"/`basename "$1"`.tmp
2392 # copies a file from gnulib into the destination directory. The destination
2393 # is known to not exist.
2395 # - destdir target directory
2396 # - local_gnulib_dir from --local-dir
2397 # - modcache true or false, from --cache-modules/--no-cache-modules
2398 # - f the original file name
2399 # - lookedup_file name of the merged (combined) file
2400 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2401 # - g the rewritten file name
2402 # - tmpfile absolute filename of the temporary file
2403 # - doit : if actions shall be executed, false if only to be printed
2404 # - symbolic true if files should be symlinked, copied otherwise
2405 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2410 echo "Copying file $g"
2411 if { test -n "$symbolic" \
2412 || { test -n "$lsymbolic" \
2413 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2414 && test -z "$lookedup_tmp" \
2415 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2416 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2418 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2426 # copies a file from gnulib into the destination directory. The destination
2427 # is known to exist.
2429 # - destdir target directory
2430 # - local_gnulib_dir from --local-dir
2431 # - modcache true or false, from --cache-modules/--no-cache-modules
2432 # - f the original file name
2433 # - lookedup_file name of the merged (combined) file
2434 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2435 # - g the rewritten file name
2436 # - tmpfile absolute filename of the temporary file
2437 # - doit : if actions shall be executed, false if only to be printed
2438 # - symbolic true if files should be symlinked, copied otherwise
2439 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2441 # - already_present nonempty if the file should already exist, empty otherwise
2444 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2445 : # The file has not changed.
2449 if test -n "$already_present"; then
2450 echo "Updating file $g (backup in ${g}~)"
2452 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2454 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2455 if { test -n "$symbolic" \
2456 || { test -n "$lsymbolic" \
2457 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2458 && test -z "$lookedup_tmp" \
2459 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2460 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2462 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2465 if test -n "$already_present"; then
2466 echo "Update file $g (backup in ${g}~)"
2468 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2474 # func_emit_lib_Makefile_am
2475 # emits the contents of library makefile to standard output.
2477 # - local_gnulib_dir from --local-dir
2478 # - modcache true or false, from --cache-modules/--no-cache-modules
2479 # - modules list of modules, including dependencies
2480 # - libname library name
2481 # - pobase directory relative to destdir where to place *.po files
2482 # - auxdir directory relative to destdir where to place build aux files
2483 # - makefile_name from --makefile-name
2484 # - libtool true if libtool will be used, false or blank otherwise
2485 # - macro_prefix prefix of gl_LIBOBJS macros to use
2486 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2487 # - actioncmd (optional) command that will reproduce this invocation
2488 # - for_test true if creating a package for testing, false otherwise
2489 # - destfile filename relative to destdir of makefile being generated
2491 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2492 # list of edits to be done to Makefile.am variables
2494 # - uses_subdirs nonempty if object files in subdirs exist
2495 func_emit_lib_Makefile_am ()
2497 # When creating an includable Makefile.am snippet, augment variables with
2498 # += instead of assigning them.
2499 if test -n "$makefile_name"; then
2504 if test "$libtool" = true; then
2507 sed_eliminate_LDFLAGS="$sed_noop"
2511 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2514 # When creating a package for testing: Attempt to provoke failures,
2515 # especially link errors, already during "make" rather than during
2516 # "make check", because "make check" is not possible in a cross-compiling
2517 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2518 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2520 sed_transform_check_PROGRAMS="$sed_noop"
2522 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2523 echo "## Process this file with automake to produce Makefile.in."
2524 func_emit_copyright_notice
2525 if test -n "$actioncmd"; then
2526 # The maximum line length (excluding the terminating newline) of any file
2527 # that is to be preprocessed by config.status is 3070. config.status uses
2528 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2529 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2530 len=`echo "$actioncmd" | wc -c`
2531 if test -n "$len" && test "$len" -le 3000; then
2532 echo "# Reproduce by: $actioncmd"
2538 for module in $modules; do
2539 func_verify_nontests_module
2540 if test -n "$module"; then
2542 func_get_automake_snippet "$module" |
2543 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2544 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2545 -e "$sed_eliminate_LDFLAGS" \
2546 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2547 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2548 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2549 -e "$sed_transform_check_PROGRAMS"
2550 if test "$module" = 'alloca'; then
2551 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2552 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2554 } > "$tmp"/amsnippet
2555 # Skip the contents if it's entirely empty.
2556 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2557 echo "## begin gnulib module $module"
2559 cat "$tmp"/amsnippet
2560 echo "## end gnulib module $module"
2563 rm -f "$tmp"/amsnippet
2564 # Test whether there are some source files in subdirectories.
2565 for f in `func_get_filelist "$module"`; do
2575 } > "$tmp"/allsnippets
2576 if test -z "$makefile_name"; then
2577 # If there are source files in subdirectories, prevent collision of the
2578 # object files (example: hash.c and libxml/hash.c).
2580 if test -n "$uses_subdirs"; then
2581 subdir_options=' subdir-objects'
2583 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2586 if test -z "$makefile_name"; then
2588 echo "noinst_HEADERS ="
2589 echo "noinst_LIBRARIES ="
2590 echo "noinst_LTLIBRARIES ="
2591 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2592 # if you specify pkgdata_DATA to empty. This is a workaround.
2593 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2594 echo "pkgdata_DATA ="
2597 echo "BUILT_SOURCES ="
2600 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2601 if test -z "$makefile_name"; then
2602 echo "MOSTLYCLEANDIRS ="
2604 echo "DISTCLEANFILES ="
2605 echo "MAINTAINERCLEANFILES ="
2607 # Execute edits that apply to the Makefile.am being generated.
2609 while test $edit != $makefile_am_edits; do
2610 edit=`expr $edit + 1`
2611 eval dir=\"\$makefile_am_edit${edit}_dir\"
2612 eval var=\"\$makefile_am_edit${edit}_var\"
2613 eval val=\"\$makefile_am_edit${edit}_val\"
2614 if test -n "$var"; then
2615 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2616 echo "${var} += ${val}"
2617 eval "makefile_am_edit${edit}_var="
2621 if test -z "$makefile_name"; then
2623 echo "AM_CPPFLAGS ="
2627 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2628 || { test -n "$makefile_name" \
2629 && test -f "$sourcebase/Makefile.am" \
2630 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2632 # One of the snippets or the user's Makefile.am already specifies an
2633 # installation location for the library. Don't confuse automake by saying
2634 # it should not be installed.
2637 # By default, the generated library should not be installed.
2638 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2641 echo "${libname}_${libext}_SOURCES ="
2642 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2643 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2644 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2645 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2646 echo "EXTRA_${libname}_${libext}_SOURCES ="
2647 if test "$libtool" = true; then
2648 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2651 if test -n "$pobase"; then
2652 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2655 cat "$tmp"/allsnippets \
2656 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2658 echo "mostlyclean-local: mostlyclean-generic"
2659 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2660 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2661 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2665 rm -f "$tmp"/allsnippets
2668 # func_emit_po_Makevars
2669 # emits the contents of po/ makefile parameterization to standard output.
2671 # - local_gnulib_dir from --local-dir
2672 # - modcache true or false, from --cache-modules/--no-cache-modules
2673 # - sourcebase directory relative to destdir where to place source code
2674 # - pobase directory relative to destdir where to place *.po files
2675 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2676 func_emit_po_Makevars ()
2678 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2679 func_emit_copyright_notice
2681 echo "# Usually the message domain is the same as the package name."
2682 echo "# But here it has a '-gnulib' suffix."
2683 echo "DOMAIN = ${po_domain}-gnulib"
2685 echo "# These two variables depend on the location of this directory."
2686 echo "subdir = ${pobase}"
2687 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2690 # These options get passed to xgettext.
2691 XGETTEXT_OPTIONS = \
2692 --keyword=_ --flag=_:1:pass-c-format \
2693 --keyword=N_ --flag=N_:1:pass-c-format \
2694 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2695 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2696 --flag=error:3:c-format --flag=error_at_line:5:c-format
2698 # This is the copyright holder that gets inserted into the header of the
2699 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2700 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2702 # This is the email address or URL to which the translators shall report
2703 # bugs in the untranslated strings:
2704 # - Strings which are not entire sentences, see the maintainer guidelines
2705 # in the GNU gettext documentation, section 'Preparing Strings'.
2706 # - Strings which use unclear terms or require additional context to be
2708 # - Strings which make invalid assumptions about notation of date, time or
2710 # - Pluralisation problems.
2711 # - Incorrect English spelling.
2712 # - Incorrect formatting.
2713 # It can be your email address, or a mailing list address where translators
2714 # can write to without being subscribed, or the URL of a web page through
2715 # which the translators can contact you.
2716 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2718 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2719 # message catalogs shall be used. It is usually empty.
2720 EXTRA_LOCALE_CATEGORIES =
2722 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2723 # context. Possible values are "yes" and "no". Set this to yes if the
2724 # package uses functions taking also a message context, like pgettext(), or
2725 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2730 # func_emit_po_POTFILES_in
2731 # emits the file list to be passed to xgettext to standard output.
2733 # - local_gnulib_dir from --local-dir
2734 # - modcache true or false, from --cache-modules/--no-cache-modules
2735 # - sourcebase directory relative to destdir where to place source code
2736 # - files list of new files
2737 func_emit_po_POTFILES_in ()
2739 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2740 func_emit_copyright_notice
2742 echo "# List of files which contain translatable strings."
2743 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2746 # func_emit_tests_Makefile_am
2747 # emits the contents of tests makefile to standard output.
2749 # - local_gnulib_dir from --local-dir
2750 # - modcache true or false, from --cache-modules/--no-cache-modules
2751 # - modules list of modules, including dependencies
2752 # - libname library name
2753 # - auxdir directory relative to destdir where to place build aux files
2754 # - makefile_name from --makefile-name
2755 # - libtool true if libtool will be used, false or blank otherwise
2756 # - sourcebase relative directory containing lib source code
2757 # - m4base relative directory containing autoconf macros
2758 # - testsbase relative directory containing unit test code
2759 # - macro_prefix prefix of gl_LIBOBJS macros to use
2760 # - for_test true if creating a package for testing, false otherwise
2761 # - use_libtests true if a libtests.a should be built, false otherwise
2762 # - destfile filename relative to destdir of makefile being generated
2764 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2765 # list of edits to be done to Makefile.am variables
2767 # - uses_subdirs nonempty if object files in subdirs exist
2768 func_emit_tests_Makefile_am ()
2770 if test "$libtool" = true; then
2772 sed_eliminate_LDFLAGS="$sed_noop"
2775 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2778 # When creating a package for testing: Attempt to provoke failures,
2779 # especially link errors, already during "make" rather than during
2780 # "make check", because "make check" is not possible in a cross-compiling
2781 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2782 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2784 sed_transform_check_PROGRAMS="$sed_noop"
2786 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2787 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2788 echo "## Process this file with automake to produce Makefile.in."
2789 func_emit_copyright_notice
2793 for module in $modules; do
2795 func_verify_tests_module
2799 if test -n "$module"; then
2801 func_get_automake_snippet "$module" |
2802 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2803 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2804 -e "$sed_eliminate_LDFLAGS" \
2805 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2806 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2807 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2808 -e "$sed_transform_check_PROGRAMS"
2809 if $use_libtests && test "$module" = 'alloca'; then
2810 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2811 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2813 } > "$tmp"/amsnippet
2814 # Skip the contents if it's entirely empty.
2815 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2816 echo "## begin gnulib module $module"
2818 cat "$tmp"/amsnippet
2819 echo "## end gnulib module $module"
2822 rm -f "$tmp"/amsnippet
2823 # Test whether there are some source files in subdirectories.
2824 for f in `func_get_filelist "$module"`; do
2826 lib/*/*.c | tests/*/*.c)
2834 } > "$tmp"/allsnippets
2835 # Generate dependencies here, since it eases the debugging of test failures.
2836 # If there are source files in subdirectories, prevent collision of the
2837 # object files (example: hash.c and libxml/hash.c).
2839 if test -n "$uses_subdirs"; then
2840 subdir_options=' subdir-objects'
2842 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2845 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2848 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2849 # variable is needed to avoid an error from automake:
2850 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2853 echo "XFAIL_TESTS ="
2854 echo "TESTS_ENVIRONMENT ="
2855 echo "noinst_PROGRAMS ="
2856 if ! $for_test; then
2857 echo "check_PROGRAMS ="
2859 echo "noinst_HEADERS ="
2860 echo "noinst_LIBRARIES ="
2861 if $use_libtests; then
2863 echo "noinst_LIBRARIES += libtests.a"
2865 echo "check_LIBRARIES = libtests.a"
2868 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2869 # if you specify pkgdata_DATA to empty. This is a workaround.
2870 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2871 echo "pkgdata_DATA ="
2874 echo "BUILT_SOURCES ="
2876 echo "MOSTLYCLEANFILES = core *.stackdump"
2877 echo "MOSTLYCLEANDIRS ="
2879 echo "DISTCLEANFILES ="
2880 echo "MAINTAINERCLEANFILES ="
2881 # Execute edits that apply to the Makefile.am being generated.
2883 while test $edit != $makefile_am_edits; do
2884 edit=`expr $edit + 1`
2885 eval dir=\"\$makefile_am_edit${edit}_dir\"
2886 eval var=\"\$makefile_am_edit${edit}_var\"
2887 eval val=\"\$makefile_am_edit${edit}_val\"
2888 if test -n "$var"; then
2889 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2890 echo "${var} += ${val}"
2891 eval "makefile_am_edit${edit}_var="
2896 echo "AM_CPPFLAGS = \\"
2897 echo " -I. -I\$(srcdir) \\"
2898 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2899 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2901 local_ldadd_before=''
2902 local_ldadd_after=''
2903 if $use_libtests; then
2904 # All test programs need to be linked with libtests.a.
2905 # It needs to be passed to the linker before ${libname}.${libext}, since
2906 # the tests-related modules depend on the main modules.
2907 # It also needs to be passed to the linker after ${libname}.${libext}
2908 # because the latter might contain incomplete modules (such as the 'error'
2909 # module whose dependency to 'progname' is voluntarily omitted).
2910 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2912 local_ldadd_before=' libtests.a'
2913 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2915 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2917 if $use_libtests; then
2918 echo "libtests_a_SOURCES ="
2919 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2920 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2921 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2922 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2923 echo "EXTRA_libtests_a_SOURCES ="
2924 # The circular dependency in LDADD requires this.
2925 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2928 # Many test scripts use ${EXEEXT} or ${srcdir}.
2929 # EXEEXT is defined by AC_PROG_CC through autoconf.
2930 # srcdir is defined by autoconf and automake.
2931 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
2933 cat "$tmp"/allsnippets \
2934 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2935 echo "# Clean up after Solaris cc."
2937 echo " rm -rf SunWS_cache"
2939 echo "mostlyclean-local: mostlyclean-generic"
2940 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2941 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2942 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2946 rm -f "$tmp"/allsnippets
2949 # func_emit_initmacro_start macro_prefix
2950 # emits the first few statements of the gl_INIT macro to standard output.
2951 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2952 func_emit_initmacro_start ()
2954 macro_prefix_arg="$1"
2955 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2956 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2957 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2958 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2960 # Furthermore it avoids an automake error like this when a Makefile.am
2961 # that uses pieces of gnulib also uses $(LIBOBJ):
2962 # automatically discovered file `error.c' should not be explicitly mentioned
2963 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2964 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2965 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2966 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2967 # automatically discovered file `error.c' should not be explicitly mentioned
2968 # We let automake know about the files to be distributed through the
2969 # EXTRA_lib_SOURCES variable.
2970 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2971 # Create data variables for checking the presence of files that are mentioned
2972 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2973 # because we want the check to happen when the configure file is created,
2974 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2975 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2976 # in which to expect them.
2977 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2978 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2982 # func_emit_initmacro_end macro_prefix
2983 # emits the last few statements of the gl_INIT macro to standard output.
2984 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2985 func_emit_initmacro_end ()
2987 macro_prefix_arg="$1"
2988 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2989 # The check is performed only when autoconf is run from the directory where
2990 # the configure.ac resides; if it is run from a different directory, the
2992 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2993 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2994 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2995 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2996 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3000 echo " m4_if(m4_sysval, [0], [],"
3001 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3003 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3004 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3005 echo " m4_popdef([AC_LIBSOURCES])"
3006 echo " m4_popdef([AC_REPLACE_FUNCS])"
3007 echo " m4_popdef([AC_LIBOBJ])"
3008 echo " AC_CONFIG_COMMANDS_PRE(["
3009 echo " ${macro_prefix_arg}_libobjs="
3010 echo " ${macro_prefix_arg}_ltlibobjs="
3011 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3012 echo " # Remove the extension."
3013 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3014 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3015 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3016 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3019 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3020 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3024 # func_emit_initmacro_done macro_prefix sourcebase
3025 # emits a few statements after the gl_INIT macro to standard output.
3026 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3027 # - sourcebase directory relative to destdir where to place source code
3028 func_emit_initmacro_done ()
3030 macro_prefix_arg="$1"
3033 echo "# Like AC_LIBOBJ, except that the module name goes"
3034 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3035 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3036 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3037 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3040 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3041 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3042 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3043 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3044 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3047 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3048 echo "# expected is derived from the gnulib-tool parameterization,"
3049 echo "# and alloca is special cased (for the alloca-opt module)."
3050 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3051 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3052 echo " m4_foreach([_gl_NAME], [\$1], ["
3053 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3054 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3055 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3061 # func_import modules
3062 # Uses also the variables
3063 # - destdir target directory
3064 # - local_gnulib_dir from --local-dir
3065 # - modcache true or false, from --cache-modules/--no-cache-modules
3066 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3067 # - libname library name
3068 # - sourcebase directory relative to destdir where to place source code
3069 # - m4base directory relative to destdir where to place *.m4 macros
3070 # - pobase directory relative to destdir where to place *.po files
3071 # - docbase directory relative to destdir where to place doc files
3072 # - testsbase directory relative to destdir where to place unit test code
3073 # - auxdir directory relative to destdir where to place build aux files
3074 # - inctests true if --with-tests was given, blank otherwise
3075 # - incobsolete true if --with-obsolete was given, blank otherwise
3076 # - avoidlist list of modules to avoid, from --avoid
3077 # - lgpl yes or a number if library's license shall be LGPL,
3079 # - makefile_name from --makefile-name
3080 # - libtool true if --libtool was given, false if --no-libtool was
3081 # given, blank otherwise
3082 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3083 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3084 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3085 # - vc_files true if --vc-files was given, false if --no-vc-files was
3086 # given, blank otherwise
3087 # - autoconf_minversion minimum supported autoconf version
3088 # - doit : if actions shall be executed, false if only to be printed
3089 # - symbolic true if files should be symlinked, copied otherwise
3090 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3092 # - do_copyrights true if copyright notices in files should be replaced,
3096 # Get the cached settings.
3097 cached_local_gnulib_dir=
3098 cached_specified_modules=
3109 cached_makefile_name=
3111 cached_macro_prefix=
3115 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3116 cached_libtool=false
3122 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3132 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3134 /gl_WITH_OBSOLETE/ {
3135 s,^.*$,cached_incobsolete=true,p
3138 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3141 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3144 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3147 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3150 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3153 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3156 s,^.*$,cached_inctests=true,p
3159 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3162 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3165 s,^.*$,cached_lgpl=yes,p
3167 /gl_MAKEFILE_NAME(/ {
3168 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3171 s,^.*$,cached_libtool=true,p
3173 /gl_MACRO_PREFIX(/ {
3174 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3177 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3180 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3182 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3183 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3188 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3189 s,^.*$,cached_files=",p
3202 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3206 # Merge the cached settings with the specified ones.
3207 # The m4base must be the same as expected from the pathname.
3208 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3209 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3211 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3212 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3213 if test -z "$local_gnulib_dir"; then
3214 if test -n "$cached_local_gnulib_dir"; then
3217 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3219 case "$cached_local_gnulib_dir" in
3221 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3223 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3224 local_gnulib_dir="$relconcat" ;;
3229 # Append the cached and the specified module names. So that
3230 # "gnulib-tool --import foo" means to add the module foo.
3231 specified_modules="$cached_specified_modules $1"
3232 # Included obsolete modules among the dependencies if specified either way.
3233 if test -z "$incobsolete"; then
3234 incobsolete="$cached_incobsolete"
3236 # Append the cached and the specified avoidlist. This is probably better
3237 # than dropping the cached one when --avoid is specified at least once.
3238 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3239 avoidlist=`echo $avoidlist`
3241 # The sourcebase defaults to the cached one.
3242 if test -z "$sourcebase"; then
3243 sourcebase="$cached_sourcebase"
3244 if test -z "$sourcebase"; then
3245 func_fatal_error "missing --source-base option"
3248 # The pobase defaults to the cached one.
3249 if test -z "$pobase"; then
3250 pobase="$cached_pobase"
3252 # The docbase defaults to the cached one.
3253 if test -z "$docbase"; then
3254 docbase="$cached_docbase"
3255 if test -z "$docbase"; then
3256 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."
3259 # The testsbase defaults to the cached one.
3260 if test -z "$testsbase"; then
3261 testsbase="$cached_testsbase"
3262 if test -z "$testsbase"; then
3263 func_fatal_error "missing --tests-base option"
3266 # Require the tests if specified either way.
3267 if test -z "$inctests"; then
3268 inctests="$cached_inctests"
3270 # The libname defaults to the cached one.
3271 if test -z "$supplied_libname"; then
3272 libname="$cached_libname"
3273 if test -z "$libname"; then
3274 func_fatal_error "missing --lib option"
3277 # Require LGPL if specified either way.
3278 if test -z "$lgpl"; then
3281 # The makefile_name defaults to the cached one.
3282 if test -z "$makefile_name"; then
3283 makefile_name="$cached_makefile_name"
3285 # Use libtool if specified either way, or if guessed.
3286 if test -z "$libtool"; then
3287 if test -n "$cached_m4base"; then
3288 libtool="$cached_libtool"
3290 libtool="$guessed_libtool"
3293 # The macro_prefix defaults to the cached one.
3294 if test -z "$macro_prefix"; then
3295 macro_prefix="$cached_macro_prefix"
3296 if test -z "$macro_prefix"; then
3297 func_fatal_error "missing --macro-prefix option"
3300 # The po_domain defaults to the cached one.
3301 if test -z "$po_domain"; then
3302 po_domain="$cached_po_domain"
3304 # The vc_files defaults to the cached one.
3305 if test -z "$vc_files"; then
3306 vc_files="$cached_vc_files"
3309 # Canonicalize the list of specified modules.
3310 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3312 # Determine final module list.
3313 modules="$specified_modules"
3314 func_modules_transitive_closure
3315 if test $verbose -ge 0; then
3316 echo "Module list with included dependencies:"
3317 echo "$modules" | sed -e 's/^/ /'
3319 final_modules="$modules"
3321 # Determine main module list and tests-related module list separately.
3322 # The main module list is the transitive closure of the specified modules,
3323 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3324 # is specified, it will consist only of LGPLed source.
3325 # The tests-related module list is the transitive closure of the specified
3326 # modules, including tests modules, minus the main module list excluding
3327 # modules of applicability 'all'. Its lib/* sources (brought in through
3328 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3329 # source, even if --lgpl is specified.
3330 # Determine main module list.
3331 saved_inctests="$inctests"
3333 modules="$specified_modules"
3334 func_modules_transitive_closure
3335 main_modules="$modules"
3336 inctests="$saved_inctests"
3337 if test $verbose -ge 1; then
3338 echo "Main module list:"
3339 echo "$main_modules" | sed -e 's/^/ /'
3341 # Determine tests-related module list.
3342 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3343 testsrelated_modules=`func_reset_sigpipe
3344 for module in $main_modules; do
3345 if test \`func_get_applicability $module\` = main; then
3349 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3350 if test $verbose -ge 1; then
3351 echo "Tests-related module list:"
3352 echo "$testsrelated_modules" | sed -e 's/^/ /'
3355 # Add the dummy module to the main module list if needed.
3356 modules="$main_modules"
3357 func_modules_add_dummy
3358 main_modules="$modules"
3360 # Determine whether a $testsbase/libtests.a is needed.
3362 for module in $testsrelated_modules; do
3363 func_verify_nontests_module
3364 if test -n "$module"; then
3365 all_files=`func_get_filelist $module`
3366 # Test whether some file in $all_files lies in lib/.
3367 for f in $all_files; do
3378 # Add the dummy module to the tests-related module list if needed.
3379 if $use_libtests; then
3380 modules="$testsrelated_modules"
3381 func_modules_add_dummy
3382 testsrelated_modules="$modules"
3385 # If --lgpl, verify that the licenses of modules are compatible.
3386 if test -n "$lgpl"; then
3387 license_incompatibilities=
3388 for module in $main_modules; do
3389 license=`func_get_license $module`
3391 'GPLed build tool') ;;
3392 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3397 LGPL | LGPLv2+ | LGPLv3+) ;;
3398 *) func_append license_incompatibilities "$module $license$nl" ;;
3404 *) func_append license_incompatibilities "$module $license$nl" ;;
3407 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3412 if test -n "$license_incompatibilities"; then
3413 # Format the license incompatibilities as a table.
3414 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3415 s,^\(.................................................[^ ]*\) *, \1 ,'
3416 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3417 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3421 # Show banner notice of every module.
3422 modules="$main_modules"
3425 # Determine script to apply to imported library files.
3426 sed_transform_lib_file=
3427 for module in $main_modules; do
3428 if test $module = config-h; then
3429 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3430 sed_transform_lib_file=$sed_transform_lib_file'
3431 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3436 sed_transform_main_lib_file="$sed_transform_lib_file"
3437 if test -n "$do_copyrights"; then
3438 if test -n "$lgpl"; then
3442 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3443 s/GNU General/GNU Lesser General/g
3447 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3448 s/GNU General/GNU Lesser General/g
3449 s/version [23]\([ ,]\)/version 2.1\1/g
3452 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3456 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3457 s/GNU Lesser General/GNU General/g
3458 s/GNU Library General/GNU General/g
3459 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3464 # Determine script to apply to auxiliary files that go into $auxdir/.
3465 sed_transform_build_aux_file=
3466 if test -n "$do_copyrights"; then
3468 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3469 s/GNU Lesser General/GNU General/g
3470 s/GNU Library General/GNU General/g
3471 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3475 # Determine script to apply to library files that go into $testsbase/.
3476 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3477 if test -n "$do_copyrights"; then
3479 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3480 s/GNU Lesser General/GNU General/g
3481 s/GNU Library General/GNU General/g
3482 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3486 # Determine the final file lists.
3487 # They must be computed separately, because files in lib/* go into
3488 # $sourcebase/ if they are in the main file list but into $testsbase/
3489 # if they are in the tests-related file list. Furthermore lib/dummy.c
3491 # Determine final main file list.
3492 modules="$main_modules"
3493 func_modules_to_filelist
3495 # Determine final tests-related file list.
3496 modules="$testsrelated_modules"
3497 func_modules_to_filelist
3498 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3499 # Merge both file lists.
3500 sed_remove_empty_lines='/^$/d'
3501 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3502 if test $verbose -ge 0; then
3504 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3505 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3509 || func_fatal_error "refusing to do nothing"
3511 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3512 new_files="$files m4/gnulib-tool.m4"
3513 old_files="$cached_files"
3514 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3515 func_append old_files " m4/gnulib-tool.m4"
3518 rewritten='%REWRITTEN%'
3519 sed_rewrite_old_files="\
3520 s,^build-aux/,$rewritten$auxdir/,
3521 s,^doc/,$rewritten$cached_docbase/,
3522 s,^lib/,$rewritten$cached_sourcebase/,
3523 s,^m4/,$rewritten$cached_m4base/,
3524 s,^tests/,$rewritten$cached_testsbase/,
3525 s,^tests=lib/,$rewritten$cached_testsbase/,
3528 sed_rewrite_new_files="\
3529 s,^build-aux/,$rewritten$auxdir/,
3530 s,^doc/,$rewritten$docbase/,
3531 s,^lib/,$rewritten$sourcebase/,
3532 s,^m4/,$rewritten$m4base/,
3533 s,^tests/,$rewritten$testsbase/,
3534 s,^tests=lib/,$rewritten$testsbase/,
3538 # Create directories.
3539 { echo "$sourcebase"
3541 if test -n "$pobase"; then
3544 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3545 if test -n "$docfiles"; then
3548 if test -n "$inctests"; then
3552 for f in $files; do echo $f; done \
3553 | sed -e "$sed_rewrite_new_files" \
3554 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3557 { # Rearrange file descriptors. Needed because "while ... done < ..."
3558 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3559 exec 5<&0 < "$tmp"/dirs
3561 if test ! -d "$destdir/$d"; then
3563 echo "Creating directory $destdir/$d"
3564 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3566 echo "Create directory $destdir/$d"
3573 # Copy files or make symbolic links. Remove obsolete files.
3577 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3578 # representing the files according to the last gnulib-tool invocation.
3579 for f in $old_files; do echo $f; done \
3580 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3583 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3584 # representing the files after this gnulib-tool invocation.
3585 for f in $new_files; do echo $f; done \
3586 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3589 # First the files that are in old-files, but not in new-files:
3590 sed_take_first_column='s,'"$delimiter"'.*,,'
3591 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3592 # Remove the file. Do nothing if the user already removed it.
3593 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3595 echo "Removing file $g (backup in ${g}~)"
3596 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3598 echo "Remove file $g (backup in ${g}~)"
3600 func_append removed_files "$g$nl"
3603 # func_add_or_update handles a file that ought to be present afterwards.
3605 # - f the original file name
3606 # - g the rewritten file name
3607 # - already_present nonempty if the file should already exist, empty
3609 func_add_or_update ()
3613 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3615 func_dest_tmpfilename "$g"
3616 func_lookup_file "$f"
3617 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3618 if test -n "$sed_transform_main_lib_file"; then
3621 sed -e "$sed_transform_main_lib_file" \
3622 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3626 if test -n "$sed_transform_build_aux_file"; then
3629 sed -e "$sed_transform_build_aux_file" \
3630 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3634 if test -n "$sed_transform_testsrelated_lib_file"; then
3637 sed -e "$sed_transform_testsrelated_lib_file" \
3638 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3642 if test -f "$destdir/$g"; then
3643 # The file already exists.
3647 # Don't protest if the file should be there but isn't: it happens
3648 # frequently that developers don't put autogenerated files into CVS.
3650 func_append added_files "$g$nl"
3654 # Then the files that are in new-files, but not in old-files:
3655 sed_take_last_column='s,^.*'"$delimiter"',,'
3657 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3658 | sed -e "$sed_take_last_column" \
3659 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3660 { # Rearrange file descriptors. Needed because "while ... done < ..."
3661 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3662 exec 5<&0 < "$tmp"/added-files
3668 # Then the files that are in new-files and in old-files:
3669 already_present=true
3670 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3671 | sed -e "$sed_take_last_column" \
3672 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3673 { # Rearrange file descriptors. Needed because "while ... done < ..."
3674 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3675 exec 5<&0 < "$tmp"/kept-files
3682 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3683 actioncmd="gnulib-tool --import"
3684 func_append actioncmd " --dir=$destdir"
3685 if test -n "$local_gnulib_dir"; then
3686 func_append actioncmd " --local-dir=$local_gnulib_dir"
3688 func_append actioncmd " --lib=$libname"
3689 func_append actioncmd " --source-base=$sourcebase"
3690 func_append actioncmd " --m4-base=$m4base"
3691 if test -n "$pobase"; then
3692 func_append actioncmd " --po-base=$pobase"
3694 func_append actioncmd " --doc-base=$docbase"
3695 func_append actioncmd " --tests-base=$testsbase"
3696 func_append actioncmd " --aux-dir=$auxdir"
3697 if test -n "$inctests"; then
3698 func_append actioncmd " --with-tests"
3700 if test -n "$incobsolete"; then
3701 func_append actioncmd " --with-obsolete"
3703 for module in $avoidlist; do
3704 func_append actioncmd " --avoid=$module"
3706 if test -n "$lgpl"; then
3707 if test "$lgpl" = yes; then
3708 func_append actioncmd " --lgpl"
3710 func_append actioncmd " --lgpl=$lgpl"
3713 if test -n "$makefile_name"; then
3714 func_append actioncmd " --makefile-name=$makefile_name"
3716 if test "$libtool" = true; then
3717 func_append actioncmd " --libtool"
3719 func_append actioncmd " --no-libtool"
3721 func_append actioncmd " --macro-prefix=$macro_prefix"
3722 if test -n "$po_domain"; then
3723 func_append actioncmd " --po-domain=$po_domain"
3725 if test -n "$vc_files"; then
3726 if test "$vc_files" = true; then
3727 func_append actioncmd " --vc-files"
3729 func_append actioncmd " --no-vc-files"
3732 func_append actioncmd " `echo $specified_modules`"
3734 # Default the makefile name to Makefile.am.
3735 if test -n "$makefile_name"; then
3736 makefile_am=$makefile_name
3738 makefile_am=Makefile.am
3741 # Create normal Makefile.ams.
3744 # Setup list of Makefile.am edits that are to be performed afterwards.
3745 # Some of these edits apply to files that we will generate; others are
3746 # under the responsibility of the developer.
3748 # func_note_Makefile_am_edit dir var value
3749 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3751 func_note_Makefile_am_edit ()
3753 makefile_am_edits=`expr $makefile_am_edits + 1`
3754 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3755 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3756 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3758 if test "$makefile_am" = Makefile.am; then
3759 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3760 sourcebase_base=`basename "$sourcebase"`
3761 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3763 if test -n "$pobase"; then
3764 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3765 pobase_base=`basename "$pobase"`
3766 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3768 if test -n "$inctests"; then
3769 if test "$makefile_am" = Makefile.am; then
3770 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3771 testsbase_base=`basename "$testsbase"`
3772 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3775 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3777 # Find the first parent directory of $m4base that contains or will contain
3779 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3781 sed_butlast='s,[^/][^/]*//*$,,'
3782 dir1="${m4base}/"; dir2=""
3783 while test -n "$dir1" \
3784 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3785 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3786 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3787 || { test -n "$inctests" \
3788 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3789 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3790 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3791 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3793 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3796 # Create library makefile.
3797 func_dest_tmpfilename $sourcebase/$makefile_am
3798 destfile="$sourcebase/$makefile_am"
3799 modules="$main_modules"
3800 func_emit_lib_Makefile_am > "$tmpfile"
3801 if test -f "$destdir"/$sourcebase/$makefile_am; then
3802 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3806 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3807 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3808 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3810 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3816 echo "Creating $sourcebase/$makefile_am"
3817 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3819 echo "Create $sourcebase/$makefile_am"
3822 func_append added_files "$sourcebase/$makefile_am$nl"
3825 # Create po/ directory.
3826 if test -n "$pobase"; then
3827 # Create po makefile and auxiliary files.
3828 for file in Makefile.in.in remove-potcdate.sin; do
3829 func_dest_tmpfilename $pobase/$file
3830 func_lookup_file build-aux/po/$file
3831 cat "$lookedup_file" > "$tmpfile"
3832 if test -f "$destdir"/$pobase/$file; then
3833 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3837 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3838 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3839 mv -f "$tmpfile" "$destdir"/$pobase/$file
3841 echo "Update $pobase/$file (backup in $pobase/$file~)"
3847 echo "Creating $pobase/$file"
3848 mv -f "$tmpfile" "$destdir"/$pobase/$file
3850 echo "Create $pobase/$file"
3853 func_append added_files "$pobase/$file$nl"
3856 # Create po makefile parameterization, part 1.
3857 func_dest_tmpfilename $pobase/Makevars
3858 func_emit_po_Makevars > "$tmpfile"
3859 if test -f "$destdir"/$pobase/Makevars; then
3860 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3864 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3865 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3866 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3868 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3874 echo "Creating $pobase/Makevars"
3875 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3877 echo "Create $pobase/Makevars"
3880 func_append added_files "$pobase/Makevars$nl"
3882 # Create po makefile parameterization, part 2.
3883 func_dest_tmpfilename $pobase/POTFILES.in
3884 func_emit_po_POTFILES_in > "$tmpfile"
3885 if test -f "$destdir"/$pobase/POTFILES.in; then
3886 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3890 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3891 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3892 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3894 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3900 echo "Creating $pobase/POTFILES.in"
3901 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3903 echo "Create $pobase/POTFILES.in"
3906 func_append added_files "$pobase/POTFILES.in$nl"
3909 TP_URL="http://translationproject.org/latest/"
3910 TP_RSYNC_URI="translationproject.org::tp/latest/"
3912 echo "Fetching gnulib PO files from $TP_URL"
3913 (cd "$destdir"/$pobase \
3914 && { # Prefer rsync over wget if it is available, since it consumes
3915 # less network bandwidth, due to compression.
3916 if type rsync 2>/dev/null | grep / > /dev/null; then
3917 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3919 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3924 echo "Fetch gnulib PO files from $TP_URL"
3926 # Create po/LINGUAS.
3928 func_dest_tmpfilename $pobase/LINGUAS
3929 (cd "$destdir"/$pobase \
3930 && { echo '# Set of available languages.'
3931 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3934 if test -f "$destdir"/$pobase/LINGUAS; then
3935 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3938 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3939 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3940 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3943 echo "Creating $pobase/LINGUAS"
3944 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3945 func_append added_files "$pobase/LINGUAS$nl"
3948 if test -f "$destdir"/$pobase/LINGUAS; then
3949 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3951 echo "Create $pobase/LINGUAS"
3956 # Create m4/gnulib-cache.m4.
3957 func_dest_tmpfilename $m4base/gnulib-cache.m4
3959 func_emit_copyright_notice
3961 echo "# This file represents the specification of how gnulib-tool is used."
3962 echo "# It acts as a cache: It is written and read by gnulib-tool."
3963 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3964 echo "# like the configure.ac and various Makefile.am files."
3967 echo "# Specification in the form of a command-line invocation:"
3970 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3971 # Store the local_gnulib_dir relative to destdir.
3972 case "$local_gnulib_dir" in
3974 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3977 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3979 # destdir, local_gnulib_dir are both relative.
3980 func_relativize "$destdir" "$local_gnulib_dir"
3981 relative_local_gnulib_dir="$reldir" ;;
3984 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3986 echo "$specified_modules" | sed -e 's/^/ /g'
3988 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3989 echo "gl_AVOID([$avoidlist])"
3990 echo "gl_SOURCE_BASE([$sourcebase])"
3991 echo "gl_M4_BASE([$m4base])"
3992 echo "gl_PO_BASE([$pobase])"
3993 echo "gl_DOC_BASE([$docbase])"
3994 echo "gl_TESTS_BASE([$testsbase])"
3995 test -z "$inctests" || echo "gl_WITH_TESTS"
3996 echo "gl_LIB([$libname])"
3997 if test -n "$lgpl"; then
3998 if test "$lgpl" = yes; then
4001 echo "gl_LGPL([$lgpl])"
4004 echo "gl_MAKEFILE_NAME([$makefile_name])"
4005 if test "$libtool" = true; then
4008 echo "gl_MACRO_PREFIX([$macro_prefix])"
4009 echo "gl_PO_DOMAIN([$po_domain])"
4010 if test -n "$vc_files"; then
4011 echo "gl_VC_FILES([$vc_files])"
4014 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4015 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4019 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4020 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4021 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4023 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4027 echo "# gnulib-cache.m4 ends here"
4034 echo "Creating $m4base/gnulib-cache.m4"
4035 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4037 echo "Create $m4base/gnulib-cache.m4"
4043 # Create m4/gnulib-comp.m4.
4044 func_dest_tmpfilename $m4base/gnulib-comp.m4
4046 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4047 func_emit_copyright_notice
4049 echo "# This file represents the compiled summary of the specification in"
4050 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4051 echo "# to be invoked from configure.ac."
4052 echo "# In projects using CVS, this file can be treated like other built files."
4055 echo "# This macro should be invoked from $configure_ac, in the section"
4056 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4057 echo "# any checks for libraries, header files, types and library functions."
4058 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4060 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4061 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4062 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4063 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4064 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4065 if test -n "$uses_subdirs"; then
4066 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4068 for module in $final_modules; do
4070 if test -n "$module"; then
4071 func_get_autoconf_early_snippet "$module"
4074 | sed -e '/^$/d;' -e 's/^/ /'
4077 echo "# This macro should be invoked from $configure_ac, in the section"
4078 echo "# \"Check for header files, types and library functions\"."
4079 echo "AC_DEFUN([${macro_prefix}_INIT],"
4081 if test "$libtool" = true; then
4082 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4083 echo " gl_cond_libtool=true"
4085 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4086 echo " gl_cond_libtool=false"
4088 echo " gl_ltlibdeps="
4090 if test "$auxdir" != "build-aux"; then
4091 sed_replace_build_aux='
4093 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4094 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4098 sed_replace_build_aux="$sed_noop"
4100 func_emit_initmacro_start $macro_prefix
4101 echo " gl_source_base='$sourcebase'"
4102 for module in $main_modules; do
4104 if test -n "$module"; then
4105 func_get_autoconf_snippet "$module" \
4106 | sed -e '/^$/d;' -e 's/^/ /' \
4107 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4108 -e "$sed_replace_build_aux"
4109 if test "$module" = 'alloca' && test "$libtool" = true; then
4110 echo 'changequote(,)dnl'
4111 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4112 echo 'changequote([, ])dnl'
4113 echo 'AC_SUBST([LTALLOCA])'
4117 func_emit_initmacro_end $macro_prefix
4118 echo " gltests_libdeps="
4119 echo " gltests_ltlibdeps="
4120 func_emit_initmacro_start ${macro_prefix}tests
4121 echo " gl_source_base='$testsbase'"
4122 for module in $testsrelated_modules; do
4124 if test -n "$module"; then
4125 func_get_autoconf_snippet "$module" \
4126 | sed -e '/^$/d;' -e 's/^/ /' \
4127 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4128 -e "$sed_replace_build_aux" \
4129 -e 's/\$gl_cond_libtool/false/g' \
4130 -e 's/gl_libdeps/gltests_libdeps/g' \
4131 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4134 func_emit_initmacro_end ${macro_prefix}tests
4135 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4136 # created using libtool, because libtool already handles the dependencies.
4137 if test "$libtool" != true; then
4138 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4139 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4140 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4141 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4142 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4144 if $use_libtests; then
4145 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4146 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4149 func_emit_initmacro_done $macro_prefix $sourcebase
4150 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4152 echo "# This macro records the list of files which have been installed by"
4153 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4154 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4155 echo "$files" | sed -e 's,^, ,'
4158 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4159 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4163 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4164 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4165 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4167 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4171 echo "# gnulib-comp.m4 ends here"
4178 echo "Creating $m4base/gnulib-comp.m4"
4179 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4181 echo "Create $m4base/gnulib-comp.m4"
4187 if test -n "$inctests"; then
4188 # Create tests makefile.
4189 func_dest_tmpfilename $testsbase/$makefile_am
4190 destfile="$testsbase/$makefile_am"
4191 modules="$testsrelated_modules"
4192 func_emit_tests_Makefile_am > "$tmpfile"
4193 if test -f "$destdir"/$testsbase/$makefile_am; then
4194 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4198 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4199 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4200 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4202 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4208 echo "Creating $testsbase/$makefile_am"
4209 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4211 echo "Create $testsbase/$makefile_am"
4214 func_append added_files "$testsbase/$makefile_am$nl"
4218 if test "$vc_files" != false; then
4219 # Update the .cvsignore and .gitignore files.
4220 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4221 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4222 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4223 echo "$m4base/|A|gnulib-comp.m4"
4224 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4225 { # Rearrange file descriptors. Needed because "while ... done < ..."
4226 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4227 exec 5<&0 < "$tmp"/fileset-changes
4228 func_update_ignorelist ()
4231 if test "$ignore" = .gitignore; then
4232 # In a .gitignore file, "foo" applies to the current directory and all
4233 # subdirectories, whereas "/foo" applies to the current directory only.
4236 doubly_escaped_anchor='\\/'
4240 doubly_escaped_anchor=''
4242 if test -f "$destdir/$dir$ignore"; then
4243 if test -n "$dir_added" || test -n "$dir_removed"; then
4244 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4246 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4247 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4248 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4249 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4251 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4253 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4254 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4255 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4256 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4257 } > "$tmp"/sed-ignore-removed
4258 { cat "$destdir/$dir$ignore"~
4259 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4260 } | sed -f "$tmp"/sed-ignore-removed \
4261 > "$destdir/$dir$ignore"
4263 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4268 if test -n "$dir_added"; then
4270 echo "Creating $destdir/$dir$ignore"
4272 if test "$ignore" = .cvsignore; then
4274 # Automake generates Makefile rules that create .dirstamp files.
4277 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4278 } > "$destdir/$dir$ignore"
4280 echo "Create $destdir/$dir$ignore"
4290 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4291 func_update_ignorelist .cvsignore
4293 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4294 func_update_ignorelist .gitignore
4301 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4302 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4303 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4304 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4305 if test "$next_dir" != "$last_dir"; then
4306 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4307 last_dir="$next_dir"
4312 A) func_append last_dir_added "$file$nl";;
4313 R) func_append last_dir_removed "$file$nl";;
4316 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4323 echo "You may need to add #include directives for the following .h files."
4324 # Intersect $specified_modules and $main_modules
4325 # (since $specified_modules is not necessarily of subset of $main_modules
4326 # - some may have been skipped through --avoid, and since the elements of
4327 # $main_modules but not in $specified_modules can go away without explicit
4328 # notice - through changes in the module dependencies).
4329 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4330 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4331 # First the #include <...> directives without #ifs, sorted for convenience,
4332 # then the #include "..." directives without #ifs, sorted for convenience,
4333 # then the #include directives that are surrounded by #ifs. Not sorted.
4334 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4335 include_directive=`func_get_include_directive "$module"`
4336 case "$nl$include_directive" in
4338 echo "$include_directive" 1>&5
4341 echo "$include_directive" | grep -v 'include "' 1>&6
4342 echo "$include_directive" | grep 'include "' 1>&7
4345 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4347 LC_ALL=C sort -u "$tmp"/include-angles
4348 LC_ALL=C sort -u "$tmp"/include-quotes
4349 cat "$tmp"/include-if
4350 ) | sed -e '/^$/d' -e 's/^/ /'
4351 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4353 for module in $main_modules; do
4354 func_get_link_directive "$module"
4356 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4357 if test `wc -l < "$tmp"/link` != 0; then
4359 echo "You may need to use the following Makefile variables when linking."
4360 echo "Use them in <program>_LDADD when linking a program, or"
4361 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4367 echo "Don't forget to"
4368 if test "$makefile_am" = Makefile.am; then
4369 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4371 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4373 if test -n "$pobase"; then
4374 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4376 if test -n "$inctests"; then
4377 if test "$makefile_am" = Makefile.am; then
4378 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4380 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4384 while test $edit != $makefile_am_edits; do
4385 edit=`expr $edit + 1`
4386 eval dir=\"\$makefile_am_edit${edit}_dir\"
4387 eval var=\"\$makefile_am_edit${edit}_var\"
4388 eval val=\"\$makefile_am_edit${edit}_val\"
4389 if test -n "$var"; then
4390 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4393 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4394 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4397 # func_create_testdir testdir modules
4399 # - local_gnulib_dir from --local-dir
4400 # - modcache true or false, from --cache-modules/--no-cache-modules
4401 # - auxdir directory relative to destdir where to place build aux files
4402 func_create_testdir ()
4406 if test -z "$modules"; then
4407 # All modules together.
4408 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4409 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4410 modules=`func_all_modules`
4411 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist) ;; *) echo $m;; esac; done`
4413 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
4415 # Check that the license of every module is consistent with the license of
4417 saved_modules="$modules"
4418 saved_inctests="$inctests"
4419 # When computing transitive closures, don't consider $module to depend on
4420 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4421 # on GPL modules - therefore we don't want a warning in this case.
4423 for requested_module in $saved_modules; do
4424 requested_license=`func_get_license "$requested_module"`
4425 if test "$requested_license" != GPL; then
4426 # Here we use func_modules_transitive_closure, not just
4427 # func_get_dependencies, so that we also detect weird situations like
4428 # an LGPL module which depends on a GPLed build tool module which depends
4430 modules="$requested_module"
4431 func_modules_transitive_closure
4432 for module in $modules; do
4433 license=`func_get_license "$module"`
4435 'GPLed build tool') ;;
4436 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4438 case "$requested_license" in
4441 GPLv2+ | LGPLv2+) ;;
4442 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4448 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4454 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4463 modules="$saved_modules"
4464 inctests="$saved_inctests"
4466 # Subdirectory names.
4476 # Determine final module list.
4477 func_modules_transitive_closure
4478 if test $verbose -ge 0; then
4479 echo "Module list with included dependencies:"
4480 echo "$modules" | sed -e 's/^/ /'
4483 # Add the dummy module if needed.
4484 func_modules_add_dummy
4486 # Show banner notice of every module.
4489 # Determine final file list.
4490 func_modules_to_filelist
4491 if test $verbose -ge 0; then
4493 echo "$files" | sed -e 's/^/ /'
4496 rewritten='%REWRITTEN%'
4497 sed_rewrite_files="\
4498 s,^build-aux/,$rewritten$auxdir/,
4499 s,^doc/,$rewritten$docbase/,
4500 s,^lib/,$rewritten$sourcebase/,
4501 s,^m4/,$rewritten$m4base/,
4502 s,^tests/,$rewritten$testsbase/,
4506 # Create directories.
4507 for f in $files; do echo $f; done \
4508 | sed -e "$sed_rewrite_files" \
4509 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4510 | LC_ALL=C sort -u \
4512 { # Rearrange file descriptors. Needed because "while ... done < ..."
4513 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4514 exec 5<&0 < "$tmp"/dirs
4516 mkdir -p "$testdir/$d"
4521 # Copy files or make symbolic links.
4523 for f in $files; do echo $f; done \
4524 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4527 { # Rearrange file descriptors. Needed because "while ... done < ..."
4528 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4529 exec 5<&0 < "$tmp"/files
4531 func_lookup_file "$f"
4532 if test -n "$lookedup_tmp"; then
4533 cp -p "$lookedup_file" "$testdir/$g"
4535 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4536 if { test -n "$symbolic" \
4537 || { test -n "$lsymbolic" \
4538 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4539 func_ln "$lookedup_file" "$testdir/$g"
4541 cp -p "$lookedup_file" "$testdir/$g"
4548 # Create Makefile.ams that are for testing.
4551 # No special edits are needed.
4554 # Create $sourcebase/Makefile.am.
4555 mkdir -p "$testdir/$sourcebase"
4556 destfile="$sourcebase/Makefile.am"
4557 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4558 any_uses_subdirs="$uses_subdirs"
4560 # Create $m4base/Makefile.am.
4561 mkdir -p "$testdir/$m4base"
4562 (echo "## Process this file with automake to produce Makefile.in."
4568 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4571 ) > "$testdir/$m4base/Makefile.am"
4573 subdirs="$sourcebase $m4base"
4574 subdirs_with_configure_ac=""
4576 if false && test -f "$testdir"/$m4base/gettext.m4; then
4577 # Avoid stupid error message from automake:
4578 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4579 mkdir -p "$testdir/po"
4580 (echo "## Process this file with automake to produce Makefile.in."
4581 ) > "$testdir/po/Makefile.am"
4582 func_append subdirs " po"
4585 if test -n "$inctests"; then
4586 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4587 # Viewed from the $testsbase subdirectory, $auxdir is different.
4588 saved_auxdir="$auxdir"
4589 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4590 # Create $testsbase/Makefile.am.
4592 destfile="$testsbase/Makefile.am"
4593 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
4594 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4595 # Create $testsbase/configure.ac.
4596 (echo "# Process this file with autoconf to produce a configure script."
4597 echo "AC_INIT([dummy], [0])"
4598 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4599 echo "AM_INIT_AUTOMAKE"
4601 echo "AC_CONFIG_HEADERS([config.h])"
4604 echo "AC_PROG_INSTALL"
4605 echo "AC_PROG_MAKE_SET"
4606 echo "AC_PROG_RANLIB"
4608 if test -n "$uses_subdirs"; then
4609 echo "AM_PROG_CC_C_O"
4612 for module in $modules; do
4614 if test -n "$module"; then
4616 gnumakefile | maintainer-makefile)
4617 # These modules are meant to be used only in the top-level directory.
4620 func_get_autoconf_early_snippet "$module"
4625 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4626 if test "$libtool" = true; then
4627 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4628 echo "gl_cond_libtool=true"
4630 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4631 echo "gl_cond_libtool=false"
4633 echo "gl_ltlibdeps="
4635 # Wrap the set of autoconf snippets into an autoconf macro that is then
4636 # invoked. This is needed because autoconf does not support AC_REQUIRE
4638 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4639 # but we want the AC_REQUIRE to have its normal meaning (provide one
4640 # expansion of the required macro before the current point, and only one
4642 echo "AC_DEFUN([gl_INIT], ["
4643 sed_replace_build_aux='
4645 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4646 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4649 func_emit_initmacro_start $macro_prefix
4650 # We don't have explicit ordering constraints between the various
4651 # autoconf snippets. It's cleanest to put those of the library before
4652 # those of the tests.
4653 echo "gl_source_base='../$sourcebase'"
4654 for module in $modules; do
4655 func_verify_nontests_module
4656 if test -n "$module"; then
4658 gnumakefile | maintainer-makefile)
4659 # These modules are meant to be used only in the top-level directory.
4662 func_get_autoconf_snippet "$module" \
4663 | sed -e "$sed_replace_build_aux"
4668 echo "gl_source_base='.'"
4669 for module in $modules; do
4670 func_verify_tests_module
4671 if test -n "$module"; then
4672 func_get_autoconf_snippet "$module" \
4673 | sed -e "$sed_replace_build_aux"
4676 func_emit_initmacro_end $macro_prefix
4677 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4678 # created using libtool, because libtool already handles the dependencies.
4679 if test "$libtool" != true; then
4680 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4681 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4682 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4683 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4684 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4687 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4691 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4692 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4693 echo "AH_TOP([#include \"../config.h\"])"
4695 echo "AC_CONFIG_FILES([Makefile])"
4697 ) > "$testdir/$testsbase/configure.ac"
4698 auxdir="$saved_auxdir"
4699 func_append subdirs " $testsbase"
4700 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4703 # Create Makefile.am.
4704 (echo "## Process this file with automake to produce Makefile.in."
4706 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4708 echo "SUBDIRS = $subdirs"
4710 echo "ACLOCAL_AMFLAGS = -I $m4base"
4711 ) > "$testdir/Makefile.am"
4713 # Create configure.ac.
4714 (echo "# Process this file with autoconf to produce a configure script."
4715 echo "AC_INIT([dummy], [0])"
4716 if test "$auxdir" != "."; then
4717 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4719 echo "AM_INIT_AUTOMAKE"
4721 echo "AC_CONFIG_HEADERS([config.h])"
4724 echo "AC_PROG_INSTALL"
4725 echo "AC_PROG_MAKE_SET"
4727 echo "# For autobuild."
4728 echo "AC_CANONICAL_BUILD"
4729 echo "AC_CANONICAL_HOST"
4731 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4732 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4733 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4734 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4736 echo "AC_PROG_RANLIB"
4738 if test -n "$any_uses_subdirs"; then
4739 echo "AM_PROG_CC_C_O"
4742 for module in $modules; do
4743 func_verify_nontests_module
4744 if test -n "$module"; then
4745 func_get_autoconf_early_snippet "$module"
4748 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4749 if test "$libtool" = true; then
4750 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4751 echo "gl_cond_libtool=true"
4753 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4754 echo "gl_cond_libtool=false"
4756 echo "gl_ltlibdeps="
4758 # Wrap the set of autoconf snippets into an autoconf macro that is then
4759 # invoked. This is needed because autoconf does not support AC_REQUIRE
4761 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4762 # but we want the AC_REQUIRE to have its normal meaning (provide one
4763 # expansion of the required macro before the current point, and only one
4765 echo "AC_DEFUN([gl_INIT], ["
4766 if test "$auxdir" != "build-aux"; then
4767 sed_replace_build_aux='
4769 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4770 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4774 sed_replace_build_aux="$sed_noop"
4776 func_emit_initmacro_start $macro_prefix
4777 echo "gl_source_base='$sourcebase'"
4778 for module in $modules; do
4779 func_verify_nontests_module
4780 if test -n "$module"; then
4781 func_get_autoconf_snippet "$module" \
4782 | sed -e "$sed_replace_build_aux"
4785 func_emit_initmacro_end $macro_prefix
4786 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4787 # created using libtool, because libtool already handles the dependencies.
4788 if test "$libtool" != true; then
4789 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4790 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4791 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4792 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4793 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4796 func_emit_initmacro_done $macro_prefix $sourcebase
4800 if test -n "$subdirs_with_configure_ac"; then
4801 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4803 makefiles="Makefile"
4804 for d in $subdirs; do
4805 # For subdirs that have a configure.ac by their own, it's the subdir's
4806 # configure.ac which creates the subdir's Makefile.am, not this one.
4807 case " $subdirs_with_configure_ac " in
4809 *) func_append makefiles " $d/Makefile" ;;
4812 echo "AC_CONFIG_FILES([$makefiles])"
4814 ) > "$testdir/configure.ac"
4816 # Create autogenerated files.
4818 # Do not use "${AUTORECONF} --force --install", because it may invoke
4819 # autopoint, which brings in older versions of some of our .m4 files.
4820 if test -f $m4base/gettext.m4; then
4821 func_execute_command ${AUTOPOINT} --force || func_exit 1
4822 for f in $m4base/*.m4~; do
4824 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4828 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4829 if ! test -d build-aux; then
4830 func_execute_command mkdir build-aux || func_exit 1
4832 func_execute_command ${AUTOCONF} || func_exit 1
4833 func_execute_command ${AUTOHEADER} || func_exit 1
4834 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4836 if test -n "$inctests"; then
4837 # Create autogenerated files.
4838 (cd "$testdir/$testsbase" || func_exit 1
4839 # Do not use "${AUTORECONF} --force --install", because it may invoke
4840 # autopoint, which brings in older versions of some of our .m4 files.
4841 if test -f ../$m4base/gettext.m4; then
4842 func_execute_command ${AUTOPOINT} --force || func_exit 1
4843 for f in ../$m4base/*.m4~; do
4845 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4849 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4850 if ! test -d ../build-aux; then
4851 func_execute_command mkdir ../build-aux
4853 func_execute_command ${AUTOCONF} || func_exit 1
4854 func_execute_command ${AUTOHEADER} || func_exit 1
4855 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4858 # Need to run configure and make once, to create built files that are to be
4859 # distributed (such as getdate.c).
4860 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4861 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4862 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4863 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4864 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4865 # such $(FOO_H) because they don't refer to distributed files.
4866 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4867 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4868 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4869 | sed -e "$sed_remove_make_variables"`
4870 distributed_built_sources=`for file in $built_sources; do
4871 case "$cleaned_files" in
4876 if test -n "$distributed_built_sources"; then
4878 ./configure || func_exit 1
4880 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4881 $MAKE built_sources || func_exit 1
4883 $MAKE distclean || func_exit 1
4888 # func_create_megatestdir megatestdir allmodules
4890 # - local_gnulib_dir from --local-dir
4891 # - modcache true or false, from --cache-modules/--no-cache-modules
4892 # - auxdir directory relative to destdir where to place build aux files
4893 func_create_megatestdir ()
4897 if test -z "$allmodules"; then
4898 allmodules=`func_all_modules`
4902 # First, all modules one by one.
4903 for onemodule in $allmodules; do
4904 func_create_testdir "$megatestdir/$onemodule" $onemodule
4905 func_append megasubdirs "$onemodule "
4907 # Then, all modules all together.
4908 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4909 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
4910 func_create_testdir "$megatestdir/ALL" "$allmodules"
4911 func_append megasubdirs "ALL"
4914 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4915 vc_witness="$gnulib_dir/CVS/Entries"; \
4917 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4919 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4920 | sed -e 's,January,01,' -e 's,Jan,01,' \
4921 -e 's,February,02,' -e 's,Feb,02,' \
4922 -e 's,March,03,' -e 's,Mar,03,' \
4923 -e 's,April,04,' -e 's,Apr,04,' \
4925 -e 's,June,06,' -e 's,Jun,06,' \
4926 -e 's,July,07,' -e 's,Jul,07,' \
4927 -e 's,August,08,' -e 's,Aug,08,' \
4928 -e 's,September,09,' -e 's,Sep,09,' \
4929 -e 's,October,10,' -e 's,Oct,10,' \
4930 -e 's,November,11,' -e 's,Nov,11,' \
4931 -e 's,December,12,' -e 's,Dec,12,' \
4932 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4933 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4935 echo "CVSDATE=$cvsdate"
4936 echo ": \${MAKE=make}"
4937 echo "test -d logs || mkdir logs"
4938 echo "for module in $megasubdirs; do"
4939 echo " echo \"Working on module \$module...\""
4940 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4941 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4944 echo " : autobuild project... \$module"
4945 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4946 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4947 echo " : autobuild hostname... \`hostname\`"
4948 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
4950 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4952 ) > "$megatestdir/do-autobuild"
4953 chmod a+x "$megatestdir/do-autobuild"
4955 # Create Makefile.am.
4956 (echo "## Process this file with automake to produce Makefile.in."
4958 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4960 echo "SUBDIRS = $megasubdirs"
4962 echo "EXTRA_DIST = do-autobuild"
4963 ) > "$megatestdir/Makefile.am"
4965 # Create configure.ac.
4966 (echo "# Process this file with autoconf to produce a configure script."
4967 echo "AC_INIT([dummy], [0])"
4968 if test "$auxdir" != "."; then
4969 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4971 echo "AM_INIT_AUTOMAKE"
4973 echo "AC_PROG_MAKE_SET"
4975 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4976 echo "AC_CONFIG_FILES([Makefile])"
4978 ) > "$megatestdir/configure.ac"
4980 # Create autogenerated files.
4982 # Do not use "${AUTORECONF} --install", because autoreconf operates
4983 # recursively, but the subdirectories are already finished, therefore
4984 # calling autoreconf here would only waste lots of CPU time.
4985 func_execute_command ${ACLOCAL} || func_exit 1
4986 func_execute_command mkdir build-aux
4987 func_execute_command ${AUTOCONF} || func_exit 1
4988 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4994 func_fatal_error "no mode specified" ;;
5003 if test -z "$destdir"; then
5006 test -d "$destdir" \
5007 || func_fatal_error "destination directory does not exist: $destdir"
5009 # Prefer configure.ac to configure.in.
5010 if test -f "$destdir"/configure.ac; then
5011 configure_ac="$destdir/configure.ac"
5013 if test -f "$destdir"/configure.in; then
5014 configure_ac="$destdir/configure.in"
5016 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5020 # Analyze configure.ac.
5022 guessed_libtool=false
5027 /AC_CONFIG_AUX_DIR/ {
5028 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5030 /A[CM]_PROG_LIBTOOL/ {
5031 s,^.*$,guessed_libtool=true,p
5033 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5035 if test -z "$auxdir"; then
5036 auxdir="$guessed_auxdir"
5039 # Determine where to apply func_import.
5040 if test -n "$m4base"; then
5041 # Apply func_import to a particular gnulib directory.
5042 # Any number of additional modules can be given.
5043 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5044 # First use of gnulib in the given m4base.
5045 test -n "$supplied_libname" || supplied_libname=true
5046 test -n "$sourcebase" || sourcebase="lib"
5047 test -n "$docbase" || docbase="doc"
5048 test -n "$testsbase" || testsbase="tests"
5049 test -n "$macro_prefix" || macro_prefix="gl"
5053 # Apply func_import to all gnulib directories.
5054 # To get this list of directories, look at Makefile.am. (Not at
5055 # configure, because it may be omitted from CVS. Also, don't run
5056 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5059 if test -f "$destdir"/Makefile.am; then
5060 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5062 for arg in $aclocal_amflags; do
5063 if test -n "$m4dir_is_next"; then
5064 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5068 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5069 func_append m4dirs " $arg"
5070 m4dirs_count=`expr $m4dirs_count + 1`
5076 if test "X$arg" = "X-I"; then
5084 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5085 if test -f "$destdir"/aclocal.m4; then
5086 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5087 sedexpr2='s,^[^/]*$,.,'
5088 sedexpr3='s,/[^/]*$,,'
5089 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5090 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5093 if test $m4dirs_count = 0; then
5094 # First use of gnulib in a package.
5095 # Any number of additional modules can be given.
5096 test -n "$supplied_libname" || supplied_libname=true
5097 test -n "$sourcebase" || sourcebase="lib"
5099 test -n "$docbase" || docbase="doc"
5100 test -n "$testsbase" || testsbase="tests"
5101 test -n "$macro_prefix" || macro_prefix="gl"
5104 if test $m4dirs_count = 1; then
5105 # There's only one use of gnulib here. Assume the user means it.
5106 # Any number of additional modules can be given.
5107 for m4base in $m4dirs; do
5111 # Ambiguous - guess what the user meant.
5112 if test $# = 0; then
5113 # No further arguments. Guess the user wants to update all of them.
5114 for m4base in $m4dirs; do
5115 # Perform func_import in a subshell, so that variable values
5117 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
5118 # pobase, docbase, testsbase, inctests, libname, lgpl,
5119 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5120 # don't propagate from one directory to another.
5121 (func_import) || func_exit 1
5125 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5133 if test -z "$destdir"; then
5134 func_fatal_error "please specify --dir option"
5137 test -d "$destdir" \
5138 || func_fatal_error "could not create destination directory"
5139 test -n "$auxdir" || auxdir="build-aux"
5140 func_create_testdir "$destdir" "$*"
5143 create-megatestdir )
5144 if test -z "$destdir"; then
5145 func_fatal_error "please specify --dir option"
5147 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5148 test -n "$auxdir" || auxdir="build-aux"
5149 func_create_megatestdir "$destdir" "$*"
5153 test -n "$destdir" || destdir=testdir$$
5154 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5155 test -n "$auxdir" || auxdir="build-aux"
5156 func_create_testdir "$destdir" "$*"
5160 ../configure || func_exit 1
5161 $MAKE || func_exit 1
5162 $MAKE check || func_exit 1
5163 $MAKE distclean || func_exit 1
5164 remaining=`find . -type f -print`
5165 if test -n "$remaining"; then
5166 echo "Remaining files:" $remaining 1>&2
5167 echo "gnulib-tool: *** Stop." 1>&2
5176 test -n "$destdir" || destdir=testdir$$
5177 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5178 test -n "$auxdir" || auxdir="build-aux"
5179 func_create_megatestdir "$destdir" "$*"
5187 remaining=`find . -type f -print`
5188 if test -n "$remaining"; then
5189 echo "Remaining files:" $remaining 1>&2
5190 echo "gnulib-tool: *** Stop." 1>&2
5198 extract-description )
5202 if test -n "$module"; then
5203 func_get_description "$module"
5212 if test -n "$module"; then
5213 func_get_status "$module"
5222 if test -n "$module"; then
5223 func_get_notice "$module"
5228 extract-applicability )
5232 if test -n "$module"; then
5233 func_get_applicability "$module"
5242 if test -n "$module"; then
5243 func_get_filelist "$module"
5248 extract-dependencies )
5252 if test -n "$module"; then
5253 func_get_dependencies "$module"
5258 extract-autoconf-snippet )
5262 if test -n "$module"; then
5263 func_get_autoconf_snippet "$module"
5268 extract-automake-snippet )
5272 if test -n "$module"; then
5273 func_get_automake_snippet "$module"
5278 extract-include-directive )
5282 if test -n "$module"; then
5283 func_get_include_directive "$module"
5288 extract-link-directive )
5292 if test -n "$module"; then
5293 func_get_link_directive "$module"
5302 if test -n "$module"; then
5303 func_get_license "$module"
5308 extract-maintainer )
5312 if test -n "$module"; then
5313 func_get_maintainer "$module"
5318 extract-tests-module )
5322 if test -n "$module"; then
5323 func_get_tests_module "$module"
5329 # Verify the number of arguments.
5330 if test $# -lt 1 || test $# -gt 2; then
5331 func_fatal_error "invalid number of arguments for --$mode"
5334 # The first argument is the file to be copied.
5336 # Verify the file exists.
5337 func_lookup_file "$f"
5339 # The second argument is the destination; either a directory ot a file.
5340 # It defaults to the current directory.
5342 test -n "$dest" || dest='.'
5343 test -n "$sourcebase" || sourcebase="lib"
5344 test -n "$m4base" || m4base="m4"
5345 test -n "$docbase" || docbase="doc"
5346 test -n "$testsbase" || testsbase="tests"
5347 test -n "$auxdir" || auxdir="build-aux"
5348 rewritten='%REWRITTEN%'
5349 sed_rewrite_files="\
5350 s,^build-aux/,$rewritten$auxdir/,
5351 s,^doc/,$rewritten$docbase/,
5352 s,^lib/,$rewritten$sourcebase/,
5353 s,^m4/,$rewritten$m4base/,
5354 s,^tests/,$rewritten$testsbase/,
5357 if test -d "$dest"; then
5359 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5361 destdir=`dirname "$dest"`
5362 g=`basename "$dest"`
5365 # Create the directory for destfile.
5366 d=`dirname "$destdir/$g"`
5368 if test -n "$d" && test ! -d "$d"; then
5369 mkdir -p "$d" || func_fatal_error "failed"
5373 func_dest_tmpfilename "$g"
5374 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5375 already_present=true
5376 if test -f "$destdir/$g"; then
5377 # The file already exists.
5381 # Don't protest if the file should be there but isn't: it happens
5382 # frequently that developers don't put autogenerated files into CVS.
5389 func_fatal_error "unknown operation mode --$mode" ;;
5393 # Undo the effect of the previous 'trap' command. Some shellology:
5394 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5395 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5396 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5397 # 128 + signal number and is set before the trap-registered command is run.
5399 trap 'func_exit $?' 1 2 3 13 15
5404 # indent-tabs-mode: nil
5405 # whitespace-check-buffer-indent: nil