3 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
44 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
45 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
46 AUTOCONF="${AUTOCONFPATH}autoconf"
48 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
49 AUTOHEADER="${AUTOCONFPATH}autoheader"
51 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
52 ACLOCAL="${AUTOMAKEPATH}aclocal"
54 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
55 AUTOMAKE="${AUTOMAKEPATH}automake"
57 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
58 AUTORECONF="${AUTOCONFPATH}autoreconf"
61 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
62 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
63 AUTOPOINT="${GETTEXTPATH}autopoint"
67 if test -z "${MAKE}"; then
71 # When using GNU sed, turn off as many GNU extensions as possible,
72 # to minimize the risk of accidentally using non-portable features.
73 # However, do this only for gnulib-tool itself, not for the code that
74 # gnulib-tool generates, since we don't want "sed --posix" to leak
75 # into makefiles. And do it only for sed versions 4.2 or newer,
76 # because "sed --posix" is buggy in GNU sed 4.1.5, see
77 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
78 if (alias) > /dev/null 2>&1 \
79 && echo | sed --posix -e d >/dev/null 2>&1 \
80 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
81 [1-3]* | 4.[01]*) false;; \
85 # Define sed as an alias.
86 # It is not always possible to use aliases. Aliases are guaranteed to work
87 # if the executing shell is bash and either it is invoked as /bin/sh or
88 # is a version >= 2.0, supporting shopt. This is the common case.
89 # Two other approaches (use of a variable $sed or of a function func_sed
90 # instead of an alias) require massive, fragile code changes.
91 # An other approach (use of function sed) requires `which sed` - but
92 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
93 if test -n "$BASH_VERSION"; then
94 shopt -s expand_aliases >/dev/null 2>&1
96 alias sed='sed --posix'
99 # sed_noop is a sed expression that does nothing.
100 # An empty expression does not work with the native 'sed' on AIX 6.1.
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-applicability module
119 gnulib-tool --extract-filelist module
120 gnulib-tool --extract-dependencies module
121 gnulib-tool --extract-autoconf-snippet module
122 gnulib-tool --extract-automake-snippet module
123 gnulib-tool --extract-include-directive module
124 gnulib-tool --extract-link-directive module
125 gnulib-tool --extract-license module
126 gnulib-tool --extract-maintainer module
127 gnulib-tool --extract-tests-module module
128 gnulib-tool --copy-file file [destination]
131 --list print the available module names
132 --import import the given modules into the current package;
133 if no modules are specified, update the current
134 package from the current gnulib
135 --update update the current package, restore files omitted
137 --create-testdir create a scratch package with the given modules
138 --create-megatestdir create a mega scratch package with the given modules
139 one by one and all together
140 --test test the combination of the given modules
141 (recommended to use CC=\"gcc -Wall\" here)
142 --megatest test the given modules one by one and all together
143 (recommended to use CC=\"gcc -Wall\" here)
144 --extract-description extract the description
145 --extract-status extract the status (obsolete or not)
146 --extract-notice extract the notice or banner
147 --extract-filelist extract the list of files
148 --extract-dependencies extract the dependencies
149 --extract-autoconf-snippet extract the snippet for configure.ac
150 --extract-automake-snippet extract the snippet for library makefile
151 --extract-include-directive extract the #include directive
152 --extract-link-directive extract the linker directive
153 --extract-license report the license terms of the source files
155 --extract-maintainer report the maintainer(s) inside gnulib
156 --extract-tests-module report the unit test module, if it exists
157 --copy-file copy a file that is not part of any module
160 --dir=DIRECTORY Specify the target directory.
161 For --import, this specifies where your
162 configure.ac can be found. Defaults to current
164 --local-dir=DIRECTORY Specify a local override directory where to look
165 up files before looking in gnulib's directory.
166 --verbose Increase verbosity. May be repeated.
167 --quiet Decrease verbosity. May be repeated.
169 Options for --import:
170 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
171 --source-base=DIRECTORY
172 Directory relative to --dir where source code is
173 placed (default \"lib\").
174 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
175 placed (default \"m4\").
176 --po-base=DIRECTORY Directory relative to --dir where *.po files are
177 placed (default \"po\").
178 --doc-base=DIRECTORY Directory relative to --dir where doc files are
179 placed (default \"doc\").
180 --tests-base=DIRECTORY
181 Directory relative to --dir where unit tests are
182 placed (default \"tests\").
183 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
184 tools are placed (default \"build-aux\").
185 --with-tests Include unit tests for the included modules.
186 --with-obsolete Include obsolete modules when they occur among the
187 dependencies. By default, dependencies to obsolete
189 --avoid=MODULE Avoid including the given MODULE. Useful if you
190 have code that provides equivalent functionality.
191 This option can be repeated.
192 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
193 Also modify license template from GPL to LGPL.
194 The version number of the LGPL can be specified;
195 the default is currently LGPLv3.
196 --makefile-name=NAME Name of makefile in automake syntax in the
197 source-base and tests-base directories
198 (default \"Makefile.am\").
199 --libtool Use libtool rules.
200 --no-libtool Don't use libtool rules.
201 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
202 'gl_INIT'. Default is 'gl'.
203 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
204 the package name. A suffix '-gnulib' is appended.
205 --vc-files Update version control related files.
206 --no-vc-files Don't update version control related files
207 (.gitignore and/or .cvsignore).
208 --no-changelog Don't update or create ChangeLog files.
210 Options for --import and --update:
211 --dry-run For --import, only print what would have been done.
212 -s, --symbolic, --symlink Make symbolic links instead of copying files.
213 --local-symlink Make symbolic links instead of copying files, only
214 for files from the local override directory.
215 -S, --more-symlinks Make symbolic links instead of copying files, and
216 don't replace copyright notices.
218 Report bugs to <bug-gnulib@gnu.org>."
222 # outputs to stdout the --version message.
226 if test -d "$gnulib_dir"/.git \
227 && (git --version) >/dev/null 2>/dev/null \
228 && (date --version) >/dev/null 2>/dev/null; then
229 # gnulib checked out from git.
230 sed_extract_first_date='/^Date/{
234 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
235 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
236 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
237 date=`echo "$date" | sed -e "$sed_year_before_time"`
238 # Use GNU date to compute the time in GMT.
239 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
240 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
242 if test -d "$gnulib_dir"/CVS \
243 && (cvs --version) >/dev/null 2>/dev/null; then
244 # gnulib checked out from CVS.
245 sed_extract_first_date='/^date: /{
246 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
249 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
251 # gnulib copy without versioning information.
252 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
256 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
258 gnulib-tool (GNU $package $date)$version
259 Copyright (C) $year Free Software Foundation, Inc.
260 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
261 This is free software: you are free to change and redistribute it.
262 There is NO WARRANTY, to the extent permitted by law.
264 Written by" "Bruno Haible" "and" "Simon Josefsson"
267 # func_emit_copyright_notice
268 # outputs to stdout a header for a generated file.
269 func_emit_copyright_notice ()
271 sed -n -e '/Copyright/ {
274 }' < "$self_abspathname"
276 echo "# This file is free software, distributed under the terms of the GNU"
277 echo "# General Public License. As a special exception to the GNU General"
278 echo "# Public License, this file may be distributed as part of a program"
279 echo "# that contains a configuration script generated by Autoconf, under"
280 echo "# the same distribution terms as the rest of that program."
282 echo "# Generated by gnulib-tool."
286 # exits with a given status.
287 # This function needs to be used, rather than 'exit', when a 'trap' handler is
288 # in effect that refers to $?.
295 # locates the directory where the gnulib repository lives
297 # - progname name of this program
299 # - self_abspathname absolute pathname of gnulib-tool
300 # - gnulib_dir absolute pathname of gnulib repository
304 /*) self_abspathname="$progname" ;;
305 */*) self_abspathname=`pwd`/"$progname" ;;
308 # Iterate through the elements of $PATH.
309 # We use IFS=: instead of
310 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
311 # because the latter does not work when some PATH element contains spaces.
312 # We use a canonicalized $pathx instead of $PATH, because empty PATH
313 # elements are by definition equivalent to '.', however field splitting
314 # according to IFS=: loses empty fields in many shells:
315 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
316 # beginning, at the end, and in the middle),
317 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
318 # at the beginning and at the end,
319 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
320 # Solaris lose empty fields at the end.
321 # The 'case' statement is an optimization, to avoid evaluating the
322 # explicit canonicalization command when $PATH contains no empty fields.
324 if test "${PATH_SEPARATOR+set}" != set; then
326 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
327 chmod +x "$tmp"/conf.sh
328 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
335 if test "$PATH_SEPARATOR" = ";"; then
336 # On Windows, programs are searched in "." before $PATH.
339 # On Unix, we have to convert empty PATH elements to ".".
343 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
348 IFS="$PATH_SEPARATOR"
352 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
353 self_abspathname="$d/$progname"
358 if test -z "$self_abspathname"; then
359 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
363 while test -h "$self_abspathname"; do
364 # Resolve symbolic link.
365 linkval=`func_readlink "$self_abspathname"`
366 test -n "$linkval" || break
368 /* ) self_abspathname="$linkval" ;;
369 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
372 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
376 # creates a temporary directory.
378 # - progname name of this program
380 # - tmp pathname of freshly created temporary directory
383 # Use the environment variable TMPDIR, falling back to /tmp. This allows
384 # users to specify a different temporary directory, for example, if their
385 # /tmp is filled up or too small.
388 # Use the mktemp program if available. If not available, hide the error
390 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
391 test -n "$tmp" && test -d "$tmp"
394 # Use a simple mkdir command. It is guaranteed to fail if the directory
395 # already exists. $RANDOM is bash specific and expands to empty in shells
396 # other than bash, ksh and zsh. Its use does not increase security;
397 # rather, it minimizes the probability of failure in a very cluttered /tmp
399 tmp=$TMPDIR/gl$$-$RANDOM
400 (umask 077 && mkdir "$tmp")
403 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
408 # func_append var value
409 # appends the given value to the shell variable var.
410 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
411 # Use bash's += operator. It reduces complexity of appending repeatedly to
412 # a single variable from O(n^2) to O(n).
417 fast_func_append=true
421 eval "$1=\"\$$1\$2\""
423 fast_func_append=false
426 # func_remove_prefix var prefix
427 # removes the given prefix from the value of the shell variable var.
428 # var should be the name of a shell variable.
429 # Its value should not contain a newline and not start or end with whitespace.
430 # prefix should not contain the characters "$`\{}[]^|.
431 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
432 func_remove_prefix ()
436 fast_func_remove_prefix=true
438 func_remove_prefix ()
440 eval "value=\"\$$1\""
444 sed_escape_dots='s/\([.]\)/\\\1/g'
445 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
448 value=`echo "$value" | sed -e "s|^${prefix}||"`
449 eval "$1=\"\$value\""
451 fast_func_remove_prefix=false
454 # func_remove_suffix var suffix
455 # removes the given suffix from the value of the shell variable var.
456 # var should be the name of a shell variable.
457 # Its value should not contain a newline and not start or end with whitespace.
458 # suffix should not contain the characters "$`\{}[]^|.
459 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
460 func_remove_suffix ()
464 fast_func_remove_suffix=true
466 func_remove_suffix ()
468 eval "value=\"\$$1\""
472 sed_escape_dots='s/\([.]\)/\\\1/g'
473 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
476 value=`echo "$value" | sed -e "s|${suffix}\$||"`
477 eval "$1=\"\$value\""
479 fast_func_remove_suffix=false
482 # func_fatal_error message
483 # outputs to stderr a fatal error message, and terminates the program.
485 # - progname name of this program
488 echo "$progname: *** $1" 1>&2
489 echo "$progname: *** Stop." 1>&2
493 # func_readlink SYMLINK
494 # outputs the target of the given symlink.
495 if (type -p readlink) > /dev/null 2>&1; then
498 # Use the readlink program from GNU coreutils.
504 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
505 # would do the wrong thing if the link target contains " -> ".
506 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
510 # func_relativize DIR1 DIR2
511 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
513 # - DIR1 relative pathname, relative to the current directory
514 # - DIR2 relative pathname, relative to the current directory
516 # - reldir relative pathname of DIR2, relative to DIR1
522 sed_first='s,^\([^/]*\)/.*$,\1,'
523 sed_rest='s,^[^/]*/*,,'
524 sed_last='s,^.*/\([^/]*\)$,\1,'
525 sed_butlast='s,/*[^/]*$,,'
526 while test -n "$dir1"; do
527 first=`echo "$dir1" | sed -e "$sed_first"`
528 if test "$first" != "."; then
529 if test "$first" = ".."; then
530 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
531 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
533 first2=`echo "$dir2" | sed -e "$sed_first"`
534 if test "$first2" = "$first"; then
535 dir2=`echo "$dir2" | sed -e "$sed_rest"`
539 dir0="$dir0"/"$first"
542 dir1=`echo "$dir1" | sed -e "$sed_rest"`
547 # func_relconcat DIR1 DIR2
548 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
550 # - DIR1 relative pathname, relative to the current directory
551 # - DIR2 relative pathname, relative to DIR1
553 # - relconcat DIR1/DIR2, relative to the current directory
558 sed_first='s,^\([^/]*\)/.*$,\1,'
559 sed_rest='s,^[^/]*/*,,'
560 sed_last='s,^.*/\([^/]*\)$,\1,'
561 sed_butlast='s,/*[^/]*$,,'
563 first=`echo "$dir2" | sed -e "$sed_first"`
564 if test "$first" = "."; then
565 dir2=`echo "$dir2" | sed -e "$sed_rest"`
566 if test -z "$dir2"; then
571 last=`echo "$dir1" | sed -e "$sed_last"`
572 while test "$last" = "."; do
573 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
574 last=`echo "$dir1" | sed -e "$sed_last"`
576 if test -z "$dir1"; then
580 if test "$first" = ".."; then
581 if test "$last" = ".."; then
582 relconcat="$dir1/$dir2"
585 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
586 dir2=`echo "$dir2" | sed -e "$sed_rest"`
587 if test -z "$dir1"; then
591 if test -z "$dir2"; then
596 relconcat="$dir1/$dir2"
604 # Like ln -s, except that SRC is given relative to the current directory (or
605 # absolute), not given relative to the directory of DEST.
611 *) # SRC is relative.
614 ln -s "`pwd`/$1" "$2" ;;
615 *) # DEST is relative too.
616 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
617 test -n "$ln_destdir" || ln_destdir="."
618 func_relativize "$ln_destdir" "$1"
626 # func_ln_if_changed SRC DEST
627 # Like func_ln, but avoids munging timestamps if the link is correct.
628 func_ln_if_changed ()
630 if test $# -ne 2; then
631 echo "usage: func_ln_if_changed SRC DEST" >&2
633 ln_target=`func_readlink "$2"`
634 if test -h "$2" && test "$1" = "$ln_target"; then
643 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
644 # writes into a pipe with no readers, i.e. a pipe where all readers have
645 # already closed their file descriptor that read from it or exited entirely.
646 # The default behaviour is to terminate the current process without an error
648 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
649 # terminate the current process with an error message.
650 # This function should be called at the beginning of a command that only
651 # produces output to stdout (i.e. no side effects!), when the command that
652 # will read from this pipe might prematurely exit or close its standard input
654 if test -n "$BASH_VERSION"; then
655 # The problem has only been reported with bash. Probably it occurs only with
656 # bash-3.2. For the reasons, see
657 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
658 # Note that Solaris sh does not understand "trap - SIGPIPE".
659 func_reset_sigpipe ()
664 func_reset_sigpipe ()
670 # Ensure an 'echo' command that does not interpret backslashes.
672 # echo '\n' | wc -l prints 1 when OK, 2 when KO
673 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
674 # This problem is a weird heritage from SVR4. BSD got it right (except that
675 # BSD echo interprets '-n' as an option, which is also not desirable).
676 # Nowadays the problem occurs in 4 situations:
677 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
678 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
679 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
680 # - in zsh, when sh-emulation is not set,
681 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
682 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
683 # - in Solaris /bin/sh and OSF/1 /bin/sh.
684 # We try the following workarounds:
685 # - for all: respawn using $CONFIG_SHELL if that is set and works.
686 # - for bash >= 2.04: unset the shell option xpg_echo.
687 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
688 # - for bash < 2.0: define echo to a function that uses cat of a here document.
689 # - for zsh: turn sh-emulation on.
690 # - for ksh: alias echo to 'print -r'.
691 # - for ksh: alias echo to a function that uses cat of a here document.
692 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
693 # the ksh workaround.
694 # - otherwise: respawn using /bin/sh and rely on the workarounds.
695 # When respawning, we pass --no-reexec as first argument, so as to avoid
696 # turning this script into a fork bomb in unlucky situations.
698 if echo '\t' | grep t > /dev/null; then
699 have_echo=yes # Lucky!
701 # Try the workarounds.
702 # Respawn using $CONFIG_SHELL if that is set and works.
703 if test -z "$have_echo" \
704 && test "X$1" != "X--no-reexec" \
705 && test -n "$CONFIG_SHELL" \
706 && test -f "$CONFIG_SHELL" \
707 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
708 exec $CONFIG_SHELL "$0" --no-reexec "$@"
711 # For bash >= 2.04: unset the shell option xpg_echo.
712 if test -z "$have_echo" \
713 && test -n "$BASH_VERSION" \
714 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
718 # For bash >= 2.0: define echo to a function that uses the printf built-in.
719 # For bash < 2.0: define echo to a function that uses cat of a here document.
720 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
721 if test -z "$have_echo" \
722 && test -n "$BASH_VERSION"; then \
723 if type printf 2>/dev/null | grep / > /dev/null; then
724 # 'printf' is not a shell built-in.
732 # 'printf' is a shell built-in.
738 if echo '\t' | grep t > /dev/null; then
742 # For zsh: turn sh-emulation on.
743 if test -z "$have_echo" \
744 && test -n "$ZSH_VERSION" \
745 && (emulate sh) >/dev/null 2>&1; then
748 # For ksh: alias echo to 'print -r'.
749 if test -z "$have_echo" \
750 && (type print) >/dev/null 2>&1; then
751 # A 'print' command exists.
752 if type print 2>/dev/null | grep / > /dev/null; then
755 # 'print' is a shell built-in.
756 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
757 # 'print' is the ksh shell built-in.
758 alias echo='print -r'
762 if test -z "$have_echo" \
763 && echo '\t' | grep t > /dev/null; then
766 # For ksh: alias echo to a function that uses cat of a here document.
767 # The ksh manual page says:
768 # "Aliasing is performed when scripts are read, not while they are executed.
769 # Therefore, for an alias to take effect, the alias definition command has
770 # to be executed before the command which references the alias is read."
771 # Because of this, we have to play strange tricks with have_echo, to ensure
772 # that the top-level statement containing the test starts after the 'alias'
774 if test -z "$have_echo"; then
781 alias echo=bsd_echo 2>/dev/null
783 if test -z "$have_echo" \
784 && echo '\t' | grep t > /dev/null; then
787 if test -z "$have_echo"; then
788 unalias echo 2>/dev/null
790 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
791 if test -z "$have_echo" \
792 && test "X$1" != "X--no-reexec" \
793 && test -f /bin/ksh; then
794 exec /bin/ksh "$0" --no-reexec "$@"
797 # Otherwise: respawn using /bin/sh.
798 if test -z "$have_echo" \
799 && test "X$1" != "X--no-reexec" \
800 && test -f /bin/sh; then
801 exec /bin/sh "$0" --no-reexec "$@"
804 if test -z "$have_echo"; then
805 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
807 if echo '\t' | grep t > /dev/null; then
810 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
812 if test "X$1" = "X--no-reexec"; then
816 # Command-line option processing.
817 # Removes the OPTIONS from the arguments. Sets the variables:
818 # - mode list or import or create-testdir or create-megatestdir
819 # - destdir from --dir
820 # - local_gnulib_dir from --local-dir
821 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
822 # - libname, supplied_libname from --lib
823 # - sourcebase from --source-base
824 # - m4base from --m4-base
825 # - pobase from --po-base
826 # - docbase from --doc-base
827 # - testsbase from --tests-base
828 # - auxdir from --aux-dir
829 # - inctests true if --with-tests was given, blank otherwise
830 # - incobsolete true if --with-obsolete was given, blank otherwise
831 # - avoidlist list of modules to avoid, from --avoid
832 # - lgpl yes or a number if --lgpl was given, blank otherwise
833 # - makefile_name from --makefile-name
834 # - libtool true if --libtool was given, false if --no-libtool was
835 # given, blank otherwise
836 # - macro_prefix from --macro-prefix
837 # - po_domain from --po-domain
838 # - vc_files true if --vc-files was given, false if --no-vc-files was
839 # given, blank otherwise
840 # - autoconf_minversion minimum supported autoconf version
841 # - do_changelog false if --no-changelog was given, : otherwise
842 # - doit : if actions shall be executed, false if only to be printed
843 # - symbolic true if --symlink or --more-symlinks was given, blank
845 # - lsymbolic true if --local-symlink was given, blank otherwise
846 # - do_copyrights blank if --more-symlinks was given, true otherwise
877 while test $# -gt 0; do
882 --import | --impor | --impo | --imp | --im | --i )
885 --update | --updat | --upda | --upd | --up | --u )
888 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
891 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
892 mode=create-megatestdir
894 --test | --tes | --te | --t )
897 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
901 mode=`echo "X$1" | sed -e 's/^X--//'`
903 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
909 func_fatal_error "missing argument for --dir"
914 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
919 func_fatal_error "missing argument for --local-dir"
924 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
926 --verbose | --verbos | --verbo | --verb )
927 verbose=`expr $verbose + 1`
929 --quiet | --quie | --qui | --qu | --q )
930 verbose=`expr $verbose - 1`
935 func_fatal_error "missing argument for --lib"
938 supplied_libname=true
941 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
942 supplied_libname=true
947 func_fatal_error "missing argument for --source-base"
952 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
957 func_fatal_error "missing argument for --m4-base"
962 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
967 func_fatal_error "missing argument for --po-base"
972 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
977 func_fatal_error "missing argument for --doc-base"
982 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
987 func_fatal_error "missing argument for --tests-base"
992 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
997 func_fatal_error "missing argument for --aux-dir"
1002 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1012 if test $# = 0; then
1013 func_fatal_error "missing argument for --avoid"
1015 func_append avoidlist " $1"
1018 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1019 func_append avoidlist " $arg"
1025 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1028 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1034 if test $# = 0; then
1035 func_fatal_error "missing argument for --makefile-name"
1040 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1050 if test $# = 0; then
1051 func_fatal_error "missing argument for --macro-prefix"
1056 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1060 if test $# = 0; then
1061 func_fatal_error "missing argument for --po-domain"
1066 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1074 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
1080 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1083 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1086 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1090 --help | --hel | --he | --h )
1093 --version | --versio | --versi | --vers )
1097 # Stop option processing
1101 echo "gnulib-tool: unknown option $1" 1>&2
1102 echo "Try 'gnulib-tool --help' for more information." 1>&2
1109 if test "$mode" = update; then
1110 if test $# != 0; then
1111 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1112 echo "Try 'gnulib-tool --help' for more information." 1>&2
1113 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1114 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1117 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1118 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1119 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1120 || test -n "$inctests" || test -n "$incobsolete" \
1121 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1122 || test -n "$macro_prefix" || test -n "$po_domain" \
1123 || test -n "$vc_files"; then
1124 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1125 echo "Try 'gnulib-tool --help' for more information." 1>&2
1126 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1127 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1132 if test -n "$pobase" && test -z "$po_domain"; then
1133 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1134 echo "Try 'gnulib-tool --help' for more information." 1>&2
1137 if test -z "$pobase" && test -n "$po_domain"; then
1138 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1141 # Determine the minimum supported autoconf version from the project's
1143 DEFAULT_AUTOCONF_MINVERSION="2.59"
1144 autoconf_minversion=
1146 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1147 if test -f "$destdir"/configure.ac; then
1148 configure_ac="$destdir/configure.ac"
1150 if test -f "$destdir"/configure.in; then
1151 configure_ac="$destdir/configure.in"
1155 if test -f configure.ac; then
1156 configure_ac="configure.ac"
1158 if test -f configure.in; then
1159 configure_ac="configure.in"
1163 if test -n "$configure_ac"; then
1164 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1165 # because when some m4 files are omitted from a CVS repository,
1166 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1167 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1168 # autom4te: m4 failed with exit status: 1
1175 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1177 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1178 if test -n "$prereqs"; then
1179 autoconf_minversion=`
1180 for version in $prereqs; do echo $version; done |
1181 LC_ALL=C sort -nru | sed -e 1q
1185 if test -z "$autoconf_minversion"; then
1186 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1188 case "$autoconf_minversion" in
1189 1.* | 2.[0-4]* | 2.5[0-8]*)
1190 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1193 # Remove trailing slashes from the directory names. This is necessary for
1194 # m4base (to avoid an error in func_import) and optional for the others.
1195 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1196 case "$local_gnulib_dir" in
1197 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1199 case "$sourcebase" in
1200 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1203 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1206 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1209 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1211 case "$testsbase" in
1212 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1215 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1221 trap 'exit_status=$?
1222 if test "$signal" != 0; then
1223 echo "caught signal $signal" >&2
1226 exit $exit_status' 0
1227 for signal in 1 2 3 13 15; do
1228 trap '{ signal='$signal'; func_exit 1; }' $signal
1232 # func_lookup_file file
1233 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1236 # - local_gnulib_dir from --local-dir
1238 # - lookedup_file name of the merged (combined) file
1239 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1243 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1244 lookedup_file="$local_gnulib_dir/$lkfile"
1247 if test -f "$gnulib_dir/$lkfile"; then
1248 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1249 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1250 rm -f "$tmp/$lkbase"
1251 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1252 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1253 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1254 lookedup_file="$tmp/$lkbase"
1257 lookedup_file="$gnulib_dir/$lkfile"
1261 func_fatal_error "file $gnulib_dir/$lkfile not found"
1268 # - local_gnulib_dir from --local-dir
1271 # Filter out metainformation files like README, which are not modules.
1272 # Filter out unit test modules; they can be retrieved through
1273 # --extract-tests-module if desired.
1275 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1276 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1277 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1280 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1281 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1282 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1283 -e '/^README$/d' -e '/\/README$/d' \
1284 -e '/^TEMPLATE$/d' \
1285 -e '/^TEMPLATE-EXTENDED$/d' \
1286 -e '/^TEMPLATE-TESTS$/d' \
1289 | sed -e '/-tests$/d' \
1293 # func_verify_module
1294 # verifies a module name
1296 # - local_gnulib_dir from --local-dir
1297 # - module module name argument
1298 func_verify_module ()
1300 if { test -f "$gnulib_dir/modules/$module" \
1301 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1302 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1303 && test "CVS" != "$module" \
1304 && test "ChangeLog" != "$module" \
1305 && test "COPYING" != "$module" \
1306 && test "README" != "$module" \
1307 && test "TEMPLATE" != "$module" \
1308 && test "TEMPLATE-EXTENDED" != "$module" \
1309 && test "TEMPLATE-TESTS" != "$module"; then
1310 # OK, $module is a correct module name.
1311 # Verify that building the module description with 'patch' succeeds.
1312 func_lookup_file "modules/$module"
1314 echo "gnulib-tool: module $module doesn't exist" 1>&2
1319 # func_verify_nontests_module
1320 # verifies a module name, excluding tests modules
1322 # - local_gnulib_dir from --local-dir
1323 # - module module name argument
1324 func_verify_nontests_module ()
1327 *-tests ) module= ;;
1328 * ) func_verify_module ;;
1332 # func_verify_tests_module
1333 # verifies a module name, considering only tests modules
1335 # - local_gnulib_dir from --local-dir
1336 # - module module name argument
1337 func_verify_tests_module ()
1340 *-tests ) func_verify_module ;;
1345 sed_extract_prog=':[ ]*$/ {
1348 s/^Description:[ ]*$//
1351 s/^Applicability:[ ]*$//
1353 s/^Depends-on:[ ]*$//
1354 s/^configure\.ac-early:[ ]*$//
1355 s/^configure\.ac:[ ]*$//
1356 s/^Makefile\.am:[ ]*$//
1360 s/^Maintainer:[ ]*$//
1367 # func_get_description module
1369 # - local_gnulib_dir from --local-dir
1370 func_get_description ()
1372 func_lookup_file "modules/$1"
1373 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1376 # func_get_status module
1378 # - local_gnulib_dir from --local-dir
1381 func_lookup_file "modules/$1"
1382 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1385 # func_get_notice module
1387 # - local_gnulib_dir from --local-dir
1390 func_lookup_file "modules/$1"
1391 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1394 # func_get_applicability module
1396 # - local_gnulib_dir from --local-dir
1397 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1398 func_get_applicability ()
1400 func_lookup_file "modules/$1"
1401 { sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"
1402 # The default is 'main' or 'tests', depending on the module's name.
1404 *-tests) echo "tests";;
1407 } | sed -e 's,^ *$,,' | sed -e 1q
1410 # func_get_filelist module
1412 # - local_gnulib_dir from --local-dir
1413 func_get_filelist ()
1415 func_lookup_file "modules/$1"
1416 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1418 echo m4/gnulib-common.m4
1419 case "$autoconf_minversion" in
1426 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1427 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1428 # elements starting with prefix and ending with suffix are considered.
1429 # Processing: removed_prefix and removed_suffix are removed from each element,
1430 # added_prefix and added_suffix are added to each element.
1431 # prefix, suffix should not contain shell-special characters.
1432 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1433 # added_prefix, added_suffix should not contain the characters \|&.
1434 func_filter_filelist ()
1436 if test "$2" != "$nl" \
1437 || { $fast_func_append \
1438 && { test -z "$6" || $fast_func_remove_prefix; } \
1439 && { test -z "$7" || $fast_func_remove_suffix; }; \
1443 # Do not quote possibly-empty parameters in case patterns,
1444 # AIX and HP-UX ksh won't match them if they are empty.
1447 if test -n "$6"; then
1448 func_remove_prefix fff "$6"
1450 if test -n "$7"; then
1451 func_remove_suffix fff "$7"
1454 if test -z "$ffflist"; then
1457 func_append ffflist "$2${fff}"
1463 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1464 ffflist=`for fff in $3; do
1466 $4*$5) echo "$fff" ;;
1468 done | sed -e "$sed_fff_filter"`
1470 eval "$1=\"\$ffflist\""
1473 # func_get_dependencies module
1475 # - local_gnulib_dir from --local-dir
1476 func_get_dependencies ()
1478 # ${module}-tests always implicitly depends on ${module}.
1482 func_remove_suffix fgd1 '-tests'
1486 # Then the explicit dependencies listed in the module description.
1487 func_lookup_file "modules/$1"
1488 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1491 # func_get_autoconf_early_snippet module
1493 # - local_gnulib_dir from --local-dir
1494 func_get_autoconf_early_snippet ()
1496 func_lookup_file "modules/$1"
1497 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1500 # func_get_autoconf_snippet module
1502 # - local_gnulib_dir from --local-dir
1503 func_get_autoconf_snippet ()
1505 func_lookup_file "modules/$1"
1506 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1509 # func_get_automake_snippet module
1511 # - local_gnulib_dir from --local-dir
1512 func_get_automake_snippet ()
1514 func_lookup_file "modules/$1"
1515 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1518 # *-tests module live in tests/, not lib/.
1519 # Synthesize an EXTRA_DIST augmentation.
1520 all_files=`func_get_filelist $1`
1521 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1522 extra_files="$tests_files"
1523 if test -n "$extra_files"; then
1524 echo "EXTRA_DIST +=" $extra_files
1529 # Synthesize an EXTRA_DIST augmentation.
1530 sed_combine_lines='/\\$/{
1537 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1538 already_mentioned_files=` \
1539 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1540 | sed -e "$sed_combine_lines" \
1541 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1542 all_files=`func_get_filelist $1`
1543 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
1544 # Remove $already_mentioned_files from $lib_files.
1545 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1546 extra_files=`func_reset_sigpipe; \
1547 for f in $already_mentioned_files; do echo $f; done \
1548 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1549 if test -n "$extra_files"; then
1550 echo "EXTRA_DIST +=" $extra_files
1553 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1554 # This is necessary so that automake can generate the right list of
1556 # A possible approach would be to use autom4te --trace of the redefined
1557 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1558 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1559 # inside autoconf's built-in macros are not missed).
1560 # But it's simpler and more robust to do it here, based on the file list.
1561 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1562 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1563 # automake will generate a useless dependency; this is harmless.
1565 relocatable-prog-wrapper) ;;
1567 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
1568 if test -n "$extra_files"; then
1569 echo "EXTRA_lib_SOURCES +=" $extra_files
1574 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1575 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
1576 if test -n "$buildaux_files"; then
1577 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1578 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1581 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1582 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
1583 if test -n "$top_files"; then
1584 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1585 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1592 # func_get_include_directive module
1594 # - local_gnulib_dir from --local-dir
1595 func_get_include_directive ()
1597 func_lookup_file "modules/$1"
1598 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1599 sed -e 's/^\(["<]\)/#include \1/'
1602 # func_get_link_directive module
1604 # - local_gnulib_dir from --local-dir
1605 func_get_link_directive ()
1607 func_lookup_file "modules/$1"
1608 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1611 # func_get_license module
1613 # - local_gnulib_dir from --local-dir
1616 func_lookup_file "modules/$1"
1617 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1618 # The default is GPL.
1620 } | sed -e 's,^ *$,,' | sed -e 1q
1623 # func_get_maintainer module
1625 # - local_gnulib_dir from --local-dir
1626 func_get_maintainer ()
1628 func_lookup_file "modules/$1"
1629 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1632 # func_get_tests_module module
1634 # - local_gnulib_dir from --local-dir
1635 func_get_tests_module ()
1637 # The naming convention for tests modules is hardwired: ${module}-tests.
1638 if test -f "$gnulib_dir/modules/$1"-tests \
1639 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1640 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1645 # func_acceptable module
1646 # tests whether a module is acceptable.
1648 # - avoidlist list of modules to avoid
1651 for avoid in $avoidlist; do
1652 if test "$avoid" = "$1"; then
1659 # func_modules_transitive_closure
1661 # - local_gnulib_dir from --local-dir
1662 # - modules list of specified modules
1663 # - inctests true if tests should be included, blank otherwise
1664 # - incobsolete true if obsolete modules among dependencies should be
1665 # included, blank otherwise
1666 # - avoidlist list of modules to avoid
1667 # - tmp pathname of a temporary directory
1669 # - modules list of modules, including dependencies
1670 func_modules_transitive_closure ()
1672 # In order to process every module only once (for speed), process an "input
1673 # list" of modules, producing an "output list" of modules. During each round,
1674 # more modules can be queued in the input list. Once a module on the input
1675 # list has been processed, it is added to the "handled list", so we can avoid
1676 # to process it again.
1678 inmodules="$modules"
1680 while test -n "$inmodules"; do
1681 inmodules_this_round="$inmodules"
1682 inmodules= # Accumulator, queue for next round
1683 for module in $inmodules_this_round; do
1685 if test -n "$module"; then
1686 if func_acceptable $module; then
1687 func_append outmodules " $module"
1688 deps=`func_get_dependencies $module`
1689 # Duplicate dependencies are harmless, but Jim wants a warning.
1690 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1691 if test -n "$duplicated_deps"; then
1692 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1694 for dep in $deps; do
1695 if test -n "$incobsolete" \
1696 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
1697 func_append inmodules " $dep"
1700 if test -n "$inctests"; then
1701 testsmodule=`func_get_tests_module $module`
1702 if test -n "$testsmodule"; then
1703 func_append inmodules " $testsmodule"
1709 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1710 # Remove $handledmodules from $inmodules.
1711 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1712 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1714 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1715 rm -f "$tmp"/queued-modules
1718 # func_modules_add_dummy
1720 # - local_gnulib_dir from --local-dir
1721 # - modules list of modules, including dependencies
1723 # - modules list of modules, including 'dummy' if needed
1724 func_modules_add_dummy ()
1726 # Determine whether any module provides a lib_SOURCES augmentation.
1728 sed_remove_backslash_newline=':a
1735 for module in $modules; do
1736 func_verify_nontests_module
1737 if test -n "$module"; then
1738 # Extract the value of "lib_SOURCES += ...".
1739 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1740 # Ignore .h files since they are not compiled.
1744 have_lib_SOURCES=yes
1751 # Add the dummy module, to make sure the library will be non-empty.
1752 if test -z "$have_lib_SOURCES"; then
1753 if func_acceptable "dummy"; then
1754 func_append modules " dummy"
1759 # func_modules_notice
1761 # - local_gnulib_dir from --local-dir
1762 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1763 # - modules list of modules, including dependencies
1764 func_modules_notice ()
1766 if test $verbose -ge -1; then
1767 for module in $modules; do
1769 if test -n "$module"; then
1770 msg=`func_get_notice $module`
1771 if test -n "$msg"; then
1772 echo "Notice from module $module:"
1773 echo "$msg" | sed -e 's/^/ /'
1780 # func_modules_to_filelist
1782 # - local_gnulib_dir from --local-dir
1783 # - modules list of modules, including dependencies
1785 # - files list of files
1786 func_modules_to_filelist ()
1789 for module in $modules; do
1791 if test -n "$module"; then
1792 fs=`func_get_filelist $module`
1793 func_append files " $fs"
1796 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1799 # func_execute_command command [args...]
1800 # Executes a command.
1801 # Uses also the variables
1802 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1803 func_execute_command ()
1805 if test $verbose -ge 0; then
1809 # Commands like automake produce output to stderr even when they succeed.
1810 # Turn this output off if the command succeeds.
1811 "$@" > "$tmp"/cmdout 2>&1
1813 if test $cmdret = 0; then
1817 cat "$tmp"/cmdout 1>&2
1824 # func_dest_tmpfilename file
1825 # determines the name of a temporary file (file is relative to destdir).
1827 # - destdir target directory
1828 # - doit : if actions shall be executed, false if only to be printed
1829 # - tmp pathname of a temporary directory
1831 # - tmpfile absolute filename of the temporary file
1832 func_dest_tmpfilename ()
1835 # Put the new contents of $file in a file in the same directory (needed
1836 # to guarantee that an 'mv' to "$destdir/$file" works).
1837 tmpfile="$destdir/$1.tmp"
1839 # Put the new contents of $file in a file in a temporary directory
1840 # (because the directory of "$file" might not exist).
1841 tmpfile="$tmp"/`basename "$1"`.tmp
1846 # copies a file from gnulib into the destination directory. The destination
1847 # is known to not exist.
1849 # - destdir target directory
1850 # - local_gnulib_dir from --local-dir
1851 # - f the original file name
1852 # - lookedup_file name of the merged (combined) file
1853 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1854 # - g the rewritten file name
1855 # - tmpfile absolute filename of the temporary file
1856 # - doit : if actions shall be executed, false if only to be printed
1857 # - symbolic true if files should be symlinked, copied otherwise
1858 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1863 echo "Copying file $g"
1864 if { test -n "$symbolic" \
1865 || { test -n "$lsymbolic" \
1866 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1867 && test -z "$lookedup_tmp" \
1868 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1869 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1871 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1879 # copies a file from gnulib into the destination directory. The destination
1880 # is known to exist.
1882 # - destdir target directory
1883 # - local_gnulib_dir from --local-dir
1884 # - f the original file name
1885 # - lookedup_file name of the merged (combined) file
1886 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1887 # - g the rewritten file name
1888 # - tmpfile absolute filename of the temporary file
1889 # - doit : if actions shall be executed, false if only to be printed
1890 # - symbolic true if files should be symlinked, copied otherwise
1891 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1893 # - already_present nonempty if the file should already exist, empty otherwise
1896 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1897 : # The file has not changed.
1901 if test -n "$already_present"; then
1902 echo "Updating file $g (backup in ${g}~)"
1904 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
1906 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1907 if { test -n "$symbolic" \
1908 || { test -n "$lsymbolic" \
1909 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1910 && test -z "$lookedup_tmp" \
1911 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1912 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1914 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1917 if test -n "$already_present"; then
1918 echo "Update file $g (backup in ${g}~)"
1920 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
1926 # func_emit_lib_Makefile_am
1927 # emits the contents of library makefile to standard output.
1929 # - local_gnulib_dir from --local-dir
1930 # - modules list of modules, including dependencies
1931 # - libname library name
1932 # - pobase directory relative to destdir where to place *.po files
1933 # - auxdir directory relative to destdir where to place build aux files
1934 # - makefile_name from --makefile-name
1935 # - libtool true if libtool will be used, false or blank otherwise
1936 # - macro_prefix prefix of gl_LIBOBJS macros to use
1937 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1938 # - actioncmd (optional) command that will reproduce this invocation
1939 # - for_test true if creating a package for testing, false otherwise
1940 # - destfile filename relative to destdir of makefile being generated
1942 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1943 # list of edits to be done to Makefile.am variables
1945 # - uses_subdirs nonempty if object files in subdirs exist
1946 func_emit_lib_Makefile_am ()
1948 # When creating an includable Makefile.am snippet, augment variables with
1949 # += instead of assigning them.
1950 if test -n "$makefile_name"; then
1955 if test "$libtool" = true; then
1958 sed_eliminate_LDFLAGS="$sed_noop"
1962 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1965 # When creating a package for testing: Attempt to provoke failures,
1966 # especially link errors, already during "make" rather than during
1967 # "make check", because "make check" is not possible in a cross-compiling
1968 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1969 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1971 sed_transform_check_PROGRAMS="$sed_noop"
1973 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1974 echo "## Process this file with automake to produce Makefile.in."
1975 func_emit_copyright_notice
1976 if test -n "$actioncmd"; then
1977 # The maximum line length (excluding the terminating newline) of any file
1978 # that is to be preprocessed by config.status is 3070. config.status uses
1979 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
1980 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
1981 len=`echo "$actioncmd" | wc -c`
1982 if test -n "$len" && test "$len" -le 3000; then
1983 echo "# Reproduce by: $actioncmd"
1989 for module in $modules; do
1990 func_verify_nontests_module
1991 if test -n "$module"; then
1993 func_get_automake_snippet "$module" |
1994 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1995 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1996 -e "$sed_eliminate_LDFLAGS" \
1997 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1998 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1999 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2000 -e "$sed_transform_check_PROGRAMS"
2001 if test "$module" = 'alloca'; then
2002 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2003 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2005 } > "$tmp"/amsnippet
2006 # Skip the contents if it's entirely empty.
2007 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2008 echo "## begin gnulib module $module"
2010 cat "$tmp"/amsnippet
2011 echo "## end gnulib module $module"
2014 rm -f "$tmp"/amsnippet
2015 # Test whether there are some source files in subdirectories.
2016 for f in `func_get_filelist "$module"`; do
2026 } > "$tmp"/allsnippets
2027 if test -z "$makefile_name"; then
2028 # If there are source files in subdirectories, prevent collision of the
2029 # object files (example: hash.c and libxml/hash.c).
2031 if test -n "$uses_subdirs"; then
2032 subdir_options=' subdir-objects'
2034 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2037 if test -z "$makefile_name"; then
2039 echo "noinst_HEADERS ="
2040 echo "noinst_LIBRARIES ="
2041 echo "noinst_LTLIBRARIES ="
2042 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2043 # if you specify pkgdata_DATA to empty. This is a workaround.
2044 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2045 echo "pkgdata_DATA ="
2048 echo "BUILT_SOURCES ="
2051 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2052 if test -z "$makefile_name"; then
2053 echo "MOSTLYCLEANDIRS ="
2055 echo "DISTCLEANFILES ="
2056 echo "MAINTAINERCLEANFILES ="
2058 # Execute edits that apply to the Makefile.am being generated.
2060 while test $edit != $makefile_am_edits; do
2061 edit=`expr $edit + 1`
2062 eval dir=\"\$makefile_am_edit${edit}_dir\"
2063 eval var=\"\$makefile_am_edit${edit}_var\"
2064 eval val=\"\$makefile_am_edit${edit}_val\"
2065 if test -n "$var"; then
2066 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2067 echo "${var} += ${val}"
2068 eval "makefile_am_edit${edit}_var="
2072 if test -z "$makefile_name"; then
2074 echo "AM_CPPFLAGS ="
2078 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2079 || { test -n "$makefile_name" \
2080 && test -f "$sourcebase/Makefile.am" \
2081 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2083 # One of the snippets or the user's Makefile.am already specifies an
2084 # installation location for the library. Don't confuse automake by saying
2085 # it should not be installed.
2088 # By default, the generated library should not be installed.
2089 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2092 echo "${libname}_${libext}_SOURCES ="
2093 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2094 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2095 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2096 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2097 echo "EXTRA_${libname}_${libext}_SOURCES ="
2098 if test "$libtool" = true; then
2099 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2102 if test -n "$pobase"; then
2103 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2106 cat "$tmp"/allsnippets \
2107 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2109 echo "mostlyclean-local: mostlyclean-generic"
2110 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2111 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2112 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2116 rm -f "$tmp"/allsnippets
2119 # func_emit_po_Makevars
2120 # emits the contents of po/ makefile parameterization to standard output.
2122 # - local_gnulib_dir from --local-dir
2123 # - sourcebase directory relative to destdir where to place source code
2124 # - pobase directory relative to destdir where to place *.po files
2125 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2126 func_emit_po_Makevars ()
2128 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2129 func_emit_copyright_notice
2131 echo "# Usually the message domain is the same as the package name."
2132 echo "# But here it has a '-gnulib' suffix."
2133 echo "DOMAIN = ${po_domain}-gnulib"
2135 echo "# These two variables depend on the location of this directory."
2136 echo "subdir = ${pobase}"
2137 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2140 # These options get passed to xgettext.
2141 XGETTEXT_OPTIONS = \
2142 --keyword=_ --flag=_:1:pass-c-format \
2143 --keyword=N_ --flag=N_:1:pass-c-format \
2144 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2145 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2146 --flag=error:3:c-format --flag=error_at_line:5:c-format
2148 # This is the copyright holder that gets inserted into the header of the
2149 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2150 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2152 # This is the email address or URL to which the translators shall report
2153 # bugs in the untranslated strings:
2154 # - Strings which are not entire sentences, see the maintainer guidelines
2155 # in the GNU gettext documentation, section 'Preparing Strings'.
2156 # - Strings which use unclear terms or require additional context to be
2158 # - Strings which make invalid assumptions about notation of date, time or
2160 # - Pluralisation problems.
2161 # - Incorrect English spelling.
2162 # - Incorrect formatting.
2163 # It can be your email address, or a mailing list address where translators
2164 # can write to without being subscribed, or the URL of a web page through
2165 # which the translators can contact you.
2166 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2168 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2169 # message catalogs shall be used. It is usually empty.
2170 EXTRA_LOCALE_CATEGORIES =
2172 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2173 # context. Possible values are "yes" and "no". Set this to yes if the
2174 # package uses functions taking also a message context, like pgettext(), or
2175 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2180 # func_emit_po_POTFILES_in
2181 # emits the file list to be passed to xgettext to standard output.
2183 # - local_gnulib_dir from --local-dir
2184 # - sourcebase directory relative to destdir where to place source code
2185 # - files list of new files
2186 func_emit_po_POTFILES_in ()
2188 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2189 func_emit_copyright_notice
2191 echo "# List of files which contain translatable strings."
2192 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2195 # func_emit_tests_Makefile_am
2196 # emits the contents of tests makefile to standard output.
2198 # - local_gnulib_dir from --local-dir
2199 # - modules list of modules, including dependencies
2200 # - libname library name
2201 # - auxdir directory relative to destdir where to place build aux files
2202 # - makefile_name from --makefile-name
2203 # - libtool true if libtool will be used, false or blank otherwise
2204 # - sourcebase relative directory containing lib source code
2205 # - m4base relative directory containing autoconf macros
2206 # - testsbase relative directory containing unit test code
2207 # - macro_prefix prefix of gl_LIBOBJS macros to use
2208 # - for_test true if creating a package for testing, false otherwise
2209 # - use_libtests true if a libtests.a should be built, false otherwise
2210 # - destfile filename relative to destdir of makefile being generated
2212 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2213 # list of edits to be done to Makefile.am variables
2215 # - uses_subdirs nonempty if object files in subdirs exist
2216 func_emit_tests_Makefile_am ()
2218 if test "$libtool" = true; then
2220 sed_eliminate_LDFLAGS="$sed_noop"
2223 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2226 # When creating a package for testing: Attempt to provoke failures,
2227 # especially link errors, already during "make" rather than during
2228 # "make check", because "make check" is not possible in a cross-compiling
2229 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2230 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2232 sed_transform_check_PROGRAMS="$sed_noop"
2234 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2235 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2236 echo "## Process this file with automake to produce Makefile.in."
2237 func_emit_copyright_notice
2241 for module in $modules; do
2243 func_verify_tests_module
2247 if test -n "$module"; then
2249 func_get_automake_snippet "$module" |
2250 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2251 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2252 -e "$sed_eliminate_LDFLAGS" \
2253 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2254 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2255 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2256 -e "$sed_transform_check_PROGRAMS"
2257 if $use_libtests && test "$module" = 'alloca'; then
2258 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2259 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2261 } > "$tmp"/amsnippet
2262 # Skip the contents if it's entirely empty.
2263 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2264 echo "## begin gnulib module $module"
2266 cat "$tmp"/amsnippet
2267 echo "## end gnulib module $module"
2270 rm -f "$tmp"/amsnippet
2271 # Test whether there are some source files in subdirectories.
2272 for f in `func_get_filelist "$module"`; do
2274 lib/*/*.c | tests/*/*.c)
2282 } > "$tmp"/allsnippets
2283 # Generate dependencies here, since it eases the debugging of test failures.
2284 # If there are source files in subdirectories, prevent collision of the
2285 # object files (example: hash.c and libxml/hash.c).
2287 if test -n "$uses_subdirs"; then
2288 subdir_options=' subdir-objects'
2290 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2293 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2296 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2297 # variable is needed to avoid an error from automake:
2298 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2301 echo "XFAIL_TESTS ="
2302 echo "TESTS_ENVIRONMENT ="
2303 echo "noinst_PROGRAMS ="
2304 if ! $for_test; then
2305 echo "check_PROGRAMS ="
2307 echo "noinst_HEADERS ="
2308 echo "noinst_LIBRARIES ="
2309 if $use_libtests; then
2311 echo "noinst_LIBRARIES += libtests.a"
2313 echo "check_LIBRARIES = libtests.a"
2316 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2317 # if you specify pkgdata_DATA to empty. This is a workaround.
2318 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2319 echo "pkgdata_DATA ="
2322 echo "BUILT_SOURCES ="
2324 echo "MOSTLYCLEANFILES = core *.stackdump"
2325 echo "MOSTLYCLEANDIRS ="
2327 echo "DISTCLEANFILES ="
2328 echo "MAINTAINERCLEANFILES ="
2329 # Execute edits that apply to the Makefile.am being generated.
2331 while test $edit != $makefile_am_edits; do
2332 edit=`expr $edit + 1`
2333 eval dir=\"\$makefile_am_edit${edit}_dir\"
2334 eval var=\"\$makefile_am_edit${edit}_var\"
2335 eval val=\"\$makefile_am_edit${edit}_val\"
2336 if test -n "$var"; then
2337 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2338 echo "${var} += ${val}"
2339 eval "makefile_am_edit${edit}_var="
2344 echo "AM_CPPFLAGS = \\"
2345 echo " -I. -I\$(srcdir) \\"
2346 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2347 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2349 local_ldadd_before=''
2350 local_ldadd_after=''
2351 if $use_libtests; then
2352 # All test programs need to be linked with libtests.a.
2353 # It needs to be passed to the linker before ${libname}.${libext}, since
2354 # the tests-related modules depend on the main modules.
2355 # It also needs to be passed to the linker after ${libname}.${libext}
2356 # because the latter might contain incomplete modules (such as the 'error'
2357 # module whose dependency to 'progname' is voluntarily omitted).
2358 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2360 local_ldadd_before=' libtests.a'
2361 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2363 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2365 if $use_libtests; then
2366 echo "libtests_a_SOURCES ="
2367 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2368 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2369 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2370 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2371 echo "EXTRA_libtests_a_SOURCES ="
2372 # The circular dependency in LDADD requires this.
2373 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2376 cat "$tmp"/allsnippets \
2377 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2378 echo "# Clean up after Solaris cc."
2380 echo " rm -rf SunWS_cache"
2382 echo "mostlyclean-local: mostlyclean-generic"
2383 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2384 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2385 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2389 rm -f "$tmp"/allsnippets
2392 # func_emit_initmacro_start macro_prefix
2393 # emits the first few statements of the gl_INIT macro to standard output.
2394 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2395 func_emit_initmacro_start ()
2397 macro_prefix_arg="$1"
2398 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2399 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2400 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2401 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2403 # Furthermore it avoids an automake error like this when a Makefile.am
2404 # that uses pieces of gnulib also uses $(LIBOBJ):
2405 # automatically discovered file `error.c' should not be explicitly mentioned
2406 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2407 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2408 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2409 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2410 # automatically discovered file `error.c' should not be explicitly mentioned
2411 # We let automake know about the files to be distributed through the
2412 # EXTRA_lib_SOURCES variable.
2413 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2414 # Create data variables for checking the presence of files that are mentioned
2415 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2416 # because we want the check to happen when the configure file is created,
2417 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2418 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2419 # in which to expect them.
2420 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2421 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2425 # func_emit_initmacro_end macro_prefix
2426 # emits the last few statements of the gl_INIT macro to standard output.
2427 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2428 func_emit_initmacro_end ()
2430 macro_prefix_arg="$1"
2431 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2432 # The check is performed only when autoconf is run from the directory where
2433 # the configure.ac resides; if it is run from a different directory, the
2435 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2436 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2437 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2438 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2439 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2443 echo " m4_if(m4_sysval, [0], [],"
2444 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2446 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2447 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2448 echo " m4_popdef([AC_LIBSOURCES])"
2449 echo " m4_popdef([AC_REPLACE_FUNCS])"
2450 echo " m4_popdef([AC_LIBOBJ])"
2451 echo " AC_CONFIG_COMMANDS_PRE(["
2452 echo " ${macro_prefix_arg}_libobjs="
2453 echo " ${macro_prefix_arg}_ltlibobjs="
2454 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2455 echo " # Remove the extension."
2456 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2457 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
2458 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2459 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2462 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2463 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2467 # func_emit_initmacro_done macro_prefix sourcebase
2468 # emits a few statements after the gl_INIT macro to standard output.
2469 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2470 # - sourcebase directory relative to destdir where to place source code
2471 func_emit_initmacro_done ()
2473 macro_prefix_arg="$1"
2476 echo "# Like AC_LIBOBJ, except that the module name goes"
2477 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2478 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2479 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2480 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2483 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2484 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2485 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2486 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2487 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2490 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2491 echo "# expected is derived from the gnulib-tool parameterization,"
2492 echo "# and alloca is special cased (for the alloca-opt module)."
2493 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2494 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2495 echo " m4_foreach([_gl_NAME], [\$1], ["
2496 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2497 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2498 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2504 # func_import modules
2505 # Uses also the variables
2506 # - destdir target directory
2507 # - local_gnulib_dir from --local-dir
2508 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2509 # - libname library name
2510 # - sourcebase directory relative to destdir where to place source code
2511 # - m4base directory relative to destdir where to place *.m4 macros
2512 # - pobase directory relative to destdir where to place *.po files
2513 # - docbase directory relative to destdir where to place doc files
2514 # - testsbase directory relative to destdir where to place unit test code
2515 # - auxdir directory relative to destdir where to place build aux files
2516 # - inctests true if --with-tests was given, blank otherwise
2517 # - incobsolete true if --with-obsolete was given, blank otherwise
2518 # - avoidlist list of modules to avoid, from --avoid
2519 # - lgpl yes or a number if library's license shall be LGPL,
2521 # - makefile_name from --makefile-name
2522 # - libtool true if --libtool was given, false if --no-libtool was
2523 # given, blank otherwise
2524 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2525 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2526 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2527 # - vc_files true if --vc-files was given, false if --no-vc-files was
2528 # given, blank otherwise
2529 # - autoconf_minversion minimum supported autoconf version
2530 # - doit : if actions shall be executed, false if only to be printed
2531 # - symbolic true if files should be symlinked, copied otherwise
2532 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2534 # - do_copyrights true if copyright notices in files should be replaced,
2538 # Get the cached settings.
2539 cached_local_gnulib_dir=
2540 cached_specified_modules=
2551 cached_makefile_name=
2553 cached_macro_prefix=
2557 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2558 cached_libtool=false
2564 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
2574 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
2576 /gl_WITH_OBSOLETE/ {
2577 s,^.*$,cached_incobsolete=true,p
2580 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
2583 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
2586 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
2589 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
2592 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
2595 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
2598 s,^.*$,cached_inctests=true,p
2601 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
2604 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
2607 s,^.*$,cached_lgpl=yes,p
2609 /gl_MAKEFILE_NAME(/ {
2610 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
2613 s,^.*$,cached_libtool=true,p
2615 /gl_MACRO_PREFIX(/ {
2616 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
2619 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
2622 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
2624 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2625 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2630 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2631 s,^.*$,cached_files=",p
2644 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2648 # Merge the cached settings with the specified ones.
2649 # The m4base must be the same as expected from the pathname.
2650 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2651 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2653 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2654 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2655 if test -z "$local_gnulib_dir"; then
2656 if test -n "$cached_local_gnulib_dir"; then
2659 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2661 case "$cached_local_gnulib_dir" in
2663 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2665 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2666 local_gnulib_dir="$relconcat" ;;
2671 # Append the cached and the specified module names. So that
2672 # "gnulib-tool --import foo" means to add the module foo.
2673 specified_modules="$cached_specified_modules $1"
2674 # Included obsolete modules among the dependencies if specified either way.
2675 if test -z "$incobsolete"; then
2676 incobsolete="$cached_incobsolete"
2678 # Append the cached and the specified avoidlist. This is probably better
2679 # than dropping the cached one when --avoid is specified at least once.
2680 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2681 avoidlist=`echo $avoidlist`
2683 # The sourcebase defaults to the cached one.
2684 if test -z "$sourcebase"; then
2685 sourcebase="$cached_sourcebase"
2686 if test -z "$sourcebase"; then
2687 func_fatal_error "missing --source-base option"
2690 # The pobase defaults to the cached one.
2691 if test -z "$pobase"; then
2692 pobase="$cached_pobase"
2694 # The docbase defaults to the cached one.
2695 if test -z "$docbase"; then
2696 docbase="$cached_docbase"
2697 if test -z "$docbase"; then
2698 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."
2701 # The testsbase defaults to the cached one.
2702 if test -z "$testsbase"; then
2703 testsbase="$cached_testsbase"
2704 if test -z "$testsbase"; then
2705 func_fatal_error "missing --tests-base option"
2708 # Require the tests if specified either way.
2709 if test -z "$inctests"; then
2710 inctests="$cached_inctests"
2712 # The libname defaults to the cached one.
2713 if test -z "$supplied_libname"; then
2714 libname="$cached_libname"
2715 if test -z "$libname"; then
2716 func_fatal_error "missing --lib option"
2719 # Require LGPL if specified either way.
2720 if test -z "$lgpl"; then
2723 # The makefile_name defaults to the cached one.
2724 if test -z "$makefile_name"; then
2725 makefile_name="$cached_makefile_name"
2727 # Use libtool if specified either way, or if guessed.
2728 if test -z "$libtool"; then
2729 if test -n "$cached_m4base"; then
2730 libtool="$cached_libtool"
2732 libtool="$guessed_libtool"
2735 # The macro_prefix defaults to the cached one.
2736 if test -z "$macro_prefix"; then
2737 macro_prefix="$cached_macro_prefix"
2738 if test -z "$macro_prefix"; then
2739 func_fatal_error "missing --macro-prefix option"
2742 # The po_domain defaults to the cached one.
2743 if test -z "$po_domain"; then
2744 po_domain="$cached_po_domain"
2746 # The vc_files defaults to the cached one.
2747 if test -z "$vc_files"; then
2748 vc_files="$cached_vc_files"
2751 # Canonicalize the list of specified modules.
2752 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2754 # Determine final module list.
2755 modules="$specified_modules"
2756 func_modules_transitive_closure
2757 if test $verbose -ge 0; then
2758 echo "Module list with included dependencies:"
2759 echo "$modules" | sed -e 's/^/ /'
2761 final_modules="$modules"
2763 # Determine main module list and tests-related module list separately.
2764 # The main module list is the transitive closure of the specified modules,
2765 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2766 # is specified, it will consist only of LGPLed source.
2767 # The tests-related module list is the transitive closure of the specified
2768 # modules, including tests modules, minus the main module list excluding
2769 # modules of applicability 'all'. Its lib/* sources (brought in through
2770 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2771 # source, even if --lgpl is specified.
2772 # Determine main module list.
2773 saved_inctests="$inctests"
2775 modules="$specified_modules"
2776 func_modules_transitive_closure
2777 main_modules="$modules"
2778 inctests="$saved_inctests"
2779 if test $verbose -ge 1; then
2780 echo "Main module list:"
2781 echo "$main_modules" | sed -e 's/^/ /'
2783 # Determine tests-related module list.
2784 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2785 testsrelated_modules=`func_reset_sigpipe
2786 for module in $main_modules; do
2787 if test \`func_get_applicability $module\` = main; then
2791 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2792 if test $verbose -ge 1; then
2793 echo "Tests-related module list:"
2794 echo "$testsrelated_modules" | sed -e 's/^/ /'
2797 # Add the dummy module to the main module list if needed.
2798 modules="$main_modules"
2799 func_modules_add_dummy
2800 main_modules="$modules"
2802 # Determine whether a $testsbase/libtests.a is needed.
2804 for module in $testsrelated_modules; do
2805 func_verify_nontests_module
2806 if test -n "$module"; then
2807 all_files=`func_get_filelist $module`
2808 # Test whether some file in $all_files lies in lib/.
2809 for f in $all_files; do
2820 # Add the dummy module to the tests-related module list if needed.
2821 if $use_libtests; then
2822 modules="$testsrelated_modules"
2823 func_modules_add_dummy
2824 testsrelated_modules="$modules"
2827 # If --lgpl, verify that the licenses of modules are compatible.
2828 if test -n "$lgpl"; then
2829 license_incompatibilities=
2830 for module in $main_modules; do
2831 license=`func_get_license $module`
2833 'GPLed build tool') ;;
2834 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2839 LGPL | LGPLv2+ | LGPLv3+) ;;
2840 *) func_append license_incompatibilities "$module $license$nl" ;;
2846 *) func_append license_incompatibilities "$module $license$nl" ;;
2849 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2854 if test -n "$license_incompatibilities"; then
2855 # Format the license incompatibilities as a table.
2856 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
2857 s,^\(.................................................[^ ]*\) *, \1 ,'
2858 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
2859 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
2863 # Show banner notice of every module.
2864 modules="$main_modules"
2867 # Determine script to apply to imported library files.
2868 sed_transform_lib_file=
2869 for module in $main_modules; do
2870 if test $module = config-h; then
2871 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2872 sed_transform_lib_file=$sed_transform_lib_file'
2873 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2878 sed_transform_main_lib_file="$sed_transform_lib_file"
2879 if test -n "$do_copyrights"; then
2880 if test -n "$lgpl"; then
2884 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2885 s/GNU General/GNU Lesser General/g
2889 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2890 s/GNU General/GNU Lesser General/g
2891 s/version [23]\([ ,]\)/version 2.1\1/g
2894 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2898 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2899 s/GNU Lesser General/GNU General/g
2900 s/GNU Library General/GNU General/g
2901 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
2906 # Determine script to apply to auxiliary files that go into $auxdir/.
2907 sed_transform_build_aux_file=
2908 if test -n "$do_copyrights"; then
2910 sed_transform_build_aux_file=$sed_transform_build_aux_file'
2911 s/GNU Lesser General/GNU General/g
2912 s/GNU Library General/GNU General/g
2913 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
2917 # Determine script to apply to library files that go into $testsbase/.
2918 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2919 if test -n "$do_copyrights"; then
2921 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2922 s/GNU Lesser General/GNU General/g
2923 s/GNU Library General/GNU General/g
2924 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
2928 # Determine the final file lists.
2929 # They must be computed separately, because files in lib/* go into
2930 # $sourcebase/ if they are in the main file list but into $testsbase/
2931 # if they are in the tests-related file list. Furthermore lib/dummy.c
2933 # Determine final main file list.
2934 modules="$main_modules"
2935 func_modules_to_filelist
2937 # Determine final tests-related file list.
2938 modules="$testsrelated_modules"
2939 func_modules_to_filelist
2940 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2941 # Merge both file lists.
2942 sed_remove_empty_lines='/^$/d'
2943 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2944 if test $verbose -ge 0; then
2946 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2947 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2951 || func_fatal_error "refusing to do nothing"
2953 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2954 new_files="$files m4/gnulib-tool.m4"
2955 old_files="$cached_files"
2956 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2957 func_append old_files " m4/gnulib-tool.m4"
2960 rewritten='%REWRITTEN%'
2961 sed_rewrite_old_files="\
2962 s,^build-aux/,$rewritten$auxdir/,
2963 s,^doc/,$rewritten$cached_docbase/,
2964 s,^lib/,$rewritten$cached_sourcebase/,
2965 s,^m4/,$rewritten$cached_m4base/,
2966 s,^tests/,$rewritten$cached_testsbase/,
2967 s,^tests=lib/,$rewritten$cached_testsbase/,
2970 sed_rewrite_new_files="\
2971 s,^build-aux/,$rewritten$auxdir/,
2972 s,^doc/,$rewritten$docbase/,
2973 s,^lib/,$rewritten$sourcebase/,
2974 s,^m4/,$rewritten$m4base/,
2975 s,^tests/,$rewritten$testsbase/,
2976 s,^tests=lib/,$rewritten$testsbase/,
2980 # Create directories.
2981 { echo "$sourcebase"
2983 if test -n "$pobase"; then
2986 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2987 if test -n "$docfiles"; then
2990 if test -n "$inctests"; then
2994 for f in $files; do echo $f; done \
2995 | sed -e "$sed_rewrite_new_files" \
2996 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2999 { # Rearrange file descriptors. Needed because "while ... done < ..."
3000 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3001 exec 5<&0 < "$tmp"/dirs
3003 if test ! -d "$destdir/$d"; then
3005 echo "Creating directory $destdir/$d"
3006 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3008 echo "Create directory $destdir/$d"
3015 # Copy files or make symbolic links. Remove obsolete files.
3019 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3020 # representing the files according to the last gnulib-tool invocation.
3021 for f in $old_files; do echo $f; done \
3022 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3025 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3026 # representing the files after this gnulib-tool invocation.
3027 for f in $new_files; do echo $f; done \
3028 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3031 # First the files that are in old-files, but not in new-files:
3032 sed_take_first_column='s,'"$delimiter"'.*,,'
3033 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3034 # Remove the file. Do nothing if the user already removed it.
3035 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3037 echo "Removing file $g (backup in ${g}~)"
3038 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3040 echo "Remove file $g (backup in ${g}~)"
3042 func_append removed_files "$g$nl"
3045 # func_add_or_update handles a file that ought to be present afterwards.
3047 # - f the original file name
3048 # - g the rewritten file name
3049 # - already_present nonempty if the file should already exist, empty
3051 func_add_or_update ()
3055 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3057 func_dest_tmpfilename "$g"
3058 func_lookup_file "$f"
3059 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3060 if test -n "$sed_transform_main_lib_file"; then
3063 sed -e "$sed_transform_main_lib_file" \
3064 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3068 if test -n "$sed_transform_build_aux_file"; then
3071 sed -e "$sed_transform_build_aux_file" \
3072 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3076 if test -n "$sed_transform_testsrelated_lib_file"; then
3079 sed -e "$sed_transform_testsrelated_lib_file" \
3080 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3084 if test -f "$destdir/$g"; then
3085 # The file already exists.
3089 # Don't protest if the file should be there but isn't: it happens
3090 # frequently that developers don't put autogenerated files into CVS.
3092 func_append added_files "$g$nl"
3096 # Then the files that are in new-files, but not in old-files:
3097 sed_take_last_column='s,^.*'"$delimiter"',,'
3099 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3100 | sed -e "$sed_take_last_column" \
3101 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3102 { # Rearrange file descriptors. Needed because "while ... done < ..."
3103 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3104 exec 5<&0 < "$tmp"/added-files
3110 # Then the files that are in new-files and in old-files:
3111 already_present=true
3112 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3113 | sed -e "$sed_take_last_column" \
3114 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3115 { # Rearrange file descriptors. Needed because "while ... done < ..."
3116 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3117 exec 5<&0 < "$tmp"/kept-files
3124 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3125 actioncmd="gnulib-tool --import"
3126 func_append actioncmd " --dir=$destdir"
3127 if test -n "$local_gnulib_dir"; then
3128 func_append actioncmd " --local-dir=$local_gnulib_dir"
3130 func_append actioncmd " --lib=$libname"
3131 func_append actioncmd " --source-base=$sourcebase"
3132 func_append actioncmd " --m4-base=$m4base"
3133 if test -n "$pobase"; then
3134 func_append actioncmd " --po-base=$pobase"
3136 func_append actioncmd " --doc-base=$docbase"
3137 func_append actioncmd " --tests-base=$testsbase"
3138 func_append actioncmd " --aux-dir=$auxdir"
3139 if test -n "$inctests"; then
3140 func_append actioncmd " --with-tests"
3142 if test -n "$incobsolete"; then
3143 func_append actioncmd " --with-obsolete"
3145 for module in $avoidlist; do
3146 func_append actioncmd " --avoid=$module"
3148 if test -n "$lgpl"; then
3149 if test "$lgpl" = yes; then
3150 func_append actioncmd " --lgpl"
3152 func_append actioncmd " --lgpl=$lgpl"
3155 if test -n "$makefile_name"; then
3156 func_append actioncmd " --makefile-name=$makefile_name"
3158 if test "$libtool" = true; then
3159 func_append actioncmd " --libtool"
3161 func_append actioncmd " --no-libtool"
3163 func_append actioncmd " --macro-prefix=$macro_prefix"
3164 if test -n "$po_domain"; then
3165 func_append actioncmd " --po-domain=$po_domain"
3167 if test -n "$vc_files"; then
3168 if test "$vc_files" = true; then
3169 func_append actioncmd " --vc-files"
3171 func_append actioncmd " --no-vc-files"
3174 func_append actioncmd " `echo $specified_modules`"
3176 # Default the makefile name to Makefile.am.
3177 if test -n "$makefile_name"; then
3178 makefile_am=$makefile_name
3180 makefile_am=Makefile.am
3183 # Create normal Makefile.ams.
3186 # Setup list of Makefile.am edits that are to be performed afterwards.
3187 # Some of these edits apply to files that we will generate; others are
3188 # under the responsibility of the developer.
3190 # func_note_Makefile_am_edit dir var value
3191 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3193 func_note_Makefile_am_edit ()
3195 makefile_am_edits=`expr $makefile_am_edits + 1`
3196 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3197 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3198 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3200 if test "$makefile_am" = Makefile.am; then
3201 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3202 sourcebase_base=`basename "$sourcebase"`
3203 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3205 if test -n "$pobase"; then
3206 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3207 pobase_base=`basename "$pobase"`
3208 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3210 if test -n "$inctests"; then
3211 if test "$makefile_am" = Makefile.am; then
3212 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3213 testsbase_base=`basename "$testsbase"`
3214 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3217 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3219 # Find the first parent directory of $m4base that contains or will contain
3221 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3223 sed_butlast='s,[^/][^/]*//*$,,'
3224 dir1="${m4base}/"; dir2=""
3225 while test -n "$dir1" \
3226 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3227 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3228 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3229 || { test -n "$inctests" \
3230 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3231 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3232 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3233 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3235 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3238 # Create library makefile.
3239 func_dest_tmpfilename $sourcebase/$makefile_am
3240 destfile="$sourcebase/$makefile_am"
3241 modules="$main_modules"
3242 func_emit_lib_Makefile_am > "$tmpfile"
3243 if test -f "$destdir"/$sourcebase/$makefile_am; then
3244 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3248 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3249 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3250 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3252 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3258 echo "Creating $sourcebase/$makefile_am"
3259 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3261 echo "Create $sourcebase/$makefile_am"
3264 func_append added_files "$sourcebase/$makefile_am$nl"
3267 # Create po/ directory.
3268 if test -n "$pobase"; then
3269 # Create po makefile and auxiliary files.
3270 for file in Makefile.in.in remove-potcdate.sin; do
3271 func_dest_tmpfilename $pobase/$file
3272 func_lookup_file build-aux/po/$file
3273 cat "$lookedup_file" > "$tmpfile"
3274 if test -f "$destdir"/$pobase/$file; then
3275 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3279 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3280 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3281 mv -f "$tmpfile" "$destdir"/$pobase/$file
3283 echo "Update $pobase/$file (backup in $pobase/$file~)"
3289 echo "Creating $pobase/$file"
3290 mv -f "$tmpfile" "$destdir"/$pobase/$file
3292 echo "Create $pobase/$file"
3295 func_append added_files "$pobase/$file$nl"
3298 # Create po makefile parameterization, part 1.
3299 func_dest_tmpfilename $pobase/Makevars
3300 func_emit_po_Makevars > "$tmpfile"
3301 if test -f "$destdir"/$pobase/Makevars; then
3302 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3306 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3307 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3308 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3310 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3316 echo "Creating $pobase/Makevars"
3317 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3319 echo "Create $pobase/Makevars"
3322 func_append added_files "$pobase/Makevars$nl"
3324 # Create po makefile parameterization, part 2.
3325 func_dest_tmpfilename $pobase/POTFILES.in
3326 func_emit_po_POTFILES_in > "$tmpfile"
3327 if test -f "$destdir"/$pobase/POTFILES.in; then
3328 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3332 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3333 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3334 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3336 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3342 echo "Creating $pobase/POTFILES.in"
3343 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3345 echo "Create $pobase/POTFILES.in"
3348 func_append added_files "$pobase/POTFILES.in$nl"
3351 TP_URL="http://translationproject.org/latest/"
3352 TP_RSYNC_URI="translationproject.org::tp/latest/"
3354 echo "Fetching gnulib PO files from $TP_URL"
3355 (cd "$destdir"/$pobase \
3356 && { # Prefer rsync over wget if it is available, since it consumes
3357 # less network bandwidth, due to compression.
3358 if type rsync 2>/dev/null | grep / > /dev/null; then
3359 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3361 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3366 echo "Fetch gnulib PO files from $TP_URL"
3368 # Create po/LINGUAS.
3370 func_dest_tmpfilename $pobase/LINGUAS
3371 (cd "$destdir"/$pobase \
3372 && { echo '# Set of available languages.'
3373 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3376 if test -f "$destdir"/$pobase/LINGUAS; then
3377 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3380 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3381 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3382 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3385 echo "Creating $pobase/LINGUAS"
3386 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3387 func_append added_files "$pobase/LINGUAS$nl"
3390 if test -f "$destdir"/$pobase/LINGUAS; then
3391 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3393 echo "Create $pobase/LINGUAS"
3398 # Create m4/gnulib-cache.m4.
3399 func_dest_tmpfilename $m4base/gnulib-cache.m4
3401 func_emit_copyright_notice
3403 echo "# This file represents the specification of how gnulib-tool is used."
3404 echo "# It acts as a cache: It is written and read by gnulib-tool."
3405 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3406 echo "# like the configure.ac and various Makefile.am files."
3409 echo "# Specification in the form of a command-line invocation:"
3412 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3413 # Store the local_gnulib_dir relative to destdir.
3414 case "$local_gnulib_dir" in
3416 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3419 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3421 # destdir, local_gnulib_dir are both relative.
3422 func_relativize "$destdir" "$local_gnulib_dir"
3423 relative_local_gnulib_dir="$reldir" ;;
3426 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3428 echo "$specified_modules" | sed -e 's/^/ /g'
3430 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3431 echo "gl_AVOID([$avoidlist])"
3432 echo "gl_SOURCE_BASE([$sourcebase])"
3433 echo "gl_M4_BASE([$m4base])"
3434 echo "gl_PO_BASE([$pobase])"
3435 echo "gl_DOC_BASE([$docbase])"
3436 echo "gl_TESTS_BASE([$testsbase])"
3437 test -z "$inctests" || echo "gl_WITH_TESTS"
3438 echo "gl_LIB([$libname])"
3439 if test -n "$lgpl"; then
3440 if test "$lgpl" = yes; then
3443 echo "gl_LGPL([$lgpl])"
3446 echo "gl_MAKEFILE_NAME([$makefile_name])"
3447 if test "$libtool" = true; then
3450 echo "gl_MACRO_PREFIX([$macro_prefix])"
3451 echo "gl_PO_DOMAIN([$po_domain])"
3452 if test -n "$vc_files"; then
3453 echo "gl_VC_FILES([$vc_files])"
3456 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3457 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3461 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3462 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3463 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3465 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3469 echo "# gnulib-cache.m4 ends here"
3476 echo "Creating $m4base/gnulib-cache.m4"
3477 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3479 echo "Create $m4base/gnulib-cache.m4"
3485 # Create m4/gnulib-comp.m4.
3486 func_dest_tmpfilename $m4base/gnulib-comp.m4
3488 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3489 func_emit_copyright_notice
3491 echo "# This file represents the compiled summary of the specification in"
3492 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3493 echo "# to be invoked from configure.ac."
3494 echo "# In projects using CVS, this file can be treated like other built files."
3497 echo "# This macro should be invoked from $configure_ac, in the section"
3498 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3499 echo "# any checks for libraries, header files, types and library functions."
3500 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3502 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3503 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3504 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3505 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3506 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3507 if test -n "$uses_subdirs"; then
3508 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3510 for module in $final_modules; do
3512 if test -n "$module"; then
3513 func_get_autoconf_early_snippet "$module"
3516 | sed -e '/^$/d;' -e 's/^/ /'
3519 echo "# This macro should be invoked from $configure_ac, in the section"
3520 echo "# \"Check for header files, types and library functions\"."
3521 echo "AC_DEFUN([${macro_prefix}_INIT],"
3523 if test "$libtool" = true; then
3524 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3525 echo " gl_cond_libtool=true"
3527 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3528 echo " gl_cond_libtool=false"
3530 echo " gl_ltlibdeps="
3532 if test "$auxdir" != "build-aux"; then
3533 sed_replace_build_aux='
3535 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3536 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3540 sed_replace_build_aux="$sed_noop"
3542 func_emit_initmacro_start $macro_prefix
3543 echo " gl_source_base='$sourcebase'"
3544 for module in $main_modules; do
3546 if test -n "$module"; then
3547 func_get_autoconf_snippet "$module" \
3548 | sed -e '/^$/d;' -e 's/^/ /' \
3549 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3550 -e "$sed_replace_build_aux"
3551 if test "$module" = 'alloca' && test "$libtool" = true; then
3552 echo 'changequote(,)dnl'
3553 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3554 echo 'changequote([, ])dnl'
3555 echo 'AC_SUBST([LTALLOCA])'
3559 func_emit_initmacro_end $macro_prefix
3560 echo " gltests_libdeps="
3561 echo " gltests_ltlibdeps="
3562 func_emit_initmacro_start ${macro_prefix}tests
3563 echo " gl_source_base='$testsbase'"
3564 for module in $testsrelated_modules; do
3566 if test -n "$module"; then
3567 func_get_autoconf_snippet "$module" \
3568 | sed -e '/^$/d;' -e 's/^/ /' \
3569 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3570 -e "$sed_replace_build_aux" \
3571 -e 's/\$gl_cond_libtool/false/g' \
3572 -e 's/gl_libdeps/gltests_libdeps/g' \
3573 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3576 func_emit_initmacro_end ${macro_prefix}tests
3577 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3578 # created using libtool, because libtool already handles the dependencies.
3579 if test "$libtool" != true; then
3580 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3581 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3582 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3583 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3584 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3586 if $use_libtests; then
3587 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3588 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3591 func_emit_initmacro_done $macro_prefix $sourcebase
3592 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3594 echo "# This macro records the list of files which have been installed by"
3595 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3596 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3597 echo "$files" | sed -e 's,^, ,'
3600 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3601 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3605 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3606 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3607 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3609 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3613 echo "# gnulib-comp.m4 ends here"
3620 echo "Creating $m4base/gnulib-comp.m4"
3621 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3623 echo "Create $m4base/gnulib-comp.m4"
3629 if test -n "$inctests"; then
3630 # Create tests makefile.
3631 func_dest_tmpfilename $testsbase/$makefile_am
3632 destfile="$testsbase/$makefile_am"
3633 modules="$testsrelated_modules"
3634 func_emit_tests_Makefile_am > "$tmpfile"
3635 if test -f "$destdir"/$testsbase/$makefile_am; then
3636 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3640 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3641 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3642 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3644 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3650 echo "Creating $testsbase/$makefile_am"
3651 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3653 echo "Create $testsbase/$makefile_am"
3656 func_append added_files "$testsbase/$makefile_am$nl"
3660 if test "$vc_files" != false; then
3661 # Update the .cvsignore and .gitignore files.
3662 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3663 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3664 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3665 echo "$m4base/|A|gnulib-comp.m4"
3666 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3667 { # Rearrange file descriptors. Needed because "while ... done < ..."
3668 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3669 exec 5<&0 < "$tmp"/fileset-changes
3670 func_update_ignorelist ()
3673 if test "$ignore" = .gitignore; then
3674 # In a .gitignore file, "foo" applies to the current directory and all
3675 # subdirectories, whereas "/foo" applies to the current directory only.
3678 doubly_escaped_anchor='\\/'
3682 doubly_escaped_anchor=''
3684 if test -f "$destdir/$dir$ignore"; then
3685 if test -n "$dir_added" || test -n "$dir_removed"; then
3686 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3688 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3689 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
3690 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3691 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
3693 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3695 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3696 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3697 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3698 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
3699 } > "$tmp"/sed-ignore-removed
3700 { cat "$destdir/$dir$ignore"~
3701 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3702 } | sed -f "$tmp"/sed-ignore-removed \
3703 > "$destdir/$dir$ignore"
3705 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3710 if test -n "$dir_added"; then
3712 echo "Creating $destdir/$dir$ignore"
3714 if test "$ignore" = .cvsignore; then
3716 # Automake generates Makefile rules that create .dirstamp files.
3719 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3720 } > "$destdir/$dir$ignore"
3722 echo "Create $destdir/$dir$ignore"
3732 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3733 func_update_ignorelist .cvsignore
3735 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3736 func_update_ignorelist .gitignore
3743 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3744 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3745 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3746 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3747 if test "$next_dir" != "$last_dir"; then
3748 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3749 last_dir="$next_dir"
3754 A) func_append last_dir_added "$file$nl";;
3755 R) func_append last_dir_removed "$file$nl";;
3758 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3765 echo "You may need to add #include directives for the following .h files."
3766 # Intersect $specified_modules and $main_modules
3767 # (since $specified_modules is not necessarily of subset of $main_modules
3768 # - some may have been skipped through --avoid, and since the elements of
3769 # $main_modules but not in $specified_modules can go away without explicit
3770 # notice - through changes in the module dependencies).
3771 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3772 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3773 # First the #include <...> directives without #ifs, sorted for convenience,
3774 # then the #include "..." directives without #ifs, sorted for convenience,
3775 # then the #include directives that are surrounded by #ifs. Not sorted.
3776 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3777 include_directive=`func_get_include_directive "$module"`
3778 case "$nl$include_directive" in
3780 echo "$include_directive" 1>&5
3783 echo "$include_directive" | grep -v 'include "' 1>&6
3784 echo "$include_directive" | grep 'include "' 1>&7
3787 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3789 LC_ALL=C sort -u "$tmp"/include-angles
3790 LC_ALL=C sort -u "$tmp"/include-quotes
3791 cat "$tmp"/include-if
3792 ) | sed -e '/^$/d' -e 's/^/ /'
3793 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3795 for module in $main_modules; do
3796 func_get_link_directive "$module"
3798 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3799 if test `wc -l < "$tmp"/link` != 0; then
3801 echo "You may need to use the following Makefile variables when linking."
3802 echo "Use them in <program>_LDADD when linking a program, or"
3803 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3809 echo "Don't forget to"
3810 if test "$makefile_am" = Makefile.am; then
3811 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3813 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3815 if test -n "$pobase"; then
3816 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3818 if test -n "$inctests"; then
3819 if test "$makefile_am" = Makefile.am; then
3820 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3822 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3826 while test $edit != $makefile_am_edits; do
3827 edit=`expr $edit + 1`
3828 eval dir=\"\$makefile_am_edit${edit}_dir\"
3829 eval var=\"\$makefile_am_edit${edit}_var\"
3830 eval val=\"\$makefile_am_edit${edit}_val\"
3831 if test -n "$var"; then
3832 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
3835 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3836 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3839 # func_create_testdir testdir modules
3841 # - local_gnulib_dir from --local-dir
3842 # - auxdir directory relative to destdir where to place build aux files
3843 func_create_testdir ()
3847 if test -z "$modules"; then
3848 # All modules together.
3849 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3850 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3851 modules=`func_all_modules`
3852 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3854 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3856 # Check that the license of every module is consistent with the license of
3858 saved_modules="$modules"
3859 saved_inctests="$inctests"
3860 # When computing transitive closures, don't consider $module to depend on
3861 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3862 # on GPL modules - therefore we don't want a warning in this case.
3864 for requested_module in $saved_modules; do
3865 requested_license=`func_get_license "$requested_module"`
3866 if test "$requested_license" != GPL; then
3867 # Here we use func_modules_transitive_closure, not just
3868 # func_get_dependencies, so that we also detect weird situations like
3869 # an LGPL module which depends on a GPLed build tool module which depends
3871 modules="$requested_module"
3872 func_modules_transitive_closure
3873 for module in $modules; do
3874 license=`func_get_license "$module"`
3876 'GPLed build tool') ;;
3877 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3879 case "$requested_license" in
3882 GPLv2+ | LGPLv2+) ;;
3883 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3889 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3895 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3904 modules="$saved_modules"
3905 inctests="$saved_inctests"
3907 # Subdirectory names.
3917 # Determine final module list.
3918 func_modules_transitive_closure
3919 if test $verbose -ge 0; then
3920 echo "Module list with included dependencies:"
3921 echo "$modules" | sed -e 's/^/ /'
3924 # Add the dummy module if needed.
3925 func_modules_add_dummy
3927 # Show banner notice of every module.
3930 # Determine final file list.
3931 func_modules_to_filelist
3932 if test $verbose -ge 0; then
3934 echo "$files" | sed -e 's/^/ /'
3937 rewritten='%REWRITTEN%'
3938 sed_rewrite_files="\
3939 s,^build-aux/,$rewritten$auxdir/,
3940 s,^doc/,$rewritten$docbase/,
3941 s,^lib/,$rewritten$sourcebase/,
3942 s,^m4/,$rewritten$m4base/,
3943 s,^tests/,$rewritten$testsbase/,
3947 # Create directories.
3948 for f in $files; do echo $f; done \
3949 | sed -e "$sed_rewrite_files" \
3950 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3951 | LC_ALL=C sort -u \
3953 { # Rearrange file descriptors. Needed because "while ... done < ..."
3954 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3955 exec 5<&0 < "$tmp"/dirs
3957 mkdir -p "$testdir/$d"
3962 # Copy files or make symbolic links.
3964 for f in $files; do echo $f; done \
3965 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3968 { # Rearrange file descriptors. Needed because "while ... done < ..."
3969 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3970 exec 5<&0 < "$tmp"/files
3972 func_lookup_file "$f"
3973 if test -n "$lookedup_tmp"; then
3974 cp -p "$lookedup_file" "$testdir/$g"
3976 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3977 if { test -n "$symbolic" \
3978 || { test -n "$lsymbolic" \
3979 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3980 func_ln "$lookedup_file" "$testdir/$g"
3982 cp -p "$lookedup_file" "$testdir/$g"
3989 # Create Makefile.ams that are for testing.
3992 # No special edits are needed.
3995 # Create $sourcebase/Makefile.am.
3996 mkdir -p "$testdir/$sourcebase"
3997 destfile="$sourcebase/Makefile.am"
3998 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3999 any_uses_subdirs="$uses_subdirs"
4001 # Create $m4base/Makefile.am.
4002 mkdir -p "$testdir/$m4base"
4003 (echo "## Process this file with automake to produce Makefile.in."
4009 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4012 ) > "$testdir/$m4base/Makefile.am"
4014 subdirs="$sourcebase $m4base"
4015 subdirs_with_configure_ac=""
4017 if false && test -f "$testdir"/$m4base/gettext.m4; then
4018 # Avoid stupid error message from automake:
4019 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4020 mkdir -p "$testdir/po"
4021 (echo "## Process this file with automake to produce Makefile.in."
4022 ) > "$testdir/po/Makefile.am"
4023 func_append subdirs " po"
4026 if test -n "$inctests"; then
4027 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4028 # Viewed from the $testsbase subdirectory, $auxdir is different.
4029 saved_auxdir="$auxdir"
4030 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4031 # Create $testsbase/Makefile.am.
4033 destfile="$testsbase/Makefile.am"
4034 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
4035 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4036 # Create $testsbase/configure.ac.
4037 (echo "# Process this file with autoconf to produce a configure script."
4038 echo "AC_INIT([dummy], [0])"
4039 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4040 echo "AM_INIT_AUTOMAKE"
4042 echo "AC_CONFIG_HEADERS([config.h])"
4045 echo "AC_PROG_INSTALL"
4046 echo "AC_PROG_MAKE_SET"
4047 echo "AC_PROG_RANLIB"
4049 if test -n "$uses_subdirs"; then
4050 echo "AM_PROG_CC_C_O"
4053 for module in $modules; do
4055 if test -n "$module"; then
4057 gnumakefile | maintainer-makefile)
4058 # These modules are meant to be used only in the top-level directory.
4061 func_get_autoconf_early_snippet "$module"
4066 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4067 if test "$libtool" = true; then
4068 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4069 echo "gl_cond_libtool=true"
4071 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4072 echo "gl_cond_libtool=false"
4074 echo "gl_ltlibdeps="
4076 # Wrap the set of autoconf snippets into an autoconf macro that is then
4077 # invoked. This is needed because autoconf does not support AC_REQUIRE
4079 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4080 # but we want the AC_REQUIRE to have its normal meaning (provide one
4081 # expansion of the required macro before the current point, and only one
4083 echo "AC_DEFUN([gl_INIT], ["
4084 sed_replace_build_aux='
4086 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4087 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4090 func_emit_initmacro_start $macro_prefix
4091 # We don't have explicit ordering constraints between the various
4092 # autoconf snippets. It's cleanest to put those of the library before
4093 # those of the tests.
4094 echo "gl_source_base='../$sourcebase'"
4095 for module in $modules; do
4096 func_verify_nontests_module
4097 if test -n "$module"; then
4099 gnumakefile | maintainer-makefile)
4100 # These modules are meant to be used only in the top-level directory.
4103 func_get_autoconf_snippet "$module" \
4104 | sed -e "$sed_replace_build_aux"
4109 echo "gl_source_base='.'"
4110 for module in $modules; do
4111 func_verify_tests_module
4112 if test -n "$module"; then
4113 func_get_autoconf_snippet "$module" \
4114 | sed -e "$sed_replace_build_aux"
4117 func_emit_initmacro_end $macro_prefix
4118 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4119 # created using libtool, because libtool already handles the dependencies.
4120 if test "$libtool" != true; then
4121 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4122 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4123 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4124 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4125 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4128 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4132 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4133 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4134 echo "AH_TOP([#include \"../config.h\"])"
4136 echo "AC_CONFIG_FILES([Makefile])"
4138 ) > "$testdir/$testsbase/configure.ac"
4139 auxdir="$saved_auxdir"
4140 func_append subdirs " $testsbase"
4141 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4144 # Create Makefile.am.
4145 (echo "## Process this file with automake to produce Makefile.in."
4147 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4149 echo "SUBDIRS = $subdirs"
4151 echo "ACLOCAL_AMFLAGS = -I $m4base"
4152 ) > "$testdir/Makefile.am"
4154 # Create configure.ac.
4155 (echo "# Process this file with autoconf to produce a configure script."
4156 echo "AC_INIT([dummy], [0])"
4157 if test "$auxdir" != "."; then
4158 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4160 echo "AM_INIT_AUTOMAKE"
4162 echo "AC_CONFIG_HEADERS([config.h])"
4165 echo "AC_PROG_INSTALL"
4166 echo "AC_PROG_MAKE_SET"
4168 echo "# For autobuild."
4169 echo "AC_CANONICAL_BUILD"
4170 echo "AC_CANONICAL_HOST"
4172 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4173 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4174 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4175 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4177 echo "AC_PROG_RANLIB"
4179 if test -n "$any_uses_subdirs"; then
4180 echo "AM_PROG_CC_C_O"
4183 for module in $modules; do
4184 func_verify_nontests_module
4185 if test -n "$module"; then
4186 func_get_autoconf_early_snippet "$module"
4189 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4190 if test "$libtool" = true; then
4191 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4192 echo "gl_cond_libtool=true"
4194 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4195 echo "gl_cond_libtool=false"
4197 echo "gl_ltlibdeps="
4199 # Wrap the set of autoconf snippets into an autoconf macro that is then
4200 # invoked. This is needed because autoconf does not support AC_REQUIRE
4202 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4203 # but we want the AC_REQUIRE to have its normal meaning (provide one
4204 # expansion of the required macro before the current point, and only one
4206 echo "AC_DEFUN([gl_INIT], ["
4207 if test "$auxdir" != "build-aux"; then
4208 sed_replace_build_aux='
4210 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4211 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4215 sed_replace_build_aux="$sed_noop"
4217 func_emit_initmacro_start $macro_prefix
4218 echo "gl_source_base='$sourcebase'"
4219 for module in $modules; do
4220 func_verify_nontests_module
4221 if test -n "$module"; then
4222 func_get_autoconf_snippet "$module" \
4223 | sed -e "$sed_replace_build_aux"
4226 func_emit_initmacro_end $macro_prefix
4227 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4228 # created using libtool, because libtool already handles the dependencies.
4229 if test "$libtool" != true; then
4230 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4231 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4232 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4233 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4234 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4237 func_emit_initmacro_done $macro_prefix $sourcebase
4241 if test -n "$subdirs_with_configure_ac"; then
4242 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4244 makefiles="Makefile"
4245 for d in $subdirs; do
4246 # For subdirs that have a configure.ac by their own, it's the subdir's
4247 # configure.ac which creates the subdir's Makefile.am, not this one.
4248 case " $subdirs_with_configure_ac " in
4250 *) func_append makefiles " $d/Makefile" ;;
4253 echo "AC_CONFIG_FILES([$makefiles])"
4255 ) > "$testdir/configure.ac"
4257 # Create autogenerated files.
4259 # Do not use "${AUTORECONF} --force --install", because it may invoke
4260 # autopoint, which brings in older versions of some of our .m4 files.
4261 if test -f $m4base/gettext.m4; then
4262 func_execute_command ${AUTOPOINT} --force || func_exit 1
4263 for f in $m4base/*.m4~; do
4265 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4269 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4270 if ! test -d build-aux; then
4271 func_execute_command mkdir build-aux || func_exit 1
4273 func_execute_command ${AUTOCONF} || func_exit 1
4274 func_execute_command ${AUTOHEADER} || func_exit 1
4275 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4277 if test -n "$inctests"; then
4278 # Create autogenerated files.
4279 (cd "$testdir/$testsbase" || func_exit 1
4280 # Do not use "${AUTORECONF} --force --install", because it may invoke
4281 # autopoint, which brings in older versions of some of our .m4 files.
4282 if test -f ../$m4base/gettext.m4; then
4283 func_execute_command ${AUTOPOINT} --force || func_exit 1
4284 for f in ../$m4base/*.m4~; do
4286 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4290 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4291 if ! test -d ../build-aux; then
4292 func_execute_command mkdir ../build-aux
4294 func_execute_command ${AUTOCONF} || func_exit 1
4295 func_execute_command ${AUTOHEADER} || func_exit 1
4296 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4299 # Need to run configure and make once, to create built files that are to be
4300 # distributed (such as getdate.c).
4301 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4302 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4303 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4304 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4305 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4306 # such $(FOO_H) because they don't refer to distributed files.
4307 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4308 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4309 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4310 | sed -e "$sed_remove_make_variables"`
4311 distributed_built_sources=`for file in $built_sources; do
4312 case "$cleaned_files" in
4317 if test -n "$distributed_built_sources"; then
4319 ./configure || func_exit 1
4321 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4322 $MAKE built_sources || func_exit 1
4324 $MAKE distclean || func_exit 1
4329 # func_create_megatestdir megatestdir allmodules
4331 # - local_gnulib_dir from --local-dir
4332 # - auxdir directory relative to destdir where to place build aux files
4333 func_create_megatestdir ()
4337 if test -z "$allmodules"; then
4338 allmodules=`func_all_modules`
4342 # First, all modules one by one.
4343 for onemodule in $allmodules; do
4344 func_create_testdir "$megatestdir/$onemodule" $onemodule
4345 func_append megasubdirs "$onemodule "
4347 # Then, all modules all together.
4348 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4349 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
4350 func_create_testdir "$megatestdir/ALL" "$allmodules"
4351 func_append megasubdirs "ALL"
4354 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4355 vc_witness="$gnulib_dir/CVS/Entries"; \
4357 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4359 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4360 | sed -e 's,January,01,' -e 's,Jan,01,' \
4361 -e 's,February,02,' -e 's,Feb,02,' \
4362 -e 's,March,03,' -e 's,Mar,03,' \
4363 -e 's,April,04,' -e 's,Apr,04,' \
4365 -e 's,June,06,' -e 's,Jun,06,' \
4366 -e 's,July,07,' -e 's,Jul,07,' \
4367 -e 's,August,08,' -e 's,Aug,08,' \
4368 -e 's,September,09,' -e 's,Sep,09,' \
4369 -e 's,October,10,' -e 's,Oct,10,' \
4370 -e 's,November,11,' -e 's,Nov,11,' \
4371 -e 's,December,12,' -e 's,Dec,12,' \
4372 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4373 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4375 echo "CVSDATE=$cvsdate"
4376 echo ": \${MAKE=make}"
4377 echo "test -d logs || mkdir logs"
4378 echo "for module in $megasubdirs; do"
4379 echo " echo \"Working on module \$module...\""
4380 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4381 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4384 echo " : autobuild project... \$module"
4385 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4386 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4387 echo " : autobuild hostname... \`hostname\`"
4388 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
4390 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4392 ) > "$megatestdir/do-autobuild"
4393 chmod a+x "$megatestdir/do-autobuild"
4395 # Create Makefile.am.
4396 (echo "## Process this file with automake to produce Makefile.in."
4398 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4400 echo "SUBDIRS = $megasubdirs"
4402 echo "EXTRA_DIST = do-autobuild"
4403 ) > "$megatestdir/Makefile.am"
4405 # Create configure.ac.
4406 (echo "# Process this file with autoconf to produce a configure script."
4407 echo "AC_INIT([dummy], [0])"
4408 if test "$auxdir" != "."; then
4409 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4411 echo "AM_INIT_AUTOMAKE"
4413 echo "AC_PROG_MAKE_SET"
4415 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4416 echo "AC_CONFIG_FILES([Makefile])"
4418 ) > "$megatestdir/configure.ac"
4420 # Create autogenerated files.
4422 # Do not use "${AUTORECONF} --install", because autoreconf operates
4423 # recursively, but the subdirectories are already finished, therefore
4424 # calling autoreconf here would only waste lots of CPU time.
4425 func_execute_command ${ACLOCAL} || func_exit 1
4426 func_execute_command mkdir build-aux
4427 func_execute_command ${AUTOCONF} || func_exit 1
4428 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4434 func_fatal_error "no mode specified" ;;
4443 if test -z "$destdir"; then
4446 test -d "$destdir" \
4447 || func_fatal_error "destination directory does not exist: $destdir"
4449 # Prefer configure.ac to configure.in.
4450 if test -f "$destdir"/configure.ac; then
4451 configure_ac="$destdir/configure.ac"
4453 if test -f "$destdir"/configure.in; then
4454 configure_ac="$destdir/configure.in"
4456 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
4460 # Analyze configure.ac.
4462 guessed_libtool=false
4467 /AC_CONFIG_AUX_DIR/ {
4468 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
4470 /A[CM]_PROG_LIBTOOL/ {
4471 s,^.*$,guessed_libtool=true,p
4473 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4475 if test -z "$auxdir"; then
4476 auxdir="$guessed_auxdir"
4479 # Determine where to apply func_import.
4480 if test -n "$m4base"; then
4481 # Apply func_import to a particular gnulib directory.
4482 # Any number of additional modules can be given.
4483 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4484 # First use of gnulib in the given m4base.
4485 test -n "$supplied_libname" || supplied_libname=true
4486 test -n "$sourcebase" || sourcebase="lib"
4487 test -n "$docbase" || docbase="doc"
4488 test -n "$testsbase" || testsbase="tests"
4489 test -n "$macro_prefix" || macro_prefix="gl"
4493 # Apply func_import to all gnulib directories.
4494 # To get this list of directories, look at Makefile.am. (Not at
4495 # configure, because it may be omitted from CVS. Also, don't run
4496 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4499 if test -f "$destdir"/Makefile.am; then
4500 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4502 for arg in $aclocal_amflags; do
4503 if test -n "$m4dir_is_next"; then
4504 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4508 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4509 func_append m4dirs " $arg"
4510 m4dirs_count=`expr $m4dirs_count + 1`
4516 if test "X$arg" = "X-I"; then
4524 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4525 if test -f "$destdir"/aclocal.m4; then
4526 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4527 sedexpr2='s,^[^/]*$,.,'
4528 sedexpr3='s,/[^/]*$,,'
4529 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4530 m4dirs_count=`printf %s "$m4dirs" | wc -l`
4533 if test $m4dirs_count = 0; then
4534 # First use of gnulib in a package.
4535 # Any number of additional modules can be given.
4536 test -n "$supplied_libname" || supplied_libname=true
4537 test -n "$sourcebase" || sourcebase="lib"
4539 test -n "$docbase" || docbase="doc"
4540 test -n "$testsbase" || testsbase="tests"
4541 test -n "$macro_prefix" || macro_prefix="gl"
4544 if test $m4dirs_count = 1; then
4545 # There's only one use of gnulib here. Assume the user means it.
4546 # Any number of additional modules can be given.
4547 for m4base in $m4dirs; do
4551 # Ambiguous - guess what the user meant.
4552 if test $# = 0; then
4553 # No further arguments. Guess the user wants to update all of them.
4554 for m4base in $m4dirs; do
4555 # Perform func_import in a subshell, so that variable values
4557 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
4558 # pobase, docbase, testsbase, inctests, libname, lgpl,
4559 # makefile_name, libtool, macro_prefix, po_domain, vc_files
4560 # don't propagate from one directory to another.
4561 (func_import) || func_exit 1
4565 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4573 if test -z "$destdir"; then
4574 func_fatal_error "please specify --dir option"
4577 test -d "$destdir" \
4578 || func_fatal_error "could not create destination directory"
4579 test -n "$auxdir" || auxdir="build-aux"
4580 func_create_testdir "$destdir" "$*"
4583 create-megatestdir )
4584 if test -z "$destdir"; then
4585 func_fatal_error "please specify --dir option"
4587 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4588 test -n "$auxdir" || auxdir="build-aux"
4589 func_create_megatestdir "$destdir" "$*"
4593 test -n "$destdir" || destdir=testdir$$
4594 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4595 test -n "$auxdir" || auxdir="build-aux"
4596 func_create_testdir "$destdir" "$*"
4600 ../configure || func_exit 1
4601 $MAKE || func_exit 1
4602 $MAKE check || func_exit 1
4603 $MAKE distclean || func_exit 1
4604 remaining=`find . -type f -print`
4605 if test -n "$remaining"; then
4606 echo "Remaining files:" $remaining 1>&2
4607 echo "gnulib-tool: *** Stop." 1>&2
4616 test -n "$destdir" || destdir=testdir$$
4617 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4618 test -n "$auxdir" || auxdir="build-aux"
4619 func_create_megatestdir "$destdir" "$*"
4627 remaining=`find . -type f -print`
4628 if test -n "$remaining"; then
4629 echo "Remaining files:" $remaining 1>&2
4630 echo "gnulib-tool: *** Stop." 1>&2
4638 extract-description )
4642 if test -n "$module"; then
4643 func_get_description "$module"
4652 if test -n "$module"; then
4653 func_get_status "$module"
4662 if test -n "$module"; then
4663 func_get_notice "$module"
4668 extract-applicability )
4672 if test -n "$module"; then
4673 func_get_applicability "$module"
4682 if test -n "$module"; then
4683 func_get_filelist "$module"
4688 extract-dependencies )
4692 if test -n "$module"; then
4693 func_get_dependencies "$module"
4698 extract-autoconf-snippet )
4702 if test -n "$module"; then
4703 func_get_autoconf_snippet "$module"
4708 extract-automake-snippet )
4712 if test -n "$module"; then
4713 func_get_automake_snippet "$module"
4718 extract-include-directive )
4722 if test -n "$module"; then
4723 func_get_include_directive "$module"
4728 extract-link-directive )
4732 if test -n "$module"; then
4733 func_get_link_directive "$module"
4742 if test -n "$module"; then
4743 func_get_license "$module"
4748 extract-maintainer )
4752 if test -n "$module"; then
4753 func_get_maintainer "$module"
4758 extract-tests-module )
4762 if test -n "$module"; then
4763 func_get_tests_module "$module"
4769 # Verify the number of arguments.
4770 if test $# -lt 1 || test $# -gt 2; then
4771 func_fatal_error "invalid number of arguments for --$mode"
4774 # The first argument is the file to be copied.
4776 # Verify the file exists.
4777 func_lookup_file "$f"
4779 # The second argument is the destination; either a directory ot a file.
4780 # It defaults to the current directory.
4782 test -n "$dest" || dest='.'
4783 test -n "$sourcebase" || sourcebase="lib"
4784 test -n "$m4base" || m4base="m4"
4785 test -n "$docbase" || docbase="doc"
4786 test -n "$testsbase" || testsbase="tests"
4787 test -n "$auxdir" || auxdir="build-aux"
4788 rewritten='%REWRITTEN%'
4789 sed_rewrite_files="\
4790 s,^build-aux/,$rewritten$auxdir/,
4791 s,^doc/,$rewritten$docbase/,
4792 s,^lib/,$rewritten$sourcebase/,
4793 s,^m4/,$rewritten$m4base/,
4794 s,^tests/,$rewritten$testsbase/,
4797 if test -d "$dest"; then
4799 g=`echo "$f" | sed -e "$sed_rewrite_files"`
4801 destdir=`dirname "$dest"`
4802 g=`basename "$dest"`
4805 # Create the directory for destfile.
4806 d=`dirname "$destdir/$g"`
4808 if test -n "$d" && test ! -d "$d"; then
4809 mkdir -p "$d" || func_fatal_error "failed"
4813 func_dest_tmpfilename "$g"
4814 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4815 already_present=true
4816 if test -f "$destdir/$g"; then
4817 # The file already exists.
4821 # Don't protest if the file should be there but isn't: it happens
4822 # frequently that developers don't put autogenerated files into CVS.
4829 func_fatal_error "unknown operation mode --$mode" ;;
4833 # Undo the effect of the previous 'trap' command. Some shellology:
4834 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4835 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4836 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4837 # 128 + signal number and is set before the trap-registered command is run.
4839 trap 'func_exit $?' 1 2 3 13 15
4844 # indent-tabs-mode: nil
4845 # whitespace-check-buffer-indent: nil