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
70 # into makefiles. And do it only for sed versions 4.2 or newer,
71 # because "sed --posix" is buggy in GNU sed 4.1.5, see
72 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
73 if (alias) > /dev/null 2>&1 \
74 && echo | sed --posix -e d >/dev/null 2>&1 \
75 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
76 [1-3]* | 4.[01]*) false;; \
80 # Define sed as an alias.
81 # It is not always possible to use aliases. Aliases are guaranteed to work
82 # if the executing shell is bash and either it is invoked as /bin/sh or
83 # is a version >= 2.0, supporting shopt. This is the common case.
84 # Two other approaches (use of a variable $sed or of a function func_sed
85 # instead of an alias) require massive, fragile code changes.
86 # An other approach (use of function sed) requires `which sed` - but
87 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
88 if test -n "$BASH_VERSION"; then
89 shopt -s expand_aliases >/dev/null 2>&1
91 alias sed='sed --posix'
94 # sed_noop is a sed expression that does nothing.
95 # An empty expression does not work with the native 'sed' on AIX 6.1.
99 # outputs to stdout the --help usage message.
103 Usage: gnulib-tool --list
104 gnulib-tool --import [module1 ... moduleN]
106 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
107 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
108 gnulib-tool --test --dir=directory module1 ... moduleN
109 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
110 gnulib-tool --extract-description module
111 gnulib-tool --extract-status module
112 gnulib-tool --extract-notice module
113 gnulib-tool --extract-filelist module
114 gnulib-tool --extract-dependencies module
115 gnulib-tool --extract-autoconf-snippet module
116 gnulib-tool --extract-automake-snippet module
117 gnulib-tool --extract-include-directive module
118 gnulib-tool --extract-link-directive module
119 gnulib-tool --extract-license module
120 gnulib-tool --extract-maintainer module
121 gnulib-tool --extract-tests-module module
124 --list print the available module names
125 --import import the given modules into the current package;
126 if no modules are specified, update the current
127 package from the current gnulib
128 --update update the current package, restore files omitted
130 --create-testdir create a scratch package with the given modules
131 --create-megatestdir create a mega scratch package with the given modules
132 one by one and all together
133 --test test the combination of the given modules
134 (recommended to use CC=\"gcc -Wall\" here)
135 --megatest test the given modules one by one and all together
136 (recommended to use CC=\"gcc -Wall\" here)
137 --extract-description extract the description
138 --extract-status extract the status (obsolete or not)
139 --extract-notice extract the notice or banner
140 --extract-filelist extract the list of files
141 --extract-dependencies extract the dependencies
142 --extract-autoconf-snippet extract the snippet for configure.ac
143 --extract-automake-snippet extract the snippet for library makefile
144 --extract-include-directive extract the #include directive
145 --extract-link-directive extract the linker directive
146 --extract-license report the license terms of the source files
148 --extract-maintainer report the maintainer(s) inside gnulib
149 --extract-tests-module report the unit test module, if it exists
152 --dir=DIRECTORY Specify the target directory.
153 For --import, this specifies where your
154 configure.ac can be found. Defaults to current
156 --local-dir=DIRECTORY Specify a local override directory where to look
157 up files before looking in gnulib's directory.
158 --verbose Increase verbosity. May be repeated.
159 --quiet Decrease verbosity. May be repeated.
161 Options for --import:
162 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
163 --source-base=DIRECTORY
164 Directory relative to --dir where source code is
165 placed (default \"lib\").
166 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
167 placed (default \"m4\").
168 --po-base=DIRECTORY Directory relative to --dir where *.po files are
169 placed (default \"po\").
170 --doc-base=DIRECTORY Directory relative to --dir where doc files are
171 placed (default \"doc\").
172 --tests-base=DIRECTORY
173 Directory relative to --dir where unit tests are
174 placed (default \"tests\").
175 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
176 tools are placed (default \"build-aux\").
177 --with-tests Include unit tests for the included modules.
178 --with-obsolete Include obsolete modules when they occur among the
179 dependencies. By default, dependencies to obsolete
181 --avoid=MODULE Avoid including the given MODULE. Useful if you
182 have code that provides equivalent functionality.
183 This option can be repeated.
184 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
185 Also modify license template from GPL to LGPL.
186 The version number of the LGPL can be specified;
187 the default is currently LGPLv3.
188 --makefile-name=NAME Name of makefile in automake syntax in the
189 source-base and tests-base directories
190 (default \"Makefile.am\").
191 --libtool Use libtool rules.
192 --no-libtool Don't use libtool rules.
193 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
194 'gl_INIT'. Default is 'gl'.
195 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
196 the package name. A suffix '-gnulib' is appended.
197 --vc-files Update version control related files.
198 --no-vc-files Don't update version control related files
199 (.gitignore and/or .cvsignore).
200 --no-changelog Don't update or create ChangeLog files.
202 Options for --import and --update:
203 --dry-run For --import, only print what would have been done.
204 -s, --symbolic, --symlink Make symbolic links instead of copying files.
205 --local-symlink Make symbolic links instead of copying files, only
206 for files from the local override directory.
207 -S, --more-symlinks Make symbolic links instead of copying files, and
208 don't replace copyright notices.
210 Report bugs to <bug-gnulib@gnu.org>."
214 # outputs to stdout the --version message.
218 if test -d "$gnulib_dir"/.git \
219 && (git --version) >/dev/null 2>/dev/null \
220 && (date --version) >/dev/null 2>/dev/null; then
221 # gnulib checked out from git.
222 sed_extract_first_date='/^Date/{
226 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
227 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
228 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
229 date=`echo "$date" | sed -e "$sed_year_before_time"`
230 # Use GNU date to compute the time in GMT.
231 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
232 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
234 if test -d "$gnulib_dir"/CVS \
235 && (cvs --version) >/dev/null 2>/dev/null; then
236 # gnulib checked out from CVS.
237 sed_extract_first_date='/^date: /{
238 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
241 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
243 # gnulib copy without versioning information.
244 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
248 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
250 gnulib-tool (GNU $package $date)$version
251 Copyright (C) $year Free Software Foundation, Inc.
252 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
253 This is free software: you are free to change and redistribute it.
254 There is NO WARRANTY, to the extent permitted by law.
256 Written by" "Bruno Haible" "and" "Simon Josefsson"
259 # func_emit_copyright_notice
260 # outputs to stdout a header for a generated file.
261 func_emit_copyright_notice ()
263 sed -n '/Copyright/ {
266 }' < "$self_abspathname"
268 echo "# This file is free software, distributed under the terms of the GNU"
269 echo "# General Public License. As a special exception to the GNU General"
270 echo "# Public License, this file may be distributed as part of a program"
271 echo "# that contains a configuration script generated by Autoconf, under"
272 echo "# the same distribution terms as the rest of that program."
274 echo "# Generated by gnulib-tool."
278 # exits with a given status.
279 # This function needs to be used, rather than 'exit', when a 'trap' handler is
280 # in effect that refers to $?.
287 # locates the directory where the gnulib repository lives
289 # - progname name of this program
291 # - self_abspathname absolute pathname of gnulib-tool
292 # - gnulib_dir absolute pathname of gnulib repository
296 /*) self_abspathname="$progname" ;;
297 */*) self_abspathname=`pwd`/"$progname" ;;
300 # Iterate through the elements of $PATH.
301 # We use IFS=: instead of
302 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
303 # because the latter does not work when some PATH element contains spaces.
304 # We use a canonicalized $pathx instead of $PATH, because empty PATH
305 # elements are by definition equivalent to '.', however field splitting
306 # according to IFS=: loses empty fields in many shells:
307 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
308 # beginning, at the end, and in the middle),
309 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
310 # at the beginning and at the end,
311 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
312 # Solaris lose empty fields at the end.
313 # The 'case' statement is an optimization, to avoid evaluating the
314 # explicit canonicalization command when $PATH contains no empty fields.
316 if test "${PATH_SEPARATOR+set}" != set; then
318 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
319 chmod +x "$tmp"/conf.sh
320 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
327 if test "$PATH_SEPARATOR" = ";"; then
328 # On Windows, programs are searched in "." before $PATH.
331 # On Unix, we have to convert empty PATH elements to ".".
335 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
340 IFS="$PATH_SEPARATOR"
344 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
345 self_abspathname="$d/$progname"
350 if test -z "$self_abspathname"; then
351 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
355 while test -h "$self_abspathname"; do
356 # Resolve symbolic link.
357 linkval=`func_readlink "$self_abspathname"`
358 test -n "$linkval" || break
360 /* ) self_abspathname="$linkval" ;;
361 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
364 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
368 # creates a temporary directory.
370 # - progname name of this program
372 # - tmp pathname of freshly created temporary directory
375 # Use the environment variable TMPDIR, falling back to /tmp. This allows
376 # users to specify a different temporary directory, for example, if their
377 # /tmp is filled up or too small.
380 # Use the mktemp program if available. If not available, hide the error
382 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
383 test -n "$tmp" && test -d "$tmp"
386 # Use a simple mkdir command. It is guaranteed to fail if the directory
387 # already exists. $RANDOM is bash specific and expands to empty in shells
388 # other than bash, ksh and zsh. Its use does not increase security;
389 # rather, it minimizes the probability of failure in a very cluttered /tmp
391 tmp=$TMPDIR/gl$$-$RANDOM
392 (umask 077 && mkdir "$tmp")
395 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
400 # func_append var value
401 # appends the given value to the shell variable var.
402 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
403 # Use bash's += operator. It reduces complexity of appending repeatedly to
404 # a single variable from O(n^2) to O(n).
409 fast_func_append=true
413 eval "$1=\"\$$1\$2\""
415 fast_func_append=false
418 # func_remove_prefix var prefix
419 # removes the given prefix from the value of the shell variable var.
420 # var should be the name of a shell variable.
421 # Its value should not contain a newline and not start or end with whitespace.
422 # prefix should not contain the characters "$`\{}[]^|.
423 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
424 func_remove_prefix ()
428 fast_func_remove_prefix=true
430 func_remove_prefix ()
432 eval "value=\"\$$1\""
436 sed_escape_dots='s/\([.]\)/\\\1/g'
437 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
440 value=`echo "$value" | sed -e "s|^${prefix}||"`
441 eval "$1=\"\$value\""
443 fast_func_remove_prefix=false
446 # func_remove_suffix var suffix
447 # removes the given suffix from the value of the shell variable var.
448 # var should be the name of a shell variable.
449 # Its value should not contain a newline and not start or end with whitespace.
450 # suffix should not contain the characters "$`\{}[]^|.
451 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
452 func_remove_suffix ()
456 fast_func_remove_suffix=true
458 func_remove_suffix ()
460 eval "value=\"\$$1\""
464 sed_escape_dots='s/\([.]\)/\\\1/g'
465 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
468 value=`echo "$value" | sed -e "s|${suffix}\$||"`
469 eval "$1=\"\$value\""
471 fast_func_remove_suffix=false
474 # func_fatal_error message
475 # outputs to stderr a fatal error message, and terminates the program.
477 # - progname name of this program
480 echo "$progname: *** $1" 1>&2
481 echo "$progname: *** Stop." 1>&2
485 # func_readlink SYMLINK
486 # outputs the target of the given symlink.
487 if (type -p readlink) > /dev/null 2>&1; then
490 # Use the readlink program from GNU coreutils.
496 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
497 # would do the wrong thing if the link target contains " -> ".
498 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
502 # func_relativize DIR1 DIR2
503 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
505 # - DIR1 relative pathname, relative to the current directory
506 # - DIR2 relative pathname, relative to the current directory
508 # - reldir relative pathname of DIR2, relative to DIR1
514 sed_first='s,^\([^/]*\)/.*$,\1,'
515 sed_rest='s,^[^/]*/*,,'
516 sed_last='s,^.*/\([^/]*\)$,\1,'
517 sed_butlast='s,/*[^/]*$,,'
518 while test -n "$dir1"; do
519 first=`echo "$dir1" | sed -e "$sed_first"`
520 if test "$first" != "."; then
521 if test "$first" = ".."; then
522 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
523 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
525 first2=`echo "$dir2" | sed -e "$sed_first"`
526 if test "$first2" = "$first"; then
527 dir2=`echo "$dir2" | sed -e "$sed_rest"`
531 dir0="$dir0"/"$first"
534 dir1=`echo "$dir1" | sed -e "$sed_rest"`
539 # func_relconcat DIR1 DIR2
540 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
542 # - DIR1 relative pathname, relative to the current directory
543 # - DIR2 relative pathname, relative to DIR1
545 # - relconcat DIR1/DIR2, relative to the current directory
550 sed_first='s,^\([^/]*\)/.*$,\1,'
551 sed_rest='s,^[^/]*/*,,'
552 sed_last='s,^.*/\([^/]*\)$,\1,'
553 sed_butlast='s,/*[^/]*$,,'
555 first=`echo "$dir2" | sed -e "$sed_first"`
556 if test "$first" = "."; then
557 dir2=`echo "$dir2" | sed -e "$sed_rest"`
558 if test -z "$dir2"; then
563 last=`echo "$dir1" | sed -e "$sed_last"`
564 while test "$last" = "."; do
565 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
566 last=`echo "$dir1" | sed -e "$sed_last"`
568 if test -z "$dir1"; then
572 if test "$first" = ".."; then
573 if test "$last" = ".."; then
574 relconcat="$dir1/$dir2"
577 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
578 dir2=`echo "$dir2" | sed -e "$sed_rest"`
579 if test -z "$dir1"; then
583 if test -z "$dir2"; then
588 relconcat="$dir1/$dir2"
596 # Like ln -s, except that SRC is given relative to the current directory (or
597 # absolute), not given relative to the directory of DEST.
603 *) # SRC is relative.
606 ln -s "`pwd`/$1" "$2" ;;
607 *) # DEST is relative too.
608 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
609 test -n "$ln_destdir" || ln_destdir="."
610 func_relativize "$ln_destdir" "$1"
618 # func_ln_if_changed SRC DEST
619 # Like func_ln, but avoids munging timestamps if the link is correct.
620 func_ln_if_changed ()
622 if test $# -ne 2; then
623 echo "usage: func_ln_if_changed SRC DEST" >&2
625 ln_target=`func_readlink "$2"`
626 if test -h "$2" && test "$1" = "$ln_target"; then
635 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
636 # writes into a pipe with no readers, i.e. a pipe where all readers have
637 # already closed their file descriptor that read from it or exited entirely.
638 # The default behaviour is to terminate the current process without an error
640 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
641 # terminate the current process with an error message.
642 # This function should be called at the beginning of a command that only
643 # produces output to stdout (i.e. no side effects!), when the command that
644 # will read from this pipe might prematurely exit or close its standard input
646 if test -n "$BASH_VERSION"; then
647 # The problem has only been reported with bash. Probably it occurs only with
648 # bash-3.2. For the reasons, see
649 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
650 # Note that Solaris sh does not understand "trap - SIGPIPE".
651 func_reset_sigpipe ()
656 func_reset_sigpipe ()
662 # Ensure an 'echo' command that does not interpret backslashes.
664 # echo '\n' | wc -l prints 1 when OK, 2 when KO
665 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
666 # This problem is a weird heritage from SVR4. BSD got it right (except that
667 # BSD echo interprets '-n' as an option, which is also not desirable).
668 # Nowadays the problem occurs in 4 situations:
669 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
670 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
671 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
672 # - in zsh, when sh-emulation is not set,
673 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
674 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
675 # - in Solaris /bin/sh and OSF/1 /bin/sh.
676 # We try the following workarounds:
677 # - for all: respawn using $CONFIG_SHELL if that is set and works.
678 # - for bash >= 2.04: unset the shell option xpg_echo.
679 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
680 # - for bash < 2.0: define echo to a function that uses cat of a here document.
681 # - for zsh: turn sh-emulation on.
682 # - for ksh: alias echo to 'print -r'.
683 # - for ksh: alias echo to a function that uses cat of a here document.
684 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
685 # the ksh workaround.
686 # - otherwise: respawn using /bin/sh and rely on the workarounds.
687 # When respawning, we pass --no-reexec as first argument, so as to avoid
688 # turning this script into a fork bomb in unlucky situations.
690 if echo '\t' | grep t > /dev/null; then
691 have_echo=yes # Lucky!
693 # Try the workarounds.
694 # Respawn using $CONFIG_SHELL if that is set and works.
695 if test -z "$have_echo" \
696 && test "X$1" != "X--no-reexec" \
697 && test -n "$CONFIG_SHELL" \
698 && test -f "$CONFIG_SHELL" \
699 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
700 exec $CONFIG_SHELL "$0" --no-reexec "$@"
703 # For bash >= 2.04: unset the shell option xpg_echo.
704 if test -z "$have_echo" \
705 && test -n "$BASH_VERSION" \
706 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
710 # For bash >= 2.0: define echo to a function that uses the printf built-in.
711 # For bash < 2.0: define echo to a function that uses cat of a here document.
712 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
713 if test -z "$have_echo" \
714 && test -n "$BASH_VERSION"; then \
715 if type printf 2>/dev/null | grep / > /dev/null; then
716 # 'printf' is not a shell built-in.
724 # 'printf' is a shell built-in.
730 if echo '\t' | grep t > /dev/null; then
734 # For zsh: turn sh-emulation on.
735 if test -z "$have_echo" \
736 && test -n "$ZSH_VERSION" \
737 && (emulate sh) >/dev/null 2>&1; then
740 # For ksh: alias echo to 'print -r'.
741 if test -z "$have_echo" \
742 && (type print) >/dev/null 2>&1; then
743 # A 'print' command exists.
744 if type print 2>/dev/null | grep / > /dev/null; then
747 # 'print' is a shell built-in.
748 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
749 # 'print' is the ksh shell built-in.
750 alias echo='print -r'
754 if test -z "$have_echo" \
755 && echo '\t' | grep t > /dev/null; then
758 # For ksh: alias echo to a function that uses cat of a here document.
759 # The ksh manual page says:
760 # "Aliasing is performed when scripts are read, not while they are executed.
761 # Therefore, for an alias to take effect, the alias definition command has
762 # to be executed before the command which references the alias is read."
763 # Because of this, we have to play strange tricks with have_echo, to ensure
764 # that the top-level statement containing the test starts after the 'alias'
766 if test -z "$have_echo"; then
773 alias echo=bsd_echo 2>/dev/null
775 if test -z "$have_echo" \
776 && echo '\t' | grep t > /dev/null; then
779 if test -z "$have_echo"; then
780 unalias echo 2>/dev/null
782 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
783 if test -z "$have_echo" \
784 && test "X$1" != "X--no-reexec" \
785 && test -f /bin/ksh; then
786 exec /bin/ksh "$0" --no-reexec "$@"
789 # Otherwise: respawn using /bin/sh.
790 if test -z "$have_echo" \
791 && test "X$1" != "X--no-reexec" \
792 && test -f /bin/sh; then
793 exec /bin/sh "$0" --no-reexec "$@"
796 if test -z "$have_echo"; then
797 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
799 if echo '\t' | grep t > /dev/null; then
802 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
804 if test "X$1" = "X--no-reexec"; then
808 # Command-line option processing.
809 # Removes the OPTIONS from the arguments. Sets the variables:
810 # - mode list or import or create-testdir or create-megatestdir
811 # - destdir from --dir
812 # - local_gnulib_dir from --local-dir
813 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
814 # - libname, supplied_libname from --lib
815 # - sourcebase from --source-base
816 # - m4base from --m4-base
817 # - pobase from --po-base
818 # - docbase from --doc-base
819 # - testsbase from --tests-base
820 # - auxdir from --aux-dir
821 # - inctests true if --with-tests was given, blank otherwise
822 # - incobsolete true if --with-obsolete was given, blank otherwise
823 # - avoidlist list of modules to avoid, from --avoid
824 # - lgpl yes or a number if --lgpl was given, blank otherwise
825 # - makefile_name from --makefile-name
826 # - libtool true if --libtool was given, false if --no-libtool was
827 # given, blank otherwise
828 # - macro_prefix from --macro-prefix
829 # - po_domain from --po-domain
830 # - vc_files true if --vc-files was given, false if --no-vc-files was
831 # given, blank otherwise
832 # - autoconf_minversion minimum supported autoconf version
833 # - do_changelog false if --no-changelog was given, : otherwise
834 # - doit : if actions shall be executed, false if only to be printed
835 # - symbolic true if --symlink or --more-symlinks was given, blank
837 # - lsymbolic true if --local-symlink was given, blank otherwise
838 # - do_copyrights blank if --more-symlinks was given, true otherwise
869 while test $# -gt 0; do
874 --import | --impor | --impo | --imp | --im | --i )
877 --update | --updat | --upda | --upd | --up | --u )
880 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
883 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
884 mode=create-megatestdir
886 --test | --tes | --te | --t )
889 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
893 mode=`echo "X$1" | sed -e 's/^X--//'`
898 func_fatal_error "missing argument for --dir"
903 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
908 func_fatal_error "missing argument for --local-dir"
913 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
915 --verbose | --verbos | --verbo | --verb )
916 verbose=`expr $verbose + 1`
918 --quiet | --quie | --qui | --qu | --q )
919 verbose=`expr $verbose - 1`
924 func_fatal_error "missing argument for --lib"
927 supplied_libname=true
930 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
931 supplied_libname=true
936 func_fatal_error "missing argument for --source-base"
941 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
946 func_fatal_error "missing argument for --m4-base"
951 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
956 func_fatal_error "missing argument for --po-base"
961 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
966 func_fatal_error "missing argument for --doc-base"
971 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
976 func_fatal_error "missing argument for --tests-base"
981 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
986 func_fatal_error "missing argument for --aux-dir"
991 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1001 if test $# = 0; then
1002 func_fatal_error "missing argument for --avoid"
1004 func_append avoidlist " $1"
1007 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1008 func_append avoidlist " $arg"
1014 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1017 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1023 if test $# = 0; then
1024 func_fatal_error "missing argument for --makefile-name"
1029 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1039 if test $# = 0; then
1040 func_fatal_error "missing argument for --macro-prefix"
1045 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1049 if test $# = 0; then
1050 func_fatal_error "missing argument for --po-domain"
1055 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1063 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
1069 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1072 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1075 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1079 --help | --hel | --he | --h )
1082 --version | --versio | --versi | --vers )
1086 # Stop option processing
1090 echo "gnulib-tool: unknown option $1" 1>&2
1091 echo "Try 'gnulib-tool --help' for more information." 1>&2
1098 if test "$mode" = update; then
1099 if test $# != 0; then
1100 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1101 echo "Try 'gnulib-tool --help' for more information." 1>&2
1102 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1103 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1106 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1107 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1108 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1109 || test -n "$inctests" || test -n "$incobsolete" \
1110 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1111 || test -n "$macro_prefix" || test -n "$po_domain" \
1112 || test -n "$vc_files"; then
1113 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1114 echo "Try 'gnulib-tool --help' for more information." 1>&2
1115 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1116 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1121 if test -n "$pobase" && test -z "$po_domain"; then
1122 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1123 echo "Try 'gnulib-tool --help' for more information." 1>&2
1126 if test -z "$pobase" && test -n "$po_domain"; then
1127 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1130 # Determine the minimum supported autoconf version from the project's
1132 DEFAULT_AUTOCONF_MINVERSION="2.59"
1133 autoconf_minversion=
1135 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1136 if test -f "$destdir"/configure.ac; then
1137 configure_ac="$destdir/configure.ac"
1139 if test -f "$destdir"/configure.in; then
1140 configure_ac="$destdir/configure.in"
1144 if test -f configure.ac; then
1145 configure_ac="configure.ac"
1147 if test -f configure.in; then
1148 configure_ac="configure.in"
1152 if test -n "$configure_ac"; then
1153 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1154 # because when some m4 files are omitted from a CVS repository,
1155 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1156 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1157 # autom4te: m4 failed with exit status: 1
1164 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1166 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1167 if test -n "$prereqs"; then
1168 autoconf_minversion=`
1169 for version in $prereqs; do echo $version; done |
1170 LC_ALL=C sort -nru | sed 1q
1174 if test -z "$autoconf_minversion"; then
1175 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1177 case "$autoconf_minversion" in
1178 1.* | 2.[0-4]* | 2.5[0-8]*)
1179 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1182 # Remove trailing slashes from the directory names. This is necessary for
1183 # m4base (to avoid an error in func_import) and optional for the others.
1184 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1185 case "$local_gnulib_dir" in
1186 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1188 case "$sourcebase" in
1189 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1192 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1195 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1198 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1200 case "$testsbase" in
1201 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1204 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1210 trap 'exit_status=$?
1211 if test "$signal" != 0; then
1212 echo "caught signal $signal" >&2
1215 exit $exit_status' 0
1216 for signal in 1 2 3 13 15; do
1217 trap '{ signal='$signal'; func_exit 1; }' $signal
1221 # func_lookup_file file
1222 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1225 # - local_gnulib_dir from --local-dir
1227 # - lookedup_file name of the merged (combined) file
1228 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1232 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1233 lookedup_file="$local_gnulib_dir/$lkfile"
1236 if test -f "$gnulib_dir/$lkfile"; then
1237 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1238 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1239 rm -f "$tmp/$lkbase"
1240 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1241 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1242 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1243 lookedup_file="$tmp/$lkbase"
1246 lookedup_file="$gnulib_dir/$lkfile"
1250 func_fatal_error "file $gnulib_dir/$lkfile not found"
1257 # - local_gnulib_dir from --local-dir
1260 # Filter out metainformation files like README, which are not modules.
1261 # Filter out unit test modules; they can be retrieved through
1262 # --extract-tests-module if desired.
1264 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1265 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1266 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1269 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1270 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1271 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1272 -e '/^README$/d' -e '/\/README$/d' \
1273 -e '/^TEMPLATE$/d' \
1274 -e '/^TEMPLATE-EXTENDED$/d' \
1275 -e '/^TEMPLATE-TESTS$/d' \
1278 | sed -e '/-tests$/d' \
1282 # func_verify_module
1283 # verifies a module name
1285 # - local_gnulib_dir from --local-dir
1286 # - module module name argument
1287 func_verify_module ()
1289 if { test -f "$gnulib_dir/modules/$module" \
1290 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1291 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1292 && test "CVS" != "$module" \
1293 && test "ChangeLog" != "$module" \
1294 && test "COPYING" != "$module" \
1295 && test "README" != "$module" \
1296 && test "TEMPLATE" != "$module" \
1297 && test "TEMPLATE-EXTENDED" != "$module" \
1298 && test "TEMPLATE-TESTS" != "$module"; then
1299 # OK, $module is a correct module name.
1300 # Verify that building the module description with 'patch' succeeds.
1301 func_lookup_file "modules/$module"
1303 echo "gnulib-tool: module $module doesn't exist" 1>&2
1308 # func_verify_nontests_module
1309 # verifies a module name, excluding tests modules
1311 # - local_gnulib_dir from --local-dir
1312 # - module module name argument
1313 func_verify_nontests_module ()
1316 *-tests ) module= ;;
1317 * ) func_verify_module ;;
1321 # func_verify_tests_module
1322 # verifies a module name, considering only tests modules
1324 # - local_gnulib_dir from --local-dir
1325 # - module module name argument
1326 func_verify_tests_module ()
1329 *-tests ) func_verify_module ;;
1334 sed_extract_prog=':[ ]*$/ {
1337 s/^Description:[ ]*$//
1341 s/^Depends-on:[ ]*$//
1342 s/^configure\.ac-early:[ ]*$//
1343 s/^configure\.ac:[ ]*$//
1344 s/^Makefile\.am:[ ]*$//
1348 s/^Maintainer:[ ]*$//
1355 # func_get_description module
1357 # - local_gnulib_dir from --local-dir
1358 func_get_description ()
1360 func_lookup_file "modules/$1"
1361 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1364 # func_get_status module
1366 # - local_gnulib_dir from --local-dir
1369 func_lookup_file "modules/$1"
1370 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1373 # func_get_notice module
1375 # - local_gnulib_dir from --local-dir
1378 func_lookup_file "modules/$1"
1379 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1382 # func_get_filelist module
1384 # - local_gnulib_dir from --local-dir
1385 func_get_filelist ()
1387 func_lookup_file "modules/$1"
1388 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1390 echo m4/gnulib-common.m4
1391 case "$autoconf_minversion" in
1398 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1399 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1400 # elements starting with prefix and ending with suffix are considered.
1401 # Processing: removed_prefix and removed_suffix are removed from each element,
1402 # added_prefix and added_suffix are added to each element.
1403 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1404 # added_prefix, added_suffix should not contain the characters \|.
1405 func_filter_filelist ()
1407 if test "$2" != "$nl" \
1408 || { $fast_func_append \
1409 && { test -z "$6" || $fast_func_remove_prefix; } \
1410 && { test -z "$7" || $fast_func_remove_suffix; }; \
1416 if test -n "$6"; then
1417 func_remove_prefix fff "$6"
1419 if test -n "$7"; then
1420 func_remove_suffix fff "$7"
1423 if test -z "$ffflist"; then
1426 func_append ffflist "$2${fff}"
1432 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1433 ffflist=`for fff in $3; do
1435 "$4"*"$5") echo "$fff" ;;
1437 done | sed -e "$sed_fff_filter"`
1439 eval "$1=\"\$ffflist\""
1442 # func_get_dependencies module
1444 # - local_gnulib_dir from --local-dir
1445 func_get_dependencies ()
1447 # ${module}-tests always implicitly depends on ${module}.
1451 func_remove_suffix fgd1 '-tests'
1455 # Then the explicit dependencies listed in the module description.
1456 func_lookup_file "modules/$1"
1457 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1460 # func_get_autoconf_early_snippet module
1462 # - local_gnulib_dir from --local-dir
1463 func_get_autoconf_early_snippet ()
1465 func_lookup_file "modules/$1"
1466 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1469 # func_get_autoconf_snippet module
1471 # - local_gnulib_dir from --local-dir
1472 func_get_autoconf_snippet ()
1474 func_lookup_file "modules/$1"
1475 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1478 # func_get_automake_snippet module
1480 # - local_gnulib_dir from --local-dir
1481 func_get_automake_snippet ()
1483 func_lookup_file "modules/$1"
1484 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1487 # *-tests module live in tests/, not lib/.
1488 # Synthesize an EXTRA_DIST augmentation.
1489 all_files=`func_get_filelist $1`
1490 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1491 extra_files="$tests_files"
1492 if test -n "$extra_files"; then
1493 echo "EXTRA_DIST +=" $extra_files
1498 # Synthesize an EXTRA_DIST augmentation.
1499 sed_combine_lines='/\\$/{
1506 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1507 already_mentioned_files=` \
1508 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1509 | sed -e "$sed_combine_lines" \
1510 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1511 all_files=`func_get_filelist $1`
1512 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
1513 # Remove $already_mentioned_files from $lib_files.
1514 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1515 extra_files=`func_reset_sigpipe; \
1516 for f in $already_mentioned_files; do echo $f; done \
1517 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1518 if test -n "$extra_files"; then
1519 echo "EXTRA_DIST +=" $extra_files
1522 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1523 # This is necessary so that automake can generate the right list of
1525 # A possible approach would be to use autom4te --trace of the redefined
1526 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1527 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1528 # inside autoconf's built-in macros are not missed).
1529 # But it's simpler and more robust to do it here, based on the file list.
1530 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1531 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1532 # automake will generate a useless dependency; this is harmless.
1534 relocatable-prog-wrapper) ;;
1536 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
1537 if test -n "$extra_files"; then
1538 echo "EXTRA_lib_SOURCES +=" $extra_files
1543 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1544 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
1545 if test -n "$buildaux_files"; then
1546 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1547 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1550 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1551 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
1552 if test -n "$top_files"; then
1553 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1554 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1561 # func_get_include_directive module
1563 # - local_gnulib_dir from --local-dir
1564 func_get_include_directive ()
1566 func_lookup_file "modules/$1"
1567 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1568 sed -e 's/^\(["<]\)/#include \1/'
1571 # func_get_link_directive module
1573 # - local_gnulib_dir from --local-dir
1574 func_get_link_directive ()
1576 func_lookup_file "modules/$1"
1577 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1580 # func_get_license module
1582 # - local_gnulib_dir from --local-dir
1585 func_lookup_file "modules/$1"
1586 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1587 # The default is GPL.
1589 } | sed -e 's,^ *$,,' | sed -e 1q
1592 # func_get_maintainer module
1594 # - local_gnulib_dir from --local-dir
1595 func_get_maintainer ()
1597 func_lookup_file "modules/$1"
1598 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1601 # func_get_tests_module module
1603 # - local_gnulib_dir from --local-dir
1604 func_get_tests_module ()
1606 # The naming convention for tests modules is hardwired: ${module}-tests.
1607 if test -f "$gnulib_dir/modules/$1"-tests \
1608 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1609 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1614 # func_acceptable module
1615 # tests whether a module is acceptable.
1617 # - avoidlist list of modules to avoid
1620 for avoid in $avoidlist; do
1621 if test "$avoid" = "$1"; then
1628 # func_modules_transitive_closure
1630 # - local_gnulib_dir from --local-dir
1631 # - modules list of specified modules
1632 # - inctests true if tests should be included, blank otherwise
1633 # - incobsolete true if obsolete modules among dependencies should be
1634 # included, blank otherwise
1635 # - avoidlist list of modules to avoid
1636 # - tmp pathname of a temporary directory
1638 # - modules list of modules, including dependencies
1639 func_modules_transitive_closure ()
1641 # In order to process every module only once (for speed), process an "input
1642 # list" of modules, producing an "output list" of modules. During each round,
1643 # more modules can be queued in the input list. Once a module on the input
1644 # list has been processed, it is added to the "handled list", so we can avoid
1645 # to process it again.
1647 inmodules="$modules"
1649 while test -n "$inmodules"; do
1650 inmodules_this_round="$inmodules"
1651 inmodules= # Accumulator, queue for next round
1652 for module in $inmodules_this_round; do
1654 if test -n "$module"; then
1655 if func_acceptable $module; then
1656 func_append outmodules " $module"
1657 deps=`func_get_dependencies $module`
1658 # Duplicate dependencies are harmless, but Jim wants a warning.
1659 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1660 if test -n "$duplicated_deps"; then
1661 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1663 for dep in $deps; do
1664 if test -n "$incobsolete" \
1665 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
1666 func_append inmodules " $dep"
1669 if test -n "$inctests"; then
1670 testsmodule=`func_get_tests_module $module`
1671 if test -n "$testsmodule"; then
1672 func_append inmodules " $testsmodule"
1678 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1679 # Remove $handledmodules from $inmodules.
1680 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1681 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1683 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1684 rm -f "$tmp"/queued-modules
1687 # func_modules_add_dummy
1689 # - local_gnulib_dir from --local-dir
1690 # - modules list of modules, including dependencies
1692 # - modules list of modules, including 'dummy' if needed
1693 func_modules_add_dummy ()
1695 # Determine whether any module provides a lib_SOURCES augmentation.
1697 sed_remove_backslash_newline=':a
1704 for module in $modules; do
1705 func_verify_nontests_module
1706 if test -n "$module"; then
1707 # Extract the value of "lib_SOURCES += ...".
1708 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1709 # Ignore .h files since they are not compiled.
1713 have_lib_SOURCES=yes
1720 # Add the dummy module, to make sure the library will be non-empty.
1721 if test -z "$have_lib_SOURCES"; then
1722 if func_acceptable "dummy"; then
1723 func_append modules " dummy"
1728 # func_modules_notice
1730 # - local_gnulib_dir from --local-dir
1731 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1732 # - modules list of modules, including dependencies
1733 func_modules_notice ()
1735 if test $verbose -ge -1; then
1736 for module in $modules; do
1738 if test -n "$module"; then
1739 msg=`func_get_notice $module`
1740 if test -n "$msg"; then
1741 echo "Notice from module $module:"
1742 echo "$msg" | sed -e 's/^/ /'
1749 # func_modules_to_filelist
1751 # - local_gnulib_dir from --local-dir
1752 # - modules list of modules, including dependencies
1754 # - files list of files
1755 func_modules_to_filelist ()
1758 for module in $modules; do
1760 if test -n "$module"; then
1761 fs=`func_get_filelist $module`
1762 func_append files " $fs"
1765 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1768 # func_execute_command command [args...]
1769 # Executes a command.
1770 # Uses also the variables
1771 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1772 func_execute_command ()
1774 if test $verbose -ge 0; then
1778 # Commands like automake produce output to stderr even when they succeed.
1779 # Turn this output off if the command succeeds.
1780 "$@" > "$tmp"/cmdout 2>&1
1782 if test $cmdret = 0; then
1786 cat "$tmp"/cmdout 1>&2
1793 # func_emit_lib_Makefile_am
1794 # emits the contents of library makefile to standard output.
1796 # - local_gnulib_dir from --local-dir
1797 # - modules list of modules, including dependencies
1798 # - libname library name
1799 # - pobase directory relative to destdir where to place *.po files
1800 # - auxdir directory relative to destdir where to place build aux files
1801 # - makefile_name from --makefile-name
1802 # - libtool true if libtool will be used, false or blank otherwise
1803 # - macro_prefix prefix of gl_LIBOBJS macros to use
1804 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1805 # - actioncmd (optional) command that will reproduce this invocation
1806 # - for_test true if creating a package for testing, false otherwise
1807 # - destfile filename relative to destdir of makefile being generated
1809 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1810 # list of edits to be done to Makefile.am variables
1812 # - uses_subdirs nonempty if object files in subdirs exist
1813 func_emit_lib_Makefile_am ()
1815 # When creating an includable Makefile.am snippet, augment variables with
1816 # += instead of assigning them.
1817 if test -n "$makefile_name"; then
1822 if test "$libtool" = true; then
1825 sed_eliminate_LDFLAGS="$sed_noop"
1829 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1832 # When creating a package for testing: Attempt to provoke failures,
1833 # especially link errors, already during "make" rather than during
1834 # "make check", because "make check" is not possible in a cross-compiling
1835 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1836 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1838 sed_transform_check_PROGRAMS="$sed_noop"
1840 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1841 echo "## Process this file with automake to produce Makefile.in."
1842 func_emit_copyright_notice
1843 if test -n "$actioncmd"; then
1844 echo "# Reproduce by: $actioncmd"
1849 for module in $modules; do
1850 func_verify_nontests_module
1851 if test -n "$module"; then
1853 func_get_automake_snippet "$module" |
1854 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1855 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1856 -e "$sed_eliminate_LDFLAGS" \
1857 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1858 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1859 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1860 -e "$sed_transform_check_PROGRAMS"
1861 if test "$module" = 'alloca'; then
1862 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1863 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1866 # Skip the contents if it's entirely empty.
1867 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1868 echo "## begin gnulib module $module"
1871 echo "## end gnulib module $module"
1875 # Test whether there are some source files in subdirectories.
1876 for f in `func_get_filelist "$module"`; do
1887 if test -z "$makefile_name"; then
1888 # If there are source files in subdirectories, prevent collision of the
1889 # object files (example: hash.c and libxml/hash.c).
1891 if test -n "$uses_subdirs"; then
1892 subdir_options=' subdir-objects'
1894 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1897 if test -z "$makefile_name"; then
1899 echo "noinst_HEADERS ="
1900 echo "noinst_LIBRARIES ="
1901 echo "noinst_LTLIBRARIES ="
1902 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1903 # if you specify pkgdata_DATA to empty. This is a workaround.
1904 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1905 echo "pkgdata_DATA ="
1908 echo "BUILT_SOURCES ="
1911 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1912 if test -z "$makefile_name"; then
1913 echo "MOSTLYCLEANDIRS ="
1915 echo "DISTCLEANFILES ="
1916 echo "MAINTAINERCLEANFILES ="
1918 # Execute edits that apply to the Makefile.am being generated.
1920 while test $edit != $makefile_am_edits; do
1921 edit=`expr $edit + 1`
1922 eval dir=\"\$makefile_am_edit${edit}_dir\"
1923 eval var=\"\$makefile_am_edit${edit}_var\"
1924 eval val=\"\$makefile_am_edit${edit}_val\"
1925 if test -n "$var"; then
1926 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
1927 echo "${var} += ${val}"
1928 eval "makefile_am_edit${edit}_var="
1932 if test -z "$makefile_name"; then
1934 echo "AM_CPPFLAGS ="
1937 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1938 # One of the snippets already specifies an installation location for the
1939 # library. Don't confuse automake by saying it should not be installed.
1942 # By default, the generated library should not be installed.
1943 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1946 echo "${libname}_${libext}_SOURCES ="
1947 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1948 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
1949 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1950 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1951 echo "EXTRA_${libname}_${libext}_SOURCES ="
1952 if test "$libtool" = true; then
1953 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1956 if test -n "$pobase"; then
1957 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1960 cat allsnippets.tmp \
1961 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1963 echo "mostlyclean-local: mostlyclean-generic"
1964 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1965 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1966 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1970 rm -f allsnippets.tmp
1973 # func_emit_po_Makevars
1974 # emits the contents of po/ makefile parameterization to standard output.
1976 # - local_gnulib_dir from --local-dir
1977 # - sourcebase directory relative to destdir where to place source code
1978 # - pobase directory relative to destdir where to place *.po files
1979 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1980 func_emit_po_Makevars ()
1982 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1983 func_emit_copyright_notice
1985 echo "# Usually the message domain is the same as the package name."
1986 echo "# But here it has a '-gnulib' suffix."
1987 echo "DOMAIN = ${po_domain}-gnulib"
1989 echo "# These two variables depend on the location of this directory."
1990 echo "subdir = ${pobase}"
1991 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1994 # These options get passed to xgettext.
1995 XGETTEXT_OPTIONS = \
1996 --keyword=_ --flag=_:1:pass-c-format \
1997 --keyword=N_ --flag=N_:1:pass-c-format \
1998 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1999 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2000 --flag=error:3:c-format --flag=error_at_line:5:c-format
2002 # This is the copyright holder that gets inserted into the header of the
2003 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2004 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2006 # This is the email address or URL to which the translators shall report
2007 # bugs in the untranslated strings:
2008 # - Strings which are not entire sentences, see the maintainer guidelines
2009 # in the GNU gettext documentation, section 'Preparing Strings'.
2010 # - Strings which use unclear terms or require additional context to be
2012 # - Strings which make invalid assumptions about notation of date, time or
2014 # - Pluralisation problems.
2015 # - Incorrect English spelling.
2016 # - Incorrect formatting.
2017 # It can be your email address, or a mailing list address where translators
2018 # can write to without being subscribed, or the URL of a web page through
2019 # which the translators can contact you.
2020 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2022 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2023 # message catalogs shall be used. It is usually empty.
2024 EXTRA_LOCALE_CATEGORIES =
2026 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2027 # context. Possible values are "yes" and "no". Set this to yes if the
2028 # package uses functions taking also a message context, like pgettext(), or
2029 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2034 # func_emit_po_POTFILES_in
2035 # emits the file list to be passed to xgettext to standard output.
2037 # - local_gnulib_dir from --local-dir
2038 # - sourcebase directory relative to destdir where to place source code
2039 # - files list of new files
2040 func_emit_po_POTFILES_in ()
2042 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2043 func_emit_copyright_notice
2045 echo "# List of files which contain translatable strings."
2046 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2049 # func_emit_tests_Makefile_am
2050 # emits the contents of tests makefile to standard output.
2052 # - local_gnulib_dir from --local-dir
2053 # - modules list of modules, including dependencies
2054 # - libname library name
2055 # - auxdir directory relative to destdir where to place build aux files
2056 # - makefile_name from --makefile-name
2057 # - libtool true if libtool will be used, false or blank otherwise
2058 # - sourcebase relative directory containing lib source code
2059 # - m4base relative directory containing autoconf macros
2060 # - testsbase relative directory containing unit test code
2061 # - macro_prefix prefix of gl_LIBOBJS macros to use
2062 # - for_test true if creating a package for testing, false otherwise
2063 # - use_libtests true if a libtests.a should be built, false otherwise
2064 # - destfile filename relative to destdir of makefile being generated
2066 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2067 # list of edits to be done to Makefile.am variables
2069 # - uses_subdirs nonempty if object files in subdirs exist
2070 func_emit_tests_Makefile_am ()
2072 if test "$libtool" = true; then
2074 sed_eliminate_LDFLAGS="$sed_noop"
2077 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2080 # When creating a package for testing: Attempt to provoke failures,
2081 # especially link errors, already during "make" rather than during
2082 # "make check", because "make check" is not possible in a cross-compiling
2083 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2084 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2086 sed_transform_check_PROGRAMS="$sed_noop"
2088 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2089 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2090 echo "## Process this file with automake to produce Makefile.in."
2091 func_emit_copyright_notice
2095 for module in $modules; do
2097 func_verify_tests_module
2101 if test -n "$module"; then
2103 func_get_automake_snippet "$module" |
2104 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2105 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2106 -e "$sed_eliminate_LDFLAGS" \
2107 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2108 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2109 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2110 -e "$sed_transform_check_PROGRAMS"
2111 if $use_libtests && test "$module" = 'alloca'; then
2112 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2113 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2116 # Skip the contents if it's entirely empty.
2117 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
2118 echo "## begin gnulib module $module"
2121 echo "## end gnulib module $module"
2125 # Test whether there are some source files in subdirectories.
2126 for f in `func_get_filelist "$module"`; do
2128 lib/*/*.c | tests/*/*.c)
2137 # Generate dependencies here, since it eases the debugging of test failures.
2138 # If there are source files in subdirectories, prevent collision of the
2139 # object files (example: hash.c and libxml/hash.c).
2141 if test -n "$uses_subdirs"; then
2142 subdir_options=' subdir-objects'
2144 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2147 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2150 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2151 # variable is needed to avoid an error from automake:
2152 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2155 echo "TESTS_ENVIRONMENT ="
2156 echo "noinst_PROGRAMS ="
2157 if ! $for_test; then
2158 echo "check_PROGRAMS ="
2160 echo "noinst_HEADERS ="
2161 echo "noinst_LIBRARIES ="
2162 if $use_libtests; then
2164 echo "noinst_LIBRARIES += libtests.a"
2166 echo "check_LIBRARIES = libtests.a"
2169 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2170 # if you specify pkgdata_DATA to empty. This is a workaround.
2171 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
2172 echo "pkgdata_DATA ="
2175 echo "BUILT_SOURCES ="
2177 echo "MOSTLYCLEANFILES = core *.stackdump"
2178 echo "MOSTLYCLEANDIRS ="
2180 echo "DISTCLEANFILES ="
2181 echo "MAINTAINERCLEANFILES ="
2182 # Execute edits that apply to the Makefile.am being generated.
2184 while test $edit != $makefile_am_edits; do
2185 edit=`expr $edit + 1`
2186 eval dir=\"\$makefile_am_edit${edit}_dir\"
2187 eval var=\"\$makefile_am_edit${edit}_var\"
2188 eval val=\"\$makefile_am_edit${edit}_val\"
2189 if test -n "$var"; then
2190 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2191 echo "${var} += ${val}"
2192 eval "makefile_am_edit${edit}_var="
2197 echo "AM_CPPFLAGS = \\"
2198 echo " -I. -I\$(srcdir) \\"
2199 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2200 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2202 local_ldadd_before=''
2203 local_ldadd_after=''
2204 if $use_libtests; then
2205 # All test programs need to be linked with libtests.a.
2206 # It needs to be passed to the linker before ${libname}.${libext}, since
2207 # the tests-related modules depend on the main modules.
2208 # It also needs to be passed to the linker after ${libname}.${libext}
2209 # because the latter might contain incomplete modules (such as the 'error'
2210 # module whose dependency to 'progname' is voluntarily omitted).
2211 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2213 local_ldadd_before=' libtests.a'
2214 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2216 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2218 if $use_libtests; then
2219 echo "libtests_a_SOURCES ="
2220 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2221 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2222 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2223 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2224 echo "EXTRA_libtests_a_SOURCES ="
2225 # The circular dependency in LDADD requires this.
2226 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2229 cat allsnippets.tmp \
2230 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2231 echo "# Clean up after Solaris cc."
2233 echo " rm -rf SunWS_cache"
2235 echo "mostlyclean-local: mostlyclean-generic"
2236 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2237 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2238 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2242 rm -f allsnippets.tmp
2245 # func_emit_initmacro_start macro_prefix
2246 # emits the first few statements of the gl_INIT macro to standard output.
2247 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2248 func_emit_initmacro_start ()
2250 macro_prefix_arg="$1"
2251 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2252 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2253 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2254 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2256 # Furthermore it avoids an automake error like this when a Makefile.am
2257 # that uses pieces of gnulib also uses $(LIBOBJ):
2258 # automatically discovered file `error.c' should not be explicitly mentioned
2259 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2260 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2261 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2262 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2263 # automatically discovered file `error.c' should not be explicitly mentioned
2264 # We let automake know about the files to be distributed through the
2265 # EXTRA_lib_SOURCES variable.
2266 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2267 # Create data variables for checking the presence of files that are mentioned
2268 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2269 # because we want the check to happen when the configure file is created,
2270 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2271 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2272 # in which to expect them.
2273 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2274 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2278 # func_emit_initmacro_end macro_prefix
2279 # emits the last few statements of the gl_INIT macro to standard output.
2280 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2281 func_emit_initmacro_end ()
2283 macro_prefix_arg="$1"
2284 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2285 # The check is performed only when autoconf is run from the directory where
2286 # the configure.ac resides; if it is run from a different directory, the
2288 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2289 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2290 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2291 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2292 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2296 echo " m4_if(m4_sysval, [0], [],"
2297 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2299 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2300 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2301 echo " m4_popdef([AC_LIBSOURCES])"
2302 echo " m4_popdef([AC_REPLACE_FUNCS])"
2303 echo " m4_popdef([AC_LIBOBJ])"
2304 echo " AC_CONFIG_COMMANDS_PRE(["
2305 echo " ${macro_prefix_arg}_libobjs="
2306 echo " ${macro_prefix_arg}_ltlibobjs="
2307 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2308 echo " # Remove the extension."
2309 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2310 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2311 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2312 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2315 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2316 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2320 # func_emit_initmacro_done macro_prefix sourcebase
2321 # emits a few statements after the gl_INIT macro to standard output.
2322 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2323 # - sourcebase directory relative to destdir where to place source code
2324 func_emit_initmacro_done ()
2326 macro_prefix_arg="$1"
2329 echo "# Like AC_LIBOBJ, except that the module name goes"
2330 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2331 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2332 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2333 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2336 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2337 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2338 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2339 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2340 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2343 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2344 echo "# expected is derived from the gnulib-tool parameterization,"
2345 echo "# and alloca is special cased (for the alloca-opt module)."
2346 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2347 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2348 echo " m4_foreach([_gl_NAME], [\$1], ["
2349 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2350 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2351 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2357 # func_import modules
2358 # Uses also the variables
2359 # - destdir target directory
2360 # - local_gnulib_dir from --local-dir
2361 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2362 # - libname library name
2363 # - sourcebase directory relative to destdir where to place source code
2364 # - m4base directory relative to destdir where to place *.m4 macros
2365 # - pobase directory relative to destdir where to place *.po files
2366 # - docbase directory relative to destdir where to place doc files
2367 # - testsbase directory relative to destdir where to place unit test code
2368 # - auxdir directory relative to destdir where to place build aux files
2369 # - inctests true if --with-tests was given, blank otherwise
2370 # - incobsolete true if --with-obsolete was given, blank otherwise
2371 # - avoidlist list of modules to avoid, from --avoid
2372 # - lgpl yes or a number if library's license shall be LGPL,
2374 # - makefile_name from --makefile-name
2375 # - libtool true if --libtool was given, false if --no-libtool was
2376 # given, blank otherwise
2377 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2378 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2379 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2380 # - vc_files true if --vc-files was given, false if --no-vc-files was
2381 # given, blank otherwise
2382 # - autoconf_minversion minimum supported autoconf version
2383 # - doit : if actions shall be executed, false if only to be printed
2384 # - symbolic true if files should be symlinked, copied otherwise
2385 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2387 # - do_copyrights true if copyright notices in files should be replaced,
2391 # Get the cached settings.
2392 cached_local_gnulib_dir=
2393 cached_specified_modules=
2404 cached_makefile_name=
2406 cached_macro_prefix=
2410 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2411 cached_libtool=false
2417 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
2427 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
2429 /gl_WITH_OBSOLETE/ {
2430 s,^.*$,cached_incobsolete=true,p
2433 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
2436 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
2439 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
2442 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
2445 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
2448 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
2451 s,^.*$,cached_inctests=true,p
2454 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
2457 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
2460 s,^.*$,cached_lgpl=yes,p
2462 /gl_MAKEFILE_NAME(/ {
2463 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
2466 s,^.*$,cached_libtool=true,p
2468 /gl_MACRO_PREFIX(/ {
2469 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
2472 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
2475 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
2477 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2478 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2483 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2484 s,^.*$,cached_files=",p
2497 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2501 # Merge the cached settings with the specified ones.
2502 # The m4base must be the same as expected from the pathname.
2503 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2504 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2506 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2507 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2508 if test -z "$local_gnulib_dir"; then
2509 if test -n "$cached_local_gnulib_dir"; then
2512 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2514 case "$cached_local_gnulib_dir" in
2516 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2518 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2519 local_gnulib_dir="$relconcat" ;;
2524 # Append the cached and the specified module names. So that
2525 # "gnulib-tool --import foo" means to add the module foo.
2526 specified_modules="$cached_specified_modules $1"
2527 # Included obsolete modules among the dependencies if specified either way.
2528 if test -z "$incobsolete"; then
2529 incobsolete="$cached_incobsolete"
2531 # Append the cached and the specified avoidlist. This is probably better
2532 # than dropping the cached one when --avoid is specified at least once.
2533 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2534 avoidlist=`echo $avoidlist`
2536 # The sourcebase defaults to the cached one.
2537 if test -z "$sourcebase"; then
2538 sourcebase="$cached_sourcebase"
2539 if test -z "$sourcebase"; then
2540 func_fatal_error "missing --source-base option"
2543 # The pobase defaults to the cached one.
2544 if test -z "$pobase"; then
2545 pobase="$cached_pobase"
2547 # The docbase defaults to the cached one.
2548 if test -z "$docbase"; then
2549 docbase="$cached_docbase"
2550 if test -z "$docbase"; then
2551 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."
2554 # The testsbase defaults to the cached one.
2555 if test -z "$testsbase"; then
2556 testsbase="$cached_testsbase"
2557 if test -z "$testsbase"; then
2558 func_fatal_error "missing --tests-base option"
2561 # Require the tests if specified either way.
2562 if test -z "$inctests"; then
2563 inctests="$cached_inctests"
2565 # The libname defaults to the cached one.
2566 if test -z "$supplied_libname"; then
2567 libname="$cached_libname"
2568 if test -z "$libname"; then
2569 func_fatal_error "missing --lib option"
2572 # Require LGPL if specified either way.
2573 if test -z "$lgpl"; then
2576 # The makefile_name defaults to the cached one.
2577 if test -z "$makefile_name"; then
2578 makefile_name="$cached_makefile_name"
2580 # Use libtool if specified either way, or if guessed.
2581 if test -z "$libtool"; then
2582 if test -n "$cached_m4base"; then
2583 libtool="$cached_libtool"
2585 libtool="$guessed_libtool"
2588 # The macro_prefix defaults to the cached one.
2589 if test -z "$macro_prefix"; then
2590 macro_prefix="$cached_macro_prefix"
2591 if test -z "$macro_prefix"; then
2592 func_fatal_error "missing --macro-prefix option"
2595 # The po_domain defaults to the cached one.
2596 if test -z "$po_domain"; then
2597 po_domain="$cached_po_domain"
2599 # The vc_files defaults to the cached one.
2600 if test -z "$vc_files"; then
2601 vc_files="$cached_vc_files"
2604 # Canonicalize the list of specified modules.
2605 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2607 # Determine final module list.
2608 modules="$specified_modules"
2609 func_modules_transitive_closure
2610 if test $verbose -ge 0; then
2611 echo "Module list with included dependencies:"
2612 echo "$modules" | sed -e 's/^/ /'
2614 final_modules="$modules"
2616 # Determine main module list and tests-related module list separately.
2617 # The main module list is the transitive closure of the specified modules,
2618 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2619 # is specified, it will consist only of LGPLed source.
2620 # The tests-related module list is the transitive closure of the specified
2621 # modules, including tests modules, minus the main module list. Its lib/*
2622 # sources (brought in through dependencies of *-tests modules) go into
2623 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2624 # Determine main module list.
2625 saved_inctests="$inctests"
2627 modules="$specified_modules"
2628 func_modules_transitive_closure
2629 main_modules="$modules"
2630 inctests="$saved_inctests"
2631 if test $verbose -ge 1; then
2632 echo "Main module list:"
2633 echo "$main_modules" | sed -e 's/^/ /'
2635 # Determine tests-related module list.
2636 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2637 testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2638 if test $verbose -ge 1; then
2639 echo "Tests-related module list:"
2640 echo "$testsrelated_modules" | sed -e 's/^/ /'
2643 # Add the dummy module to the main module list if needed.
2644 modules="$main_modules"
2645 func_modules_add_dummy
2646 main_modules="$modules"
2648 # Determine whether a $testsbase/libtests.a is needed.
2650 for module in $testsrelated_modules; do
2651 func_verify_nontests_module
2652 if test -n "$module"; then
2653 all_files=`func_get_filelist $module`
2654 # Test whether some file in $all_files lies in lib/.
2655 for f in $all_files; do
2666 # Add the dummy module to the tests-related module list if needed.
2667 if $use_libtests; then
2668 modules="$testsrelated_modules"
2669 func_modules_add_dummy
2670 testsrelated_modules="$modules"
2673 # If --lgpl, verify that the licenses of modules are compatible.
2674 if test -n "$lgpl"; then
2675 license_incompatibilities=
2676 for module in $main_modules; do
2677 license=`func_get_license $module`
2679 'GPLed build tool') ;;
2680 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2686 *) func_append license_incompatibilities "$module $license$nl" ;;
2692 *) func_append license_incompatibilities "$module $license$nl" ;;
2695 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2700 if test -n "$license_incompatibilities"; then
2701 # Format the license incompatibilities as a table.
2702 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
2703 s,^\(.................................................[^ ]*\) *, \1 ,'
2704 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
2705 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
2709 # Show banner notice of every module.
2710 modules="$main_modules"
2713 # Determine script to apply to imported library files.
2714 sed_transform_lib_file=
2715 for module in $main_modules; do
2716 if test $module = config-h; then
2717 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2718 sed_transform_lib_file=$sed_transform_lib_file'
2719 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2724 sed_transform_main_lib_file="$sed_transform_lib_file"
2725 if test -n "$do_copyrights"; then
2726 if test -n "$lgpl"; then
2730 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2731 s/GNU General/GNU Lesser General/g
2735 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2736 s/GNU General/GNU Lesser General/g
2737 s/version [23]\([ ,]\)/version 2.1\1/g
2740 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2744 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2745 s/GNU Lesser General/GNU General/g
2746 s/GNU Library General/GNU General/g
2747 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2752 # Determine script to apply to library files that go into $testsbase/.
2753 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2754 if test -n "$do_copyrights"; then
2756 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2757 s/GNU Lesser General/GNU General/g
2758 s/GNU Library General/GNU General/g
2759 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2763 # Determine the final file lists.
2764 # They must be computed separately, because files in lib/* go into
2765 # $sourcebase/ if they are in the main file list but into $testsbase/
2766 # if they are in the tests-related file list. Furthermore lib/dummy.c
2768 # Determine final main file list.
2769 modules="$main_modules"
2770 func_modules_to_filelist
2772 # Determine final tests-related file list.
2773 modules="$testsrelated_modules"
2774 func_modules_to_filelist
2775 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2776 # Merge both file lists.
2777 sed_remove_empty_lines='/^$/d'
2778 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2779 if test $verbose -ge 0; then
2781 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2782 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2786 || func_fatal_error "refusing to do nothing"
2788 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2789 new_files="$files m4/gnulib-tool.m4"
2790 old_files="$cached_files"
2791 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2792 func_append old_files " m4/gnulib-tool.m4"
2795 sed_rewrite_old_files="\
2796 s,^build-aux/,$auxdir/,
2797 s,^doc/,$cached_docbase/,
2798 s,^lib/,$cached_sourcebase/,
2799 s,^m4/,$cached_m4base/,
2800 s,^tests/,$cached_testsbase/,
2801 s,^tests=lib/,$cached_testsbase/,
2803 sed_rewrite_new_files="\
2804 s,^build-aux/,$auxdir/,
2806 s,^lib/,$sourcebase/,
2808 s,^tests/,$testsbase/,
2809 s,^tests=lib/,$testsbase/,
2812 # Create directories.
2813 { echo "$sourcebase"
2815 if test -n "$pobase"; then
2818 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2819 if test -n "$docfiles"; then
2822 if test -n "$inctests"; then
2826 for f in $files; do echo $f; done \
2827 | sed -e "$sed_rewrite_new_files" \
2828 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2831 { # Rearrange file descriptors. Needed because "while ... done < ..."
2832 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2833 exec 5<&0 < "$tmp"/dirs
2835 if test ! -d "$destdir/$d"; then
2837 echo "Creating directory $destdir/$d"
2838 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2840 echo "Create directory $destdir/$d"
2847 # func_dest_tmpfilename file
2848 # determines the name of a temporary file (file is relative to destdir).
2850 # - tmpfile absolute filename of the temporary file
2851 func_dest_tmpfilename ()
2854 # Put the new contents of $file in a file in the same directory (needed
2855 # to guarantee that an 'mv' to "$destdir/$file" works).
2856 tmpfile="$destdir/$1.tmp"
2858 # Put the new contents of $file in a file in a temporary directory
2859 # (because the directory of "$file" might not exist).
2860 tmpfile="$tmp"/`basename "$1"`.tmp
2864 # Copy files or make symbolic links. Remove obsolete files.
2868 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2869 # representing the files according to the last gnulib-tool invocation.
2870 for f in $old_files; do echo $f; done \
2871 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2874 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2875 # representing the files after this gnulib-tool invocation.
2876 for f in $new_files; do echo $f; done \
2877 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2880 # First the files that are in old-files, but not in new-files:
2881 sed_take_first_column='s,'"$delimiter"'.*,,'
2882 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2883 # Remove the file. Do nothing if the user already removed it.
2884 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2886 echo "Removing file $g (backup in ${g}~)"
2887 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2889 echo "Remove file $g (backup in ${g}~)"
2891 func_append removed_files "$g$nl"
2894 # func_add_or_update handles a file that ought to be present afterwards.
2896 # - f the original file name
2897 # - g the rewritten file name
2898 # - already_present nonempty if the file already exists, empty otherwise
2899 func_add_or_update ()
2903 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2905 func_dest_tmpfilename "$g"
2906 func_lookup_file "$f"
2907 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2908 if test -n "$sed_transform_main_lib_file"; then
2911 sed -e "$sed_transform_main_lib_file" \
2912 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2916 if test -n "$sed_transform_testsrelated_lib_file"; then
2919 sed -e "$sed_transform_testsrelated_lib_file" \
2920 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2924 if test -f "$destdir/$g"; then
2925 # The file already exists.
2926 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2927 : # The file has not changed.
2931 if test -n "$already_present"; then
2932 echo "Updating file $g (backup in ${g}~)"
2934 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2936 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2937 if { test -n "$symbolic" \
2938 || { test -n "$lsymbolic" \
2939 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2940 && test -z "$lookedup_tmp" \
2941 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2942 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2944 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2947 if test -n "$already_present"; then
2948 echo "Update file $g (backup in ${g}~)"
2950 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2956 # Don't protest if the file should be there but isn't: it happens
2957 # frequently that developers don't put autogenerated files into CVS.
2959 echo "Copying file $g"
2960 if { test -n "$symbolic" \
2961 || { test -n "$lsymbolic" \
2962 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2963 && test -z "$lookedup_tmp" \
2964 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2965 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2967 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2972 func_append added_files "$g$nl"
2976 # Then the files that are in new-files, but not in old-files:
2977 sed_take_last_column='s,^.*'"$delimiter"',,'
2979 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2980 | sed -e "$sed_take_last_column" \
2981 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2982 { # Rearrange file descriptors. Needed because "while ... done < ..."
2983 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2984 exec 5<&0 < "$tmp"/added-files
2990 # Then the files that are in new-files and in old-files:
2991 already_present=true
2992 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2993 | sed -e "$sed_take_last_column" \
2994 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2995 { # Rearrange file descriptors. Needed because "while ... done < ..."
2996 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2997 exec 5<&0 < "$tmp"/kept-files
3004 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3005 actioncmd="gnulib-tool --import"
3006 func_append actioncmd " --dir=$destdir"
3007 if test -n "$local_gnulib_dir"; then
3008 func_append actioncmd " --local-dir=$local_gnulib_dir"
3010 func_append actioncmd " --lib=$libname"
3011 func_append actioncmd " --source-base=$sourcebase"
3012 func_append actioncmd " --m4-base=$m4base"
3013 if test -n "$pobase"; then
3014 func_append actioncmd " --po-base=$pobase"
3016 func_append actioncmd " --doc-base=$docbase"
3017 func_append actioncmd " --tests-base=$testsbase"
3018 func_append actioncmd " --aux-dir=$auxdir"
3019 if test -n "$inctests"; then
3020 func_append actioncmd " --with-tests"
3022 if test -n "$incobsolete"; then
3023 func_append actioncmd " --with-obsolete"
3025 for module in $avoidlist; do
3026 func_append actioncmd " --avoid=$module"
3028 if test -n "$lgpl"; then
3029 if test "$lgpl" = yes; then
3030 func_append actioncmd " --lgpl"
3032 func_append actioncmd " --lgpl=$lgpl"
3035 if test -n "$makefile_name"; then
3036 func_append actioncmd " --makefile-name=$makefile_name"
3038 if test "$libtool" = true; then
3039 func_append actioncmd " --libtool"
3041 func_append actioncmd " --no-libtool"
3043 func_append actioncmd " --macro-prefix=$macro_prefix"
3044 if test -n "$po_domain"; then
3045 func_append actioncmd " --po-domain=$po_domain"
3047 if test -n "$vc_files"; then
3048 if test "$vc_files" = true; then
3049 func_append actioncmd " --vc-files"
3051 func_append actioncmd " --no-vc-files"
3054 func_append actioncmd " `echo $specified_modules`"
3056 # Default the makefile name to Makefile.am.
3057 if test -n "$makefile_name"; then
3058 makefile_am=$makefile_name
3060 makefile_am=Makefile.am
3063 # Create normal Makefile.ams.
3066 # Setup list of Makefile.am edits that are to be performed afterwards.
3067 # Some of these edits apply to files that we will generate; others are
3068 # under the responsibility of the developer.
3070 # func_note_Makefile_am_edit dir var value
3071 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3073 func_note_Makefile_am_edit ()
3075 makefile_am_edits=`expr $makefile_am_edits + 1`
3076 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3077 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3078 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3080 if test "$makefile_am" = Makefile.am; then
3081 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3082 sourcebase_base=`basename "$sourcebase"`
3083 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3085 if test -n "$pobase"; then
3086 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3087 pobase_base=`basename "$pobase"`
3088 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3090 if test -n "$inctests"; then
3091 if test "$makefile_am" = Makefile.am; then
3092 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3093 testsbase_base=`basename "$testsbase"`
3094 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3097 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3099 # Find the first parent directory of $m4base that contains or will contain
3101 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3103 sed_butlast='s,[^/][^/]*//*$,,'
3104 dir1="${m4base}/"; dir2=""
3105 while test -n "$dir1" \
3106 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3107 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3108 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3109 || { test -n "$inctests" \
3110 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3111 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3112 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3113 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3115 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3118 # Create library makefile.
3119 func_dest_tmpfilename $sourcebase/$makefile_am
3120 destfile="$sourcebase/$makefile_am"
3121 modules="$main_modules"
3122 func_emit_lib_Makefile_am > "$tmpfile"
3123 if test -f "$destdir"/$sourcebase/$makefile_am; then
3124 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3128 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3129 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3130 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3132 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3138 echo "Creating $sourcebase/$makefile_am"
3139 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3141 echo "Create $sourcebase/$makefile_am"
3144 func_append added_files "$sourcebase/$makefile_am$nl"
3147 # Create po/ directory.
3148 if test -n "$pobase"; then
3149 # Create po makefile and auxiliary files.
3150 for file in Makefile.in.in remove-potcdate.sin; do
3151 func_dest_tmpfilename $pobase/$file
3152 func_lookup_file build-aux/po/$file
3153 cat "$lookedup_file" > "$tmpfile"
3154 if test -f "$destdir"/$pobase/$file; then
3155 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3159 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3160 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3161 mv -f "$tmpfile" "$destdir"/$pobase/$file
3163 echo "Update $pobase/$file (backup in $pobase/$file~)"
3169 echo "Creating $pobase/$file"
3170 mv -f "$tmpfile" "$destdir"/$pobase/$file
3172 echo "Create $pobase/$file"
3175 func_append added_files "$pobase/$file$nl"
3178 # Create po makefile parameterization, part 1.
3179 func_dest_tmpfilename $pobase/Makevars
3180 func_emit_po_Makevars > "$tmpfile"
3181 if test -f "$destdir"/$pobase/Makevars; then
3182 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3186 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3187 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3188 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3190 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3196 echo "Creating $pobase/Makevars"
3197 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3199 echo "Create $pobase/Makevars"
3202 func_append added_files "$pobase/Makevars$nl"
3204 # Create po makefile parameterization, part 2.
3205 func_dest_tmpfilename $pobase/POTFILES.in
3206 func_emit_po_POTFILES_in > "$tmpfile"
3207 if test -f "$destdir"/$pobase/POTFILES.in; then
3208 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3212 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3213 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3214 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3216 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3222 echo "Creating $pobase/POTFILES.in"
3223 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3225 echo "Create $pobase/POTFILES.in"
3228 func_append added_files "$pobase/POTFILES.in$nl"
3231 TP_URL="http://translationproject.org/latest/"
3232 TP_RSYNC_URI="translationproject.org::tp/latest/"
3234 echo "Fetching gnulib PO files from $TP_URL"
3235 (cd "$destdir"/$pobase \
3236 && { # Prefer rsync over wget if it is available, since it consumes
3237 # less network bandwidth, due to compression.
3238 if type rsync 2>/dev/null | grep / > /dev/null; then
3239 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3241 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3246 echo "Fetch gnulib PO files from $TP_URL"
3248 # Create po/LINGUAS.
3250 func_dest_tmpfilename $pobase/LINGUAS
3251 (cd "$destdir"/$pobase \
3252 && { echo '# Set of available languages.'
3253 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3256 if test -f "$destdir"/$pobase/LINGUAS; then
3257 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3260 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3261 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3262 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3265 echo "Creating $pobase/LINGUAS"
3266 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3267 func_append added_files "$pobase/LINGUAS$nl"
3270 if test -f "$destdir"/$pobase/LINGUAS; then
3271 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3273 echo "Create $pobase/LINGUAS"
3278 # Create m4/gnulib-cache.m4.
3279 func_dest_tmpfilename $m4base/gnulib-cache.m4
3281 func_emit_copyright_notice
3283 echo "# This file represents the specification of how gnulib-tool is used."
3284 echo "# It acts as a cache: It is written and read by gnulib-tool."
3285 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3286 echo "# like the configure.ac and various Makefile.am files."
3289 echo "# Specification in the form of a command-line invocation:"
3292 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3293 # Store the local_gnulib_dir relative to destdir.
3294 case "$local_gnulib_dir" in
3296 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3299 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3301 # destdir, local_gnulib_dir are both relative.
3302 func_relativize "$destdir" "$local_gnulib_dir"
3303 relative_local_gnulib_dir="$reldir" ;;
3306 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3308 echo "$specified_modules" | sed 's/^/ /g'
3310 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3311 echo "gl_AVOID([$avoidlist])"
3312 echo "gl_SOURCE_BASE([$sourcebase])"
3313 echo "gl_M4_BASE([$m4base])"
3314 echo "gl_PO_BASE([$pobase])"
3315 echo "gl_DOC_BASE([$docbase])"
3316 echo "gl_TESTS_BASE([$testsbase])"
3317 test -z "$inctests" || echo "gl_WITH_TESTS"
3318 echo "gl_LIB([$libname])"
3319 if test -n "$lgpl"; then
3320 if test "$lgpl" = yes; then
3323 echo "gl_LGPL([$lgpl])"
3326 echo "gl_MAKEFILE_NAME([$makefile_name])"
3327 if test "$libtool" = true; then
3330 echo "gl_MACRO_PREFIX([$macro_prefix])"
3331 echo "gl_PO_DOMAIN([$po_domain])"
3332 if test -n "$vc_files"; then
3333 echo "gl_VC_FILES([$vc_files])"
3336 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3337 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3341 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3342 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3343 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3345 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3349 echo "# gnulib-cache.m4 ends here"
3356 echo "Creating $m4base/gnulib-cache.m4"
3357 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3359 echo "Create $m4base/gnulib-cache.m4"
3365 # Create m4/gnulib-comp.m4.
3366 func_dest_tmpfilename $m4base/gnulib-comp.m4
3368 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3369 func_emit_copyright_notice
3371 echo "# This file represents the compiled summary of the specification in"
3372 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3373 echo "# to be invoked from configure.ac."
3374 echo "# In projects using CVS, this file can be treated like other built files."
3377 echo "# This macro should be invoked from $configure_ac, in the section"
3378 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3379 echo "# any checks for libraries, header files, types and library functions."
3380 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3382 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3383 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3384 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3385 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3386 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3387 if test -n "$uses_subdirs"; then
3388 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3390 for module in $final_modules; do
3392 if test -n "$module"; then
3393 func_get_autoconf_early_snippet "$module"
3396 | sed -e '/^$/d;' -e 's/^/ /'
3399 echo "# This macro should be invoked from $configure_ac, in the section"
3400 echo "# \"Check for header files, types and library functions\"."
3401 echo "AC_DEFUN([${macro_prefix}_INIT],"
3403 if test "$libtool" = true; then
3404 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3405 echo " gl_cond_libtool=true"
3407 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3408 echo " gl_cond_libtool=false"
3410 echo " gl_ltlibdeps="
3412 if test "$auxdir" != "build-aux"; then
3413 sed_replace_build_aux='
3415 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3416 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3420 sed_replace_build_aux="$sed_noop"
3422 func_emit_initmacro_start $macro_prefix
3423 echo " gl_source_base='$sourcebase'"
3424 for module in $main_modules; do
3426 if test -n "$module"; then
3427 func_get_autoconf_snippet "$module" \
3428 | sed -e '/^$/d;' -e 's/^/ /' \
3429 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3430 -e "$sed_replace_build_aux"
3431 if test "$module" = 'alloca' && test "$libtool" = true; then
3432 echo 'changequote(,)dnl'
3433 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3434 echo 'changequote([, ])dnl'
3435 echo 'AC_SUBST([LTALLOCA])'
3439 func_emit_initmacro_end $macro_prefix
3440 echo " gltests_libdeps="
3441 echo " gltests_ltlibdeps="
3442 func_emit_initmacro_start ${macro_prefix}tests
3443 echo " gl_source_base='$testsbase'"
3444 for module in $testsrelated_modules; do
3446 if test -n "$module"; then
3447 func_get_autoconf_snippet "$module" \
3448 | sed -e '/^$/d;' -e 's/^/ /' \
3449 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3450 -e "$sed_replace_build_aux" \
3451 -e 's/\$gl_cond_libtool/false/g' \
3452 -e 's/gl_libdeps/gltests_libdeps/g' \
3453 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3456 func_emit_initmacro_end ${macro_prefix}tests
3457 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3458 # created using libtool, because libtool already handles the dependencies.
3459 if test "$libtool" != true; then
3460 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3461 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3462 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3463 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3464 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3466 if $use_libtests; then
3467 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3468 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3471 func_emit_initmacro_done $macro_prefix $sourcebase
3472 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3474 echo "# This macro records the list of files which have been installed by"
3475 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3476 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3477 echo "$files" | sed -e 's,^, ,'
3480 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3481 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3485 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3486 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3487 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3489 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3493 echo "# gnulib-comp.m4 ends here"
3500 echo "Creating $m4base/gnulib-comp.m4"
3501 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3503 echo "Create $m4base/gnulib-comp.m4"
3509 if test -n "$inctests"; then
3510 # Create tests makefile.
3511 func_dest_tmpfilename $testsbase/$makefile_am
3512 destfile="$testsbase/$makefile_am"
3513 modules="$testsrelated_modules"
3514 func_emit_tests_Makefile_am > "$tmpfile"
3515 if test -f "$destdir"/$testsbase/$makefile_am; then
3516 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3520 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3521 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3522 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3524 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3530 echo "Creating $testsbase/$makefile_am"
3531 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3533 echo "Create $testsbase/$makefile_am"
3536 func_append added_files "$testsbase/$makefile_am$nl"
3540 if test "$vc_files" != false; then
3541 # Update the .cvsignore and .gitignore files.
3542 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3543 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3544 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3545 echo "$m4base/|A|gnulib-comp.m4"
3546 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3547 { # Rearrange file descriptors. Needed because "while ... done < ..."
3548 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3549 exec 5<&0 < "$tmp"/fileset-changes
3550 func_update_ignorelist ()
3553 if test "$ignore" = .gitignore; then
3554 # In a .gitignore file, "foo" applies to the current directory and all
3555 # subdirectories, whereas "/foo" applies to the current directory only.
3558 doubly_escaped_anchor='\\/'
3562 doubly_escaped_anchor=''
3564 if test -f "$destdir/$dir$ignore"; then
3565 if test -n "$dir_added" || test -n "$dir_removed"; then
3566 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3568 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3569 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
3570 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3571 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
3573 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3575 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3576 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3577 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3578 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
3579 } > "$tmp"/sed-ignore-removed
3580 { cat "$destdir/$dir$ignore"~
3581 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3582 } | sed -f "$tmp"/sed-ignore-removed \
3583 > "$destdir/$dir$ignore"
3585 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3590 if test -n "$dir_added"; then
3592 echo "Creating $destdir/$dir$ignore"
3594 if test "$ignore" = .cvsignore; then
3596 # Automake generates Makefile rules that create .dirstamp files.
3599 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3600 } > "$destdir/$dir$ignore"
3602 echo "Create $destdir/$dir$ignore"
3612 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3613 func_update_ignorelist .cvsignore
3615 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3616 func_update_ignorelist .gitignore
3623 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3624 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3625 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3626 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3627 if test "$next_dir" != "$last_dir"; then
3628 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3629 last_dir="$next_dir"
3634 A) func_append last_dir_added "$file$nl";;
3635 R) func_append last_dir_removed "$file$nl";;
3638 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3645 echo "You may need to add #include directives for the following .h files."
3646 # Intersect $specified_modules and $main_modules
3647 # (since $specified_modules is not necessarily of subset of $main_modules
3648 # - some may have been skipped through --avoid, and since the elements of
3649 # $main_modules but not in $specified_modules can go away without explicit
3650 # notice - through changes in the module dependencies).
3651 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3652 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3653 # First the #include <...> directives without #ifs, sorted for convenience,
3654 # then the #include "..." directives without #ifs, sorted for convenience,
3655 # then the #include directives that are surrounded by #ifs. Not sorted.
3656 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3657 include_directive=`func_get_include_directive "$module"`
3658 case "$nl$include_directive" in
3660 echo "$include_directive" 1>&5
3663 echo "$include_directive" | grep -v 'include "' 1>&6
3664 echo "$include_directive" | grep 'include "' 1>&7
3667 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3669 LC_ALL=C sort -u "$tmp"/include-angles
3670 LC_ALL=C sort -u "$tmp"/include-quotes
3671 cat "$tmp"/include-if
3672 ) | sed -e '/^$/d' -e 's/^/ /'
3673 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3675 for module in $main_modules; do
3676 func_get_link_directive "$module"
3678 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3679 if test `wc -l < "$tmp"/link` != 0; then
3681 echo "You may need to use the following Makefile variables when linking."
3682 echo "Use them in <program>_LDADD when linking a program, or"
3683 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3689 echo "Don't forget to"
3690 if test "$makefile_am" = Makefile.am; then
3691 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3693 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3695 if test -n "$pobase"; then
3696 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3698 if test -n "$inctests"; then
3699 if test "$makefile_am" = Makefile.am; then
3700 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3702 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3706 while test $edit != $makefile_am_edits; do
3707 edit=`expr $edit + 1`
3708 eval dir=\"\$makefile_am_edit${edit}_dir\"
3709 eval var=\"\$makefile_am_edit${edit}_var\"
3710 eval val=\"\$makefile_am_edit${edit}_val\"
3711 if test -n "$var"; then
3712 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
3715 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3716 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3719 # func_create_testdir testdir modules
3721 # - local_gnulib_dir from --local-dir
3722 # - auxdir directory relative to destdir where to place build aux files
3723 func_create_testdir ()
3727 if test -z "$modules"; then
3728 # All modules together.
3729 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3730 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3731 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3732 modules=`func_all_modules`
3733 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3735 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3737 # Check that the license of every module is consistent with the license of
3739 saved_modules="$modules"
3740 saved_inctests="$inctests"
3741 # When computing transitive closures, don't consider $module to depend on
3742 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3743 # on GPL modules - therefore we don't want a warning in this case.
3745 for requested_module in $saved_modules; do
3746 requested_license=`func_get_license "$requested_module"`
3747 if test "$requested_license" != GPL; then
3748 # Here we use func_modules_transitive_closure, not just
3749 # func_get_dependencies, so that we also detect weird situations like
3750 # an LGPL module which depends on a GPLed build tool module which depends
3752 modules="$requested_module"
3753 func_modules_transitive_closure
3754 for module in $modules; do
3755 license=`func_get_license "$module"`
3757 'GPLed build tool') ;;
3758 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3760 case "$requested_license" in
3763 GPLv2+ | LGPLv2+) ;;
3764 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3770 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3776 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3785 modules="$saved_modules"
3786 inctests="$saved_inctests"
3788 # Subdirectory names.
3798 # Determine final module list.
3799 func_modules_transitive_closure
3800 if test $verbose -ge 0; then
3801 echo "Module list with included dependencies:"
3802 echo "$modules" | sed -e 's/^/ /'
3805 # Add the dummy module if needed.
3806 func_modules_add_dummy
3808 # Show banner notice of every module.
3811 # Determine final file list.
3812 func_modules_to_filelist
3813 if test $verbose -ge 0; then
3815 echo "$files" | sed -e 's/^/ /'
3818 sed_rewrite_files="\
3819 s,^build-aux/,$auxdir/,
3821 s,^lib/,$sourcebase/,
3823 s,^tests/,$testsbase/,
3826 # Create directories.
3827 for f in $files; do echo $f; done \
3828 | sed -e "$sed_rewrite_files" \
3829 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3830 | LC_ALL=C sort -u \
3832 { # Rearrange file descriptors. Needed because "while ... done < ..."
3833 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3834 exec 5<&0 < "$tmp"/dirs
3836 mkdir -p "$testdir/$d"
3841 # Copy files or make symbolic links.
3843 for f in $files; do echo $f; done \
3844 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3847 { # Rearrange file descriptors. Needed because "while ... done < ..."
3848 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3849 exec 5<&0 < "$tmp"/files
3851 func_lookup_file "$f"
3852 if test -n "$lookedup_tmp"; then
3853 cp -p "$lookedup_file" "$testdir/$g"
3855 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3856 if { test -n "$symbolic" \
3857 || { test -n "$lsymbolic" \
3858 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3859 func_ln "$lookedup_file" "$testdir/$g"
3861 cp -p "$lookedup_file" "$testdir/$g"
3868 # Create Makefile.ams that are for testing.
3871 # No special edits are needed.
3874 # Create $sourcebase/Makefile.am.
3875 mkdir -p "$testdir/$sourcebase"
3876 destfile="$sourcebase/Makefile.am"
3877 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3878 any_uses_subdirs="$uses_subdirs"
3880 # Create $m4base/Makefile.am.
3881 mkdir -p "$testdir/$m4base"
3882 (echo "## Process this file with automake to produce Makefile.in."
3888 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3891 ) > "$testdir/$m4base/Makefile.am"
3893 subdirs="$sourcebase $m4base"
3894 subdirs_with_configure_ac=""
3896 if false && test -f "$testdir"/$m4base/gettext.m4; then
3897 # Avoid stupid error message from automake:
3898 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3899 mkdir -p "$testdir/po"
3900 (echo "## Process this file with automake to produce Makefile.in."
3901 ) > "$testdir/po/Makefile.am"
3902 func_append subdirs " po"
3905 if test -n "$inctests"; then
3906 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3907 # Viewed from the $testsbase subdirectory, $auxdir is different.
3908 saved_auxdir="$auxdir"
3909 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3910 # Create $testsbase/Makefile.am.
3912 destfile="$testsbase/Makefile.am"
3913 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3914 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3915 # Create $testsbase/configure.ac.
3916 (echo "# Process this file with autoconf to produce a configure script."
3917 echo "AC_INIT([dummy], [0])"
3918 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3919 echo "AM_INIT_AUTOMAKE"
3921 echo "AM_CONFIG_HEADER([config.h])"
3924 echo "AC_PROG_INSTALL"
3925 echo "AC_PROG_MAKE_SET"
3926 echo "AC_PROG_RANLIB"
3928 for module in $modules; do
3930 if test -n "$module"; then
3932 gnumakefile | maintainer-makefile)
3933 # These modules are meant to be used only in the top-level directory.
3936 func_get_autoconf_early_snippet "$module"
3941 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3942 if test "$libtool" = true; then
3943 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3944 echo "gl_cond_libtool=true"
3946 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3947 echo "gl_cond_libtool=false"
3949 echo "gl_ltlibdeps="
3951 # Wrap the set of autoconf snippets into an autoconf macro that is then
3952 # invoked. This is needed because autoconf does not support AC_REQUIRE
3954 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3955 # but we want the AC_REQUIRE to have its normal meaning (provide one
3956 # expansion of the required macro before the current point, and only one
3958 echo "AC_DEFUN([gl_INIT], ["
3959 sed_replace_build_aux='
3961 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3962 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3965 func_emit_initmacro_start $macro_prefix
3966 # We don't have explicit ordering constraints between the various
3967 # autoconf snippets. It's cleanest to put those of the library before
3968 # those of the tests.
3969 echo "gl_source_base='../$sourcebase'"
3970 for module in $modules; do
3971 func_verify_nontests_module
3972 if test -n "$module"; then
3974 gnumakefile | maintainer-makefile)
3975 # These modules are meant to be used only in the top-level directory.
3978 func_get_autoconf_snippet "$module" \
3979 | sed -e "$sed_replace_build_aux"
3984 echo "gl_source_base='.'"
3985 for module in $modules; do
3986 func_verify_tests_module
3987 if test -n "$module"; then
3988 func_get_autoconf_snippet "$module" \
3989 | sed -e "$sed_replace_build_aux"
3992 func_emit_initmacro_end $macro_prefix
3993 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3994 # created using libtool, because libtool already handles the dependencies.
3995 if test "$libtool" != true; then
3996 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3997 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3998 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3999 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4000 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4003 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4007 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4008 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4009 echo "AH_TOP([#include \"../config.h\"])"
4011 echo "AC_OUTPUT([Makefile])"
4012 ) > "$testdir/$testsbase/configure.ac"
4013 auxdir="$saved_auxdir"
4014 func_append subdirs " $testsbase"
4015 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4018 # Create Makefile.am.
4019 (echo "## Process this file with automake to produce Makefile.in."
4021 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4023 echo "SUBDIRS = $subdirs"
4025 echo "ACLOCAL_AMFLAGS = -I $m4base"
4026 ) > "$testdir/Makefile.am"
4028 # Create configure.ac.
4029 (echo "# Process this file with autoconf to produce a configure script."
4030 echo "AC_INIT([dummy], [0])"
4031 if test "$auxdir" != "."; then
4032 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4034 echo "AM_INIT_AUTOMAKE"
4036 echo "AM_CONFIG_HEADER([config.h])"
4039 echo "AC_PROG_INSTALL"
4040 echo "AC_PROG_MAKE_SET"
4042 echo "# For autobuild."
4043 echo "AC_CANONICAL_BUILD"
4044 echo "AC_CANONICAL_HOST"
4046 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4047 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4048 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4049 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4051 echo "AC_PROG_RANLIB"
4053 if test -n "$any_uses_subdirs"; then
4054 echo "AM_PROG_CC_C_O"
4057 for module in $modules; do
4058 func_verify_nontests_module
4059 if test -n "$module"; then
4060 func_get_autoconf_early_snippet "$module"
4063 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4064 if test "$libtool" = true; then
4065 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4066 echo "gl_cond_libtool=true"
4068 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4069 echo "gl_cond_libtool=false"
4071 echo "gl_ltlibdeps="
4073 # Wrap the set of autoconf snippets into an autoconf macro that is then
4074 # invoked. This is needed because autoconf does not support AC_REQUIRE
4076 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4077 # but we want the AC_REQUIRE to have its normal meaning (provide one
4078 # expansion of the required macro before the current point, and only one
4080 echo "AC_DEFUN([gl_INIT], ["
4081 if test "$auxdir" != "build-aux"; then
4082 sed_replace_build_aux='
4084 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4085 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4089 sed_replace_build_aux="$sed_noop"
4091 func_emit_initmacro_start $macro_prefix
4092 echo "gl_source_base='$sourcebase'"
4093 for module in $modules; do
4094 func_verify_nontests_module
4095 if test -n "$module"; then
4096 func_get_autoconf_snippet "$module" \
4097 | sed -e "$sed_replace_build_aux"
4100 func_emit_initmacro_end $macro_prefix
4101 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4102 # created using libtool, because libtool already handles the dependencies.
4103 if test "$libtool" != true; then
4104 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4105 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4106 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4107 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4108 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4111 func_emit_initmacro_done $macro_prefix $sourcebase
4115 if test -n "$subdirs_with_configure_ac"; then
4116 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4118 makefiles="Makefile"
4119 for d in $subdirs; do
4120 # For subdirs that have a configure.ac by their own, it's the subdir's
4121 # configure.ac which creates the subdir's Makefile.am, not this one.
4122 case " $subdirs_with_configure_ac " in
4124 *) func_append makefiles " $d/Makefile" ;;
4127 echo "AC_OUTPUT([$makefiles])"
4128 ) > "$testdir/configure.ac"
4130 # Create autogenerated files.
4132 # Do not use "${AUTORECONF} --force --install", because it may invoke
4133 # autopoint, which brings in older versions of some of our .m4 files.
4134 if test -f $m4base/gettext.m4; then
4135 func_execute_command ${AUTOPOINT} --force || func_exit 1
4136 for f in $m4base/*.m4~; do
4138 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4142 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4143 if ! test -d build-aux; then
4144 func_execute_command mkdir build-aux || func_exit 1
4146 func_execute_command ${AUTOCONF} || func_exit 1
4147 func_execute_command ${AUTOHEADER} || func_exit 1
4148 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4150 if test -n "$inctests"; then
4151 # Create autogenerated files.
4152 (cd "$testdir/$testsbase" || func_exit 1
4153 # Do not use "${AUTORECONF} --force --install", because it may invoke
4154 # autopoint, which brings in older versions of some of our .m4 files.
4155 if test -f ../$m4base/gettext.m4; then
4156 func_execute_command ${AUTOPOINT} --force || func_exit 1
4157 for f in ../$m4base/*.m4~; do
4159 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4163 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4164 if ! test -d ../build-aux; then
4165 func_execute_command mkdir ../build-aux
4167 func_execute_command ${AUTOCONF} || func_exit 1
4168 func_execute_command ${AUTOHEADER} || func_exit 1
4169 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4172 # Need to run configure and make once, to create built files that are to be
4173 # distributed (such as getdate.c).
4174 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4175 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4176 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4177 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4178 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4179 # such $(FOO_H) because they don't refer to distributed files.
4180 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4181 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4182 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4183 | sed -e "$sed_remove_make_variables"`
4184 distributed_built_sources=`for file in $built_sources; do
4185 case "$cleaned_files" in
4190 if test -n "$distributed_built_sources"; then
4192 ./configure || func_exit 1
4194 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4195 make built_sources || func_exit 1
4197 make distclean || func_exit 1
4202 # func_create_megatestdir megatestdir allmodules
4204 # - local_gnulib_dir from --local-dir
4205 # - auxdir directory relative to destdir where to place build aux files
4206 func_create_megatestdir ()
4210 if test -z "$allmodules"; then
4211 allmodules=`func_all_modules`
4215 # First, all modules one by one.
4216 for onemodule in $allmodules; do
4217 func_create_testdir "$megatestdir/$onemodule" $onemodule
4218 func_append megasubdirs "$onemodule "
4220 # Then, all modules all together.
4221 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4222 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
4223 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
4224 func_create_testdir "$megatestdir/ALL" "$allmodules"
4225 func_append megasubdirs "ALL"
4228 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4229 vc_witness="$gnulib_dir/CVS/Entries"; \
4231 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4233 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4234 | sed -e 's,January,01,' -e 's,Jan,01,' \
4235 -e 's,February,02,' -e 's,Feb,02,' \
4236 -e 's,March,03,' -e 's,Mar,03,' \
4237 -e 's,April,04,' -e 's,Apr,04,' \
4239 -e 's,June,06,' -e 's,Jun,06,' \
4240 -e 's,July,07,' -e 's,Jul,07,' \
4241 -e 's,August,08,' -e 's,Aug,08,' \
4242 -e 's,September,09,' -e 's,Sep,09,' \
4243 -e 's,October,10,' -e 's,Oct,10,' \
4244 -e 's,November,11,' -e 's,Nov,11,' \
4245 -e 's,December,12,' -e 's,Dec,12,' \
4246 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4247 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4249 echo "CVSDATE=$cvsdate"
4250 echo "test -d logs || mkdir logs"
4251 echo "for module in $megasubdirs; do"
4252 echo " echo \"Working on module \$module...\""
4253 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4254 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4257 echo " : autobuild project... \$module"
4258 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4259 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4260 echo " : autobuild hostname... \`hostname\`"
4261 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
4263 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4265 ) > "$megatestdir/do-autobuild"
4266 chmod a+x "$megatestdir/do-autobuild"
4268 # Create Makefile.am.
4269 (echo "## Process this file with automake to produce Makefile.in."
4271 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4273 echo "SUBDIRS = $megasubdirs"
4275 echo "EXTRA_DIST = do-autobuild"
4276 ) > "$megatestdir/Makefile.am"
4278 # Create configure.ac.
4279 (echo "# Process this file with autoconf to produce a configure script."
4280 echo "AC_INIT([dummy], [0])"
4281 if test "$auxdir" != "."; then
4282 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4284 echo "AM_INIT_AUTOMAKE"
4286 echo "AC_PROG_MAKE_SET"
4288 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4289 echo "AC_OUTPUT([Makefile])"
4290 ) > "$megatestdir/configure.ac"
4292 # Create autogenerated files.
4294 # Do not use "${AUTORECONF} --install", because autoreconf operates
4295 # recursively, but the subdirectories are already finished, therefore
4296 # calling autoreconf here would only waste lots of CPU time.
4297 func_execute_command ${ACLOCAL} || func_exit 1
4298 func_execute_command mkdir build-aux
4299 func_execute_command ${AUTOCONF} || func_exit 1
4300 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4306 func_fatal_error "no mode specified" ;;
4315 if test -z "$destdir"; then
4318 test -d "$destdir" \
4319 || func_fatal_error "destination directory does not exist: $destdir"
4321 # Prefer configure.ac to configure.in.
4322 if test -f "$destdir"/configure.ac; then
4323 configure_ac="$destdir/configure.ac"
4325 if test -f "$destdir"/configure.in; then
4326 configure_ac="$destdir/configure.in"
4328 func_fatal_error "cannot find $destdir/configure.ac"
4332 # Analyze configure.ac.
4334 guessed_libtool=false
4339 /AC_CONFIG_AUX_DIR/ {
4340 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
4342 /A[CM]_PROG_LIBTOOL/ {
4343 s,^.*$,guessed_libtool=true,p
4345 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4347 if test -z "$auxdir"; then
4348 auxdir="$guessed_auxdir"
4351 # Determine where to apply func_import.
4352 if test -n "$m4base"; then
4353 # Apply func_import to a particular gnulib directory.
4354 # Any number of additional modules can be given.
4355 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4356 # First use of gnulib in the given m4base.
4357 test -n "$supplied_libname" || supplied_libname=true
4358 test -n "$sourcebase" || sourcebase="lib"
4359 test -n "$docbase" || docbase="doc"
4360 test -n "$testsbase" || testsbase="tests"
4361 test -n "$macro_prefix" || macro_prefix="gl"
4365 # Apply func_import to all gnulib directories.
4366 # To get this list of directories, look at Makefile.am. (Not at
4367 # configure, because it may be omitted from CVS. Also, don't run
4368 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4371 if test -f "$destdir"/Makefile.am; then
4372 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4374 for arg in $aclocal_amflags; do
4375 if test -n "$m4dir_is_next"; then
4376 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4380 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4381 func_append m4dirs " $arg"
4382 m4dirs_count=`expr $m4dirs_count + 1`
4388 if test "X$arg" = "X-I"; then
4396 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4397 if test -f "$destdir"/aclocal.m4; then
4398 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4399 sedexpr2='s,^[^/]*$,.,'
4400 sedexpr3='s,/[^/]*$,,'
4401 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4402 m4dirs_count=`echo "$m4dirs" | wc -l`
4405 if test $m4dirs_count = 0; then
4406 # First use of gnulib in a package.
4407 # Any number of additional modules can be given.
4408 test -n "$supplied_libname" || supplied_libname=true
4409 test -n "$sourcebase" || sourcebase="lib"
4411 test -n "$docbase" || docbase="doc"
4412 test -n "$testsbase" || testsbase="tests"
4413 test -n "$macro_prefix" || macro_prefix="gl"
4416 if test $m4dirs_count = 1; then
4417 # There's only one use of gnulib here. Assume the user means it.
4418 # Any number of additional modules can be given.
4419 for m4base in $m4dirs; do
4423 # Ambiguous - guess what the user meant.
4424 if test $# = 0; then
4425 # No further arguments. Guess the user wants to update all of them.
4426 for m4base in $m4dirs; do
4427 # Perform func_import in a subshell, so that variable values
4429 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
4430 # pobase, docbase, testsbase, inctests, libname, lgpl,
4431 # makefile_name, libtool, macro_prefix, po_domain, vc_files
4432 # don't propagate from one directory to another.
4433 (func_import) || func_exit 1
4437 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4445 if test -z "$destdir"; then
4446 func_fatal_error "please specify --dir option"
4449 test -d "$destdir" \
4450 || func_fatal_error "could not create destination directory"
4451 test -n "$auxdir" || auxdir="build-aux"
4452 func_create_testdir "$destdir" "$*"
4455 create-megatestdir )
4456 if test -z "$destdir"; then
4457 func_fatal_error "please specify --dir option"
4459 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4460 test -n "$auxdir" || auxdir="build-aux"
4461 func_create_megatestdir "$destdir" "$*"
4465 test -n "$destdir" || destdir=testdir$$
4466 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4467 test -n "$auxdir" || auxdir="build-aux"
4468 func_create_testdir "$destdir" "$*"
4472 ../configure || func_exit 1
4474 make check || func_exit 1
4475 make distclean || func_exit 1
4476 remaining=`find . -type f -print`
4477 if test -n "$remaining"; then
4478 echo "Remaining files:" $remaining 1>&2
4479 echo "gnulib-tool: *** Stop." 1>&2
4488 test -n "$destdir" || destdir=testdir$$
4489 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4490 test -n "$auxdir" || auxdir="build-aux"
4491 func_create_megatestdir "$destdir" "$*"
4499 remaining=`find . -type f -print`
4500 if test -n "$remaining"; then
4501 echo "Remaining files:" $remaining 1>&2
4502 echo "gnulib-tool: *** Stop." 1>&2
4510 extract-description )
4514 if test -n "$module"; then
4515 func_get_description "$module"
4524 if test -n "$module"; then
4525 func_get_status "$module"
4534 if test -n "$module"; then
4535 func_get_notice "$module"
4544 if test -n "$module"; then
4545 func_get_filelist "$module"
4550 extract-dependencies )
4554 if test -n "$module"; then
4555 func_get_dependencies "$module"
4560 extract-autoconf-snippet )
4564 if test -n "$module"; then
4565 func_get_autoconf_snippet "$module"
4570 extract-automake-snippet )
4574 if test -n "$module"; then
4575 func_get_automake_snippet "$module"
4580 extract-include-directive )
4584 if test -n "$module"; then
4585 func_get_include_directive "$module"
4590 extract-link-directive )
4594 if test -n "$module"; then
4595 func_get_link_directive "$module"
4604 if test -n "$module"; then
4605 func_get_license "$module"
4610 extract-maintainer )
4614 if test -n "$module"; then
4615 func_get_maintainer "$module"
4620 extract-tests-module )
4624 if test -n "$module"; then
4625 func_get_tests_module "$module"
4631 func_fatal_error "unknown operation mode --$mode" ;;
4635 # Undo the effect of the previous 'trap' command. Some shellology:
4636 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4637 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4638 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4639 # 128 + signal number and is set before the trap-registered command is run.
4641 trap 'func_exit $?' 1 2 3 13 15
4646 # indent-tabs-mode: nil
4647 # whitespace-check-buffer-indent: nil