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"
67 if test -z "${MAKE}"; then
71 # When using GNU sed, turn off as many GNU extensions as possible,
72 # to minimize the risk of accidentally using non-portable features.
73 # However, do this only for gnulib-tool itself, not for the code that
74 # gnulib-tool generates, since we don't want "sed --posix" to leak
75 # into makefiles. And do it only for sed versions 4.2 or newer,
76 # because "sed --posix" is buggy in GNU sed 4.1.5, see
77 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
78 if (alias) > /dev/null 2>&1 \
79 && echo | sed --posix -e d >/dev/null 2>&1 \
80 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
81 [1-3]* | 4.[01]*) false;; \
85 # Define sed as an alias.
86 # It is not always possible to use aliases. Aliases are guaranteed to work
87 # if the executing shell is bash and either it is invoked as /bin/sh or
88 # is a version >= 2.0, supporting shopt. This is the common case.
89 # Two other approaches (use of a variable $sed or of a function func_sed
90 # instead of an alias) require massive, fragile code changes.
91 # An other approach (use of function sed) requires `which sed` - but
92 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
93 if test -n "$BASH_VERSION"; then
94 shopt -s expand_aliases >/dev/null 2>&1
96 alias sed='sed --posix'
99 # sed_noop is a sed expression that does nothing.
100 # An empty expression does not work with the native 'sed' on AIX 6.1.
104 # outputs to stdout the --help usage message.
108 Usage: gnulib-tool --list
109 gnulib-tool --import [module1 ... moduleN]
111 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
112 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
113 gnulib-tool --test --dir=directory module1 ... moduleN
114 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
115 gnulib-tool --extract-description module
116 gnulib-tool --extract-status module
117 gnulib-tool --extract-notice module
118 gnulib-tool --extract-filelist module
119 gnulib-tool --extract-dependencies module
120 gnulib-tool --extract-autoconf-snippet module
121 gnulib-tool --extract-automake-snippet module
122 gnulib-tool --extract-include-directive module
123 gnulib-tool --extract-link-directive module
124 gnulib-tool --extract-license module
125 gnulib-tool --extract-maintainer module
126 gnulib-tool --extract-tests-module module
127 gnulib-tool --copy-file file [destination]
130 --list print the available module names
131 --import import the given modules into the current package;
132 if no modules are specified, update the current
133 package from the current gnulib
134 --update update the current package, restore files omitted
136 --create-testdir create a scratch package with the given modules
137 --create-megatestdir create a mega scratch package with the given modules
138 one by one and all together
139 --test test the combination of the given modules
140 (recommended to use CC=\"gcc -Wall\" here)
141 --megatest test the given modules one by one and all together
142 (recommended to use CC=\"gcc -Wall\" here)
143 --extract-description extract the description
144 --extract-status extract the status (obsolete or not)
145 --extract-notice extract the notice or banner
146 --extract-filelist extract the list of files
147 --extract-dependencies extract the dependencies
148 --extract-autoconf-snippet extract the snippet for configure.ac
149 --extract-automake-snippet extract the snippet for library makefile
150 --extract-include-directive extract the #include directive
151 --extract-link-directive extract the linker directive
152 --extract-license report the license terms of the source files
154 --extract-maintainer report the maintainer(s) inside gnulib
155 --extract-tests-module report the unit test module, if it exists
156 --copy-file copy a file that is not part of any module
159 --dir=DIRECTORY Specify the target directory.
160 For --import, this specifies where your
161 configure.ac can be found. Defaults to current
163 --local-dir=DIRECTORY Specify a local override directory where to look
164 up files before looking in gnulib's directory.
165 --verbose Increase verbosity. May be repeated.
166 --quiet Decrease verbosity. May be repeated.
168 Options for --import:
169 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
170 --source-base=DIRECTORY
171 Directory relative to --dir where source code is
172 placed (default \"lib\").
173 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
174 placed (default \"m4\").
175 --po-base=DIRECTORY Directory relative to --dir where *.po files are
176 placed (default \"po\").
177 --doc-base=DIRECTORY Directory relative to --dir where doc files are
178 placed (default \"doc\").
179 --tests-base=DIRECTORY
180 Directory relative to --dir where unit tests are
181 placed (default \"tests\").
182 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
183 tools are placed (default \"build-aux\").
184 --with-tests Include unit tests for the included modules.
185 --with-obsolete Include obsolete modules when they occur among the
186 dependencies. By default, dependencies to obsolete
188 --avoid=MODULE Avoid including the given MODULE. Useful if you
189 have code that provides equivalent functionality.
190 This option can be repeated.
191 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
192 Also modify license template from GPL to LGPL.
193 The version number of the LGPL can be specified;
194 the default is currently LGPLv3.
195 --makefile-name=NAME Name of makefile in automake syntax in the
196 source-base and tests-base directories
197 (default \"Makefile.am\").
198 --libtool Use libtool rules.
199 --no-libtool Don't use libtool rules.
200 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
201 'gl_INIT'. Default is 'gl'.
202 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
203 the package name. A suffix '-gnulib' is appended.
204 --vc-files Update version control related files.
205 --no-vc-files Don't update version control related files
206 (.gitignore and/or .cvsignore).
207 --no-changelog Don't update or create ChangeLog files.
209 Options for --import and --update:
210 --dry-run For --import, only print what would have been done.
211 -s, --symbolic, --symlink Make symbolic links instead of copying files.
212 --local-symlink Make symbolic links instead of copying files, only
213 for files from the local override directory.
214 -S, --more-symlinks Make symbolic links instead of copying files, and
215 don't replace copyright notices.
217 Report bugs to <bug-gnulib@gnu.org>."
221 # outputs to stdout the --version message.
225 if test -d "$gnulib_dir"/.git \
226 && (git --version) >/dev/null 2>/dev/null \
227 && (date --version) >/dev/null 2>/dev/null; then
228 # gnulib checked out from git.
229 sed_extract_first_date='/^Date/{
233 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
234 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
235 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
236 date=`echo "$date" | sed -e "$sed_year_before_time"`
237 # Use GNU date to compute the time in GMT.
238 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
239 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
241 if test -d "$gnulib_dir"/CVS \
242 && (cvs --version) >/dev/null 2>/dev/null; then
243 # gnulib checked out from CVS.
244 sed_extract_first_date='/^date: /{
245 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
248 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
250 # gnulib copy without versioning information.
251 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
255 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
257 gnulib-tool (GNU $package $date)$version
258 Copyright (C) $year Free Software Foundation, Inc.
259 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
260 This is free software: you are free to change and redistribute it.
261 There is NO WARRANTY, to the extent permitted by law.
263 Written by" "Bruno Haible" "and" "Simon Josefsson"
266 # func_emit_copyright_notice
267 # outputs to stdout a header for a generated file.
268 func_emit_copyright_notice ()
270 sed -n '/Copyright/ {
273 }' < "$self_abspathname"
275 echo "# This file is free software, distributed under the terms of the GNU"
276 echo "# General Public License. As a special exception to the GNU General"
277 echo "# Public License, this file may be distributed as part of a program"
278 echo "# that contains a configuration script generated by Autoconf, under"
279 echo "# the same distribution terms as the rest of that program."
281 echo "# Generated by gnulib-tool."
285 # exits with a given status.
286 # This function needs to be used, rather than 'exit', when a 'trap' handler is
287 # in effect that refers to $?.
294 # locates the directory where the gnulib repository lives
296 # - progname name of this program
298 # - self_abspathname absolute pathname of gnulib-tool
299 # - gnulib_dir absolute pathname of gnulib repository
303 /*) self_abspathname="$progname" ;;
304 */*) self_abspathname=`pwd`/"$progname" ;;
307 # Iterate through the elements of $PATH.
308 # We use IFS=: instead of
309 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
310 # because the latter does not work when some PATH element contains spaces.
311 # We use a canonicalized $pathx instead of $PATH, because empty PATH
312 # elements are by definition equivalent to '.', however field splitting
313 # according to IFS=: loses empty fields in many shells:
314 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
315 # beginning, at the end, and in the middle),
316 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
317 # at the beginning and at the end,
318 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
319 # Solaris lose empty fields at the end.
320 # The 'case' statement is an optimization, to avoid evaluating the
321 # explicit canonicalization command when $PATH contains no empty fields.
323 if test "${PATH_SEPARATOR+set}" != set; then
325 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
326 chmod +x "$tmp"/conf.sh
327 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
334 if test "$PATH_SEPARATOR" = ";"; then
335 # On Windows, programs are searched in "." before $PATH.
338 # On Unix, we have to convert empty PATH elements to ".".
342 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
347 IFS="$PATH_SEPARATOR"
351 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
352 self_abspathname="$d/$progname"
357 if test -z "$self_abspathname"; then
358 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
362 while test -h "$self_abspathname"; do
363 # Resolve symbolic link.
364 linkval=`func_readlink "$self_abspathname"`
365 test -n "$linkval" || break
367 /* ) self_abspathname="$linkval" ;;
368 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
371 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
375 # creates a temporary directory.
377 # - progname name of this program
379 # - tmp pathname of freshly created temporary directory
382 # Use the environment variable TMPDIR, falling back to /tmp. This allows
383 # users to specify a different temporary directory, for example, if their
384 # /tmp is filled up or too small.
387 # Use the mktemp program if available. If not available, hide the error
389 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
390 test -n "$tmp" && test -d "$tmp"
393 # Use a simple mkdir command. It is guaranteed to fail if the directory
394 # already exists. $RANDOM is bash specific and expands to empty in shells
395 # other than bash, ksh and zsh. Its use does not increase security;
396 # rather, it minimizes the probability of failure in a very cluttered /tmp
398 tmp=$TMPDIR/gl$$-$RANDOM
399 (umask 077 && mkdir "$tmp")
402 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
407 # func_append var value
408 # appends the given value to the shell variable var.
409 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
410 # Use bash's += operator. It reduces complexity of appending repeatedly to
411 # a single variable from O(n^2) to O(n).
416 fast_func_append=true
420 eval "$1=\"\$$1\$2\""
422 fast_func_append=false
425 # func_remove_prefix var prefix
426 # removes the given prefix from the value of the shell variable var.
427 # var should be the name of a shell variable.
428 # Its value should not contain a newline and not start or end with whitespace.
429 # prefix should not contain the characters "$`\{}[]^|.
430 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
431 func_remove_prefix ()
435 fast_func_remove_prefix=true
437 func_remove_prefix ()
439 eval "value=\"\$$1\""
443 sed_escape_dots='s/\([.]\)/\\\1/g'
444 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
447 value=`echo "$value" | sed -e "s|^${prefix}||"`
448 eval "$1=\"\$value\""
450 fast_func_remove_prefix=false
453 # func_remove_suffix var suffix
454 # removes the given suffix from the value of the shell variable var.
455 # var should be the name of a shell variable.
456 # Its value should not contain a newline and not start or end with whitespace.
457 # suffix should not contain the characters "$`\{}[]^|.
458 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
459 func_remove_suffix ()
463 fast_func_remove_suffix=true
465 func_remove_suffix ()
467 eval "value=\"\$$1\""
471 sed_escape_dots='s/\([.]\)/\\\1/g'
472 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
475 value=`echo "$value" | sed -e "s|${suffix}\$||"`
476 eval "$1=\"\$value\""
478 fast_func_remove_suffix=false
481 # func_fatal_error message
482 # outputs to stderr a fatal error message, and terminates the program.
484 # - progname name of this program
487 echo "$progname: *** $1" 1>&2
488 echo "$progname: *** Stop." 1>&2
492 # func_readlink SYMLINK
493 # outputs the target of the given symlink.
494 if (type -p readlink) > /dev/null 2>&1; then
497 # Use the readlink program from GNU coreutils.
503 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
504 # would do the wrong thing if the link target contains " -> ".
505 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
509 # func_relativize DIR1 DIR2
510 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
512 # - DIR1 relative pathname, relative to the current directory
513 # - DIR2 relative pathname, relative to the current directory
515 # - reldir relative pathname of DIR2, relative to DIR1
521 sed_first='s,^\([^/]*\)/.*$,\1,'
522 sed_rest='s,^[^/]*/*,,'
523 sed_last='s,^.*/\([^/]*\)$,\1,'
524 sed_butlast='s,/*[^/]*$,,'
525 while test -n "$dir1"; do
526 first=`echo "$dir1" | sed -e "$sed_first"`
527 if test "$first" != "."; then
528 if test "$first" = ".."; then
529 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
530 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
532 first2=`echo "$dir2" | sed -e "$sed_first"`
533 if test "$first2" = "$first"; then
534 dir2=`echo "$dir2" | sed -e "$sed_rest"`
538 dir0="$dir0"/"$first"
541 dir1=`echo "$dir1" | sed -e "$sed_rest"`
546 # func_relconcat DIR1 DIR2
547 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
549 # - DIR1 relative pathname, relative to the current directory
550 # - DIR2 relative pathname, relative to DIR1
552 # - relconcat DIR1/DIR2, relative to the current directory
557 sed_first='s,^\([^/]*\)/.*$,\1,'
558 sed_rest='s,^[^/]*/*,,'
559 sed_last='s,^.*/\([^/]*\)$,\1,'
560 sed_butlast='s,/*[^/]*$,,'
562 first=`echo "$dir2" | sed -e "$sed_first"`
563 if test "$first" = "."; then
564 dir2=`echo "$dir2" | sed -e "$sed_rest"`
565 if test -z "$dir2"; then
570 last=`echo "$dir1" | sed -e "$sed_last"`
571 while test "$last" = "."; do
572 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
573 last=`echo "$dir1" | sed -e "$sed_last"`
575 if test -z "$dir1"; then
579 if test "$first" = ".."; then
580 if test "$last" = ".."; then
581 relconcat="$dir1/$dir2"
584 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
585 dir2=`echo "$dir2" | sed -e "$sed_rest"`
586 if test -z "$dir1"; then
590 if test -z "$dir2"; then
595 relconcat="$dir1/$dir2"
603 # Like ln -s, except that SRC is given relative to the current directory (or
604 # absolute), not given relative to the directory of DEST.
610 *) # SRC is relative.
613 ln -s "`pwd`/$1" "$2" ;;
614 *) # DEST is relative too.
615 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
616 test -n "$ln_destdir" || ln_destdir="."
617 func_relativize "$ln_destdir" "$1"
625 # func_ln_if_changed SRC DEST
626 # Like func_ln, but avoids munging timestamps if the link is correct.
627 func_ln_if_changed ()
629 if test $# -ne 2; then
630 echo "usage: func_ln_if_changed SRC DEST" >&2
632 ln_target=`func_readlink "$2"`
633 if test -h "$2" && test "$1" = "$ln_target"; then
642 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
643 # writes into a pipe with no readers, i.e. a pipe where all readers have
644 # already closed their file descriptor that read from it or exited entirely.
645 # The default behaviour is to terminate the current process without an error
647 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
648 # terminate the current process with an error message.
649 # This function should be called at the beginning of a command that only
650 # produces output to stdout (i.e. no side effects!), when the command that
651 # will read from this pipe might prematurely exit or close its standard input
653 if test -n "$BASH_VERSION"; then
654 # The problem has only been reported with bash. Probably it occurs only with
655 # bash-3.2. For the reasons, see
656 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
657 # Note that Solaris sh does not understand "trap - SIGPIPE".
658 func_reset_sigpipe ()
663 func_reset_sigpipe ()
669 # Ensure an 'echo' command that does not interpret backslashes.
671 # echo '\n' | wc -l prints 1 when OK, 2 when KO
672 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
673 # This problem is a weird heritage from SVR4. BSD got it right (except that
674 # BSD echo interprets '-n' as an option, which is also not desirable).
675 # Nowadays the problem occurs in 4 situations:
676 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
677 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
678 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
679 # - in zsh, when sh-emulation is not set,
680 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
681 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
682 # - in Solaris /bin/sh and OSF/1 /bin/sh.
683 # We try the following workarounds:
684 # - for all: respawn using $CONFIG_SHELL if that is set and works.
685 # - for bash >= 2.04: unset the shell option xpg_echo.
686 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
687 # - for bash < 2.0: define echo to a function that uses cat of a here document.
688 # - for zsh: turn sh-emulation on.
689 # - for ksh: alias echo to 'print -r'.
690 # - for ksh: alias echo to a function that uses cat of a here document.
691 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
692 # the ksh workaround.
693 # - otherwise: respawn using /bin/sh and rely on the workarounds.
694 # When respawning, we pass --no-reexec as first argument, so as to avoid
695 # turning this script into a fork bomb in unlucky situations.
697 if echo '\t' | grep t > /dev/null; then
698 have_echo=yes # Lucky!
700 # Try the workarounds.
701 # Respawn using $CONFIG_SHELL if that is set and works.
702 if test -z "$have_echo" \
703 && test "X$1" != "X--no-reexec" \
704 && test -n "$CONFIG_SHELL" \
705 && test -f "$CONFIG_SHELL" \
706 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
707 exec $CONFIG_SHELL "$0" --no-reexec "$@"
710 # For bash >= 2.04: unset the shell option xpg_echo.
711 if test -z "$have_echo" \
712 && test -n "$BASH_VERSION" \
713 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
717 # For bash >= 2.0: define echo to a function that uses the printf built-in.
718 # For bash < 2.0: define echo to a function that uses cat of a here document.
719 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
720 if test -z "$have_echo" \
721 && test -n "$BASH_VERSION"; then \
722 if type printf 2>/dev/null | grep / > /dev/null; then
723 # 'printf' is not a shell built-in.
731 # 'printf' is a shell built-in.
737 if echo '\t' | grep t > /dev/null; then
741 # For zsh: turn sh-emulation on.
742 if test -z "$have_echo" \
743 && test -n "$ZSH_VERSION" \
744 && (emulate sh) >/dev/null 2>&1; then
747 # For ksh: alias echo to 'print -r'.
748 if test -z "$have_echo" \
749 && (type print) >/dev/null 2>&1; then
750 # A 'print' command exists.
751 if type print 2>/dev/null | grep / > /dev/null; then
754 # 'print' is a shell built-in.
755 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
756 # 'print' is the ksh shell built-in.
757 alias echo='print -r'
761 if test -z "$have_echo" \
762 && echo '\t' | grep t > /dev/null; then
765 # For ksh: alias echo to a function that uses cat of a here document.
766 # The ksh manual page says:
767 # "Aliasing is performed when scripts are read, not while they are executed.
768 # Therefore, for an alias to take effect, the alias definition command has
769 # to be executed before the command which references the alias is read."
770 # Because of this, we have to play strange tricks with have_echo, to ensure
771 # that the top-level statement containing the test starts after the 'alias'
773 if test -z "$have_echo"; then
780 alias echo=bsd_echo 2>/dev/null
782 if test -z "$have_echo" \
783 && echo '\t' | grep t > /dev/null; then
786 if test -z "$have_echo"; then
787 unalias echo 2>/dev/null
789 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
790 if test -z "$have_echo" \
791 && test "X$1" != "X--no-reexec" \
792 && test -f /bin/ksh; then
793 exec /bin/ksh "$0" --no-reexec "$@"
796 # Otherwise: respawn using /bin/sh.
797 if test -z "$have_echo" \
798 && test "X$1" != "X--no-reexec" \
799 && test -f /bin/sh; then
800 exec /bin/sh "$0" --no-reexec "$@"
803 if test -z "$have_echo"; then
804 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
806 if echo '\t' | grep t > /dev/null; then
809 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
811 if test "X$1" = "X--no-reexec"; then
815 # Command-line option processing.
816 # Removes the OPTIONS from the arguments. Sets the variables:
817 # - mode list or import or create-testdir or create-megatestdir
818 # - destdir from --dir
819 # - local_gnulib_dir from --local-dir
820 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
821 # - libname, supplied_libname from --lib
822 # - sourcebase from --source-base
823 # - m4base from --m4-base
824 # - pobase from --po-base
825 # - docbase from --doc-base
826 # - testsbase from --tests-base
827 # - auxdir from --aux-dir
828 # - inctests true if --with-tests was given, blank otherwise
829 # - incobsolete true if --with-obsolete was given, blank otherwise
830 # - avoidlist list of modules to avoid, from --avoid
831 # - lgpl yes or a number if --lgpl was given, blank otherwise
832 # - makefile_name from --makefile-name
833 # - libtool true if --libtool was given, false if --no-libtool was
834 # given, blank otherwise
835 # - macro_prefix from --macro-prefix
836 # - po_domain from --po-domain
837 # - vc_files true if --vc-files was given, false if --no-vc-files was
838 # given, blank otherwise
839 # - autoconf_minversion minimum supported autoconf version
840 # - do_changelog false if --no-changelog was given, : otherwise
841 # - doit : if actions shall be executed, false if only to be printed
842 # - symbolic true if --symlink or --more-symlinks was given, blank
844 # - lsymbolic true if --local-symlink was given, blank otherwise
845 # - do_copyrights blank if --more-symlinks was given, true otherwise
876 while test $# -gt 0; do
881 --import | --impor | --impo | --imp | --im | --i )
884 --update | --updat | --upda | --upd | --up | --u )
887 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
890 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
891 mode=create-megatestdir
893 --test | --tes | --te | --t )
896 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
900 mode=`echo "X$1" | sed -e 's/^X--//'`
902 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
908 func_fatal_error "missing argument for --dir"
913 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
918 func_fatal_error "missing argument for --local-dir"
923 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
925 --verbose | --verbos | --verbo | --verb )
926 verbose=`expr $verbose + 1`
928 --quiet | --quie | --qui | --qu | --q )
929 verbose=`expr $verbose - 1`
934 func_fatal_error "missing argument for --lib"
937 supplied_libname=true
940 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
941 supplied_libname=true
946 func_fatal_error "missing argument for --source-base"
951 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
956 func_fatal_error "missing argument for --m4-base"
961 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
966 func_fatal_error "missing argument for --po-base"
971 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
976 func_fatal_error "missing argument for --doc-base"
981 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
986 func_fatal_error "missing argument for --tests-base"
991 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
996 func_fatal_error "missing argument for --aux-dir"
1001 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1011 if test $# = 0; then
1012 func_fatal_error "missing argument for --avoid"
1014 func_append avoidlist " $1"
1017 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1018 func_append avoidlist " $arg"
1024 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1027 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1033 if test $# = 0; then
1034 func_fatal_error "missing argument for --makefile-name"
1039 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1049 if test $# = 0; then
1050 func_fatal_error "missing argument for --macro-prefix"
1055 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1059 if test $# = 0; then
1060 func_fatal_error "missing argument for --po-domain"
1065 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1073 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
1079 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1082 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1085 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1089 --help | --hel | --he | --h )
1092 --version | --versio | --versi | --vers )
1096 # Stop option processing
1100 echo "gnulib-tool: unknown option $1" 1>&2
1101 echo "Try 'gnulib-tool --help' for more information." 1>&2
1108 if test "$mode" = update; then
1109 if test $# != 0; then
1110 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1111 echo "Try 'gnulib-tool --help' for more information." 1>&2
1112 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1113 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1116 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1117 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1118 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1119 || test -n "$inctests" || test -n "$incobsolete" \
1120 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1121 || test -n "$macro_prefix" || test -n "$po_domain" \
1122 || test -n "$vc_files"; then
1123 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1124 echo "Try 'gnulib-tool --help' for more information." 1>&2
1125 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1126 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1131 if test -n "$pobase" && test -z "$po_domain"; then
1132 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1133 echo "Try 'gnulib-tool --help' for more information." 1>&2
1136 if test -z "$pobase" && test -n "$po_domain"; then
1137 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1140 # Determine the minimum supported autoconf version from the project's
1142 DEFAULT_AUTOCONF_MINVERSION="2.59"
1143 autoconf_minversion=
1145 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1146 if test -f "$destdir"/configure.ac; then
1147 configure_ac="$destdir/configure.ac"
1149 if test -f "$destdir"/configure.in; then
1150 configure_ac="$destdir/configure.in"
1154 if test -f configure.ac; then
1155 configure_ac="configure.ac"
1157 if test -f configure.in; then
1158 configure_ac="configure.in"
1162 if test -n "$configure_ac"; then
1163 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1164 # because when some m4 files are omitted from a CVS repository,
1165 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1166 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1167 # autom4te: m4 failed with exit status: 1
1174 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1176 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1177 if test -n "$prereqs"; then
1178 autoconf_minversion=`
1179 for version in $prereqs; do echo $version; done |
1180 LC_ALL=C sort -nru | sed 1q
1184 if test -z "$autoconf_minversion"; then
1185 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1187 case "$autoconf_minversion" in
1188 1.* | 2.[0-4]* | 2.5[0-8]*)
1189 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1192 # Remove trailing slashes from the directory names. This is necessary for
1193 # m4base (to avoid an error in func_import) and optional for the others.
1194 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1195 case "$local_gnulib_dir" in
1196 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1198 case "$sourcebase" in
1199 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1202 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1205 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1208 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1210 case "$testsbase" in
1211 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1214 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1220 trap 'exit_status=$?
1221 if test "$signal" != 0; then
1222 echo "caught signal $signal" >&2
1225 exit $exit_status' 0
1226 for signal in 1 2 3 13 15; do
1227 trap '{ signal='$signal'; func_exit 1; }' $signal
1231 # func_lookup_file file
1232 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1235 # - local_gnulib_dir from --local-dir
1237 # - lookedup_file name of the merged (combined) file
1238 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1242 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1243 lookedup_file="$local_gnulib_dir/$lkfile"
1246 if test -f "$gnulib_dir/$lkfile"; then
1247 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1248 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1249 rm -f "$tmp/$lkbase"
1250 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1251 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1252 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1253 lookedup_file="$tmp/$lkbase"
1256 lookedup_file="$gnulib_dir/$lkfile"
1260 func_fatal_error "file $gnulib_dir/$lkfile not found"
1267 # - local_gnulib_dir from --local-dir
1270 # Filter out metainformation files like README, which are not modules.
1271 # Filter out unit test modules; they can be retrieved through
1272 # --extract-tests-module if desired.
1274 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1275 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1276 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1279 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1280 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1281 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1282 -e '/^README$/d' -e '/\/README$/d' \
1283 -e '/^TEMPLATE$/d' \
1284 -e '/^TEMPLATE-EXTENDED$/d' \
1285 -e '/^TEMPLATE-TESTS$/d' \
1288 | sed -e '/-tests$/d' \
1292 # func_verify_module
1293 # verifies a module name
1295 # - local_gnulib_dir from --local-dir
1296 # - module module name argument
1297 func_verify_module ()
1299 if { test -f "$gnulib_dir/modules/$module" \
1300 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1301 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1302 && test "CVS" != "$module" \
1303 && test "ChangeLog" != "$module" \
1304 && test "COPYING" != "$module" \
1305 && test "README" != "$module" \
1306 && test "TEMPLATE" != "$module" \
1307 && test "TEMPLATE-EXTENDED" != "$module" \
1308 && test "TEMPLATE-TESTS" != "$module"; then
1309 # OK, $module is a correct module name.
1310 # Verify that building the module description with 'patch' succeeds.
1311 func_lookup_file "modules/$module"
1313 echo "gnulib-tool: module $module doesn't exist" 1>&2
1318 # func_verify_nontests_module
1319 # verifies a module name, excluding tests modules
1321 # - local_gnulib_dir from --local-dir
1322 # - module module name argument
1323 func_verify_nontests_module ()
1326 *-tests ) module= ;;
1327 * ) func_verify_module ;;
1331 # func_verify_tests_module
1332 # verifies a module name, considering only tests modules
1334 # - local_gnulib_dir from --local-dir
1335 # - module module name argument
1336 func_verify_tests_module ()
1339 *-tests ) func_verify_module ;;
1344 sed_extract_prog=':[ ]*$/ {
1347 s/^Description:[ ]*$//
1351 s/^Depends-on:[ ]*$//
1352 s/^configure\.ac-early:[ ]*$//
1353 s/^configure\.ac:[ ]*$//
1354 s/^Makefile\.am:[ ]*$//
1358 s/^Maintainer:[ ]*$//
1365 # func_get_description module
1367 # - local_gnulib_dir from --local-dir
1368 func_get_description ()
1370 func_lookup_file "modules/$1"
1371 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1374 # func_get_status module
1376 # - local_gnulib_dir from --local-dir
1379 func_lookup_file "modules/$1"
1380 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1383 # func_get_notice module
1385 # - local_gnulib_dir from --local-dir
1388 func_lookup_file "modules/$1"
1389 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1392 # func_get_filelist module
1394 # - local_gnulib_dir from --local-dir
1395 func_get_filelist ()
1397 func_lookup_file "modules/$1"
1398 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1400 echo m4/gnulib-common.m4
1401 case "$autoconf_minversion" in
1408 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1409 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1410 # elements starting with prefix and ending with suffix are considered.
1411 # Processing: removed_prefix and removed_suffix are removed from each element,
1412 # added_prefix and added_suffix are added to each element.
1413 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1414 # added_prefix, added_suffix should not contain the characters \|&.
1415 func_filter_filelist ()
1417 if test "$2" != "$nl" \
1418 || { $fast_func_append \
1419 && { test -z "$6" || $fast_func_remove_prefix; } \
1420 && { test -z "$7" || $fast_func_remove_suffix; }; \
1426 if test -n "$6"; then
1427 func_remove_prefix fff "$6"
1429 if test -n "$7"; then
1430 func_remove_suffix fff "$7"
1433 if test -z "$ffflist"; then
1436 func_append ffflist "$2${fff}"
1442 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1443 ffflist=`for fff in $3; do
1445 "$4"*"$5") echo "$fff" ;;
1447 done | sed -e "$sed_fff_filter"`
1449 eval "$1=\"\$ffflist\""
1452 # func_get_dependencies module
1454 # - local_gnulib_dir from --local-dir
1455 func_get_dependencies ()
1457 # ${module}-tests always implicitly depends on ${module}.
1461 func_remove_suffix fgd1 '-tests'
1465 # Then the explicit dependencies listed in the module description.
1466 func_lookup_file "modules/$1"
1467 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1470 # func_get_autoconf_early_snippet module
1472 # - local_gnulib_dir from --local-dir
1473 func_get_autoconf_early_snippet ()
1475 func_lookup_file "modules/$1"
1476 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1479 # func_get_autoconf_snippet module
1481 # - local_gnulib_dir from --local-dir
1482 func_get_autoconf_snippet ()
1484 func_lookup_file "modules/$1"
1485 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1488 # func_get_automake_snippet module
1490 # - local_gnulib_dir from --local-dir
1491 func_get_automake_snippet ()
1493 func_lookup_file "modules/$1"
1494 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1497 # *-tests module live in tests/, not lib/.
1498 # Synthesize an EXTRA_DIST augmentation.
1499 all_files=`func_get_filelist $1`
1500 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1501 extra_files="$tests_files"
1502 if test -n "$extra_files"; then
1503 echo "EXTRA_DIST +=" $extra_files
1508 # Synthesize an EXTRA_DIST augmentation.
1509 sed_combine_lines='/\\$/{
1516 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1517 already_mentioned_files=` \
1518 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1519 | sed -e "$sed_combine_lines" \
1520 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1521 all_files=`func_get_filelist $1`
1522 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
1523 # Remove $already_mentioned_files from $lib_files.
1524 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1525 extra_files=`func_reset_sigpipe; \
1526 for f in $already_mentioned_files; do echo $f; done \
1527 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1528 if test -n "$extra_files"; then
1529 echo "EXTRA_DIST +=" $extra_files
1532 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1533 # This is necessary so that automake can generate the right list of
1535 # A possible approach would be to use autom4te --trace of the redefined
1536 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1537 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1538 # inside autoconf's built-in macros are not missed).
1539 # But it's simpler and more robust to do it here, based on the file list.
1540 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1541 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1542 # automake will generate a useless dependency; this is harmless.
1544 relocatable-prog-wrapper) ;;
1546 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
1547 if test -n "$extra_files"; then
1548 echo "EXTRA_lib_SOURCES +=" $extra_files
1553 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1554 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
1555 if test -n "$buildaux_files"; then
1556 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1557 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1560 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1561 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
1562 if test -n "$top_files"; then
1563 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1564 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1571 # func_get_include_directive module
1573 # - local_gnulib_dir from --local-dir
1574 func_get_include_directive ()
1576 func_lookup_file "modules/$1"
1577 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1578 sed -e 's/^\(["<]\)/#include \1/'
1581 # func_get_link_directive module
1583 # - local_gnulib_dir from --local-dir
1584 func_get_link_directive ()
1586 func_lookup_file "modules/$1"
1587 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1590 # func_get_license module
1592 # - local_gnulib_dir from --local-dir
1595 func_lookup_file "modules/$1"
1596 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1597 # The default is GPL.
1599 } | sed -e 's,^ *$,,' | sed -e 1q
1602 # func_get_maintainer module
1604 # - local_gnulib_dir from --local-dir
1605 func_get_maintainer ()
1607 func_lookup_file "modules/$1"
1608 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1611 # func_get_tests_module module
1613 # - local_gnulib_dir from --local-dir
1614 func_get_tests_module ()
1616 # The naming convention for tests modules is hardwired: ${module}-tests.
1617 if test -f "$gnulib_dir/modules/$1"-tests \
1618 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1619 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1624 # func_acceptable module
1625 # tests whether a module is acceptable.
1627 # - avoidlist list of modules to avoid
1630 for avoid in $avoidlist; do
1631 if test "$avoid" = "$1"; then
1638 # func_modules_transitive_closure
1640 # - local_gnulib_dir from --local-dir
1641 # - modules list of specified modules
1642 # - inctests true if tests should be included, blank otherwise
1643 # - incobsolete true if obsolete modules among dependencies should be
1644 # included, blank otherwise
1645 # - avoidlist list of modules to avoid
1646 # - tmp pathname of a temporary directory
1648 # - modules list of modules, including dependencies
1649 func_modules_transitive_closure ()
1651 # In order to process every module only once (for speed), process an "input
1652 # list" of modules, producing an "output list" of modules. During each round,
1653 # more modules can be queued in the input list. Once a module on the input
1654 # list has been processed, it is added to the "handled list", so we can avoid
1655 # to process it again.
1657 inmodules="$modules"
1659 while test -n "$inmodules"; do
1660 inmodules_this_round="$inmodules"
1661 inmodules= # Accumulator, queue for next round
1662 for module in $inmodules_this_round; do
1664 if test -n "$module"; then
1665 if func_acceptable $module; then
1666 func_append outmodules " $module"
1667 deps=`func_get_dependencies $module`
1668 # Duplicate dependencies are harmless, but Jim wants a warning.
1669 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1670 if test -n "$duplicated_deps"; then
1671 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1673 for dep in $deps; do
1674 if test -n "$incobsolete" \
1675 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
1676 func_append inmodules " $dep"
1679 if test -n "$inctests"; then
1680 testsmodule=`func_get_tests_module $module`
1681 if test -n "$testsmodule"; then
1682 func_append inmodules " $testsmodule"
1688 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1689 # Remove $handledmodules from $inmodules.
1690 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1691 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1693 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1694 rm -f "$tmp"/queued-modules
1697 # func_modules_add_dummy
1699 # - local_gnulib_dir from --local-dir
1700 # - modules list of modules, including dependencies
1702 # - modules list of modules, including 'dummy' if needed
1703 func_modules_add_dummy ()
1705 # Determine whether any module provides a lib_SOURCES augmentation.
1707 sed_remove_backslash_newline=':a
1714 for module in $modules; do
1715 func_verify_nontests_module
1716 if test -n "$module"; then
1717 # Extract the value of "lib_SOURCES += ...".
1718 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1719 # Ignore .h files since they are not compiled.
1723 have_lib_SOURCES=yes
1730 # Add the dummy module, to make sure the library will be non-empty.
1731 if test -z "$have_lib_SOURCES"; then
1732 if func_acceptable "dummy"; then
1733 func_append modules " dummy"
1738 # func_modules_notice
1740 # - local_gnulib_dir from --local-dir
1741 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1742 # - modules list of modules, including dependencies
1743 func_modules_notice ()
1745 if test $verbose -ge -1; then
1746 for module in $modules; do
1748 if test -n "$module"; then
1749 msg=`func_get_notice $module`
1750 if test -n "$msg"; then
1751 echo "Notice from module $module:"
1752 echo "$msg" | sed -e 's/^/ /'
1759 # func_modules_to_filelist
1761 # - local_gnulib_dir from --local-dir
1762 # - modules list of modules, including dependencies
1764 # - files list of files
1765 func_modules_to_filelist ()
1768 for module in $modules; do
1770 if test -n "$module"; then
1771 fs=`func_get_filelist $module`
1772 func_append files " $fs"
1775 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1778 # func_execute_command command [args...]
1779 # Executes a command.
1780 # Uses also the variables
1781 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1782 func_execute_command ()
1784 if test $verbose -ge 0; then
1788 # Commands like automake produce output to stderr even when they succeed.
1789 # Turn this output off if the command succeeds.
1790 "$@" > "$tmp"/cmdout 2>&1
1792 if test $cmdret = 0; then
1796 cat "$tmp"/cmdout 1>&2
1803 # func_dest_tmpfilename file
1804 # determines the name of a temporary file (file is relative to destdir).
1806 # - destdir target directory
1807 # - doit : if actions shall be executed, false if only to be printed
1808 # - tmp pathname of a temporary directory
1810 # - tmpfile absolute filename of the temporary file
1811 func_dest_tmpfilename ()
1814 # Put the new contents of $file in a file in the same directory (needed
1815 # to guarantee that an 'mv' to "$destdir/$file" works).
1816 tmpfile="$destdir/$1.tmp"
1818 # Put the new contents of $file in a file in a temporary directory
1819 # (because the directory of "$file" might not exist).
1820 tmpfile="$tmp"/`basename "$1"`.tmp
1825 # copies a file from gnulib into the destination directory. The destination
1826 # is known to not exist.
1828 # - destdir target directory
1829 # - local_gnulib_dir from --local-dir
1830 # - f the original file name
1831 # - lookedup_file name of the merged (combined) file
1832 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1833 # - g the rewritten file name
1834 # - tmpfile absolute filename of the temporary file
1835 # - doit : if actions shall be executed, false if only to be printed
1836 # - symbolic true if files should be symlinked, copied otherwise
1837 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1842 echo "Copying file $g"
1843 if { test -n "$symbolic" \
1844 || { test -n "$lsymbolic" \
1845 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1846 && test -z "$lookedup_tmp" \
1847 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1848 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1850 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1858 # copies a file from gnulib into the destination directory. The destination
1859 # is known to exist.
1861 # - destdir target directory
1862 # - local_gnulib_dir from --local-dir
1863 # - f the original file name
1864 # - lookedup_file name of the merged (combined) file
1865 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1866 # - g the rewritten file name
1867 # - tmpfile absolute filename of the temporary file
1868 # - doit : if actions shall be executed, false if only to be printed
1869 # - symbolic true if files should be symlinked, copied otherwise
1870 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1872 # - already_present nonempty if the file should already exist, empty otherwise
1875 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1876 : # The file has not changed.
1880 if test -n "$already_present"; then
1881 echo "Updating file $g (backup in ${g}~)"
1883 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
1885 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1886 if { test -n "$symbolic" \
1887 || { test -n "$lsymbolic" \
1888 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1889 && test -z "$lookedup_tmp" \
1890 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1891 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1893 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1896 if test -n "$already_present"; then
1897 echo "Update file $g (backup in ${g}~)"
1899 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
1905 # func_emit_lib_Makefile_am
1906 # emits the contents of library makefile to standard output.
1908 # - local_gnulib_dir from --local-dir
1909 # - modules list of modules, including dependencies
1910 # - libname library name
1911 # - pobase directory relative to destdir where to place *.po files
1912 # - auxdir directory relative to destdir where to place build aux files
1913 # - makefile_name from --makefile-name
1914 # - libtool true if libtool will be used, false or blank otherwise
1915 # - macro_prefix prefix of gl_LIBOBJS macros to use
1916 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1917 # - actioncmd (optional) command that will reproduce this invocation
1918 # - for_test true if creating a package for testing, false otherwise
1919 # - destfile filename relative to destdir of makefile being generated
1921 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1922 # list of edits to be done to Makefile.am variables
1924 # - uses_subdirs nonempty if object files in subdirs exist
1925 func_emit_lib_Makefile_am ()
1927 # When creating an includable Makefile.am snippet, augment variables with
1928 # += instead of assigning them.
1929 if test -n "$makefile_name"; then
1934 if test "$libtool" = true; then
1937 sed_eliminate_LDFLAGS="$sed_noop"
1941 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1944 # When creating a package for testing: Attempt to provoke failures,
1945 # especially link errors, already during "make" rather than during
1946 # "make check", because "make check" is not possible in a cross-compiling
1947 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1948 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1950 sed_transform_check_PROGRAMS="$sed_noop"
1952 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1953 echo "## Process this file with automake to produce Makefile.in."
1954 func_emit_copyright_notice
1955 if test -n "$actioncmd"; then
1956 # The maximum line length (excluding the terminating newline) of any file
1957 # that is to be preprocessed by config.status is 3070. config.status uses
1958 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
1959 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
1960 len=`echo "$actioncmd" | wc -c`
1961 if test -n "$len" && test "$len" -le 3000; then
1962 echo "# Reproduce by: $actioncmd"
1968 for module in $modules; do
1969 func_verify_nontests_module
1970 if test -n "$module"; then
1972 func_get_automake_snippet "$module" |
1973 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1974 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1975 -e "$sed_eliminate_LDFLAGS" \
1976 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1977 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1978 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1979 -e "$sed_transform_check_PROGRAMS"
1980 if test "$module" = 'alloca'; then
1981 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1982 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1985 # Skip the contents if it's entirely empty.
1986 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1987 echo "## begin gnulib module $module"
1990 echo "## end gnulib module $module"
1994 # Test whether there are some source files in subdirectories.
1995 for f in `func_get_filelist "$module"`; do
2006 if test -z "$makefile_name"; then
2007 # If there are source files in subdirectories, prevent collision of the
2008 # object files (example: hash.c and libxml/hash.c).
2010 if test -n "$uses_subdirs"; then
2011 subdir_options=' subdir-objects'
2013 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2016 if test -z "$makefile_name"; then
2018 echo "noinst_HEADERS ="
2019 echo "noinst_LIBRARIES ="
2020 echo "noinst_LTLIBRARIES ="
2021 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2022 # if you specify pkgdata_DATA to empty. This is a workaround.
2023 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
2024 echo "pkgdata_DATA ="
2027 echo "BUILT_SOURCES ="
2030 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2031 if test -z "$makefile_name"; then
2032 echo "MOSTLYCLEANDIRS ="
2034 echo "DISTCLEANFILES ="
2035 echo "MAINTAINERCLEANFILES ="
2037 # Execute edits that apply to the Makefile.am being generated.
2039 while test $edit != $makefile_am_edits; do
2040 edit=`expr $edit + 1`
2041 eval dir=\"\$makefile_am_edit${edit}_dir\"
2042 eval var=\"\$makefile_am_edit${edit}_var\"
2043 eval val=\"\$makefile_am_edit${edit}_val\"
2044 if test -n "$var"; then
2045 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2046 echo "${var} += ${val}"
2047 eval "makefile_am_edit${edit}_var="
2051 if test -z "$makefile_name"; then
2053 echo "AM_CPPFLAGS ="
2057 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null \
2058 || { test -n "$makefile_name" \
2059 && test -f "$sourcebase/Makefile.am" \
2060 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2062 # One of the snippets or the user's Makefile.am already specifies an
2063 # installation location for the library. Don't confuse automake by saying
2064 # it should not be installed.
2067 # By default, the generated library should not be installed.
2068 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2071 echo "${libname}_${libext}_SOURCES ="
2072 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2073 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2074 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2075 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2076 echo "EXTRA_${libname}_${libext}_SOURCES ="
2077 if test "$libtool" = true; then
2078 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2081 if test -n "$pobase"; then
2082 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2085 cat allsnippets.tmp \
2086 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2088 echo "mostlyclean-local: mostlyclean-generic"
2089 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2090 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2091 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2095 rm -f allsnippets.tmp
2098 # func_emit_po_Makevars
2099 # emits the contents of po/ makefile parameterization to standard output.
2101 # - local_gnulib_dir from --local-dir
2102 # - sourcebase directory relative to destdir where to place source code
2103 # - pobase directory relative to destdir where to place *.po files
2104 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2105 func_emit_po_Makevars ()
2107 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2108 func_emit_copyright_notice
2110 echo "# Usually the message domain is the same as the package name."
2111 echo "# But here it has a '-gnulib' suffix."
2112 echo "DOMAIN = ${po_domain}-gnulib"
2114 echo "# These two variables depend on the location of this directory."
2115 echo "subdir = ${pobase}"
2116 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2119 # These options get passed to xgettext.
2120 XGETTEXT_OPTIONS = \
2121 --keyword=_ --flag=_:1:pass-c-format \
2122 --keyword=N_ --flag=N_:1:pass-c-format \
2123 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2124 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2125 --flag=error:3:c-format --flag=error_at_line:5:c-format
2127 # This is the copyright holder that gets inserted into the header of the
2128 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2129 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2131 # This is the email address or URL to which the translators shall report
2132 # bugs in the untranslated strings:
2133 # - Strings which are not entire sentences, see the maintainer guidelines
2134 # in the GNU gettext documentation, section 'Preparing Strings'.
2135 # - Strings which use unclear terms or require additional context to be
2137 # - Strings which make invalid assumptions about notation of date, time or
2139 # - Pluralisation problems.
2140 # - Incorrect English spelling.
2141 # - Incorrect formatting.
2142 # It can be your email address, or a mailing list address where translators
2143 # can write to without being subscribed, or the URL of a web page through
2144 # which the translators can contact you.
2145 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2147 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2148 # message catalogs shall be used. It is usually empty.
2149 EXTRA_LOCALE_CATEGORIES =
2151 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2152 # context. Possible values are "yes" and "no". Set this to yes if the
2153 # package uses functions taking also a message context, like pgettext(), or
2154 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2159 # func_emit_po_POTFILES_in
2160 # emits the file list to be passed to xgettext to standard output.
2162 # - local_gnulib_dir from --local-dir
2163 # - sourcebase directory relative to destdir where to place source code
2164 # - files list of new files
2165 func_emit_po_POTFILES_in ()
2167 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2168 func_emit_copyright_notice
2170 echo "# List of files which contain translatable strings."
2171 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2174 # func_emit_tests_Makefile_am
2175 # emits the contents of tests makefile to standard output.
2177 # - local_gnulib_dir from --local-dir
2178 # - modules list of modules, including dependencies
2179 # - libname library name
2180 # - auxdir directory relative to destdir where to place build aux files
2181 # - makefile_name from --makefile-name
2182 # - libtool true if libtool will be used, false or blank otherwise
2183 # - sourcebase relative directory containing lib source code
2184 # - m4base relative directory containing autoconf macros
2185 # - testsbase relative directory containing unit test code
2186 # - macro_prefix prefix of gl_LIBOBJS macros to use
2187 # - for_test true if creating a package for testing, false otherwise
2188 # - use_libtests true if a libtests.a should be built, false otherwise
2189 # - destfile filename relative to destdir of makefile being generated
2191 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2192 # list of edits to be done to Makefile.am variables
2194 # - uses_subdirs nonempty if object files in subdirs exist
2195 func_emit_tests_Makefile_am ()
2197 if test "$libtool" = true; then
2199 sed_eliminate_LDFLAGS="$sed_noop"
2202 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2205 # When creating a package for testing: Attempt to provoke failures,
2206 # especially link errors, already during "make" rather than during
2207 # "make check", because "make check" is not possible in a cross-compiling
2208 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2209 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2211 sed_transform_check_PROGRAMS="$sed_noop"
2213 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2214 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2215 echo "## Process this file with automake to produce Makefile.in."
2216 func_emit_copyright_notice
2220 for module in $modules; do
2222 func_verify_tests_module
2226 if test -n "$module"; then
2228 func_get_automake_snippet "$module" |
2229 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2230 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2231 -e "$sed_eliminate_LDFLAGS" \
2232 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2233 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2234 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2235 -e "$sed_transform_check_PROGRAMS"
2236 if $use_libtests && test "$module" = 'alloca'; then
2237 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2238 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2241 # Skip the contents if it's entirely empty.
2242 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
2243 echo "## begin gnulib module $module"
2246 echo "## end gnulib module $module"
2250 # Test whether there are some source files in subdirectories.
2251 for f in `func_get_filelist "$module"`; do
2253 lib/*/*.c | tests/*/*.c)
2262 # Generate dependencies here, since it eases the debugging of test failures.
2263 # If there are source files in subdirectories, prevent collision of the
2264 # object files (example: hash.c and libxml/hash.c).
2266 if test -n "$uses_subdirs"; then
2267 subdir_options=' subdir-objects'
2269 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2272 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2275 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2276 # variable is needed to avoid an error from automake:
2277 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2280 echo "XFAIL_TESTS ="
2281 echo "TESTS_ENVIRONMENT ="
2282 echo "noinst_PROGRAMS ="
2283 if ! $for_test; then
2284 echo "check_PROGRAMS ="
2286 echo "noinst_HEADERS ="
2287 echo "noinst_LIBRARIES ="
2288 if $use_libtests; then
2290 echo "noinst_LIBRARIES += libtests.a"
2292 echo "check_LIBRARIES = libtests.a"
2295 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2296 # if you specify pkgdata_DATA to empty. This is a workaround.
2297 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
2298 echo "pkgdata_DATA ="
2301 echo "BUILT_SOURCES ="
2303 echo "MOSTLYCLEANFILES = core *.stackdump"
2304 echo "MOSTLYCLEANDIRS ="
2306 echo "DISTCLEANFILES ="
2307 echo "MAINTAINERCLEANFILES ="
2308 # Execute edits that apply to the Makefile.am being generated.
2310 while test $edit != $makefile_am_edits; do
2311 edit=`expr $edit + 1`
2312 eval dir=\"\$makefile_am_edit${edit}_dir\"
2313 eval var=\"\$makefile_am_edit${edit}_var\"
2314 eval val=\"\$makefile_am_edit${edit}_val\"
2315 if test -n "$var"; then
2316 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2317 echo "${var} += ${val}"
2318 eval "makefile_am_edit${edit}_var="
2323 echo "AM_CPPFLAGS = \\"
2324 echo " -I. -I\$(srcdir) \\"
2325 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2326 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2328 local_ldadd_before=''
2329 local_ldadd_after=''
2330 if $use_libtests; then
2331 # All test programs need to be linked with libtests.a.
2332 # It needs to be passed to the linker before ${libname}.${libext}, since
2333 # the tests-related modules depend on the main modules.
2334 # It also needs to be passed to the linker after ${libname}.${libext}
2335 # because the latter might contain incomplete modules (such as the 'error'
2336 # module whose dependency to 'progname' is voluntarily omitted).
2337 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2339 local_ldadd_before=' libtests.a'
2340 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2342 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2344 if $use_libtests; then
2345 echo "libtests_a_SOURCES ="
2346 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2347 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2348 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2349 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2350 echo "EXTRA_libtests_a_SOURCES ="
2351 # The circular dependency in LDADD requires this.
2352 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2355 cat allsnippets.tmp \
2356 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2357 echo "# Clean up after Solaris cc."
2359 echo " rm -rf SunWS_cache"
2361 echo "mostlyclean-local: mostlyclean-generic"
2362 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2363 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2364 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2368 rm -f allsnippets.tmp
2371 # func_emit_initmacro_start macro_prefix
2372 # emits the first few statements of the gl_INIT macro to standard output.
2373 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2374 func_emit_initmacro_start ()
2376 macro_prefix_arg="$1"
2377 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2378 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2379 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2380 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2382 # Furthermore it avoids an automake error like this when a Makefile.am
2383 # that uses pieces of gnulib also uses $(LIBOBJ):
2384 # automatically discovered file `error.c' should not be explicitly mentioned
2385 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2386 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2387 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2388 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2389 # automatically discovered file `error.c' should not be explicitly mentioned
2390 # We let automake know about the files to be distributed through the
2391 # EXTRA_lib_SOURCES variable.
2392 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2393 # Create data variables for checking the presence of files that are mentioned
2394 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2395 # because we want the check to happen when the configure file is created,
2396 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2397 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2398 # in which to expect them.
2399 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2400 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2404 # func_emit_initmacro_end macro_prefix
2405 # emits the last few statements of the gl_INIT macro to standard output.
2406 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2407 func_emit_initmacro_end ()
2409 macro_prefix_arg="$1"
2410 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2411 # The check is performed only when autoconf is run from the directory where
2412 # the configure.ac resides; if it is run from a different directory, the
2414 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2415 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2416 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2417 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2418 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2422 echo " m4_if(m4_sysval, [0], [],"
2423 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2425 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2426 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2427 echo " m4_popdef([AC_LIBSOURCES])"
2428 echo " m4_popdef([AC_REPLACE_FUNCS])"
2429 echo " m4_popdef([AC_LIBOBJ])"
2430 echo " AC_CONFIG_COMMANDS_PRE(["
2431 echo " ${macro_prefix_arg}_libobjs="
2432 echo " ${macro_prefix_arg}_ltlibobjs="
2433 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2434 echo " # Remove the extension."
2435 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2436 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2437 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2438 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2441 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2442 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2446 # func_emit_initmacro_done macro_prefix sourcebase
2447 # emits a few statements after the gl_INIT macro to standard output.
2448 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2449 # - sourcebase directory relative to destdir where to place source code
2450 func_emit_initmacro_done ()
2452 macro_prefix_arg="$1"
2455 echo "# Like AC_LIBOBJ, except that the module name goes"
2456 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2457 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2458 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2459 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2462 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2463 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2464 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2465 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2466 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2469 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2470 echo "# expected is derived from the gnulib-tool parameterization,"
2471 echo "# and alloca is special cased (for the alloca-opt module)."
2472 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2473 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2474 echo " m4_foreach([_gl_NAME], [\$1], ["
2475 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2476 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2477 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2483 # func_import modules
2484 # Uses also the variables
2485 # - destdir target directory
2486 # - local_gnulib_dir from --local-dir
2487 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2488 # - libname library name
2489 # - sourcebase directory relative to destdir where to place source code
2490 # - m4base directory relative to destdir where to place *.m4 macros
2491 # - pobase directory relative to destdir where to place *.po files
2492 # - docbase directory relative to destdir where to place doc files
2493 # - testsbase directory relative to destdir where to place unit test code
2494 # - auxdir directory relative to destdir where to place build aux files
2495 # - inctests true if --with-tests was given, blank otherwise
2496 # - incobsolete true if --with-obsolete was given, blank otherwise
2497 # - avoidlist list of modules to avoid, from --avoid
2498 # - lgpl yes or a number if library's license shall be LGPL,
2500 # - makefile_name from --makefile-name
2501 # - libtool true if --libtool was given, false if --no-libtool was
2502 # given, blank otherwise
2503 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2504 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2505 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2506 # - vc_files true if --vc-files was given, false if --no-vc-files was
2507 # given, blank otherwise
2508 # - autoconf_minversion minimum supported autoconf version
2509 # - doit : if actions shall be executed, false if only to be printed
2510 # - symbolic true if files should be symlinked, copied otherwise
2511 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2513 # - do_copyrights true if copyright notices in files should be replaced,
2517 # Get the cached settings.
2518 cached_local_gnulib_dir=
2519 cached_specified_modules=
2530 cached_makefile_name=
2532 cached_macro_prefix=
2536 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2537 cached_libtool=false
2543 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
2553 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
2555 /gl_WITH_OBSOLETE/ {
2556 s,^.*$,cached_incobsolete=true,p
2559 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
2562 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
2565 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
2568 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
2571 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
2574 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
2577 s,^.*$,cached_inctests=true,p
2580 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
2583 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
2586 s,^.*$,cached_lgpl=yes,p
2588 /gl_MAKEFILE_NAME(/ {
2589 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
2592 s,^.*$,cached_libtool=true,p
2594 /gl_MACRO_PREFIX(/ {
2595 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
2598 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
2601 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
2603 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2604 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2609 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2610 s,^.*$,cached_files=",p
2623 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2627 # Merge the cached settings with the specified ones.
2628 # The m4base must be the same as expected from the pathname.
2629 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2630 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2632 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2633 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2634 if test -z "$local_gnulib_dir"; then
2635 if test -n "$cached_local_gnulib_dir"; then
2638 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2640 case "$cached_local_gnulib_dir" in
2642 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2644 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2645 local_gnulib_dir="$relconcat" ;;
2650 # Append the cached and the specified module names. So that
2651 # "gnulib-tool --import foo" means to add the module foo.
2652 specified_modules="$cached_specified_modules $1"
2653 # Included obsolete modules among the dependencies if specified either way.
2654 if test -z "$incobsolete"; then
2655 incobsolete="$cached_incobsolete"
2657 # Append the cached and the specified avoidlist. This is probably better
2658 # than dropping the cached one when --avoid is specified at least once.
2659 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2660 avoidlist=`echo $avoidlist`
2662 # The sourcebase defaults to the cached one.
2663 if test -z "$sourcebase"; then
2664 sourcebase="$cached_sourcebase"
2665 if test -z "$sourcebase"; then
2666 func_fatal_error "missing --source-base option"
2669 # The pobase defaults to the cached one.
2670 if test -z "$pobase"; then
2671 pobase="$cached_pobase"
2673 # The docbase defaults to the cached one.
2674 if test -z "$docbase"; then
2675 docbase="$cached_docbase"
2676 if test -z "$docbase"; then
2677 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."
2680 # The testsbase defaults to the cached one.
2681 if test -z "$testsbase"; then
2682 testsbase="$cached_testsbase"
2683 if test -z "$testsbase"; then
2684 func_fatal_error "missing --tests-base option"
2687 # Require the tests if specified either way.
2688 if test -z "$inctests"; then
2689 inctests="$cached_inctests"
2691 # The libname defaults to the cached one.
2692 if test -z "$supplied_libname"; then
2693 libname="$cached_libname"
2694 if test -z "$libname"; then
2695 func_fatal_error "missing --lib option"
2698 # Require LGPL if specified either way.
2699 if test -z "$lgpl"; then
2702 # The makefile_name defaults to the cached one.
2703 if test -z "$makefile_name"; then
2704 makefile_name="$cached_makefile_name"
2706 # Use libtool if specified either way, or if guessed.
2707 if test -z "$libtool"; then
2708 if test -n "$cached_m4base"; then
2709 libtool="$cached_libtool"
2711 libtool="$guessed_libtool"
2714 # The macro_prefix defaults to the cached one.
2715 if test -z "$macro_prefix"; then
2716 macro_prefix="$cached_macro_prefix"
2717 if test -z "$macro_prefix"; then
2718 func_fatal_error "missing --macro-prefix option"
2721 # The po_domain defaults to the cached one.
2722 if test -z "$po_domain"; then
2723 po_domain="$cached_po_domain"
2725 # The vc_files defaults to the cached one.
2726 if test -z "$vc_files"; then
2727 vc_files="$cached_vc_files"
2730 # Canonicalize the list of specified modules.
2731 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2733 # Determine final module list.
2734 modules="$specified_modules"
2735 func_modules_transitive_closure
2736 if test $verbose -ge 0; then
2737 echo "Module list with included dependencies:"
2738 echo "$modules" | sed -e 's/^/ /'
2740 final_modules="$modules"
2742 # Determine main module list and tests-related module list separately.
2743 # The main module list is the transitive closure of the specified modules,
2744 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2745 # is specified, it will consist only of LGPLed source.
2746 # The tests-related module list is the transitive closure of the specified
2747 # modules, including tests modules, minus the main module list excluding
2748 # 'link-warning'. Its lib/* sources (brought in through dependencies of
2749 # *-tests modules) go into $testsbase/. It may contain GPLed source, even if
2750 # --lgpl is specified.
2751 # Determine main module list.
2752 saved_inctests="$inctests"
2754 modules="$specified_modules"
2755 func_modules_transitive_closure
2756 main_modules="$modules"
2757 inctests="$saved_inctests"
2758 if test $verbose -ge 1; then
2759 echo "Main module list:"
2760 echo "$main_modules" | sed -e 's/^/ /'
2762 # Determine tests-related module list.
2763 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2764 sed_remove_link_warning='/^link-warning$/d'
2765 testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | sed -e "$sed_remove_link_warning" | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2766 if test $verbose -ge 1; then
2767 echo "Tests-related module list:"
2768 echo "$testsrelated_modules" | sed -e 's/^/ /'
2771 # Add the dummy module to the main module list if needed.
2772 modules="$main_modules"
2773 func_modules_add_dummy
2774 main_modules="$modules"
2776 # Determine whether a $testsbase/libtests.a is needed.
2778 for module in $testsrelated_modules; do
2779 func_verify_nontests_module
2780 if test -n "$module"; then
2781 all_files=`func_get_filelist $module`
2782 # Test whether some file in $all_files lies in lib/.
2783 for f in $all_files; do
2794 # Add the dummy module to the tests-related module list if needed.
2795 if $use_libtests; then
2796 modules="$testsrelated_modules"
2797 func_modules_add_dummy
2798 testsrelated_modules="$modules"
2801 # If --lgpl, verify that the licenses of modules are compatible.
2802 if test -n "$lgpl"; then
2803 license_incompatibilities=
2804 for module in $main_modules; do
2805 license=`func_get_license $module`
2807 'GPLed build tool') ;;
2808 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2813 LGPL | LGPLv2+ | LGPLv3+) ;;
2814 *) func_append license_incompatibilities "$module $license$nl" ;;
2820 *) func_append license_incompatibilities "$module $license$nl" ;;
2823 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2828 if test -n "$license_incompatibilities"; then
2829 # Format the license incompatibilities as a table.
2830 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
2831 s,^\(.................................................[^ ]*\) *, \1 ,'
2832 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
2833 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
2837 # Show banner notice of every module.
2838 modules="$main_modules"
2841 # Determine script to apply to imported library files.
2842 sed_transform_lib_file=
2843 for module in $main_modules; do
2844 if test $module = config-h; then
2845 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2846 sed_transform_lib_file=$sed_transform_lib_file'
2847 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2852 sed_transform_main_lib_file="$sed_transform_lib_file"
2853 if test -n "$do_copyrights"; then
2854 if test -n "$lgpl"; then
2858 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2859 s/GNU General/GNU Lesser General/g
2863 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2864 s/GNU General/GNU Lesser General/g
2865 s/version [23]\([ ,]\)/version 2.1\1/g
2868 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2872 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2873 s/GNU Lesser General/GNU General/g
2874 s/GNU Library General/GNU General/g
2875 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
2880 # Determine script to apply to auxiliary files that go into $auxdir/.
2881 sed_transform_build_aux_file=
2882 if test -n "$do_copyrights"; then
2884 sed_transform_build_aux_file=$sed_transform_build_aux_file'
2885 s/GNU Lesser General/GNU General/g
2886 s/GNU Library General/GNU General/g
2887 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
2891 # Determine script to apply to library files that go into $testsbase/.
2892 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2893 if test -n "$do_copyrights"; then
2895 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2896 s/GNU Lesser General/GNU General/g
2897 s/GNU Library General/GNU General/g
2898 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
2902 # Determine the final file lists.
2903 # They must be computed separately, because files in lib/* go into
2904 # $sourcebase/ if they are in the main file list but into $testsbase/
2905 # if they are in the tests-related file list. Furthermore lib/dummy.c
2907 # Determine final main file list.
2908 modules="$main_modules"
2909 func_modules_to_filelist
2911 # Determine final tests-related file list.
2912 modules="$testsrelated_modules"
2913 func_modules_to_filelist
2914 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2915 # Merge both file lists.
2916 sed_remove_empty_lines='/^$/d'
2917 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2918 if test $verbose -ge 0; then
2920 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2921 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2925 || func_fatal_error "refusing to do nothing"
2927 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2928 new_files="$files m4/gnulib-tool.m4"
2929 old_files="$cached_files"
2930 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2931 func_append old_files " m4/gnulib-tool.m4"
2934 rewritten='%REWRITTEN%'
2935 sed_rewrite_old_files="\
2936 s,^build-aux/,$rewritten$auxdir/,
2937 s,^doc/,$rewritten$cached_docbase/,
2938 s,^lib/,$rewritten$cached_sourcebase/,
2939 s,^m4/,$rewritten$cached_m4base/,
2940 s,^tests/,$rewritten$cached_testsbase/,
2941 s,^tests=lib/,$rewritten$cached_testsbase/,
2944 sed_rewrite_new_files="\
2945 s,^build-aux/,$rewritten$auxdir/,
2946 s,^doc/,$rewritten$docbase/,
2947 s,^lib/,$rewritten$sourcebase/,
2948 s,^m4/,$rewritten$m4base/,
2949 s,^tests/,$rewritten$testsbase/,
2950 s,^tests=lib/,$rewritten$testsbase/,
2954 # Create directories.
2955 { echo "$sourcebase"
2957 if test -n "$pobase"; then
2960 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2961 if test -n "$docfiles"; then
2964 if test -n "$inctests"; then
2968 for f in $files; do echo $f; done \
2969 | sed -e "$sed_rewrite_new_files" \
2970 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2973 { # Rearrange file descriptors. Needed because "while ... done < ..."
2974 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2975 exec 5<&0 < "$tmp"/dirs
2977 if test ! -d "$destdir/$d"; then
2979 echo "Creating directory $destdir/$d"
2980 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2982 echo "Create directory $destdir/$d"
2989 # Copy files or make symbolic links. Remove obsolete files.
2993 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2994 # representing the files according to the last gnulib-tool invocation.
2995 for f in $old_files; do echo $f; done \
2996 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2999 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3000 # representing the files after this gnulib-tool invocation.
3001 for f in $new_files; do echo $f; done \
3002 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3005 # First the files that are in old-files, but not in new-files:
3006 sed_take_first_column='s,'"$delimiter"'.*,,'
3007 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3008 # Remove the file. Do nothing if the user already removed it.
3009 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3011 echo "Removing file $g (backup in ${g}~)"
3012 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3014 echo "Remove file $g (backup in ${g}~)"
3016 func_append removed_files "$g$nl"
3019 # func_add_or_update handles a file that ought to be present afterwards.
3021 # - f the original file name
3022 # - g the rewritten file name
3023 # - already_present nonempty if the file should already exist, empty
3025 func_add_or_update ()
3029 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3031 func_dest_tmpfilename "$g"
3032 func_lookup_file "$f"
3033 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3034 if test -n "$sed_transform_main_lib_file"; then
3037 sed -e "$sed_transform_main_lib_file" \
3038 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3042 if test -n "$sed_transform_build_aux_file"; then
3045 sed -e "$sed_transform_build_aux_file" \
3046 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3050 if test -n "$sed_transform_testsrelated_lib_file"; then
3053 sed -e "$sed_transform_testsrelated_lib_file" \
3054 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3058 if test -f "$destdir/$g"; then
3059 # The file already exists.
3063 # Don't protest if the file should be there but isn't: it happens
3064 # frequently that developers don't put autogenerated files into CVS.
3066 func_append added_files "$g$nl"
3070 # Then the files that are in new-files, but not in old-files:
3071 sed_take_last_column='s,^.*'"$delimiter"',,'
3073 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3074 | sed -e "$sed_take_last_column" \
3075 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3076 { # Rearrange file descriptors. Needed because "while ... done < ..."
3077 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3078 exec 5<&0 < "$tmp"/added-files
3084 # Then the files that are in new-files and in old-files:
3085 already_present=true
3086 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3087 | sed -e "$sed_take_last_column" \
3088 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3089 { # Rearrange file descriptors. Needed because "while ... done < ..."
3090 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3091 exec 5<&0 < "$tmp"/kept-files
3098 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3099 actioncmd="gnulib-tool --import"
3100 func_append actioncmd " --dir=$destdir"
3101 if test -n "$local_gnulib_dir"; then
3102 func_append actioncmd " --local-dir=$local_gnulib_dir"
3104 func_append actioncmd " --lib=$libname"
3105 func_append actioncmd " --source-base=$sourcebase"
3106 func_append actioncmd " --m4-base=$m4base"
3107 if test -n "$pobase"; then
3108 func_append actioncmd " --po-base=$pobase"
3110 func_append actioncmd " --doc-base=$docbase"
3111 func_append actioncmd " --tests-base=$testsbase"
3112 func_append actioncmd " --aux-dir=$auxdir"
3113 if test -n "$inctests"; then
3114 func_append actioncmd " --with-tests"
3116 if test -n "$incobsolete"; then
3117 func_append actioncmd " --with-obsolete"
3119 for module in $avoidlist; do
3120 func_append actioncmd " --avoid=$module"
3122 if test -n "$lgpl"; then
3123 if test "$lgpl" = yes; then
3124 func_append actioncmd " --lgpl"
3126 func_append actioncmd " --lgpl=$lgpl"
3129 if test -n "$makefile_name"; then
3130 func_append actioncmd " --makefile-name=$makefile_name"
3132 if test "$libtool" = true; then
3133 func_append actioncmd " --libtool"
3135 func_append actioncmd " --no-libtool"
3137 func_append actioncmd " --macro-prefix=$macro_prefix"
3138 if test -n "$po_domain"; then
3139 func_append actioncmd " --po-domain=$po_domain"
3141 if test -n "$vc_files"; then
3142 if test "$vc_files" = true; then
3143 func_append actioncmd " --vc-files"
3145 func_append actioncmd " --no-vc-files"
3148 func_append actioncmd " `echo $specified_modules`"
3150 # Default the makefile name to Makefile.am.
3151 if test -n "$makefile_name"; then
3152 makefile_am=$makefile_name
3154 makefile_am=Makefile.am
3157 # Create normal Makefile.ams.
3160 # Setup list of Makefile.am edits that are to be performed afterwards.
3161 # Some of these edits apply to files that we will generate; others are
3162 # under the responsibility of the developer.
3164 # func_note_Makefile_am_edit dir var value
3165 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3167 func_note_Makefile_am_edit ()
3169 makefile_am_edits=`expr $makefile_am_edits + 1`
3170 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3171 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3172 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3174 if test "$makefile_am" = Makefile.am; then
3175 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3176 sourcebase_base=`basename "$sourcebase"`
3177 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3179 if test -n "$pobase"; then
3180 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3181 pobase_base=`basename "$pobase"`
3182 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3184 if test -n "$inctests"; then
3185 if test "$makefile_am" = Makefile.am; then
3186 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3187 testsbase_base=`basename "$testsbase"`
3188 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3191 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3193 # Find the first parent directory of $m4base that contains or will contain
3195 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3197 sed_butlast='s,[^/][^/]*//*$,,'
3198 dir1="${m4base}/"; dir2=""
3199 while test -n "$dir1" \
3200 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3201 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3202 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3203 || { test -n "$inctests" \
3204 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3205 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3206 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3207 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3209 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3212 # Create library makefile.
3213 func_dest_tmpfilename $sourcebase/$makefile_am
3214 destfile="$sourcebase/$makefile_am"
3215 modules="$main_modules"
3216 func_emit_lib_Makefile_am > "$tmpfile"
3217 if test -f "$destdir"/$sourcebase/$makefile_am; then
3218 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3222 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3223 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3224 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3226 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3232 echo "Creating $sourcebase/$makefile_am"
3233 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3235 echo "Create $sourcebase/$makefile_am"
3238 func_append added_files "$sourcebase/$makefile_am$nl"
3241 # Create po/ directory.
3242 if test -n "$pobase"; then
3243 # Create po makefile and auxiliary files.
3244 for file in Makefile.in.in remove-potcdate.sin; do
3245 func_dest_tmpfilename $pobase/$file
3246 func_lookup_file build-aux/po/$file
3247 cat "$lookedup_file" > "$tmpfile"
3248 if test -f "$destdir"/$pobase/$file; then
3249 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3253 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3254 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3255 mv -f "$tmpfile" "$destdir"/$pobase/$file
3257 echo "Update $pobase/$file (backup in $pobase/$file~)"
3263 echo "Creating $pobase/$file"
3264 mv -f "$tmpfile" "$destdir"/$pobase/$file
3266 echo "Create $pobase/$file"
3269 func_append added_files "$pobase/$file$nl"
3272 # Create po makefile parameterization, part 1.
3273 func_dest_tmpfilename $pobase/Makevars
3274 func_emit_po_Makevars > "$tmpfile"
3275 if test -f "$destdir"/$pobase/Makevars; then
3276 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3280 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3281 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3282 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3284 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3290 echo "Creating $pobase/Makevars"
3291 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3293 echo "Create $pobase/Makevars"
3296 func_append added_files "$pobase/Makevars$nl"
3298 # Create po makefile parameterization, part 2.
3299 func_dest_tmpfilename $pobase/POTFILES.in
3300 func_emit_po_POTFILES_in > "$tmpfile"
3301 if test -f "$destdir"/$pobase/POTFILES.in; then
3302 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3306 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3307 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3308 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3310 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3316 echo "Creating $pobase/POTFILES.in"
3317 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3319 echo "Create $pobase/POTFILES.in"
3322 func_append added_files "$pobase/POTFILES.in$nl"
3325 TP_URL="http://translationproject.org/latest/"
3326 TP_RSYNC_URI="translationproject.org::tp/latest/"
3328 echo "Fetching gnulib PO files from $TP_URL"
3329 (cd "$destdir"/$pobase \
3330 && { # Prefer rsync over wget if it is available, since it consumes
3331 # less network bandwidth, due to compression.
3332 if type rsync 2>/dev/null | grep / > /dev/null; then
3333 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3335 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3340 echo "Fetch gnulib PO files from $TP_URL"
3342 # Create po/LINGUAS.
3344 func_dest_tmpfilename $pobase/LINGUAS
3345 (cd "$destdir"/$pobase \
3346 && { echo '# Set of available languages.'
3347 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3350 if test -f "$destdir"/$pobase/LINGUAS; then
3351 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3354 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3355 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3356 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3359 echo "Creating $pobase/LINGUAS"
3360 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3361 func_append added_files "$pobase/LINGUAS$nl"
3364 if test -f "$destdir"/$pobase/LINGUAS; then
3365 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3367 echo "Create $pobase/LINGUAS"
3372 # Create m4/gnulib-cache.m4.
3373 func_dest_tmpfilename $m4base/gnulib-cache.m4
3375 func_emit_copyright_notice
3377 echo "# This file represents the specification of how gnulib-tool is used."
3378 echo "# It acts as a cache: It is written and read by gnulib-tool."
3379 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3380 echo "# like the configure.ac and various Makefile.am files."
3383 echo "# Specification in the form of a command-line invocation:"
3386 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3387 # Store the local_gnulib_dir relative to destdir.
3388 case "$local_gnulib_dir" in
3390 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3393 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3395 # destdir, local_gnulib_dir are both relative.
3396 func_relativize "$destdir" "$local_gnulib_dir"
3397 relative_local_gnulib_dir="$reldir" ;;
3400 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3402 echo "$specified_modules" | sed 's/^/ /g'
3404 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3405 echo "gl_AVOID([$avoidlist])"
3406 echo "gl_SOURCE_BASE([$sourcebase])"
3407 echo "gl_M4_BASE([$m4base])"
3408 echo "gl_PO_BASE([$pobase])"
3409 echo "gl_DOC_BASE([$docbase])"
3410 echo "gl_TESTS_BASE([$testsbase])"
3411 test -z "$inctests" || echo "gl_WITH_TESTS"
3412 echo "gl_LIB([$libname])"
3413 if test -n "$lgpl"; then
3414 if test "$lgpl" = yes; then
3417 echo "gl_LGPL([$lgpl])"
3420 echo "gl_MAKEFILE_NAME([$makefile_name])"
3421 if test "$libtool" = true; then
3424 echo "gl_MACRO_PREFIX([$macro_prefix])"
3425 echo "gl_PO_DOMAIN([$po_domain])"
3426 if test -n "$vc_files"; then
3427 echo "gl_VC_FILES([$vc_files])"
3430 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3431 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3435 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3436 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3437 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3439 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3443 echo "# gnulib-cache.m4 ends here"
3450 echo "Creating $m4base/gnulib-cache.m4"
3451 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3453 echo "Create $m4base/gnulib-cache.m4"
3459 # Create m4/gnulib-comp.m4.
3460 func_dest_tmpfilename $m4base/gnulib-comp.m4
3462 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3463 func_emit_copyright_notice
3465 echo "# This file represents the compiled summary of the specification in"
3466 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3467 echo "# to be invoked from configure.ac."
3468 echo "# In projects using CVS, this file can be treated like other built files."
3471 echo "# This macro should be invoked from $configure_ac, in the section"
3472 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3473 echo "# any checks for libraries, header files, types and library functions."
3474 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3476 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3477 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3478 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3479 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3480 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3481 if test -n "$uses_subdirs"; then
3482 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3484 for module in $final_modules; do
3486 if test -n "$module"; then
3487 func_get_autoconf_early_snippet "$module"
3490 | sed -e '/^$/d;' -e 's/^/ /'
3493 echo "# This macro should be invoked from $configure_ac, in the section"
3494 echo "# \"Check for header files, types and library functions\"."
3495 echo "AC_DEFUN([${macro_prefix}_INIT],"
3497 if test "$libtool" = true; then
3498 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3499 echo " gl_cond_libtool=true"
3501 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3502 echo " gl_cond_libtool=false"
3504 echo " gl_ltlibdeps="
3506 if test "$auxdir" != "build-aux"; then
3507 sed_replace_build_aux='
3509 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3510 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3514 sed_replace_build_aux="$sed_noop"
3516 func_emit_initmacro_start $macro_prefix
3517 echo " gl_source_base='$sourcebase'"
3518 for module in $main_modules; do
3520 if test -n "$module"; then
3521 func_get_autoconf_snippet "$module" \
3522 | sed -e '/^$/d;' -e 's/^/ /' \
3523 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3524 -e "$sed_replace_build_aux"
3525 if test "$module" = 'alloca' && test "$libtool" = true; then
3526 echo 'changequote(,)dnl'
3527 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3528 echo 'changequote([, ])dnl'
3529 echo 'AC_SUBST([LTALLOCA])'
3533 func_emit_initmacro_end $macro_prefix
3534 echo " gltests_libdeps="
3535 echo " gltests_ltlibdeps="
3536 func_emit_initmacro_start ${macro_prefix}tests
3537 echo " gl_source_base='$testsbase'"
3538 for module in $testsrelated_modules; do
3540 if test -n "$module"; then
3541 func_get_autoconf_snippet "$module" \
3542 | sed -e '/^$/d;' -e 's/^/ /' \
3543 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3544 -e "$sed_replace_build_aux" \
3545 -e 's/\$gl_cond_libtool/false/g' \
3546 -e 's/gl_libdeps/gltests_libdeps/g' \
3547 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3550 func_emit_initmacro_end ${macro_prefix}tests
3551 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3552 # created using libtool, because libtool already handles the dependencies.
3553 if test "$libtool" != true; then
3554 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3555 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3556 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3557 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3558 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3560 if $use_libtests; then
3561 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3562 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3565 func_emit_initmacro_done $macro_prefix $sourcebase
3566 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3568 echo "# This macro records the list of files which have been installed by"
3569 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3570 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3571 echo "$files" | sed -e 's,^, ,'
3574 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3575 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3579 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3580 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3581 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3583 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3587 echo "# gnulib-comp.m4 ends here"
3594 echo "Creating $m4base/gnulib-comp.m4"
3595 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3597 echo "Create $m4base/gnulib-comp.m4"
3603 if test -n "$inctests"; then
3604 # Create tests makefile.
3605 func_dest_tmpfilename $testsbase/$makefile_am
3606 destfile="$testsbase/$makefile_am"
3607 modules="$testsrelated_modules"
3608 func_emit_tests_Makefile_am > "$tmpfile"
3609 if test -f "$destdir"/$testsbase/$makefile_am; then
3610 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3614 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3615 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3616 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3618 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3624 echo "Creating $testsbase/$makefile_am"
3625 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3627 echo "Create $testsbase/$makefile_am"
3630 func_append added_files "$testsbase/$makefile_am$nl"
3634 if test "$vc_files" != false; then
3635 # Update the .cvsignore and .gitignore files.
3636 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3637 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3638 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3639 echo "$m4base/|A|gnulib-comp.m4"
3640 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3641 { # Rearrange file descriptors. Needed because "while ... done < ..."
3642 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3643 exec 5<&0 < "$tmp"/fileset-changes
3644 func_update_ignorelist ()
3647 if test "$ignore" = .gitignore; then
3648 # In a .gitignore file, "foo" applies to the current directory and all
3649 # subdirectories, whereas "/foo" applies to the current directory only.
3652 doubly_escaped_anchor='\\/'
3656 doubly_escaped_anchor=''
3658 if test -f "$destdir/$dir$ignore"; then
3659 if test -n "$dir_added" || test -n "$dir_removed"; then
3660 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3662 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3663 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
3664 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3665 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
3667 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3669 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3670 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3671 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3672 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
3673 } > "$tmp"/sed-ignore-removed
3674 { cat "$destdir/$dir$ignore"~
3675 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3676 } | sed -f "$tmp"/sed-ignore-removed \
3677 > "$destdir/$dir$ignore"
3679 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3684 if test -n "$dir_added"; then
3686 echo "Creating $destdir/$dir$ignore"
3688 if test "$ignore" = .cvsignore; then
3690 # Automake generates Makefile rules that create .dirstamp files.
3693 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3694 } > "$destdir/$dir$ignore"
3696 echo "Create $destdir/$dir$ignore"
3706 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3707 func_update_ignorelist .cvsignore
3709 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3710 func_update_ignorelist .gitignore
3717 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3718 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3719 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3720 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3721 if test "$next_dir" != "$last_dir"; then
3722 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3723 last_dir="$next_dir"
3728 A) func_append last_dir_added "$file$nl";;
3729 R) func_append last_dir_removed "$file$nl";;
3732 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3739 echo "You may need to add #include directives for the following .h files."
3740 # Intersect $specified_modules and $main_modules
3741 # (since $specified_modules is not necessarily of subset of $main_modules
3742 # - some may have been skipped through --avoid, and since the elements of
3743 # $main_modules but not in $specified_modules can go away without explicit
3744 # notice - through changes in the module dependencies).
3745 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3746 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3747 # First the #include <...> directives without #ifs, sorted for convenience,
3748 # then the #include "..." directives without #ifs, sorted for convenience,
3749 # then the #include directives that are surrounded by #ifs. Not sorted.
3750 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3751 include_directive=`func_get_include_directive "$module"`
3752 case "$nl$include_directive" in
3754 echo "$include_directive" 1>&5
3757 echo "$include_directive" | grep -v 'include "' 1>&6
3758 echo "$include_directive" | grep 'include "' 1>&7
3761 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3763 LC_ALL=C sort -u "$tmp"/include-angles
3764 LC_ALL=C sort -u "$tmp"/include-quotes
3765 cat "$tmp"/include-if
3766 ) | sed -e '/^$/d' -e 's/^/ /'
3767 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3769 for module in $main_modules; do
3770 func_get_link_directive "$module"
3772 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3773 if test `wc -l < "$tmp"/link` != 0; then
3775 echo "You may need to use the following Makefile variables when linking."
3776 echo "Use them in <program>_LDADD when linking a program, or"
3777 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3783 echo "Don't forget to"
3784 if test "$makefile_am" = Makefile.am; then
3785 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3787 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3789 if test -n "$pobase"; then
3790 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3792 if test -n "$inctests"; then
3793 if test "$makefile_am" = Makefile.am; then
3794 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3796 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3800 while test $edit != $makefile_am_edits; do
3801 edit=`expr $edit + 1`
3802 eval dir=\"\$makefile_am_edit${edit}_dir\"
3803 eval var=\"\$makefile_am_edit${edit}_var\"
3804 eval val=\"\$makefile_am_edit${edit}_val\"
3805 if test -n "$var"; then
3806 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
3809 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3810 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3813 # func_create_testdir testdir modules
3815 # - local_gnulib_dir from --local-dir
3816 # - auxdir directory relative to destdir where to place build aux files
3817 func_create_testdir ()
3821 if test -z "$modules"; then
3822 # All modules together.
3823 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3824 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3825 modules=`func_all_modules`
3826 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3828 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3830 # Check that the license of every module is consistent with the license of
3832 saved_modules="$modules"
3833 saved_inctests="$inctests"
3834 # When computing transitive closures, don't consider $module to depend on
3835 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3836 # on GPL modules - therefore we don't want a warning in this case.
3838 for requested_module in $saved_modules; do
3839 requested_license=`func_get_license "$requested_module"`
3840 if test "$requested_license" != GPL; then
3841 # Here we use func_modules_transitive_closure, not just
3842 # func_get_dependencies, so that we also detect weird situations like
3843 # an LGPL module which depends on a GPLed build tool module which depends
3845 modules="$requested_module"
3846 func_modules_transitive_closure
3847 for module in $modules; do
3848 license=`func_get_license "$module"`
3850 'GPLed build tool') ;;
3851 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3853 case "$requested_license" in
3856 GPLv2+ | LGPLv2+) ;;
3857 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3863 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3869 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3878 modules="$saved_modules"
3879 inctests="$saved_inctests"
3881 # Subdirectory names.
3891 # Determine final module list.
3892 func_modules_transitive_closure
3893 if test $verbose -ge 0; then
3894 echo "Module list with included dependencies:"
3895 echo "$modules" | sed -e 's/^/ /'
3898 # Add the dummy module if needed.
3899 func_modules_add_dummy
3901 # Show banner notice of every module.
3904 # Determine final file list.
3905 func_modules_to_filelist
3906 if test $verbose -ge 0; then
3908 echo "$files" | sed -e 's/^/ /'
3911 rewritten='%REWRITTEN%'
3912 sed_rewrite_files="\
3913 s,^build-aux/,$rewritten$auxdir/,
3914 s,^doc/,$rewritten$docbase/,
3915 s,^lib/,$rewritten$sourcebase/,
3916 s,^m4/,$rewritten$m4base/,
3917 s,^tests/,$rewritten$testsbase/,
3921 # Create directories.
3922 for f in $files; do echo $f; done \
3923 | sed -e "$sed_rewrite_files" \
3924 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3925 | LC_ALL=C sort -u \
3927 { # Rearrange file descriptors. Needed because "while ... done < ..."
3928 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3929 exec 5<&0 < "$tmp"/dirs
3931 mkdir -p "$testdir/$d"
3936 # Copy files or make symbolic links.
3938 for f in $files; do echo $f; done \
3939 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3942 { # Rearrange file descriptors. Needed because "while ... done < ..."
3943 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3944 exec 5<&0 < "$tmp"/files
3946 func_lookup_file "$f"
3947 if test -n "$lookedup_tmp"; then
3948 cp -p "$lookedup_file" "$testdir/$g"
3950 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3951 if { test -n "$symbolic" \
3952 || { test -n "$lsymbolic" \
3953 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3954 func_ln "$lookedup_file" "$testdir/$g"
3956 cp -p "$lookedup_file" "$testdir/$g"
3963 # Create Makefile.ams that are for testing.
3966 # No special edits are needed.
3969 # Create $sourcebase/Makefile.am.
3970 mkdir -p "$testdir/$sourcebase"
3971 destfile="$sourcebase/Makefile.am"
3972 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3973 any_uses_subdirs="$uses_subdirs"
3975 # Create $m4base/Makefile.am.
3976 mkdir -p "$testdir/$m4base"
3977 (echo "## Process this file with automake to produce Makefile.in."
3983 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3986 ) > "$testdir/$m4base/Makefile.am"
3988 subdirs="$sourcebase $m4base"
3989 subdirs_with_configure_ac=""
3991 if false && test -f "$testdir"/$m4base/gettext.m4; then
3992 # Avoid stupid error message from automake:
3993 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3994 mkdir -p "$testdir/po"
3995 (echo "## Process this file with automake to produce Makefile.in."
3996 ) > "$testdir/po/Makefile.am"
3997 func_append subdirs " po"
4000 if test -n "$inctests"; then
4001 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4002 # Viewed from the $testsbase subdirectory, $auxdir is different.
4003 saved_auxdir="$auxdir"
4004 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
4005 # Create $testsbase/Makefile.am.
4007 destfile="$testsbase/Makefile.am"
4008 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
4009 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4010 # Create $testsbase/configure.ac.
4011 (echo "# Process this file with autoconf to produce a configure script."
4012 echo "AC_INIT([dummy], [0])"
4013 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4014 echo "AM_INIT_AUTOMAKE"
4016 echo "AC_CONFIG_HEADERS([config.h])"
4019 echo "AC_PROG_INSTALL"
4020 echo "AC_PROG_MAKE_SET"
4021 echo "AC_PROG_RANLIB"
4023 if test -n "$uses_subdirs"; then
4024 echo "AM_PROG_CC_C_O"
4027 for module in $modules; do
4029 if test -n "$module"; then
4031 gnumakefile | maintainer-makefile)
4032 # These modules are meant to be used only in the top-level directory.
4035 func_get_autoconf_early_snippet "$module"
4040 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4041 if test "$libtool" = true; then
4042 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4043 echo "gl_cond_libtool=true"
4045 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4046 echo "gl_cond_libtool=false"
4048 echo "gl_ltlibdeps="
4050 # Wrap the set of autoconf snippets into an autoconf macro that is then
4051 # invoked. This is needed because autoconf does not support AC_REQUIRE
4053 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4054 # but we want the AC_REQUIRE to have its normal meaning (provide one
4055 # expansion of the required macro before the current point, and only one
4057 echo "AC_DEFUN([gl_INIT], ["
4058 sed_replace_build_aux='
4060 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4061 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4064 func_emit_initmacro_start $macro_prefix
4065 # We don't have explicit ordering constraints between the various
4066 # autoconf snippets. It's cleanest to put those of the library before
4067 # those of the tests.
4068 echo "gl_source_base='../$sourcebase'"
4069 for module in $modules; do
4070 func_verify_nontests_module
4071 if test -n "$module"; then
4073 gnumakefile | maintainer-makefile)
4074 # These modules are meant to be used only in the top-level directory.
4077 func_get_autoconf_snippet "$module" \
4078 | sed -e "$sed_replace_build_aux"
4083 echo "gl_source_base='.'"
4084 for module in $modules; do
4085 func_verify_tests_module
4086 if test -n "$module"; then
4087 func_get_autoconf_snippet "$module" \
4088 | sed -e "$sed_replace_build_aux"
4091 func_emit_initmacro_end $macro_prefix
4092 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4093 # created using libtool, because libtool already handles the dependencies.
4094 if test "$libtool" != true; then
4095 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4096 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4097 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4098 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4099 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4102 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4106 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4107 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4108 echo "AH_TOP([#include \"../config.h\"])"
4110 echo "AC_CONFIG_FILES([Makefile])"
4112 ) > "$testdir/$testsbase/configure.ac"
4113 auxdir="$saved_auxdir"
4114 func_append subdirs " $testsbase"
4115 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4118 # Create Makefile.am.
4119 (echo "## Process this file with automake to produce Makefile.in."
4121 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4123 echo "SUBDIRS = $subdirs"
4125 echo "ACLOCAL_AMFLAGS = -I $m4base"
4126 ) > "$testdir/Makefile.am"
4128 # Create configure.ac.
4129 (echo "# Process this file with autoconf to produce a configure script."
4130 echo "AC_INIT([dummy], [0])"
4131 if test "$auxdir" != "."; then
4132 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4134 echo "AM_INIT_AUTOMAKE"
4136 echo "AC_CONFIG_HEADERS([config.h])"
4139 echo "AC_PROG_INSTALL"
4140 echo "AC_PROG_MAKE_SET"
4142 echo "# For autobuild."
4143 echo "AC_CANONICAL_BUILD"
4144 echo "AC_CANONICAL_HOST"
4146 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4147 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4148 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4149 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4151 echo "AC_PROG_RANLIB"
4153 if test -n "$any_uses_subdirs"; then
4154 echo "AM_PROG_CC_C_O"
4157 for module in $modules; do
4158 func_verify_nontests_module
4159 if test -n "$module"; then
4160 func_get_autoconf_early_snippet "$module"
4163 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4164 if test "$libtool" = true; then
4165 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4166 echo "gl_cond_libtool=true"
4168 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4169 echo "gl_cond_libtool=false"
4171 echo "gl_ltlibdeps="
4173 # Wrap the set of autoconf snippets into an autoconf macro that is then
4174 # invoked. This is needed because autoconf does not support AC_REQUIRE
4176 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4177 # but we want the AC_REQUIRE to have its normal meaning (provide one
4178 # expansion of the required macro before the current point, and only one
4180 echo "AC_DEFUN([gl_INIT], ["
4181 if test "$auxdir" != "build-aux"; then
4182 sed_replace_build_aux='
4184 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4185 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4189 sed_replace_build_aux="$sed_noop"
4191 func_emit_initmacro_start $macro_prefix
4192 echo "gl_source_base='$sourcebase'"
4193 for module in $modules; do
4194 func_verify_nontests_module
4195 if test -n "$module"; then
4196 func_get_autoconf_snippet "$module" \
4197 | sed -e "$sed_replace_build_aux"
4200 func_emit_initmacro_end $macro_prefix
4201 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4202 # created using libtool, because libtool already handles the dependencies.
4203 if test "$libtool" != true; then
4204 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4205 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4206 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4207 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4208 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4211 func_emit_initmacro_done $macro_prefix $sourcebase
4215 if test -n "$subdirs_with_configure_ac"; then
4216 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4218 makefiles="Makefile"
4219 for d in $subdirs; do
4220 # For subdirs that have a configure.ac by their own, it's the subdir's
4221 # configure.ac which creates the subdir's Makefile.am, not this one.
4222 case " $subdirs_with_configure_ac " in
4224 *) func_append makefiles " $d/Makefile" ;;
4227 echo "AC_CONFIG_FILES([$makefiles])"
4229 ) > "$testdir/configure.ac"
4231 # Create autogenerated files.
4233 # Do not use "${AUTORECONF} --force --install", because it may invoke
4234 # autopoint, which brings in older versions of some of our .m4 files.
4235 if test -f $m4base/gettext.m4; then
4236 func_execute_command ${AUTOPOINT} --force || func_exit 1
4237 for f in $m4base/*.m4~; do
4239 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4243 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4244 if ! test -d build-aux; then
4245 func_execute_command mkdir build-aux || func_exit 1
4247 func_execute_command ${AUTOCONF} || func_exit 1
4248 func_execute_command ${AUTOHEADER} || func_exit 1
4249 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4251 if test -n "$inctests"; then
4252 # Create autogenerated files.
4253 (cd "$testdir/$testsbase" || func_exit 1
4254 # Do not use "${AUTORECONF} --force --install", because it may invoke
4255 # autopoint, which brings in older versions of some of our .m4 files.
4256 if test -f ../$m4base/gettext.m4; then
4257 func_execute_command ${AUTOPOINT} --force || func_exit 1
4258 for f in ../$m4base/*.m4~; do
4260 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4264 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4265 if ! test -d ../build-aux; then
4266 func_execute_command mkdir ../build-aux
4268 func_execute_command ${AUTOCONF} || func_exit 1
4269 func_execute_command ${AUTOHEADER} || func_exit 1
4270 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4273 # Need to run configure and make once, to create built files that are to be
4274 # distributed (such as getdate.c).
4275 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4276 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4277 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4278 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4279 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4280 # such $(FOO_H) because they don't refer to distributed files.
4281 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4282 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4283 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4284 | sed -e "$sed_remove_make_variables"`
4285 distributed_built_sources=`for file in $built_sources; do
4286 case "$cleaned_files" in
4291 if test -n "$distributed_built_sources"; then
4293 ./configure || func_exit 1
4295 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4296 $MAKE built_sources || func_exit 1
4298 $MAKE distclean || func_exit 1
4303 # func_create_megatestdir megatestdir allmodules
4305 # - local_gnulib_dir from --local-dir
4306 # - auxdir directory relative to destdir where to place build aux files
4307 func_create_megatestdir ()
4311 if test -z "$allmodules"; then
4312 allmodules=`func_all_modules`
4316 # First, all modules one by one.
4317 for onemodule in $allmodules; do
4318 func_create_testdir "$megatestdir/$onemodule" $onemodule
4319 func_append megasubdirs "$onemodule "
4321 # Then, all modules all together.
4322 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4323 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
4324 func_create_testdir "$megatestdir/ALL" "$allmodules"
4325 func_append megasubdirs "ALL"
4328 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4329 vc_witness="$gnulib_dir/CVS/Entries"; \
4331 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4333 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4334 | sed -e 's,January,01,' -e 's,Jan,01,' \
4335 -e 's,February,02,' -e 's,Feb,02,' \
4336 -e 's,March,03,' -e 's,Mar,03,' \
4337 -e 's,April,04,' -e 's,Apr,04,' \
4339 -e 's,June,06,' -e 's,Jun,06,' \
4340 -e 's,July,07,' -e 's,Jul,07,' \
4341 -e 's,August,08,' -e 's,Aug,08,' \
4342 -e 's,September,09,' -e 's,Sep,09,' \
4343 -e 's,October,10,' -e 's,Oct,10,' \
4344 -e 's,November,11,' -e 's,Nov,11,' \
4345 -e 's,December,12,' -e 's,Dec,12,' \
4346 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4347 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4349 echo "CVSDATE=$cvsdate"
4350 echo ": \${MAKE=make}"
4351 echo "test -d logs || mkdir logs"
4352 echo "for module in $megasubdirs; do"
4353 echo " echo \"Working on module \$module...\""
4354 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4355 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4358 echo " : autobuild project... \$module"
4359 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4360 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4361 echo " : autobuild hostname... \`hostname\`"
4362 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
4364 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4366 ) > "$megatestdir/do-autobuild"
4367 chmod a+x "$megatestdir/do-autobuild"
4369 # Create Makefile.am.
4370 (echo "## Process this file with automake to produce Makefile.in."
4372 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4374 echo "SUBDIRS = $megasubdirs"
4376 echo "EXTRA_DIST = do-autobuild"
4377 ) > "$megatestdir/Makefile.am"
4379 # Create configure.ac.
4380 (echo "# Process this file with autoconf to produce a configure script."
4381 echo "AC_INIT([dummy], [0])"
4382 if test "$auxdir" != "."; then
4383 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4385 echo "AM_INIT_AUTOMAKE"
4387 echo "AC_PROG_MAKE_SET"
4389 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4390 echo "AC_CONFIG_FILES([Makefile])"
4392 ) > "$megatestdir/configure.ac"
4394 # Create autogenerated files.
4396 # Do not use "${AUTORECONF} --install", because autoreconf operates
4397 # recursively, but the subdirectories are already finished, therefore
4398 # calling autoreconf here would only waste lots of CPU time.
4399 func_execute_command ${ACLOCAL} || func_exit 1
4400 func_execute_command mkdir build-aux
4401 func_execute_command ${AUTOCONF} || func_exit 1
4402 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4408 func_fatal_error "no mode specified" ;;
4417 if test -z "$destdir"; then
4420 test -d "$destdir" \
4421 || func_fatal_error "destination directory does not exist: $destdir"
4423 # Prefer configure.ac to configure.in.
4424 if test -f "$destdir"/configure.ac; then
4425 configure_ac="$destdir/configure.ac"
4427 if test -f "$destdir"/configure.in; then
4428 configure_ac="$destdir/configure.in"
4430 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
4434 # Analyze configure.ac.
4436 guessed_libtool=false
4441 /AC_CONFIG_AUX_DIR/ {
4442 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
4444 /A[CM]_PROG_LIBTOOL/ {
4445 s,^.*$,guessed_libtool=true,p
4447 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4449 if test -z "$auxdir"; then
4450 auxdir="$guessed_auxdir"
4453 # Determine where to apply func_import.
4454 if test -n "$m4base"; then
4455 # Apply func_import to a particular gnulib directory.
4456 # Any number of additional modules can be given.
4457 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4458 # First use of gnulib in the given m4base.
4459 test -n "$supplied_libname" || supplied_libname=true
4460 test -n "$sourcebase" || sourcebase="lib"
4461 test -n "$docbase" || docbase="doc"
4462 test -n "$testsbase" || testsbase="tests"
4463 test -n "$macro_prefix" || macro_prefix="gl"
4467 # Apply func_import to all gnulib directories.
4468 # To get this list of directories, look at Makefile.am. (Not at
4469 # configure, because it may be omitted from CVS. Also, don't run
4470 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4473 if test -f "$destdir"/Makefile.am; then
4474 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4476 for arg in $aclocal_amflags; do
4477 if test -n "$m4dir_is_next"; then
4478 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4482 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4483 func_append m4dirs " $arg"
4484 m4dirs_count=`expr $m4dirs_count + 1`
4490 if test "X$arg" = "X-I"; then
4498 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4499 if test -f "$destdir"/aclocal.m4; then
4500 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4501 sedexpr2='s,^[^/]*$,.,'
4502 sedexpr3='s,/[^/]*$,,'
4503 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4504 m4dirs_count=`printf %s "$m4dirs" | wc -l`
4507 if test $m4dirs_count = 0; then
4508 # First use of gnulib in a package.
4509 # Any number of additional modules can be given.
4510 test -n "$supplied_libname" || supplied_libname=true
4511 test -n "$sourcebase" || sourcebase="lib"
4513 test -n "$docbase" || docbase="doc"
4514 test -n "$testsbase" || testsbase="tests"
4515 test -n "$macro_prefix" || macro_prefix="gl"
4518 if test $m4dirs_count = 1; then
4519 # There's only one use of gnulib here. Assume the user means it.
4520 # Any number of additional modules can be given.
4521 for m4base in $m4dirs; do
4525 # Ambiguous - guess what the user meant.
4526 if test $# = 0; then
4527 # No further arguments. Guess the user wants to update all of them.
4528 for m4base in $m4dirs; do
4529 # Perform func_import in a subshell, so that variable values
4531 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
4532 # pobase, docbase, testsbase, inctests, libname, lgpl,
4533 # makefile_name, libtool, macro_prefix, po_domain, vc_files
4534 # don't propagate from one directory to another.
4535 (func_import) || func_exit 1
4539 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4547 if test -z "$destdir"; then
4548 func_fatal_error "please specify --dir option"
4551 test -d "$destdir" \
4552 || func_fatal_error "could not create destination directory"
4553 test -n "$auxdir" || auxdir="build-aux"
4554 func_create_testdir "$destdir" "$*"
4557 create-megatestdir )
4558 if test -z "$destdir"; then
4559 func_fatal_error "please specify --dir option"
4561 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4562 test -n "$auxdir" || auxdir="build-aux"
4563 func_create_megatestdir "$destdir" "$*"
4567 test -n "$destdir" || destdir=testdir$$
4568 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4569 test -n "$auxdir" || auxdir="build-aux"
4570 func_create_testdir "$destdir" "$*"
4574 ../configure || func_exit 1
4575 $MAKE || func_exit 1
4576 $MAKE check || func_exit 1
4577 $MAKE distclean || func_exit 1
4578 remaining=`find . -type f -print`
4579 if test -n "$remaining"; then
4580 echo "Remaining files:" $remaining 1>&2
4581 echo "gnulib-tool: *** Stop." 1>&2
4590 test -n "$destdir" || destdir=testdir$$
4591 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4592 test -n "$auxdir" || auxdir="build-aux"
4593 func_create_megatestdir "$destdir" "$*"
4601 remaining=`find . -type f -print`
4602 if test -n "$remaining"; then
4603 echo "Remaining files:" $remaining 1>&2
4604 echo "gnulib-tool: *** Stop." 1>&2
4612 extract-description )
4616 if test -n "$module"; then
4617 func_get_description "$module"
4626 if test -n "$module"; then
4627 func_get_status "$module"
4636 if test -n "$module"; then
4637 func_get_notice "$module"
4646 if test -n "$module"; then
4647 func_get_filelist "$module"
4652 extract-dependencies )
4656 if test -n "$module"; then
4657 func_get_dependencies "$module"
4662 extract-autoconf-snippet )
4666 if test -n "$module"; then
4667 func_get_autoconf_snippet "$module"
4672 extract-automake-snippet )
4676 if test -n "$module"; then
4677 func_get_automake_snippet "$module"
4682 extract-include-directive )
4686 if test -n "$module"; then
4687 func_get_include_directive "$module"
4692 extract-link-directive )
4696 if test -n "$module"; then
4697 func_get_link_directive "$module"
4706 if test -n "$module"; then
4707 func_get_license "$module"
4712 extract-maintainer )
4716 if test -n "$module"; then
4717 func_get_maintainer "$module"
4722 extract-tests-module )
4726 if test -n "$module"; then
4727 func_get_tests_module "$module"
4733 # Verify the number of arguments.
4734 if test $# -lt 1 || test $# -gt 2; then
4735 func_fatal_error "invalid number of arguments for --$mode"
4738 # The first argument is the file to be copied.
4740 # Verify the file exists.
4741 func_lookup_file "$f"
4743 # The second argument is the destination; either a directory ot a file.
4744 # It defaults to the current directory.
4746 test -n "$dest" || dest='.'
4747 test -n "$sourcebase" || sourcebase="lib"
4748 test -n "$m4base" || m4base="m4"
4749 test -n "$docbase" || docbase="doc"
4750 test -n "$testsbase" || testsbase="tests"
4751 test -n "$auxdir" || auxdir="build-aux"
4752 rewritten='%REWRITTEN%'
4753 sed_rewrite_files="\
4754 s,^build-aux/,$rewritten$auxdir/,
4755 s,^doc/,$rewritten$docbase/,
4756 s,^lib/,$rewritten$sourcebase/,
4757 s,^m4/,$rewritten$m4base/,
4758 s,^tests/,$rewritten$testsbase/,
4761 if test -d "$dest"; then
4763 g=`echo "$f" | sed -e "$sed_rewrite_files"`
4765 destdir=`dirname "$dest"`
4766 g=`basename "$dest"`
4769 # Create the directory for destfile.
4770 d=`dirname "$destdir/$g"`
4772 if test -n "$d" && test ! -d "$d"; then
4773 mkdir -p "$d" || func_fatal_error "failed"
4777 func_dest_tmpfilename "$g"
4778 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4779 already_present=true
4780 if test -f "$destdir/$g"; then
4781 # The file already exists.
4785 # Don't protest if the file should be there but isn't: it happens
4786 # frequently that developers don't put autogenerated files into CVS.
4793 func_fatal_error "unknown operation mode --$mode" ;;
4797 # Undo the effect of the previous 'trap' command. Some shellology:
4798 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4799 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4800 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4801 # 128 + signal number and is set before the trap-registered command is run.
4803 trap 'func_exit $?' 1 2 3 13 15
4808 # indent-tabs-mode: nil
4809 # whitespace-check-buffer-indent: nil