3 # Copyright (C) 2002-2009 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
44 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
45 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
46 AUTOCONF="${AUTOCONFPATH}autoconf"
48 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
49 AUTOHEADER="${AUTOCONFPATH}autoheader"
51 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
52 ACLOCAL="${AUTOMAKEPATH}aclocal"
54 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
55 AUTOMAKE="${AUTOMAKEPATH}automake"
57 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
58 AUTORECONF="${AUTOCONFPATH}autoreconf"
61 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
62 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
63 AUTOPOINT="${GETTEXTPATH}autopoint"
66 # When using GNU sed, turn off as many GNU extensions as possible,
67 # to minimize the risk of accidentally using non-portable features.
68 # However, do this only for gnulib-tool itself, not for the code that
69 # gnulib-tool generates, since we don't want "sed --posix" to leak
71 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
72 # Define sed as an alias.
73 # It is not always possible to use aliases. Aliases are guaranteed to work
74 # if the executing shell is bash and either it is invoked as /bin/sh or
75 # is a version >= 2.0, supporting shopt. This is the common case.
76 # Two other approaches (use of a variable $sed or of a function func_sed
77 # instead of an alias) require massive, fragile code changes.
78 # An other approach (use of function sed) requires `which sed` - but 'which'
79 # is hard to emulate, due to missing "test -x" on some platforms.
80 if test -n "$BASH_VERSION"; then
81 shopt -s expand_aliases >/dev/null 2>&1
83 alias sed='sed --posix'
86 # sed_noop is a sed expression that does nothing.
87 # An empty expression does not work with the native 'sed' on AIX 6.1.
91 # outputs to stdout the --help usage message.
95 Usage: gnulib-tool --list
96 gnulib-tool --import [module1 ... moduleN]
98 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
99 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
100 gnulib-tool --test --dir=directory module1 ... moduleN
101 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
102 gnulib-tool --extract-description module
103 gnulib-tool --extract-status module
104 gnulib-tool --extract-notice module
105 gnulib-tool --extract-filelist module
106 gnulib-tool --extract-dependencies module
107 gnulib-tool --extract-autoconf-snippet module
108 gnulib-tool --extract-automake-snippet module
109 gnulib-tool --extract-include-directive module
110 gnulib-tool --extract-link-directive module
111 gnulib-tool --extract-license module
112 gnulib-tool --extract-maintainer module
113 gnulib-tool --extract-tests-module module
116 --list print the available module names
117 --import import the given modules into the current package;
118 if no modules are specified, update the current
119 package from the current gnulib
120 --update update the current package, restore files omitted
122 --create-testdir create a scratch package with the given modules
123 --create-megatestdir create a mega scratch package with the given modules
124 one by one and all together
125 --test test the combination of the given modules
126 (recommended to use CC=\"gcc -Wall\" here)
127 --megatest test the given modules one by one and all together
128 (recommended to use CC=\"gcc -Wall\" here)
129 --extract-description extract the description
130 --extract-status extract the status (obsolete or not)
131 --extract-notice extract the notice or banner
132 --extract-filelist extract the list of files
133 --extract-dependencies extract the dependencies
134 --extract-autoconf-snippet extract the snippet for configure.ac
135 --extract-automake-snippet extract the snippet for library makefile
136 --extract-include-directive extract the #include directive
137 --extract-link-directive extract the linker directive
138 --extract-license report the license terms of the source files
140 --extract-maintainer report the maintainer(s) inside gnulib
141 --extract-tests-module report the unit test module, if it exists
144 --dir=DIRECTORY Specify the target directory.
145 For --import, this specifies where your
146 configure.ac can be found. Defaults to current
148 --local-dir=DIRECTORY Specify a local override directory where to look
149 up files before looking in gnulib's directory.
150 --verbose Increase verbosity. May be repeated.
151 --quiet Decrease verbosity. May be repeated.
153 Options for --import:
154 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
155 --source-base=DIRECTORY
156 Directory relative to --dir where source code is
157 placed (default \"lib\").
158 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
159 placed (default \"m4\").
160 --po-base=DIRECTORY Directory relative to --dir where *.po files are
161 placed (default \"po\").
162 --doc-base=DIRECTORY Directory relative to --dir where doc files are
163 placed (default \"doc\").
164 --tests-base=DIRECTORY
165 Directory relative to --dir where unit tests are
166 placed (default \"tests\").
167 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
168 tools are placed (default \"build-aux\").
169 --with-tests Include unit tests for the included modules.
170 --with-obsolete Include obsolete modules when they occur among the
171 dependencies. By default, dependencies to obsolete
173 --avoid=MODULE Avoid including the given MODULE. Useful if you
174 have code that provides equivalent functionality.
175 This option can be repeated.
176 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
177 Also modify license template from GPL to LGPL.
178 The version number of the LGPL can be specified;
179 the default is currently LGPLv3.
180 --makefile-name=NAME Name of makefile in automake syntax in the
181 source-base and tests-base directories
182 (default \"Makefile.am\").
183 --libtool Use libtool rules.
184 --no-libtool Don't use libtool rules.
185 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
186 'gl_INIT'. Default is 'gl'.
187 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
188 the package name. A suffix '-gnulib' is appended.
189 --vc-files Update version control related files.
190 --no-vc-files Don't update version control related files
191 (.gitignore and/or .cvsignore).
192 --no-changelog Don't update or create ChangeLog files.
194 Options for --import and --update:
195 --dry-run For --import, only print what would have been done.
196 -s, --symbolic, --symlink Make symbolic links instead of copying files.
197 --local-symlink Make symbolic links instead of copying files, only
198 for files from the local override directory.
199 -S, --more-symlinks Make symbolic links instead of copying files, and
200 don't replace copyright notices.
202 Report bugs to <bug-gnulib@gnu.org>."
206 # outputs to stdout the --version message.
210 if test -d "$gnulib_dir"/.git \
211 && (git --version) >/dev/null 2>/dev/null \
212 && (date --version) >/dev/null 2>/dev/null; then
213 # gnulib checked out from git.
214 sed_extract_first_date='/^Date/{
218 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
219 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
220 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
221 date=`echo "$date" | sed -e "$sed_year_before_time"`
222 # Use GNU date to compute the time in GMT.
223 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
224 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
226 if test -d "$gnulib_dir"/CVS \
227 && (cvs --version) >/dev/null 2>/dev/null; then
228 # gnulib checked out from CVS.
229 sed_extract_first_date='/^date: /{
230 s/^date: \([0-9][0-9][0-9][0-9]\).\([0-9][0-9]\).\([0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1-\2-\3 \4/p
233 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
235 # gnulib copy without versioning information.
236 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
240 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
242 gnulib-tool (GNU $package $date)$version
243 Copyright (C) $year Free Software Foundation, Inc.
244 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
245 This is free software: you are free to change and redistribute it.
246 There is NO WARRANTY, to the extent permitted by law.
248 Written by" "Bruno Haible" "and" "Simon Josefsson"
251 # func_emit_copyright_notice
252 # outputs to stdout a header for a generated file.
253 func_emit_copyright_notice ()
255 sed -n '/Copyright/ {
258 }' < "$self_abspathname"
260 echo "# This file is free software, distributed under the terms of the GNU"
261 echo "# General Public License. As a special exception to the GNU General"
262 echo "# Public License, this file may be distributed as part of a program"
263 echo "# that contains a configuration script generated by Autoconf, under"
264 echo "# the same distribution terms as the rest of that program."
266 echo "# Generated by gnulib-tool."
270 # exits with a given status.
271 # This function needs to be used, rather than 'exit', when a 'trap' handler is
272 # in effect that refers to $?.
279 # locates the directory where the gnulib repository lives
281 # - progname name of this program
283 # - self_abspathname absolute pathname of gnulib-tool
284 # - gnulib_dir absolute pathname of gnulib repository
288 /*) self_abspathname="$progname" ;;
289 */*) self_abspathname=`pwd`/"$progname" ;;
292 # Iterate through the elements of $PATH.
293 # We use IFS=: instead of
294 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
295 # because the latter does not work when some PATH element contains spaces.
296 # We use a canonicalized $pathx instead of $PATH, because empty PATH
297 # elements are by definition equivalent to '.', however field splitting
298 # according to IFS=: loses empty fields in many shells:
299 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
300 # beginning, at the end, and in the middle),
301 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
302 # at the beginning and at the end,
303 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
304 # Solaris lose empty fields at the end.
305 # The 'case' statement is an optimization, to avoid evaluating the
306 # explicit canonicalization command when $PATH contains no empty fields.
308 if test "${PATH_SEPARATOR+set}" != set; then
310 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
311 chmod +x "$tmp"/conf.sh
312 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
319 if test "$PATH_SEPARATOR" = ";"; then
320 # On Windows, programs are searched in "." before $PATH.
323 # On Unix, we have to convert empty PATH elements to ".".
327 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
332 IFS="$PATH_SEPARATOR"
336 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
337 self_abspathname="$d/$progname"
342 if test -z "$self_abspathname"; then
343 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
347 while test -h "$self_abspathname"; do
348 # Resolve symbolic link.
349 linkval=`func_readlink "$self_abspathname"`
350 test -n "$linkval" || break
352 /* ) self_abspathname="$linkval" ;;
353 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
356 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
360 # creates a temporary directory.
362 # - progname name of this program
364 # - tmp pathname of freshly created temporary directory
367 # Use the environment variable TMPDIR, falling back to /tmp. This allows
368 # users to specify a different temporary directory, for example, if their
369 # /tmp is filled up or too small.
372 # Use the mktemp program if available. If not available, hide the error
374 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
375 test -n "$tmp" && test -d "$tmp"
378 # Use a simple mkdir command. It is guaranteed to fail if the directory
379 # already exists. $RANDOM is bash specific and expands to empty in shells
380 # other than bash, ksh and zsh. Its use does not increase security;
381 # rather, it minimizes the probability of failure in a very cluttered /tmp
383 tmp=$TMPDIR/gl$$-$RANDOM
384 (umask 077 && mkdir "$tmp")
387 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
392 # func_append var value
393 # appends the given value to the shell variable var.
394 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
395 # Use bash's += operator. It reduces complexity of appending repeatedly to
396 # a single variable from O(n^2) to O(n).
401 fast_func_append=true
405 eval "$1=\"\$$1\$2\""
407 fast_func_append=false
410 # func_remove_prefix var prefix
411 # removes the given prefix from the value of the shell variable var.
412 # var should be the name of a shell variable.
413 # Its value should not contain a newline and not start or end with whitespace.
414 # prefix should not contain the characters "$`\{}[]^|.
415 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
416 func_remove_prefix ()
420 fast_func_remove_prefix=true
422 func_remove_prefix ()
424 eval "value=\"\$$1\""
428 sed_escape_dots='s/\([.]\)/\\\1/g'
429 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
432 value=`echo "$value" | sed -e "s|^${prefix}||"`
433 eval "$1=\"\$value\""
435 fast_func_remove_prefix=false
438 # func_remove_suffix var suffix
439 # removes the given suffix from the value of the shell variable var.
440 # var should be the name of a shell variable.
441 # Its value should not contain a newline and not start or end with whitespace.
442 # suffix should not contain the characters "$`\{}[]^|.
443 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
444 func_remove_suffix ()
448 fast_func_remove_suffix=true
450 func_remove_suffix ()
452 eval "value=\"\$$1\""
456 sed_escape_dots='s/\([.]\)/\\\1/g'
457 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
460 value=`echo "$value" | sed -e "s|${suffix}\$||"`
461 eval "$1=\"\$value\""
463 fast_func_remove_suffix=false
466 # func_fatal_error message
467 # outputs to stderr a fatal error message, and terminates the program.
469 # - progname name of this program
472 echo "$progname: *** $1" 1>&2
473 echo "$progname: *** Stop." 1>&2
477 # func_readlink SYMLINK
478 # outputs the target of the given symlink.
479 if (type -p readlink) > /dev/null 2>&1; then
482 # Use the readlink program from GNU coreutils.
488 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
489 # would do the wrong thing if the link target contains " -> ".
490 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
494 # func_relativize DIR1 DIR2
495 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
497 # - DIR1 relative pathname, relative to the current directory
498 # - DIR2 relative pathname, relative to the current directory
500 # - reldir relative pathname of DIR2, relative to DIR1
506 sed_first='s,^\([^/]*\)/.*$,\1,'
507 sed_rest='s,^[^/]*/*,,'
508 sed_last='s,^.*/\([^/]*\)$,\1,'
509 sed_butlast='s,/*[^/]*$,,'
510 while test -n "$dir1"; do
511 first=`echo "$dir1" | sed -e "$sed_first"`
512 if test "$first" != "."; then
513 if test "$first" = ".."; then
514 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
515 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
517 first2=`echo "$dir2" | sed -e "$sed_first"`
518 if test "$first2" = "$first"; then
519 dir2=`echo "$dir2" | sed -e "$sed_rest"`
523 dir0="$dir0"/"$first"
526 dir1=`echo "$dir1" | sed -e "$sed_rest"`
531 # func_relconcat DIR1 DIR2
532 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
534 # - DIR1 relative pathname, relative to the current directory
535 # - DIR2 relative pathname, relative to DIR1
537 # - relconcat DIR1/DIR2, relative to the current directory
542 sed_first='s,^\([^/]*\)/.*$,\1,'
543 sed_rest='s,^[^/]*/*,,'
544 sed_last='s,^.*/\([^/]*\)$,\1,'
545 sed_butlast='s,/*[^/]*$,,'
547 first=`echo "$dir2" | sed -e "$sed_first"`
548 if test "$first" = "."; then
549 dir2=`echo "$dir2" | sed -e "$sed_rest"`
550 if test -z "$dir2"; then
555 last=`echo "$dir1" | sed -e "$sed_last"`
556 while test "$last" = "."; do
557 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
558 last=`echo "$dir1" | sed -e "$sed_last"`
560 if test -z "$dir1"; then
564 if test "$first" = ".."; then
565 if test "$last" = ".."; then
566 relconcat="$dir1/$dir2"
569 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
570 dir2=`echo "$dir2" | sed -e "$sed_rest"`
571 if test -z "$dir1"; then
575 if test -z "$dir2"; then
580 relconcat="$dir1/$dir2"
588 # Like ln -s, except that SRC is given relative to the current directory (or
589 # absolute), not given relative to the directory of DEST.
595 *) # SRC is relative.
598 ln -s "`pwd`/$1" "$2" ;;
599 *) # DEST is relative too.
600 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
601 test -n "$ln_destdir" || ln_destdir="."
602 func_relativize "$ln_destdir" "$1"
610 # func_ln_if_changed SRC DEST
611 # Like func_ln, but avoids munging timestamps if the link is correct.
612 func_ln_if_changed ()
614 if test $# -ne 2; then
615 echo "usage: func_ln_if_changed SRC DEST" >&2
617 ln_target=`func_readlink "$2"`
618 if test -h "$2" && test "$1" = "$ln_target"; then
627 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
628 # writes into a pipe with no readers, i.e. a pipe where all readers have
629 # already closed their file descriptor that read from it or exited entirely.
630 # The default behaviour is to terminate the current process without an error
632 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
633 # terminate the current process with an error message.
634 # This function should be called at the beginning of a command that only
635 # produces output to stdout (i.e. no side effects!), when the command that
636 # will read from this pipe might prematurely exit or close its standard input
638 if test -n "$BASH_VERSION"; then
639 # The problem has only been reported with bash. Probably it occurs only with
640 # bash-3.2. For the reasons, see
641 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
642 # Note that Solaris sh does not understand "trap - SIGPIPE".
643 func_reset_sigpipe ()
648 func_reset_sigpipe ()
654 # Ensure an 'echo' command that does not interpret backslashes.
656 # echo '\n' | wc -l prints 1 when OK, 2 when KO
657 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
658 # This problem is a weird heritage from SVR4. BSD got it right (except that
659 # BSD echo interprets '-n' as an option, which is also not desirable).
660 # Nowadays the problem occurs in 4 situations:
661 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
662 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
663 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
664 # - in zsh, when sh-emulation is not set,
665 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
666 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
667 # - in Solaris /bin/sh and OSF/1 /bin/sh.
668 # We try the following workarounds:
669 # - for all: respawn using $CONFIG_SHELL if that is set and works.
670 # - for bash >= 2.04: unset the shell option xpg_echo.
671 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
672 # - for bash < 2.0: define echo to a function that uses cat of a here document.
673 # - for zsh: turn sh-emulation on.
674 # - for ksh: alias echo to 'print -r'.
675 # - for ksh: alias echo to a function that uses cat of a here document.
676 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
677 # the ksh workaround.
678 # - otherwise: respawn using /bin/sh and rely on the workarounds.
679 # When respawning, we pass --no-reexec as first argument, so as to avoid
680 # turning this script into a fork bomb in unlucky situations.
682 if echo '\t' | grep t > /dev/null; then
683 have_echo=yes # Lucky!
685 # Try the workarounds.
686 # Respawn using $CONFIG_SHELL if that is set and works.
687 if test -z "$have_echo" \
688 && test "X$1" != "X--no-reexec" \
689 && test -n "$CONFIG_SHELL" \
690 && test -f "$CONFIG_SHELL" \
691 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
692 exec $CONFIG_SHELL "$0" --no-reexec "$@"
695 # For bash >= 2.04: unset the shell option xpg_echo.
696 if test -z "$have_echo" \
697 && test -n "$BASH_VERSION" \
698 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
702 # For bash >= 2.0: define echo to a function that uses the printf built-in.
703 # For bash < 2.0: define echo to a function that uses cat of a here document.
704 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
705 if test -z "$have_echo" \
706 && test -n "$BASH_VERSION"; then \
707 if type printf 2>/dev/null | grep / > /dev/null; then
708 # 'printf' is not a shell built-in.
716 # 'printf' is a shell built-in.
722 if echo '\t' | grep t > /dev/null; then
726 # For zsh: turn sh-emulation on.
727 if test -z "$have_echo" \
728 && test -n "$ZSH_VERSION" \
729 && (emulate sh) >/dev/null 2>&1; then
732 # For ksh: alias echo to 'print -r'.
733 if test -z "$have_echo" \
734 && (type print) >/dev/null 2>&1; then
735 # A 'print' command exists.
736 if type print 2>/dev/null | grep / > /dev/null; then
739 # 'print' is a shell built-in.
740 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
741 # 'print' is the ksh shell built-in.
742 alias echo='print -r'
746 if test -z "$have_echo" \
747 && echo '\t' | grep t > /dev/null; then
750 # For ksh: alias echo to a function that uses cat of a here document.
751 # The ksh manual page says:
752 # "Aliasing is performed when scripts are read, not while they are executed.
753 # Therefore, for an alias to take effect, the alias definition command has
754 # to be executed before the command which references the alias is read."
755 # Because of this, we have to play strange tricks with have_echo, to ensure
756 # that the top-level statement containing the test starts after the 'alias'
758 if test -z "$have_echo"; then
765 alias echo=bsd_echo 2>/dev/null
767 if test -z "$have_echo" \
768 && echo '\t' | grep t > /dev/null; then
771 if test -z "$have_echo"; then
772 unalias echo 2>/dev/null
774 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
775 if test -z "$have_echo" \
776 && test "X$1" != "X--no-reexec" \
777 && test -f /bin/ksh; then
778 exec /bin/ksh "$0" --no-reexec "$@"
781 # Otherwise: respawn using /bin/sh.
782 if test -z "$have_echo" \
783 && test "X$1" != "X--no-reexec" \
784 && test -f /bin/sh; then
785 exec /bin/sh "$0" --no-reexec "$@"
788 if test -z "$have_echo"; then
789 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
791 if echo '\t' | grep t > /dev/null; then
794 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
796 if test "X$1" = "X--no-reexec"; then
800 # Command-line option processing.
801 # Removes the OPTIONS from the arguments. Sets the variables:
802 # - mode list or import or create-testdir or create-megatestdir
803 # - destdir from --dir
804 # - local_gnulib_dir from --local-dir
805 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
806 # - libname, supplied_libname from --lib
807 # - sourcebase from --source-base
808 # - m4base from --m4-base
809 # - pobase from --po-base
810 # - docbase from --doc-base
811 # - testsbase from --tests-base
812 # - auxdir from --aux-dir
813 # - inctests true if --with-tests was given, blank otherwise
814 # - incobsolete true if --with-obsolete was given, blank otherwise
815 # - avoidlist list of modules to avoid, from --avoid
816 # - lgpl yes or a number if --lgpl was given, blank otherwise
817 # - makefile_name from --makefile-name
818 # - libtool true if --libtool was given, false if --no-libtool was
819 # given, blank otherwise
820 # - macro_prefix from --macro-prefix
821 # - po_domain from --po-domain
822 # - vc_files true if --vc-files was given, false if --no-vc-files was
823 # given, blank otherwise
824 # - autoconf_minversion minimum supported autoconf version
825 # - do_changelog false if --no-changelog was given, : otherwise
826 # - doit : if actions shall be executed, false if only to be printed
827 # - symbolic true if --symlink or --more-symlinks was given, blank
829 # - lsymbolic true if --local-symlink was given, blank otherwise
830 # - do_copyrights blank if --more-symlinks was given, true otherwise
861 while test $# -gt 0; do
866 --import | --impor | --impo | --imp | --im | --i )
869 --update | --updat | --upda | --upd | --up | --u )
872 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
875 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
876 mode=create-megatestdir
878 --test | --tes | --te | --t )
881 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
885 mode=`echo "X$1" | sed -e 's/^X--//'`
890 func_fatal_error "missing argument for --dir"
895 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
900 func_fatal_error "missing argument for --local-dir"
905 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
907 --verbose | --verbos | --verbo | --verb )
908 verbose=`expr $verbose + 1`
910 --quiet | --quie | --qui | --qu | --q )
911 verbose=`expr $verbose - 1`
916 func_fatal_error "missing argument for --lib"
919 supplied_libname=true
922 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
923 supplied_libname=true
928 func_fatal_error "missing argument for --source-base"
933 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
938 func_fatal_error "missing argument for --m4-base"
943 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
948 func_fatal_error "missing argument for --po-base"
953 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
958 func_fatal_error "missing argument for --doc-base"
963 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
968 func_fatal_error "missing argument for --tests-base"
973 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
978 func_fatal_error "missing argument for --aux-dir"
983 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
994 func_fatal_error "missing argument for --avoid"
996 func_append avoidlist " $1"
999 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1000 func_append avoidlist " $arg"
1006 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1009 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1015 if test $# = 0; then
1016 func_fatal_error "missing argument for --makefile-name"
1021 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1031 if test $# = 0; then
1032 func_fatal_error "missing argument for --macro-prefix"
1037 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1041 if test $# = 0; then
1042 func_fatal_error "missing argument for --po-domain"
1047 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1055 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
1061 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1064 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1067 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1071 --help | --hel | --he | --h )
1074 --version | --versio | --versi | --vers )
1078 # Stop option processing
1082 echo "gnulib-tool: unknown option $1" 1>&2
1083 echo "Try 'gnulib-tool --help' for more information." 1>&2
1090 if test "$mode" = update; then
1091 if test $# != 0; then
1092 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1093 echo "Try 'gnulib-tool --help' for more information." 1>&2
1094 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1095 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1098 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1099 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1100 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1101 || test -n "$inctests" || test -n "$incobsolete" \
1102 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1103 || test -n "$macro_prefix" || test -n "$po_domain" \
1104 || test -n "$vc_files"; then
1105 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1106 echo "Try 'gnulib-tool --help' for more information." 1>&2
1107 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1108 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1113 if test -n "$pobase" && test -z "$po_domain"; then
1114 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1115 echo "Try 'gnulib-tool --help' for more information." 1>&2
1118 if test -z "$pobase" && test -n "$po_domain"; then
1119 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1122 # Determine the minimum supported autoconf version from the project's
1124 DEFAULT_AUTOCONF_MINVERSION="2.59"
1125 autoconf_minversion=
1127 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1128 if test -f "$destdir"/configure.ac; then
1129 configure_ac="$destdir/configure.ac"
1131 if test -f "$destdir"/configure.in; then
1132 configure_ac="$destdir/configure.in"
1136 if test -f configure.ac; then
1137 configure_ac="configure.ac"
1139 if test -f configure.in; then
1140 configure_ac="configure.in"
1144 if test -n "$configure_ac"; then
1145 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1146 # because when some m4 files are omitted from a CVS repository,
1147 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1148 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1149 # autom4te: m4 failed with exit status: 1
1156 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1158 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1159 if test -n "$prereqs"; then
1160 autoconf_minversion=`
1161 for version in $prereqs; do echo $version; done |
1162 LC_ALL=C sort -nru | sed 1q
1166 if test -z "$autoconf_minversion"; then
1167 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1169 case "$autoconf_minversion" in
1170 1.* | 2.[0-4]* | 2.5[0-8]*)
1171 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1174 # Remove trailing slashes from the directory names. This is necessary for
1175 # m4base (to avoid an error in func_import) and optional for the others.
1176 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1177 case "$local_gnulib_dir" in
1178 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1180 case "$sourcebase" in
1181 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1184 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1187 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1190 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1192 case "$testsbase" in
1193 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1196 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1202 trap 'exit_status=$?
1203 if test "$signal" != 0; then
1204 echo "caught signal $signal" >&2
1207 exit $exit_status' 0
1208 for signal in 1 2 3 13 15; do
1209 trap '{ signal='$signal'; func_exit 1; }' $signal
1213 # func_lookup_file file
1214 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1217 # - local_gnulib_dir from --local-dir
1219 # - lookedup_file name of the merged (combined) file
1220 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1224 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1225 lookedup_file="$local_gnulib_dir/$lkfile"
1228 if test -f "$gnulib_dir/$lkfile"; then
1229 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1230 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1231 rm -f "$tmp/$lkbase"
1232 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1233 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1234 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1235 lookedup_file="$tmp/$lkbase"
1238 lookedup_file="$gnulib_dir/$lkfile"
1242 func_fatal_error "file $gnulib_dir/$lkfile not found"
1249 # - local_gnulib_dir from --local-dir
1252 # Filter out metainformation files like README, which are not modules.
1253 # Filter out unit test modules; they can be retrieved through
1254 # --extract-tests-module if desired.
1256 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1257 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1258 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1261 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1262 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1263 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1264 -e '/^README$/d' -e '/\/README$/d' \
1265 -e '/^TEMPLATE$/d' \
1266 -e '/^TEMPLATE-EXTENDED$/d' \
1267 -e '/^TEMPLATE-TESTS$/d' \
1270 | sed -e '/-tests$/d' \
1274 # func_verify_module
1275 # verifies a module name
1277 # - local_gnulib_dir from --local-dir
1278 # - module module name argument
1279 func_verify_module ()
1281 if { test -f "$gnulib_dir/modules/$module" \
1282 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1283 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1284 && test "CVS" != "$module" \
1285 && test "ChangeLog" != "$module" \
1286 && test "COPYING" != "$module" \
1287 && test "README" != "$module" \
1288 && test "TEMPLATE" != "$module" \
1289 && test "TEMPLATE-EXTENDED" != "$module" \
1290 && test "TEMPLATE-TESTS" != "$module"; then
1291 # OK, $module is a correct module name.
1292 # Verify that building the module description with 'patch' succeeds.
1293 func_lookup_file "modules/$module"
1295 echo "gnulib-tool: module $module doesn't exist" 1>&2
1300 # func_verify_nontests_module
1301 # verifies a module name, excluding tests modules
1303 # - local_gnulib_dir from --local-dir
1304 # - module module name argument
1305 func_verify_nontests_module ()
1308 *-tests ) module= ;;
1309 * ) func_verify_module ;;
1313 # func_verify_tests_module
1314 # verifies a module name, considering only tests modules
1316 # - local_gnulib_dir from --local-dir
1317 # - module module name argument
1318 func_verify_tests_module ()
1321 *-tests ) func_verify_module ;;
1326 sed_extract_prog=':[ ]*$/ {
1329 s/^Description:[ ]*$//
1333 s/^Depends-on:[ ]*$//
1334 s/^configure\.ac-early:[ ]*$//
1335 s/^configure\.ac:[ ]*$//
1336 s/^Makefile\.am:[ ]*$//
1340 s/^Maintainer:[ ]*$//
1347 # func_get_description module
1349 # - local_gnulib_dir from --local-dir
1350 func_get_description ()
1352 func_lookup_file "modules/$1"
1353 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1356 # func_get_status module
1358 # - local_gnulib_dir from --local-dir
1361 func_lookup_file "modules/$1"
1362 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1365 # func_get_notice module
1367 # - local_gnulib_dir from --local-dir
1370 func_lookup_file "modules/$1"
1371 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1374 # func_get_filelist module
1376 # - local_gnulib_dir from --local-dir
1377 func_get_filelist ()
1379 func_lookup_file "modules/$1"
1380 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1382 echo m4/gnulib-common.m4
1383 case "$autoconf_minversion" in
1390 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1391 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1392 # elements starting with prefix and ending with suffix are considered.
1393 # Processing: removed_prefix and removed_suffix are removed from each element,
1394 # added_prefix and added_suffix are added to each element.
1395 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1396 # added_prefix, added_suffix should not contain the characters \|.
1397 func_filter_filelist ()
1399 if test "$2" != "$nl" \
1400 || { $fast_func_append \
1401 && { test -z "$6" || $fast_func_remove_prefix; } \
1402 && { test -z "$7" || $fast_func_remove_suffix; }; \
1408 if test -n "$6"; then
1409 func_remove_prefix fff "$6"
1411 if test -n "$7"; then
1412 func_remove_suffix fff "$7"
1415 if test -z "$ffflist"; then
1418 func_append ffflist "$2${fff}"
1424 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1425 ffflist=`for fff in $3; do
1427 "$4"*"$5") echo "$fff" ;;
1429 done | sed -e "$sed_fff_filter"`
1431 eval "$1=\"\$ffflist\""
1434 # func_get_dependencies module
1436 # - local_gnulib_dir from --local-dir
1437 func_get_dependencies ()
1439 # ${module}-tests always implicitly depends on ${module}.
1443 func_remove_suffix fgd1 '-tests'
1447 # Then the explicit dependencies listed in the module description.
1448 func_lookup_file "modules/$1"
1449 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1452 # func_get_autoconf_early_snippet module
1454 # - local_gnulib_dir from --local-dir
1455 func_get_autoconf_early_snippet ()
1457 func_lookup_file "modules/$1"
1458 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1461 # func_get_autoconf_snippet module
1463 # - local_gnulib_dir from --local-dir
1464 func_get_autoconf_snippet ()
1466 func_lookup_file "modules/$1"
1467 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1470 # func_get_automake_snippet module
1472 # - local_gnulib_dir from --local-dir
1473 func_get_automake_snippet ()
1475 func_lookup_file "modules/$1"
1476 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1479 # *-tests module live in tests/, not lib/.
1480 # Synthesize an EXTRA_DIST augmentation.
1481 all_files=`func_get_filelist $1`
1482 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1483 extra_files="$tests_files"
1484 if test -n "$extra_files"; then
1485 echo "EXTRA_DIST +=" $extra_files
1490 # Synthesize an EXTRA_DIST augmentation.
1491 sed_combine_lines='/\\$/{
1498 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1499 already_mentioned_files=` \
1500 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1501 | sed -e "$sed_combine_lines" \
1502 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1503 all_files=`func_get_filelist $1`
1504 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
1505 # Remove $already_mentioned_files from $lib_files.
1506 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1507 extra_files=`func_reset_sigpipe; \
1508 for f in $already_mentioned_files; do echo $f; done \
1509 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1510 if test -n "$extra_files"; then
1511 echo "EXTRA_DIST +=" $extra_files
1514 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1515 # This is necessary so that automake can generate the right list of
1517 # A possible approach would be to use autom4te --trace of the redefined
1518 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1519 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1520 # inside autoconf's built-in macros are not missed).
1521 # But it's simpler and more robust to do it here, based on the file list.
1522 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1523 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1524 # automake will generate a useless dependency; this is harmless.
1526 relocatable-prog-wrapper) ;;
1528 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
1529 if test -n "$extra_files"; then
1530 echo "EXTRA_lib_SOURCES +=" $extra_files
1535 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1536 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
1537 if test -n "$buildaux_files"; then
1538 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1539 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1542 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1543 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
1544 if test -n "$top_files"; then
1545 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1546 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1553 # func_get_include_directive module
1555 # - local_gnulib_dir from --local-dir
1556 func_get_include_directive ()
1558 func_lookup_file "modules/$1"
1559 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1560 sed -e 's/^\(["<]\)/#include \1/'
1563 # func_get_link_directive module
1565 # - local_gnulib_dir from --local-dir
1566 func_get_link_directive ()
1568 func_lookup_file "modules/$1"
1569 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1572 # func_get_license module
1574 # - local_gnulib_dir from --local-dir
1577 func_lookup_file "modules/$1"
1578 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1579 # The default is GPL.
1581 } | sed -e 's,^ *$,,' | sed -e 1q
1584 # func_get_maintainer module
1586 # - local_gnulib_dir from --local-dir
1587 func_get_maintainer ()
1589 func_lookup_file "modules/$1"
1590 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1593 # func_get_tests_module module
1595 # - local_gnulib_dir from --local-dir
1596 func_get_tests_module ()
1598 # The naming convention for tests modules is hardwired: ${module}-tests.
1599 if test -f "$gnulib_dir/modules/$1"-tests \
1600 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1601 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1606 # func_acceptable module
1607 # tests whether a module is acceptable.
1609 # - avoidlist list of modules to avoid
1612 for avoid in $avoidlist; do
1613 if test "$avoid" = "$1"; then
1620 # func_modules_transitive_closure
1622 # - local_gnulib_dir from --local-dir
1623 # - modules list of specified modules
1624 # - inctests true if tests should be included, blank otherwise
1625 # - incobsolete true if obsolete modules among dependencies should be
1626 # included, blank otherwise
1627 # - avoidlist list of modules to avoid
1628 # - tmp pathname of a temporary directory
1630 # - modules list of modules, including dependencies
1631 func_modules_transitive_closure ()
1633 # In order to process every module only once (for speed), process an "input
1634 # list" of modules, producing an "output list" of modules. During each round,
1635 # more modules can be queued in the input list. Once a module on the input
1636 # list has been processed, it is added to the "handled list", so we can avoid
1637 # to process it again.
1639 inmodules="$modules"
1641 while test -n "$inmodules"; do
1642 inmodules_this_round="$inmodules"
1643 inmodules= # Accumulator, queue for next round
1644 for module in $inmodules_this_round; do
1646 if test -n "$module"; then
1647 if func_acceptable $module; then
1648 func_append outmodules " $module"
1649 deps=`func_get_dependencies $module`
1650 # Duplicate dependencies are harmless, but Jim wants a warning.
1651 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1652 if test -n "$duplicated_deps"; then
1653 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1655 for dep in $deps; do
1656 if test -n "$incobsolete" \
1657 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
1658 func_append inmodules " $dep"
1661 if test -n "$inctests"; then
1662 testsmodule=`func_get_tests_module $module`
1663 if test -n "$testsmodule"; then
1664 func_append inmodules " $testsmodule"
1670 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1671 # Remove $handledmodules from $inmodules.
1672 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1673 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1675 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1676 rm -f "$tmp"/queued-modules
1679 # func_modules_add_dummy
1681 # - local_gnulib_dir from --local-dir
1682 # - modules list of modules, including dependencies
1684 # - modules list of modules, including 'dummy' if needed
1685 func_modules_add_dummy ()
1687 # Determine whether any module provides a lib_SOURCES augmentation.
1689 sed_remove_backslash_newline=':a
1696 for module in $modules; do
1697 func_verify_nontests_module
1698 if test -n "$module"; then
1699 # Extract the value of "lib_SOURCES += ...".
1700 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1701 # Ignore .h files since they are not compiled.
1705 have_lib_SOURCES=yes
1712 # Add the dummy module, to make sure the library will be non-empty.
1713 if test -z "$have_lib_SOURCES"; then
1714 if func_acceptable "dummy"; then
1715 func_append modules " dummy"
1720 # func_modules_notice
1722 # - local_gnulib_dir from --local-dir
1723 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1724 # - modules list of modules, including dependencies
1725 func_modules_notice ()
1727 if test $verbose -ge -1; then
1728 for module in $modules; do
1730 if test -n "$module"; then
1731 msg=`func_get_notice $module`
1732 if test -n "$msg"; then
1733 echo "Notice from module $module:"
1734 echo "$msg" | sed -e 's/^/ /'
1741 # func_modules_to_filelist
1743 # - local_gnulib_dir from --local-dir
1744 # - modules list of modules, including dependencies
1746 # - files list of files
1747 func_modules_to_filelist ()
1750 for module in $modules; do
1752 if test -n "$module"; then
1753 fs=`func_get_filelist $module`
1754 func_append files " $fs"
1757 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1760 # func_execute_command command [args...]
1761 # Executes a command.
1762 # Uses also the variables
1763 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1764 func_execute_command ()
1766 if test $verbose -ge 0; then
1770 # Commands like automake produce output to stderr even when they succeed.
1771 # Turn this output off if the command succeeds.
1772 "$@" > "$tmp"/cmdout 2>&1
1774 if test $cmdret = 0; then
1778 cat "$tmp"/cmdout 1>&2
1785 # func_emit_lib_Makefile_am
1786 # emits the contents of library makefile to standard output.
1788 # - local_gnulib_dir from --local-dir
1789 # - modules list of modules, including dependencies
1790 # - libname library name
1791 # - pobase directory relative to destdir where to place *.po files
1792 # - auxdir directory relative to destdir where to place build aux files
1793 # - makefile_name from --makefile-name
1794 # - libtool true if libtool will be used, false or blank otherwise
1795 # - macro_prefix prefix of gl_LIBOBJS macros to use
1796 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1797 # - actioncmd (optional) command that will reproduce this invocation
1798 # - for_test true if creating a package for testing, false otherwise
1799 # - destfile filename relative to destdir of makefile being generated
1801 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1802 # list of edits to be done to Makefile.am variables
1804 # - uses_subdirs nonempty if object files in subdirs exist
1805 func_emit_lib_Makefile_am ()
1807 # When creating an includable Makefile.am snippet, augment variables with
1808 # += instead of assigning them.
1809 if test -n "$makefile_name"; then
1814 if test "$libtool" = true; then
1817 sed_eliminate_LDFLAGS="$sed_noop"
1821 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1824 # When creating a package for testing: Attempt to provoke failures,
1825 # especially link errors, already during "make" rather than during
1826 # "make check", because "make check" is not possible in a cross-compiling
1827 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1828 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1830 sed_transform_check_PROGRAMS="$sed_noop"
1832 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1833 echo "## Process this file with automake to produce Makefile.in."
1834 func_emit_copyright_notice
1835 if test -n "$actioncmd"; then
1836 echo "# Reproduce by: $actioncmd"
1841 for module in $modules; do
1842 func_verify_nontests_module
1843 if test -n "$module"; then
1845 func_get_automake_snippet "$module" |
1846 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1847 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1848 -e "$sed_eliminate_LDFLAGS" \
1849 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1850 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1851 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1852 -e "$sed_transform_check_PROGRAMS"
1853 if test "$module" = 'alloca'; then
1854 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1855 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1858 # Skip the contents if it's entirely empty.
1859 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1860 echo "## begin gnulib module $module"
1863 echo "## end gnulib module $module"
1867 # Test whether there are some source files in subdirectories.
1868 for f in `func_get_filelist "$module"`; do
1879 if test -z "$makefile_name"; then
1880 # If there are source files in subdirectories, prevent collision of the
1881 # object files (example: hash.c and libxml/hash.c).
1883 if test -n "$uses_subdirs"; then
1884 subdir_options=' subdir-objects'
1886 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1889 if test -z "$makefile_name"; then
1891 echo "noinst_HEADERS ="
1892 echo "noinst_LIBRARIES ="
1893 echo "noinst_LTLIBRARIES ="
1894 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1895 # if you specify pkgdata_DATA to empty. This is a workaround.
1896 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1897 echo "pkgdata_DATA ="
1900 echo "BUILT_SOURCES ="
1903 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1904 if test -z "$makefile_name"; then
1905 echo "MOSTLYCLEANDIRS ="
1907 echo "DISTCLEANFILES ="
1908 echo "MAINTAINERCLEANFILES ="
1910 # Execute edits that apply to the Makefile.am being generated.
1912 while test $edit != $makefile_am_edits; do
1913 edit=`expr $edit + 1`
1914 eval dir=\"\$makefile_am_edit${edit}_dir\"
1915 eval var=\"\$makefile_am_edit${edit}_var\"
1916 eval val=\"\$makefile_am_edit${edit}_val\"
1917 if test -n "$var"; then
1918 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
1919 echo "${var} += ${val}"
1920 eval "makefile_am_edit${edit}_var="
1924 if test -z "$makefile_name"; then
1926 echo "AM_CPPFLAGS ="
1929 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1930 # One of the snippets already specifies an installation location for the
1931 # library. Don't confuse automake by saying it should not be installed.
1934 # By default, the generated library should not be installed.
1935 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1938 echo "${libname}_${libext}_SOURCES ="
1939 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1940 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
1941 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1942 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1943 echo "EXTRA_${libname}_${libext}_SOURCES ="
1944 if test "$libtool" = true; then
1945 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1948 if test -n "$pobase"; then
1949 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1952 cat allsnippets.tmp \
1953 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1955 echo "mostlyclean-local: mostlyclean-generic"
1956 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1957 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1958 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1962 rm -f allsnippets.tmp
1965 # func_emit_po_Makevars
1966 # emits the contents of po/ makefile parameterization to standard output.
1968 # - local_gnulib_dir from --local-dir
1969 # - sourcebase directory relative to destdir where to place source code
1970 # - pobase directory relative to destdir where to place *.po files
1971 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1972 func_emit_po_Makevars ()
1974 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1975 func_emit_copyright_notice
1977 echo "# Usually the message domain is the same as the package name."
1978 echo "# But here it has a '-gnulib' suffix."
1979 echo "DOMAIN = ${po_domain}-gnulib"
1981 echo "# These two variables depend on the location of this directory."
1982 echo "subdir = ${pobase}"
1983 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1986 # These options get passed to xgettext.
1987 XGETTEXT_OPTIONS = \
1988 --keyword=_ --flag=_:1:pass-c-format \
1989 --keyword=N_ --flag=N_:1:pass-c-format \
1990 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1991 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1992 --flag=error:3:c-format --flag=error_at_line:5:c-format
1994 # This is the copyright holder that gets inserted into the header of the
1995 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1996 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1998 # This is the email address or URL to which the translators shall report
1999 # bugs in the untranslated strings:
2000 # - Strings which are not entire sentences, see the maintainer guidelines
2001 # in the GNU gettext documentation, section 'Preparing Strings'.
2002 # - Strings which use unclear terms or require additional context to be
2004 # - Strings which make invalid assumptions about notation of date, time or
2006 # - Pluralisation problems.
2007 # - Incorrect English spelling.
2008 # - Incorrect formatting.
2009 # It can be your email address, or a mailing list address where translators
2010 # can write to without being subscribed, or the URL of a web page through
2011 # which the translators can contact you.
2012 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2014 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2015 # message catalogs shall be used. It is usually empty.
2016 EXTRA_LOCALE_CATEGORIES =
2018 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2019 # context. Possible values are "yes" and "no". Set this to yes if the
2020 # package uses functions taking also a message context, like pgettext(), or
2021 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2026 # func_emit_po_POTFILES_in
2027 # emits the file list to be passed to xgettext to standard output.
2029 # - local_gnulib_dir from --local-dir
2030 # - sourcebase directory relative to destdir where to place source code
2031 # - files list of new files
2032 func_emit_po_POTFILES_in ()
2034 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2035 func_emit_copyright_notice
2037 echo "# List of files which contain translatable strings."
2038 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2041 # func_emit_tests_Makefile_am
2042 # emits the contents of tests makefile to standard output.
2044 # - local_gnulib_dir from --local-dir
2045 # - modules list of modules, including dependencies
2046 # - libname library name
2047 # - auxdir directory relative to destdir where to place build aux files
2048 # - makefile_name from --makefile-name
2049 # - libtool true if libtool will be used, false or blank otherwise
2050 # - sourcebase relative directory containing lib source code
2051 # - m4base relative directory containing autoconf macros
2052 # - testsbase relative directory containing unit test code
2053 # - macro_prefix prefix of gl_LIBOBJS macros to use
2054 # - for_test true if creating a package for testing, false otherwise
2055 # - use_libtests true if a libtests.a should be built, false otherwise
2056 # - destfile filename relative to destdir of makefile being generated
2058 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2059 # list of edits to be done to Makefile.am variables
2061 # - uses_subdirs nonempty if object files in subdirs exist
2062 func_emit_tests_Makefile_am ()
2064 if test "$libtool" = true; then
2066 sed_eliminate_LDFLAGS="$sed_noop"
2069 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2072 # When creating a package for testing: Attempt to provoke failures,
2073 # especially link errors, already during "make" rather than during
2074 # "make check", because "make check" is not possible in a cross-compiling
2075 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2076 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2078 sed_transform_check_PROGRAMS="$sed_noop"
2080 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2081 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2082 echo "## Process this file with automake to produce Makefile.in."
2083 func_emit_copyright_notice
2087 for module in $modules; do
2089 func_verify_tests_module
2093 if test -n "$module"; then
2095 func_get_automake_snippet "$module" |
2096 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2097 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2098 -e "$sed_eliminate_LDFLAGS" \
2099 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2100 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2101 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2102 -e "$sed_transform_check_PROGRAMS"
2103 if $use_libtests && test "$module" = 'alloca'; then
2104 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2105 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2108 # Skip the contents if it's entirely empty.
2109 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
2110 echo "## begin gnulib module $module"
2113 echo "## end gnulib module $module"
2117 # Test whether there are some source files in subdirectories.
2118 for f in `func_get_filelist "$module"`; do
2120 lib/*/*.c | tests/*/*.c)
2129 # Generate dependencies here, since it eases the debugging of test failures.
2130 # If there are source files in subdirectories, prevent collision of the
2131 # object files (example: hash.c and libxml/hash.c).
2133 if test -n "$uses_subdirs"; then
2134 subdir_options=' subdir-objects'
2136 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2139 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2142 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2143 # variable is needed to avoid an error from automake:
2144 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2147 echo "TESTS_ENVIRONMENT ="
2148 echo "noinst_PROGRAMS ="
2149 if ! $for_test; then
2150 echo "check_PROGRAMS ="
2152 echo "noinst_HEADERS ="
2153 echo "noinst_LIBRARIES ="
2154 if $use_libtests; then
2156 echo "noinst_LIBRARIES += libtests.a"
2158 echo "check_LIBRARIES = libtests.a"
2161 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2162 # if you specify pkgdata_DATA to empty. This is a workaround.
2163 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
2164 echo "pkgdata_DATA ="
2167 echo "BUILT_SOURCES ="
2169 echo "MOSTLYCLEANFILES = core *.stackdump"
2170 echo "MOSTLYCLEANDIRS ="
2172 echo "DISTCLEANFILES ="
2173 echo "MAINTAINERCLEANFILES ="
2174 # Execute edits that apply to the Makefile.am being generated.
2176 while test $edit != $makefile_am_edits; do
2177 edit=`expr $edit + 1`
2178 eval dir=\"\$makefile_am_edit${edit}_dir\"
2179 eval var=\"\$makefile_am_edit${edit}_var\"
2180 eval val=\"\$makefile_am_edit${edit}_val\"
2181 if test -n "$var"; then
2182 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2183 echo "${var} += ${val}"
2184 eval "makefile_am_edit${edit}_var="
2189 echo "AM_CPPFLAGS = \\"
2190 echo " -I. -I\$(srcdir) \\"
2191 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2192 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2194 local_ldadd_before=''
2195 local_ldadd_after=''
2196 if $use_libtests; then
2197 # All test programs need to be linked with libtests.a.
2198 # It needs to be passed to the linker before ${libname}.${libext}, since
2199 # the tests-related modules depend on the main modules.
2200 # It also needs to be passed to the linker after ${libname}.${libext}
2201 # because the latter might contain incomplete modules (such as the 'error'
2202 # module whose dependency to 'progname' is voluntarily omitted).
2203 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2205 local_ldadd_before=' libtests.a'
2206 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2208 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2210 if $use_libtests; then
2211 echo "libtests_a_SOURCES ="
2212 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2213 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2214 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2215 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2216 echo "EXTRA_libtests_a_SOURCES ="
2217 # The circular dependency in LDADD requires this.
2218 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2221 cat allsnippets.tmp \
2222 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2223 echo "# Clean up after Solaris cc."
2225 echo " rm -rf SunWS_cache"
2227 echo "mostlyclean-local: mostlyclean-generic"
2228 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2229 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2230 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2234 rm -f allsnippets.tmp
2237 # func_emit_initmacro_start macro_prefix
2238 # emits the first few statements of the gl_INIT macro to standard output.
2239 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2240 func_emit_initmacro_start ()
2242 macro_prefix_arg="$1"
2243 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2244 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2245 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2246 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2248 # Furthermore it avoids an automake error like this when a Makefile.am
2249 # that uses pieces of gnulib also uses $(LIBOBJ):
2250 # automatically discovered file `error.c' should not be explicitly mentioned
2251 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2252 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2253 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2254 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2255 # automatically discovered file `error.c' should not be explicitly mentioned
2256 # We let automake know about the files to be distributed through the
2257 # EXTRA_lib_SOURCES variable.
2258 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2259 # Create data variables for checking the presence of files that are mentioned
2260 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2261 # because we want the check to happen when the configure file is created,
2262 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2263 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2264 # in which to expect them.
2265 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2266 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2270 # func_emit_initmacro_end macro_prefix
2271 # emits the last few statements of the gl_INIT macro to standard output.
2272 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2273 func_emit_initmacro_end ()
2275 macro_prefix_arg="$1"
2276 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2277 # The check is performed only when autoconf is run from the directory where
2278 # the configure.ac resides; if it is run from a different directory, the
2280 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2281 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2282 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2283 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2284 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2288 echo " m4_if(m4_sysval, [0], [],"
2289 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2291 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2292 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2293 echo " m4_popdef([AC_LIBSOURCES])"
2294 echo " m4_popdef([AC_REPLACE_FUNCS])"
2295 echo " m4_popdef([AC_LIBOBJ])"
2296 echo " AC_CONFIG_COMMANDS_PRE(["
2297 echo " ${macro_prefix_arg}_libobjs="
2298 echo " ${macro_prefix_arg}_ltlibobjs="
2299 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2300 echo " # Remove the extension."
2301 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2302 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2303 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2304 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2307 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2308 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2312 # func_emit_initmacro_done macro_prefix sourcebase
2313 # emits a few statements after the gl_INIT macro to standard output.
2314 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2315 # - sourcebase directory relative to destdir where to place source code
2316 func_emit_initmacro_done ()
2318 macro_prefix_arg="$1"
2321 echo "# Like AC_LIBOBJ, except that the module name goes"
2322 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2323 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2324 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2325 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2328 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2329 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2330 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2331 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2332 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2335 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2336 echo "# expected is derived from the gnulib-tool parameterization,"
2337 echo "# and alloca is special cased (for the alloca-opt module)."
2338 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2339 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2340 echo " m4_foreach([_gl_NAME], [\$1], ["
2341 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2342 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2343 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2349 # func_import modules
2350 # Uses also the variables
2351 # - destdir target directory
2352 # - local_gnulib_dir from --local-dir
2353 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2354 # - libname library name
2355 # - sourcebase directory relative to destdir where to place source code
2356 # - m4base directory relative to destdir where to place *.m4 macros
2357 # - pobase directory relative to destdir where to place *.po files
2358 # - docbase directory relative to destdir where to place doc files
2359 # - testsbase directory relative to destdir where to place unit test code
2360 # - auxdir directory relative to destdir where to place build aux files
2361 # - inctests true if --with-tests was given, blank otherwise
2362 # - incobsolete true if --with-obsolete was given, blank otherwise
2363 # - avoidlist list of modules to avoid, from --avoid
2364 # - lgpl yes or a number if library's license shall be LGPL,
2366 # - makefile_name from --makefile-name
2367 # - libtool true if --libtool was given, false if --no-libtool was
2368 # given, blank otherwise
2369 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2370 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2371 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2372 # - vc_files true if --vc-files was given, false if --no-vc-files was
2373 # given, blank otherwise
2374 # - autoconf_minversion minimum supported autoconf version
2375 # - doit : if actions shall be executed, false if only to be printed
2376 # - symbolic true if files should be symlinked, copied otherwise
2377 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2379 # - do_copyrights true if copyright notices in files should be replaced,
2383 # Get the cached settings.
2384 cached_local_gnulib_dir=
2385 cached_specified_modules=
2396 cached_makefile_name=
2398 cached_macro_prefix=
2402 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2403 cached_libtool=false
2409 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
2419 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
2421 /gl_WITH_OBSOLETE/ {
2422 s,^.*$,cached_incobsolete=true,p
2425 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
2428 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
2431 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
2434 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
2437 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
2440 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
2443 s,^.*$,cached_inctests=true,p
2446 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
2449 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
2452 s,^.*$,cached_lgpl=yes,p
2454 /gl_MAKEFILE_NAME(/ {
2455 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
2458 s,^.*$,cached_libtool=true,p
2460 /gl_MACRO_PREFIX(/ {
2461 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
2464 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
2467 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
2469 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2470 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2475 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2476 s,^.*$,cached_files=",p
2489 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2493 # Merge the cached settings with the specified ones.
2494 # The m4base must be the same as expected from the pathname.
2495 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2496 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2498 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2499 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2500 if test -z "$local_gnulib_dir"; then
2501 if test -n "$cached_local_gnulib_dir"; then
2504 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2506 case "$cached_local_gnulib_dir" in
2508 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2510 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2511 local_gnulib_dir="$relconcat" ;;
2516 # Append the cached and the specified module names. So that
2517 # "gnulib-tool --import foo" means to add the module foo.
2518 specified_modules="$cached_specified_modules $1"
2519 # Included obsolete modules among the dependencies if specified either way.
2520 if test -z "$incobsolete"; then
2521 incobsolete="$cached_incobsolete"
2523 # Append the cached and the specified avoidlist. This is probably better
2524 # than dropping the cached one when --avoid is specified at least once.
2525 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2526 avoidlist=`echo $avoidlist`
2528 # The sourcebase defaults to the cached one.
2529 if test -z "$sourcebase"; then
2530 sourcebase="$cached_sourcebase"
2531 if test -z "$sourcebase"; then
2532 func_fatal_error "missing --source-base option"
2535 # The pobase defaults to the cached one.
2536 if test -z "$pobase"; then
2537 pobase="$cached_pobase"
2539 # The docbase defaults to the cached one.
2540 if test -z "$docbase"; then
2541 docbase="$cached_docbase"
2542 if test -z "$docbase"; then
2543 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."
2546 # The testsbase defaults to the cached one.
2547 if test -z "$testsbase"; then
2548 testsbase="$cached_testsbase"
2549 if test -z "$testsbase"; then
2550 func_fatal_error "missing --tests-base option"
2553 # Require the tests if specified either way.
2554 if test -z "$inctests"; then
2555 inctests="$cached_inctests"
2557 # The libname defaults to the cached one.
2558 if test -z "$supplied_libname"; then
2559 libname="$cached_libname"
2560 if test -z "$libname"; then
2561 func_fatal_error "missing --lib option"
2564 # Require LGPL if specified either way.
2565 if test -z "$lgpl"; then
2568 # The makefile_name defaults to the cached one.
2569 if test -z "$makefile_name"; then
2570 makefile_name="$cached_makefile_name"
2572 # Use libtool if specified either way, or if guessed.
2573 if test -z "$libtool"; then
2574 if test -n "$cached_m4base"; then
2575 libtool="$cached_libtool"
2577 libtool="$guessed_libtool"
2580 # The macro_prefix defaults to the cached one.
2581 if test -z "$macro_prefix"; then
2582 macro_prefix="$cached_macro_prefix"
2583 if test -z "$macro_prefix"; then
2584 func_fatal_error "missing --macro-prefix option"
2587 # The po_domain defaults to the cached one.
2588 if test -z "$po_domain"; then
2589 po_domain="$cached_po_domain"
2591 # The vc_files defaults to the cached one.
2592 if test -z "$vc_files"; then
2593 vc_files="$cached_vc_files"
2596 # Canonicalize the list of specified modules.
2597 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2599 # Determine final module list.
2600 modules="$specified_modules"
2601 func_modules_transitive_closure
2602 if test $verbose -ge 0; then
2603 echo "Module list with included dependencies:"
2604 echo "$modules" | sed -e 's/^/ /'
2606 final_modules="$modules"
2608 # Determine main module list and tests-related module list separately.
2609 # The main module list is the transitive closure of the specified modules,
2610 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2611 # is specified, it will consist only of LGPLed source.
2612 # The tests-related module list is the transitive closure of the specified
2613 # modules, including tests modules, minus the main module list. Its lib/*
2614 # sources (brought in through dependencies of *-tests modules) go into
2615 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2616 # Determine main module list.
2617 saved_inctests="$inctests"
2619 modules="$specified_modules"
2620 func_modules_transitive_closure
2621 main_modules="$modules"
2622 inctests="$saved_inctests"
2623 if test $verbose -ge 1; then
2624 echo "Main module list:"
2625 echo "$main_modules" | sed -e 's/^/ /'
2627 # Determine tests-related module list.
2628 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2629 testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2630 if test $verbose -ge 1; then
2631 echo "Tests-related module list:"
2632 echo "$testsrelated_modules" | sed -e 's/^/ /'
2635 # Add the dummy module to the main module list if needed.
2636 modules="$main_modules"
2637 func_modules_add_dummy
2638 main_modules="$modules"
2640 # Determine whether a $testsbase/libtests.a is needed.
2642 for module in $testsrelated_modules; do
2643 func_verify_nontests_module
2644 if test -n "$module"; then
2645 all_files=`func_get_filelist $module`
2646 # Test whether some file in $all_files lies in lib/.
2647 for f in $all_files; do
2658 # Add the dummy module to the tests-related module list if needed.
2659 if $use_libtests; then
2660 modules="$testsrelated_modules"
2661 func_modules_add_dummy
2662 testsrelated_modules="$modules"
2665 # If --lgpl, verify that the licenses of modules are compatible.
2666 if test -n "$lgpl"; then
2667 license_incompatibilities=
2668 for module in $main_modules; do
2669 license=`func_get_license $module`
2671 'GPLed build tool') ;;
2672 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2678 *) func_append license_incompatibilities "$module $license$nl" ;;
2684 *) func_append license_incompatibilities "$module $license$nl" ;;
2687 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2692 if test -n "$license_incompatibilities"; then
2693 # Format the license incompatibilities as a table.
2694 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
2695 s,^\(.................................................[^ ]*\) *, \1 ,'
2696 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
2697 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
2701 # Show banner notice of every module.
2702 modules="$main_modules"
2705 # Determine script to apply to imported library files.
2706 sed_transform_lib_file=
2707 for module in $main_modules; do
2708 if test $module = config-h; then
2709 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2710 sed_transform_lib_file=$sed_transform_lib_file'
2711 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2716 sed_transform_main_lib_file="$sed_transform_lib_file"
2717 if test -n "$do_copyrights"; then
2718 if test -n "$lgpl"; then
2722 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2723 s/GNU General/GNU Lesser General/g
2727 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2728 s/GNU General/GNU Lesser General/g
2729 s/version [23]\([ ,]\)/version 2.1\1/g
2732 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2736 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2737 s/GNU Lesser General/GNU General/g
2738 s/GNU Library General/GNU General/g
2739 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2744 # Determine script to apply to library files that go into $testsbase/.
2745 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2746 if test -n "$do_copyrights"; then
2748 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2749 s/GNU Lesser General/GNU General/g
2750 s/GNU Library General/GNU General/g
2751 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2755 # Determine the final file lists.
2756 # They must be computed separately, because files in lib/* go into
2757 # $sourcebase/ if they are in the main file list but into $testsbase/
2758 # if they are in the tests-related file list. Furthermore lib/dummy.c
2760 # Determine final main file list.
2761 modules="$main_modules"
2762 func_modules_to_filelist
2764 # Determine final tests-related file list.
2765 modules="$testsrelated_modules"
2766 func_modules_to_filelist
2767 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2768 # Merge both file lists.
2769 sed_remove_empty_lines='/^$/d'
2770 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2771 if test $verbose -ge 0; then
2773 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2774 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2778 || func_fatal_error "refusing to do nothing"
2780 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2781 new_files="$files m4/gnulib-tool.m4"
2782 old_files="$cached_files"
2783 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2784 func_append old_files " m4/gnulib-tool.m4"
2787 sed_rewrite_old_files="\
2788 s,^build-aux/,$auxdir/,
2789 s,^doc/,$cached_docbase/,
2790 s,^lib/,$cached_sourcebase/,
2791 s,^m4/,$cached_m4base/,
2792 s,^tests/,$cached_testsbase/,
2793 s,^tests=lib/,$cached_testsbase/,
2795 sed_rewrite_new_files="\
2796 s,^build-aux/,$auxdir/,
2798 s,^lib/,$sourcebase/,
2800 s,^tests/,$testsbase/,
2801 s,^tests=lib/,$testsbase/,
2804 # Create directories.
2805 { echo "$sourcebase"
2807 if test -n "$pobase"; then
2810 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2811 if test -n "$docfiles"; then
2814 if test -n "$inctests"; then
2818 for f in $files; do echo $f; done \
2819 | sed -e "$sed_rewrite_new_files" \
2820 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2823 { # Rearrange file descriptors. Needed because "while ... done < ..."
2824 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2825 exec 5<&0 < "$tmp"/dirs
2827 if test ! -d "$destdir/$d"; then
2829 echo "Creating directory $destdir/$d"
2830 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2832 echo "Create directory $destdir/$d"
2839 # func_dest_tmpfilename file
2840 # determines the name of a temporary file (file is relative to destdir).
2842 # - tmpfile absolute filename of the temporary file
2843 func_dest_tmpfilename ()
2846 # Put the new contents of $file in a file in the same directory (needed
2847 # to guarantee that an 'mv' to "$destdir/$file" works).
2848 tmpfile="$destdir/$1.tmp"
2850 # Put the new contents of $file in a file in a temporary directory
2851 # (because the directory of "$file" might not exist).
2852 tmpfile="$tmp"/`basename "$1"`.tmp
2856 # Copy files or make symbolic links. Remove obsolete files.
2860 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2861 # representing the files according to the last gnulib-tool invocation.
2862 for f in $old_files; do echo $f; done \
2863 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2866 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2867 # representing the files after this gnulib-tool invocation.
2868 for f in $new_files; do echo $f; done \
2869 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2872 # First the files that are in old-files, but not in new-files:
2873 sed_take_first_column='s,'"$delimiter"'.*,,'
2874 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2875 # Remove the file. Do nothing if the user already removed it.
2876 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2878 echo "Removing file $g (backup in ${g}~)"
2879 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2881 echo "Remove file $g (backup in ${g}~)"
2883 func_append removed_files "$g$nl"
2886 # func_add_or_update handles a file that ought to be present afterwards.
2888 # - f the original file name
2889 # - g the rewritten file name
2890 # - already_present nonempty if the file already exists, empty otherwise
2891 func_add_or_update ()
2895 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2897 func_dest_tmpfilename "$g"
2898 func_lookup_file "$f"
2899 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2900 if test -n "$sed_transform_main_lib_file"; then
2903 sed -e "$sed_transform_main_lib_file" \
2904 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2908 if test -n "$sed_transform_testsrelated_lib_file"; then
2911 sed -e "$sed_transform_testsrelated_lib_file" \
2912 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2916 if test -f "$destdir/$g"; then
2917 # The file already exists.
2918 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2919 : # The file has not changed.
2923 if test -n "$already_present"; then
2924 echo "Updating file $g (backup in ${g}~)"
2926 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2928 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2929 if { test -n "$symbolic" \
2930 || { test -n "$lsymbolic" \
2931 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2932 && test -z "$lookedup_tmp" \
2933 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2934 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2936 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2939 if test -n "$already_present"; then
2940 echo "Update file $g (backup in ${g}~)"
2942 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2948 # Don't protest if the file should be there but isn't: it happens
2949 # frequently that developers don't put autogenerated files into CVS.
2951 echo "Copying file $g"
2952 if { test -n "$symbolic" \
2953 || { test -n "$lsymbolic" \
2954 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2955 && test -z "$lookedup_tmp" \
2956 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2957 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2959 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2964 func_append added_files "$g$nl"
2968 # Then the files that are in new-files, but not in old-files:
2969 sed_take_last_column='s,^.*'"$delimiter"',,'
2971 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2972 | sed -e "$sed_take_last_column" \
2973 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2974 { # Rearrange file descriptors. Needed because "while ... done < ..."
2975 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2976 exec 5<&0 < "$tmp"/added-files
2982 # Then the files that are in new-files and in old-files:
2983 already_present=true
2984 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2985 | sed -e "$sed_take_last_column" \
2986 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2987 { # Rearrange file descriptors. Needed because "while ... done < ..."
2988 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2989 exec 5<&0 < "$tmp"/kept-files
2996 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2997 actioncmd="gnulib-tool --import"
2998 func_append actioncmd " --dir=$destdir"
2999 if test -n "$local_gnulib_dir"; then
3000 func_append actioncmd " --local-dir=$local_gnulib_dir"
3002 func_append actioncmd " --lib=$libname"
3003 func_append actioncmd " --source-base=$sourcebase"
3004 func_append actioncmd " --m4-base=$m4base"
3005 if test -n "$pobase"; then
3006 func_append actioncmd " --po-base=$pobase"
3008 func_append actioncmd " --doc-base=$docbase"
3009 func_append actioncmd " --tests-base=$testsbase"
3010 func_append actioncmd " --aux-dir=$auxdir"
3011 if test -n "$inctests"; then
3012 func_append actioncmd " --with-tests"
3014 if test -n "$incobsolete"; then
3015 func_append actioncmd " --with-obsolete"
3017 for module in $avoidlist; do
3018 func_append actioncmd " --avoid=$module"
3020 if test -n "$lgpl"; then
3021 if test "$lgpl" = yes; then
3022 func_append actioncmd " --lgpl"
3024 func_append actioncmd " --lgpl=$lgpl"
3027 if test -n "$makefile_name"; then
3028 func_append actioncmd " --makefile-name=$makefile_name"
3030 if test "$libtool" = true; then
3031 func_append actioncmd " --libtool"
3033 func_append actioncmd " --no-libtool"
3035 func_append actioncmd " --macro-prefix=$macro_prefix"
3036 if test -n "$po_domain"; then
3037 func_append actioncmd " --po-domain=$po_domain"
3039 if test -n "$vc_files"; then
3040 if test "$vc_files" = true; then
3041 func_append actioncmd " --vc-files"
3043 func_append actioncmd " --no-vc-files"
3046 func_append actioncmd " `echo $specified_modules`"
3048 # Default the makefile name to Makefile.am.
3049 if test -n "$makefile_name"; then
3050 makefile_am=$makefile_name
3052 makefile_am=Makefile.am
3055 # Create normal Makefile.ams.
3058 # Setup list of Makefile.am edits that are to be performed afterwards.
3059 # Some of these edits apply to files that we will generate; others are
3060 # under the responsibility of the developer.
3062 # func_note_Makefile_am_edit dir var value
3063 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3065 func_note_Makefile_am_edit ()
3067 makefile_am_edits=`expr $makefile_am_edits + 1`
3068 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3069 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3070 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3072 if test "$makefile_am" = Makefile.am; then
3073 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3074 sourcebase_base=`basename "$sourcebase"`
3075 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3077 if test -n "$pobase"; then
3078 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3079 pobase_base=`basename "$pobase"`
3080 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3082 if test -n "$inctests"; then
3083 if test "$makefile_am" = Makefile.am; then
3084 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3085 testsbase_base=`basename "$testsbase"`
3086 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3089 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3091 # Find the first parent directory of $m4base that contains or will contain
3093 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3095 sed_butlast='s,[^/][^/]*//*$,,'
3096 dir1="${m4base}/"; dir2=""
3097 while test -n "$dir1" \
3098 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3099 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3100 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3101 || { test -n "$inctests" \
3102 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3103 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3104 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3105 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3107 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3110 # Create library makefile.
3111 func_dest_tmpfilename $sourcebase/$makefile_am
3112 destfile="$sourcebase/$makefile_am"
3113 modules="$main_modules"
3114 func_emit_lib_Makefile_am > "$tmpfile"
3115 if test -f "$destdir"/$sourcebase/$makefile_am; then
3116 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3120 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3121 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3122 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3124 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3130 echo "Creating $sourcebase/$makefile_am"
3131 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3133 echo "Create $sourcebase/$makefile_am"
3136 func_append added_files "$sourcebase/$makefile_am$nl"
3139 # Create po/ directory.
3140 if test -n "$pobase"; then
3141 # Create po makefile and auxiliary files.
3142 for file in Makefile.in.in remove-potcdate.sin; do
3143 func_dest_tmpfilename $pobase/$file
3144 func_lookup_file build-aux/po/$file
3145 cat "$lookedup_file" > "$tmpfile"
3146 if test -f "$destdir"/$pobase/$file; then
3147 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3151 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3152 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3153 mv -f "$tmpfile" "$destdir"/$pobase/$file
3155 echo "Update $pobase/$file (backup in $pobase/$file~)"
3161 echo "Creating $pobase/$file"
3162 mv -f "$tmpfile" "$destdir"/$pobase/$file
3164 echo "Create $pobase/$file"
3167 func_append added_files "$pobase/$file$nl"
3170 # Create po makefile parameterization, part 1.
3171 func_dest_tmpfilename $pobase/Makevars
3172 func_emit_po_Makevars > "$tmpfile"
3173 if test -f "$destdir"/$pobase/Makevars; then
3174 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3178 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3179 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3180 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3182 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3188 echo "Creating $pobase/Makevars"
3189 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3191 echo "Create $pobase/Makevars"
3194 func_append added_files "$pobase/Makevars$nl"
3196 # Create po makefile parameterization, part 2.
3197 func_dest_tmpfilename $pobase/POTFILES.in
3198 func_emit_po_POTFILES_in > "$tmpfile"
3199 if test -f "$destdir"/$pobase/POTFILES.in; then
3200 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3204 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3205 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3206 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3208 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3214 echo "Creating $pobase/POTFILES.in"
3215 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3217 echo "Create $pobase/POTFILES.in"
3220 func_append added_files "$pobase/POTFILES.in$nl"
3223 TP_URL="http://translationproject.org/latest/"
3224 TP_RSYNC_URI="translationproject.org::tp/latest/"
3226 echo "Fetching gnulib PO files from $TP_URL"
3227 (cd "$destdir"/$pobase \
3228 && { # Prefer rsync over wget if it is available, since it consumes
3229 # less network bandwidth, due to compression.
3230 if type rsync 2>/dev/null | grep / > /dev/null; then
3231 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3233 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3238 echo "Fetch gnulib PO files from $TP_URL"
3240 # Create po/LINGUAS.
3242 func_dest_tmpfilename $pobase/LINGUAS
3243 (cd "$destdir"/$pobase \
3244 && { echo '# Set of available languages.'
3245 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3248 if test -f "$destdir"/$pobase/LINGUAS; then
3249 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3252 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3253 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3254 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3257 echo "Creating $pobase/LINGUAS"
3258 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3259 func_append added_files "$pobase/LINGUAS$nl"
3262 if test -f "$destdir"/$pobase/LINGUAS; then
3263 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3265 echo "Create $pobase/LINGUAS"
3270 # Create m4/gnulib-cache.m4.
3271 func_dest_tmpfilename $m4base/gnulib-cache.m4
3273 func_emit_copyright_notice
3275 echo "# This file represents the specification of how gnulib-tool is used."
3276 echo "# It acts as a cache: It is written and read by gnulib-tool."
3277 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3278 echo "# like the configure.ac and various Makefile.am files."
3281 echo "# Specification in the form of a command-line invocation:"
3284 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3285 # Store the local_gnulib_dir relative to destdir.
3286 case "$local_gnulib_dir" in
3288 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3291 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3293 # destdir, local_gnulib_dir are both relative.
3294 func_relativize "$destdir" "$local_gnulib_dir"
3295 relative_local_gnulib_dir="$reldir" ;;
3298 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3300 echo "$specified_modules" | sed 's/^/ /g'
3302 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3303 echo "gl_AVOID([$avoidlist])"
3304 echo "gl_SOURCE_BASE([$sourcebase])"
3305 echo "gl_M4_BASE([$m4base])"
3306 echo "gl_PO_BASE([$pobase])"
3307 echo "gl_DOC_BASE([$docbase])"
3308 echo "gl_TESTS_BASE([$testsbase])"
3309 test -z "$inctests" || echo "gl_WITH_TESTS"
3310 echo "gl_LIB([$libname])"
3311 if test -n "$lgpl"; then
3312 if test "$lgpl" = yes; then
3315 echo "gl_LGPL([$lgpl])"
3318 echo "gl_MAKEFILE_NAME([$makefile_name])"
3319 if test "$libtool" = true; then
3322 echo "gl_MACRO_PREFIX([$macro_prefix])"
3323 echo "gl_PO_DOMAIN([$po_domain])"
3324 if test -n "$vc_files"; then
3325 echo "gl_VC_FILES([$vc_files])"
3328 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3329 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3333 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3334 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3335 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3337 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3341 echo "# gnulib-cache.m4 ends here"
3348 echo "Creating $m4base/gnulib-cache.m4"
3349 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3351 echo "Create $m4base/gnulib-cache.m4"
3357 # Create m4/gnulib-comp.m4.
3358 func_dest_tmpfilename $m4base/gnulib-comp.m4
3360 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3361 func_emit_copyright_notice
3363 echo "# This file represents the compiled summary of the specification in"
3364 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3365 echo "# to be invoked from configure.ac."
3366 echo "# In projects using CVS, this file can be treated like other built files."
3369 echo "# This macro should be invoked from $configure_ac, in the section"
3370 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3371 echo "# any checks for libraries, header files, types and library functions."
3372 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3374 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3375 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3376 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3377 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3378 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3379 if test -n "$uses_subdirs"; then
3380 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3382 for module in $final_modules; do
3384 if test -n "$module"; then
3385 func_get_autoconf_early_snippet "$module"
3388 | sed -e '/^$/d;' -e 's/^/ /'
3391 echo "# This macro should be invoked from $configure_ac, in the section"
3392 echo "# \"Check for header files, types and library functions\"."
3393 echo "AC_DEFUN([${macro_prefix}_INIT],"
3395 if test "$libtool" = true; then
3396 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3397 echo " gl_cond_libtool=true"
3399 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3400 echo " gl_cond_libtool=false"
3402 echo " gl_ltlibdeps="
3404 if test "$auxdir" != "build-aux"; then
3405 sed_replace_build_aux='
3407 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3408 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3412 sed_replace_build_aux="$sed_noop"
3414 func_emit_initmacro_start $macro_prefix
3415 echo " gl_source_base='$sourcebase'"
3416 for module in $main_modules; do
3418 if test -n "$module"; then
3419 func_get_autoconf_snippet "$module" \
3420 | sed -e '/^$/d;' -e 's/^/ /' \
3421 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3422 -e "$sed_replace_build_aux"
3423 if test "$module" = 'alloca' && test "$libtool" = true; then
3424 echo 'changequote(,)dnl'
3425 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3426 echo 'changequote([, ])dnl'
3427 echo 'AC_SUBST([LTALLOCA])'
3431 func_emit_initmacro_end $macro_prefix
3432 echo " gltests_libdeps="
3433 echo " gltests_ltlibdeps="
3434 func_emit_initmacro_start ${macro_prefix}tests
3435 echo " gl_source_base='$testsbase'"
3436 for module in $testsrelated_modules; do
3438 if test -n "$module"; then
3439 func_get_autoconf_snippet "$module" \
3440 | sed -e '/^$/d;' -e 's/^/ /' \
3441 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3442 -e "$sed_replace_build_aux" \
3443 -e 's/\$gl_cond_libtool/false/g' \
3444 -e 's/gl_libdeps/gltests_libdeps/g' \
3445 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3448 func_emit_initmacro_end ${macro_prefix}tests
3449 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3450 # created using libtool, because libtool already handles the dependencies.
3451 if test "$libtool" != true; then
3452 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3453 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3454 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3455 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3456 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3458 if $use_libtests; then
3459 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3460 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3463 func_emit_initmacro_done $macro_prefix $sourcebase
3464 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3466 echo "# This macro records the list of files which have been installed by"
3467 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3468 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3469 echo "$files" | sed -e 's,^, ,'
3472 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3473 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3477 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3478 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3479 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3481 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3485 echo "# gnulib-comp.m4 ends here"
3492 echo "Creating $m4base/gnulib-comp.m4"
3493 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3495 echo "Create $m4base/gnulib-comp.m4"
3501 if test -n "$inctests"; then
3502 # Create tests makefile.
3503 func_dest_tmpfilename $testsbase/$makefile_am
3504 destfile="$testsbase/$makefile_am"
3505 modules="$testsrelated_modules"
3506 func_emit_tests_Makefile_am > "$tmpfile"
3507 if test -f "$destdir"/$testsbase/$makefile_am; then
3508 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3512 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3513 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3514 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3516 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3522 echo "Creating $testsbase/$makefile_am"
3523 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3525 echo "Create $testsbase/$makefile_am"
3528 func_append added_files "$testsbase/$makefile_am$nl"
3532 if test "$vc_files" != false; then
3533 # Update the .cvsignore and .gitignore files.
3534 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3535 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3536 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3537 echo "$m4base/|A|gnulib-comp.m4"
3538 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3539 { # Rearrange file descriptors. Needed because "while ... done < ..."
3540 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3541 exec 5<&0 < "$tmp"/fileset-changes
3542 func_update_ignorelist ()
3545 if test "$ignore" = .gitignore; then
3546 # In a .gitignore file, "foo" applies to the current directory and all
3547 # subdirectories, whereas "/foo" applies to the current directory only.
3550 doubly_escaped_anchor='\\/'
3554 doubly_escaped_anchor=''
3556 if test -f "$destdir/$dir$ignore"; then
3557 if test -n "$dir_added" || test -n "$dir_removed"; then
3558 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3560 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3561 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
3562 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3563 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
3565 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3567 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3568 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3569 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3570 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,\$/d,' < "$tmp"/ignore-removed; fi
3571 } > "$tmp"/sed-ignore-removed
3572 { cat "$destdir/$dir$ignore"~
3573 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3574 } | sed -f "$tmp"/sed-ignore-removed \
3575 > "$destdir/$dir$ignore"
3577 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3582 if test -n "$dir_added"; then
3584 echo "Creating $destdir/$dir$ignore"
3586 if test "$ignore" = .cvsignore; then
3588 # Automake generates Makefile rules that create .dirstamp files.
3591 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3592 } > "$destdir/$dir$ignore"
3594 echo "Create $destdir/$dir$ignore"
3604 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3605 func_update_ignorelist .cvsignore
3607 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3608 func_update_ignorelist .gitignore
3615 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3616 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3617 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3618 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3619 if test "$next_dir" != "$last_dir"; then
3620 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3621 last_dir="$next_dir"
3626 A) func_append last_dir_added "$file$nl";;
3627 R) func_append last_dir_removed "$file$nl";;
3630 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3637 echo "You may need to add #include directives for the following .h files."
3638 # Intersect $specified_modules and $main_modules
3639 # (since $specified_modules is not necessarily of subset of $main_modules
3640 # - some may have been skipped through --avoid, and since the elements of
3641 # $main_modules but not in $specified_modules can go away without explicit
3642 # notice - through changes in the module dependencies).
3643 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3644 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3645 # First the #include <...> directives without #ifs, sorted for convenience,
3646 # then the #include "..." directives without #ifs, sorted for convenience,
3647 # then the #include directives that are surrounded by #ifs. Not sorted.
3648 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3649 include_directive=`func_get_include_directive "$module"`
3650 case "$nl$include_directive" in
3652 echo "$include_directive" 1>&5
3655 echo "$include_directive" | grep -v 'include "' 1>&6
3656 echo "$include_directive" | grep 'include "' 1>&7
3659 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3661 LC_ALL=C sort -u "$tmp"/include-angles
3662 LC_ALL=C sort -u "$tmp"/include-quotes
3663 cat "$tmp"/include-if
3664 ) | sed -e '/^$/d' -e 's/^/ /'
3665 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3667 for module in $main_modules; do
3668 func_get_link_directive "$module"
3670 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3671 if test `wc -l < "$tmp"/link` != 0; then
3673 echo "You may need to use the following Makefile variables when linking."
3674 echo "Use them in <program>_LDADD when linking a program, or"
3675 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3681 echo "Don't forget to"
3682 if test "$makefile_am" = Makefile.am; then
3683 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3685 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3687 if test -n "$pobase"; then
3688 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3690 if test -n "$inctests"; then
3691 if test "$makefile_am" = Makefile.am; then
3692 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3694 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3698 while test $edit != $makefile_am_edits; do
3699 edit=`expr $edit + 1`
3700 eval dir=\"\$makefile_am_edit${edit}_dir\"
3701 eval var=\"\$makefile_am_edit${edit}_var\"
3702 eval val=\"\$makefile_am_edit${edit}_val\"
3703 if test -n "$var"; then
3704 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
3707 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3708 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3711 # func_create_testdir testdir modules
3713 # - local_gnulib_dir from --local-dir
3714 # - auxdir directory relative to destdir where to place build aux files
3715 func_create_testdir ()
3719 if test -z "$modules"; then
3720 # All modules together.
3721 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3722 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3723 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3724 modules=`func_all_modules`
3725 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3727 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3729 # Check that the license of every module is consistent with the license of
3731 saved_modules="$modules"
3732 saved_inctests="$inctests"
3733 # When computing transitive closures, don't consider $module to depend on
3734 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3735 # on GPL modules - therefore we don't want a warning in this case.
3737 for requested_module in $saved_modules; do
3738 requested_license=`func_get_license "$requested_module"`
3739 if test "$requested_license" != GPL; then
3740 # Here we use func_modules_transitive_closure, not just
3741 # func_get_dependencies, so that we also detect weird situations like
3742 # an LGPL module which depends on a GPLed build tool module which depends
3744 modules="$requested_module"
3745 func_modules_transitive_closure
3746 for module in $modules; do
3747 license=`func_get_license "$module"`
3749 'GPLed build tool') ;;
3750 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3752 case "$requested_license" in
3755 GPLv2+ | LGPLv2+) ;;
3756 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3762 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3768 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3777 modules="$saved_modules"
3778 inctests="$saved_inctests"
3780 # Subdirectory names.
3790 # Determine final module list.
3791 func_modules_transitive_closure
3792 if test $verbose -ge 0; then
3793 echo "Module list with included dependencies:"
3794 echo "$modules" | sed -e 's/^/ /'
3797 # Add the dummy module if needed.
3798 func_modules_add_dummy
3800 # Show banner notice of every module.
3803 # Determine final file list.
3804 func_modules_to_filelist
3805 if test $verbose -ge 0; then
3807 echo "$files" | sed -e 's/^/ /'
3810 sed_rewrite_files="\
3811 s,^build-aux/,$auxdir/,
3813 s,^lib/,$sourcebase/,
3815 s,^tests/,$testsbase/,
3818 # Create directories.
3819 for f in $files; do echo $f; done \
3820 | sed -e "$sed_rewrite_files" \
3821 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3822 | LC_ALL=C sort -u \
3824 { # Rearrange file descriptors. Needed because "while ... done < ..."
3825 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3826 exec 5<&0 < "$tmp"/dirs
3828 mkdir -p "$testdir/$d"
3833 # Copy files or make symbolic links.
3835 for f in $files; do echo $f; done \
3836 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3839 { # Rearrange file descriptors. Needed because "while ... done < ..."
3840 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3841 exec 5<&0 < "$tmp"/files
3843 func_lookup_file "$f"
3844 if test -n "$lookedup_tmp"; then
3845 cp -p "$lookedup_file" "$testdir/$g"
3847 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3848 if { test -n "$symbolic" \
3849 || { test -n "$lsymbolic" \
3850 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3851 func_ln "$lookedup_file" "$testdir/$g"
3853 cp -p "$lookedup_file" "$testdir/$g"
3860 # Create Makefile.ams that are for testing.
3863 # No special edits are needed.
3866 # Create $sourcebase/Makefile.am.
3867 mkdir -p "$testdir/$sourcebase"
3868 destfile="$sourcebase/Makefile.am"
3869 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3870 any_uses_subdirs="$uses_subdirs"
3872 # Create $m4base/Makefile.am.
3873 mkdir -p "$testdir/$m4base"
3874 (echo "## Process this file with automake to produce Makefile.in."
3880 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3883 ) > "$testdir/$m4base/Makefile.am"
3885 subdirs="$sourcebase $m4base"
3886 subdirs_with_configure_ac=""
3888 if false && test -f "$testdir"/$m4base/gettext.m4; then
3889 # Avoid stupid error message from automake:
3890 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3891 mkdir -p "$testdir/po"
3892 (echo "## Process this file with automake to produce Makefile.in."
3893 ) > "$testdir/po/Makefile.am"
3894 func_append subdirs " po"
3897 if test -n "$inctests"; then
3898 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3899 # Viewed from the $testsbase subdirectory, $auxdir is different.
3900 saved_auxdir="$auxdir"
3901 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3902 # Create $testsbase/Makefile.am.
3904 destfile="$testsbase/Makefile.am"
3905 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3906 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3907 # Create $testsbase/configure.ac.
3908 (echo "# Process this file with autoconf to produce a configure script."
3909 echo "AC_INIT([dummy], [0])"
3910 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3911 echo "AM_INIT_AUTOMAKE"
3913 echo "AM_CONFIG_HEADER([config.h])"
3916 echo "AC_PROG_INSTALL"
3917 echo "AC_PROG_MAKE_SET"
3918 echo "AC_PROG_RANLIB"
3920 for module in $modules; do
3922 if test -n "$module"; then
3924 gnumakefile | maintainer-makefile)
3925 # These modules are meant to be used only in the top-level directory.
3928 func_get_autoconf_early_snippet "$module"
3933 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3934 if test "$libtool" = true; then
3935 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3936 echo "gl_cond_libtool=true"
3938 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3939 echo "gl_cond_libtool=false"
3941 echo "gl_ltlibdeps="
3943 # Wrap the set of autoconf snippets into an autoconf macro that is then
3944 # invoked. This is needed because autoconf does not support AC_REQUIRE
3946 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3947 # but we want the AC_REQUIRE to have its normal meaning (provide one
3948 # expansion of the required macro before the current point, and only one
3950 echo "AC_DEFUN([gl_INIT], ["
3951 sed_replace_build_aux='
3953 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3954 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3957 func_emit_initmacro_start $macro_prefix
3958 # We don't have explicit ordering constraints between the various
3959 # autoconf snippets. It's cleanest to put those of the library before
3960 # those of the tests.
3961 echo "gl_source_base='../$sourcebase'"
3962 for module in $modules; do
3963 func_verify_nontests_module
3964 if test -n "$module"; then
3966 gnumakefile | maintainer-makefile)
3967 # These modules are meant to be used only in the top-level directory.
3970 func_get_autoconf_snippet "$module" \
3971 | sed -e "$sed_replace_build_aux"
3976 echo "gl_source_base='.'"
3977 for module in $modules; do
3978 func_verify_tests_module
3979 if test -n "$module"; then
3980 func_get_autoconf_snippet "$module" \
3981 | sed -e "$sed_replace_build_aux"
3984 func_emit_initmacro_end $macro_prefix
3985 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3986 # created using libtool, because libtool already handles the dependencies.
3987 if test "$libtool" != true; then
3988 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3989 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3990 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3991 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3992 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3995 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3999 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4000 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4001 echo "AH_TOP([#include \"../config.h\"])"
4003 echo "AC_OUTPUT([Makefile])"
4004 ) > "$testdir/$testsbase/configure.ac"
4005 auxdir="$saved_auxdir"
4006 func_append subdirs " $testsbase"
4007 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4010 # Create Makefile.am.
4011 (echo "## Process this file with automake to produce Makefile.in."
4013 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4015 echo "SUBDIRS = $subdirs"
4017 echo "ACLOCAL_AMFLAGS = -I $m4base"
4018 ) > "$testdir/Makefile.am"
4020 # Create configure.ac.
4021 (echo "# Process this file with autoconf to produce a configure script."
4022 echo "AC_INIT([dummy], [0])"
4023 if test "$auxdir" != "."; then
4024 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4026 echo "AM_INIT_AUTOMAKE"
4028 echo "AM_CONFIG_HEADER([config.h])"
4031 echo "AC_PROG_INSTALL"
4032 echo "AC_PROG_MAKE_SET"
4034 echo "# For autobuild."
4035 echo "AC_CANONICAL_BUILD"
4036 echo "AC_CANONICAL_HOST"
4038 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4039 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4040 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4041 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4043 echo "AC_PROG_RANLIB"
4045 if test -n "$any_uses_subdirs"; then
4046 echo "AM_PROG_CC_C_O"
4049 for module in $modules; do
4050 func_verify_nontests_module
4051 if test -n "$module"; then
4052 func_get_autoconf_early_snippet "$module"
4055 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4056 if test "$libtool" = true; then
4057 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4058 echo "gl_cond_libtool=true"
4060 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4061 echo "gl_cond_libtool=false"
4063 echo "gl_ltlibdeps="
4065 # Wrap the set of autoconf snippets into an autoconf macro that is then
4066 # invoked. This is needed because autoconf does not support AC_REQUIRE
4068 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4069 # but we want the AC_REQUIRE to have its normal meaning (provide one
4070 # expansion of the required macro before the current point, and only one
4072 echo "AC_DEFUN([gl_INIT], ["
4073 if test "$auxdir" != "build-aux"; then
4074 sed_replace_build_aux='
4076 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4077 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4081 sed_replace_build_aux="$sed_noop"
4083 func_emit_initmacro_start $macro_prefix
4084 echo "gl_source_base='$sourcebase'"
4085 for module in $modules; do
4086 func_verify_nontests_module
4087 if test -n "$module"; then
4088 func_get_autoconf_snippet "$module" \
4089 | sed -e "$sed_replace_build_aux"
4092 func_emit_initmacro_end $macro_prefix
4093 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4094 # created using libtool, because libtool already handles the dependencies.
4095 if test "$libtool" != true; then
4096 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4097 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4098 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4099 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4100 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4103 func_emit_initmacro_done $macro_prefix $sourcebase
4107 if test -n "$subdirs_with_configure_ac"; then
4108 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4110 makefiles="Makefile"
4111 for d in $subdirs; do
4112 # For subdirs that have a configure.ac by their own, it's the subdir's
4113 # configure.ac which creates the subdir's Makefile.am, not this one.
4114 case " $subdirs_with_configure_ac " in
4116 *) func_append makefiles " $d/Makefile" ;;
4119 echo "AC_OUTPUT([$makefiles])"
4120 ) > "$testdir/configure.ac"
4122 # Create autogenerated files.
4124 # Do not use "${AUTORECONF} --force --install", because it may invoke
4125 # autopoint, which brings in older versions of some of our .m4 files.
4126 if test -f $m4base/gettext.m4; then
4127 func_execute_command ${AUTOPOINT} --force || func_exit 1
4128 for f in $m4base/*.m4~; do
4130 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4134 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4135 if ! test -d build-aux; then
4136 func_execute_command mkdir build-aux || func_exit 1
4138 func_execute_command ${AUTOCONF} || func_exit 1
4139 func_execute_command ${AUTOHEADER} || func_exit 1
4140 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4142 if test -n "$inctests"; then
4143 # Create autogenerated files.
4144 (cd "$testdir/$testsbase" || func_exit 1
4145 # Do not use "${AUTORECONF} --force --install", because it may invoke
4146 # autopoint, which brings in older versions of some of our .m4 files.
4147 if test -f ../$m4base/gettext.m4; then
4148 func_execute_command ${AUTOPOINT} --force || func_exit 1
4149 for f in ../$m4base/*.m4~; do
4151 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4155 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4156 if ! test -d ../build-aux; then
4157 func_execute_command mkdir ../build-aux
4159 func_execute_command ${AUTOCONF} || func_exit 1
4160 func_execute_command ${AUTOHEADER} || func_exit 1
4161 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4164 # Need to run configure and make once, to create built files that are to be
4165 # distributed (such as getdate.c).
4166 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4167 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4168 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4169 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4170 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4171 # such $(FOO_H) because they don't refer to distributed files.
4172 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4173 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4174 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4175 | sed -e "$sed_remove_make_variables"`
4176 distributed_built_sources=`for file in $built_sources; do
4177 case "$cleaned_files" in
4182 if test -n "$distributed_built_sources"; then
4184 ./configure || func_exit 1
4186 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4187 make built_sources || func_exit 1
4189 make distclean || func_exit 1
4194 # func_create_megatestdir megatestdir allmodules
4196 # - local_gnulib_dir from --local-dir
4197 # - auxdir directory relative to destdir where to place build aux files
4198 func_create_megatestdir ()
4202 if test -z "$allmodules"; then
4203 allmodules=`func_all_modules`
4207 # First, all modules one by one.
4208 for onemodule in $allmodules; do
4209 func_create_testdir "$megatestdir/$onemodule" $onemodule
4210 func_append megasubdirs "$onemodule "
4212 # Then, all modules all together.
4213 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4214 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
4215 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
4216 func_create_testdir "$megatestdir/ALL" "$allmodules"
4217 func_append megasubdirs "ALL"
4220 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4221 vc_witness="$gnulib_dir/CVS/Entries"; \
4223 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4225 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4226 | sed -e 's,January,01,' -e 's,Jan,01,' \
4227 -e 's,February,02,' -e 's,Feb,02,' \
4228 -e 's,March,03,' -e 's,Mar,03,' \
4229 -e 's,April,04,' -e 's,Apr,04,' \
4231 -e 's,June,06,' -e 's,Jun,06,' \
4232 -e 's,July,07,' -e 's,Jul,07,' \
4233 -e 's,August,08,' -e 's,Aug,08,' \
4234 -e 's,September,09,' -e 's,Sep,09,' \
4235 -e 's,October,10,' -e 's,Oct,10,' \
4236 -e 's,November,11,' -e 's,Nov,11,' \
4237 -e 's,December,12,' -e 's,Dec,12,' \
4238 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4239 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4241 echo "CVSDATE=$cvsdate"
4242 echo "test -d logs || mkdir logs"
4243 echo "for module in $megasubdirs; do"
4244 echo " echo \"Working on module \$module...\""
4245 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4246 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4249 echo " : autobuild project... \$module"
4250 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4251 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4252 echo " : autobuild hostname... \`hostname\`"
4253 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
4255 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4257 ) > "$megatestdir/do-autobuild"
4258 chmod a+x "$megatestdir/do-autobuild"
4260 # Create Makefile.am.
4261 (echo "## Process this file with automake to produce Makefile.in."
4263 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4265 echo "SUBDIRS = $megasubdirs"
4267 echo "EXTRA_DIST = do-autobuild"
4268 ) > "$megatestdir/Makefile.am"
4270 # Create configure.ac.
4271 (echo "# Process this file with autoconf to produce a configure script."
4272 echo "AC_INIT([dummy], [0])"
4273 if test "$auxdir" != "."; then
4274 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4276 echo "AM_INIT_AUTOMAKE"
4278 echo "AC_PROG_MAKE_SET"
4280 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4281 echo "AC_OUTPUT([Makefile])"
4282 ) > "$megatestdir/configure.ac"
4284 # Create autogenerated files.
4286 # Do not use "${AUTORECONF} --install", because autoreconf operates
4287 # recursively, but the subdirectories are already finished, therefore
4288 # calling autoreconf here would only waste lots of CPU time.
4289 func_execute_command ${ACLOCAL} || func_exit 1
4290 func_execute_command mkdir build-aux
4291 func_execute_command ${AUTOCONF} || func_exit 1
4292 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4298 func_fatal_error "no mode specified" ;;
4307 if test -z "$destdir"; then
4310 test -d "$destdir" \
4311 || func_fatal_error "destination directory does not exist: $destdir"
4313 # Prefer configure.ac to configure.in.
4314 if test -f "$destdir"/configure.ac; then
4315 configure_ac="$destdir/configure.ac"
4317 if test -f "$destdir"/configure.in; then
4318 configure_ac="$destdir/configure.in"
4320 func_fatal_error "cannot find $destdir/configure.ac"
4324 # Analyze configure.ac.
4326 guessed_libtool=false
4331 /AC_CONFIG_AUX_DIR/ {
4332 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
4334 /A[CM]_PROG_LIBTOOL/ {
4335 s,^.*$,guessed_libtool=true,p
4337 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4339 if test -z "$auxdir"; then
4340 auxdir="$guessed_auxdir"
4343 # Determine where to apply func_import.
4344 if test -n "$m4base"; then
4345 # Apply func_import to a particular gnulib directory.
4346 # Any number of additional modules can be given.
4347 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4348 # First use of gnulib in the given m4base.
4349 test -n "$supplied_libname" || supplied_libname=true
4350 test -n "$sourcebase" || sourcebase="lib"
4351 test -n "$docbase" || docbase="doc"
4352 test -n "$testsbase" || testsbase="tests"
4353 test -n "$macro_prefix" || macro_prefix="gl"
4357 # Apply func_import to all gnulib directories.
4358 # To get this list of directories, look at Makefile.am. (Not at
4359 # configure, because it may be omitted from CVS. Also, don't run
4360 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4363 if test -f "$destdir"/Makefile.am; then
4364 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4366 for arg in $aclocal_amflags; do
4367 if test -n "$m4dir_is_next"; then
4368 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4372 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4373 func_append m4dirs " $arg"
4374 m4dirs_count=`expr $m4dirs_count + 1`
4380 if test "X$arg" = "X-I"; then
4388 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4389 if test -f "$destdir"/aclocal.m4; then
4390 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4391 sedexpr2='s,^[^/]*$,.,'
4392 sedexpr3='s,/[^/]*$,,'
4393 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4394 m4dirs_count=`echo "$m4dirs" | wc -l`
4397 if test $m4dirs_count = 0; then
4398 # First use of gnulib in a package.
4399 # Any number of additional modules can be given.
4400 test -n "$supplied_libname" || supplied_libname=true
4401 test -n "$sourcebase" || sourcebase="lib"
4403 test -n "$docbase" || docbase="doc"
4404 test -n "$testsbase" || testsbase="tests"
4405 test -n "$macro_prefix" || macro_prefix="gl"
4408 if test $m4dirs_count = 1; then
4409 # There's only one use of gnulib here. Assume the user means it.
4410 # Any number of additional modules can be given.
4411 for m4base in $m4dirs; do
4415 # Ambiguous - guess what the user meant.
4416 if test $# = 0; then
4417 # No further arguments. Guess the user wants to update all of them.
4418 for m4base in $m4dirs; do
4419 # Perform func_import in a subshell, so that variable values
4421 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
4422 # pobase, docbase, testsbase, inctests, libname, lgpl,
4423 # makefile_name, libtool, macro_prefix, po_domain, vc_files
4424 # don't propagate from one directory to another.
4425 (func_import) || func_exit 1
4429 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4437 if test -z "$destdir"; then
4438 func_fatal_error "please specify --dir option"
4441 test -d "$destdir" \
4442 || func_fatal_error "could not create destination directory"
4443 test -n "$auxdir" || auxdir="build-aux"
4444 func_create_testdir "$destdir" "$*"
4447 create-megatestdir )
4448 if test -z "$destdir"; then
4449 func_fatal_error "please specify --dir option"
4451 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4452 test -n "$auxdir" || auxdir="build-aux"
4453 func_create_megatestdir "$destdir" "$*"
4457 test -n "$destdir" || destdir=testdir$$
4458 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4459 test -n "$auxdir" || auxdir="build-aux"
4460 func_create_testdir "$destdir" "$*"
4464 ../configure || func_exit 1
4466 make check || func_exit 1
4467 make distclean || func_exit 1
4468 remaining=`find . -type f -print`
4469 if test -n "$remaining"; then
4470 echo "Remaining files:" $remaining 1>&2
4471 echo "gnulib-tool: *** Stop." 1>&2
4480 test -n "$destdir" || destdir=testdir$$
4481 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4482 test -n "$auxdir" || auxdir="build-aux"
4483 func_create_megatestdir "$destdir" "$*"
4491 remaining=`find . -type f -print`
4492 if test -n "$remaining"; then
4493 echo "Remaining files:" $remaining 1>&2
4494 echo "gnulib-tool: *** Stop." 1>&2
4502 extract-description )
4506 if test -n "$module"; then
4507 func_get_description "$module"
4516 if test -n "$module"; then
4517 func_get_status "$module"
4526 if test -n "$module"; then
4527 func_get_notice "$module"
4536 if test -n "$module"; then
4537 func_get_filelist "$module"
4542 extract-dependencies )
4546 if test -n "$module"; then
4547 func_get_dependencies "$module"
4552 extract-autoconf-snippet )
4556 if test -n "$module"; then
4557 func_get_autoconf_snippet "$module"
4562 extract-automake-snippet )
4566 if test -n "$module"; then
4567 func_get_automake_snippet "$module"
4572 extract-include-directive )
4576 if test -n "$module"; then
4577 func_get_include_directive "$module"
4582 extract-link-directive )
4586 if test -n "$module"; then
4587 func_get_link_directive "$module"
4596 if test -n "$module"; then
4597 func_get_license "$module"
4602 extract-maintainer )
4606 if test -n "$module"; then
4607 func_get_maintainer "$module"
4612 extract-tests-module )
4616 if test -n "$module"; then
4617 func_get_tests_module "$module"
4623 func_fatal_error "unknown operation mode --$mode" ;;
4627 # Undo the effect of the previous 'trap' command. Some shellology:
4628 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4629 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4630 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4631 # 128 + signal number and is set before the trap-registered command is run.
4633 trap 'func_exit $?' 1 2 3 13 15
4638 # indent-tabs-mode: nil
4639 # whitespace-check-buffer-indent: nil