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 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1432 # added_prefix, added_suffix should not contain the characters \|&.
1433 func_filter_filelist ()
1435 if test "$2" != "$nl" \
1436 || { $fast_func_append \
1437 && { test -z "$6" || $fast_func_remove_prefix; } \
1438 && { test -z "$7" || $fast_func_remove_suffix; }; \
1444 if test -n "$6"; then
1445 func_remove_prefix fff "$6"
1447 if test -n "$7"; then
1448 func_remove_suffix fff "$7"
1451 if test -z "$ffflist"; then
1454 func_append ffflist "$2${fff}"
1460 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1461 ffflist=`for fff in $3; do
1463 "$4"*"$5") echo "$fff" ;;
1465 done | sed -e "$sed_fff_filter"`
1467 eval "$1=\"\$ffflist\""
1470 # func_get_dependencies module
1472 # - local_gnulib_dir from --local-dir
1473 func_get_dependencies ()
1475 # ${module}-tests always implicitly depends on ${module}.
1479 func_remove_suffix fgd1 '-tests'
1483 # Then the explicit dependencies listed in the module description.
1484 func_lookup_file "modules/$1"
1485 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1488 # func_get_autoconf_early_snippet module
1490 # - local_gnulib_dir from --local-dir
1491 func_get_autoconf_early_snippet ()
1493 func_lookup_file "modules/$1"
1494 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1497 # func_get_autoconf_snippet module
1499 # - local_gnulib_dir from --local-dir
1500 func_get_autoconf_snippet ()
1502 func_lookup_file "modules/$1"
1503 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1506 # func_get_automake_snippet module
1508 # - local_gnulib_dir from --local-dir
1509 func_get_automake_snippet ()
1511 func_lookup_file "modules/$1"
1512 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1515 # *-tests module live in tests/, not lib/.
1516 # Synthesize an EXTRA_DIST augmentation.
1517 all_files=`func_get_filelist $1`
1518 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1519 extra_files="$tests_files"
1520 if test -n "$extra_files"; then
1521 echo "EXTRA_DIST +=" $extra_files
1526 # Synthesize an EXTRA_DIST augmentation.
1527 sed_combine_lines='/\\$/{
1534 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1535 already_mentioned_files=` \
1536 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1537 | sed -e "$sed_combine_lines" \
1538 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1539 all_files=`func_get_filelist $1`
1540 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
1541 # Remove $already_mentioned_files from $lib_files.
1542 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1543 extra_files=`func_reset_sigpipe; \
1544 for f in $already_mentioned_files; do echo $f; done \
1545 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1546 if test -n "$extra_files"; then
1547 echo "EXTRA_DIST +=" $extra_files
1550 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1551 # This is necessary so that automake can generate the right list of
1553 # A possible approach would be to use autom4te --trace of the redefined
1554 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1555 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1556 # inside autoconf's built-in macros are not missed).
1557 # But it's simpler and more robust to do it here, based on the file list.
1558 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1559 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1560 # automake will generate a useless dependency; this is harmless.
1562 relocatable-prog-wrapper) ;;
1564 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
1565 if test -n "$extra_files"; then
1566 echo "EXTRA_lib_SOURCES +=" $extra_files
1571 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1572 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
1573 if test -n "$buildaux_files"; then
1574 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1575 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1578 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1579 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
1580 if test -n "$top_files"; then
1581 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1582 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1589 # func_get_include_directive module
1591 # - local_gnulib_dir from --local-dir
1592 func_get_include_directive ()
1594 func_lookup_file "modules/$1"
1595 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1596 sed -e 's/^\(["<]\)/#include \1/'
1599 # func_get_link_directive module
1601 # - local_gnulib_dir from --local-dir
1602 func_get_link_directive ()
1604 func_lookup_file "modules/$1"
1605 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1608 # func_get_license module
1610 # - local_gnulib_dir from --local-dir
1613 func_lookup_file "modules/$1"
1614 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1615 # The default is GPL.
1617 } | sed -e 's,^ *$,,' | sed -e 1q
1620 # func_get_maintainer module
1622 # - local_gnulib_dir from --local-dir
1623 func_get_maintainer ()
1625 func_lookup_file "modules/$1"
1626 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1629 # func_get_tests_module module
1631 # - local_gnulib_dir from --local-dir
1632 func_get_tests_module ()
1634 # The naming convention for tests modules is hardwired: ${module}-tests.
1635 if test -f "$gnulib_dir/modules/$1"-tests \
1636 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1637 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1642 # func_acceptable module
1643 # tests whether a module is acceptable.
1645 # - avoidlist list of modules to avoid
1648 for avoid in $avoidlist; do
1649 if test "$avoid" = "$1"; then
1656 # func_modules_transitive_closure
1658 # - local_gnulib_dir from --local-dir
1659 # - modules list of specified modules
1660 # - inctests true if tests should be included, blank otherwise
1661 # - incobsolete true if obsolete modules among dependencies should be
1662 # included, blank otherwise
1663 # - avoidlist list of modules to avoid
1664 # - tmp pathname of a temporary directory
1666 # - modules list of modules, including dependencies
1667 func_modules_transitive_closure ()
1669 # In order to process every module only once (for speed), process an "input
1670 # list" of modules, producing an "output list" of modules. During each round,
1671 # more modules can be queued in the input list. Once a module on the input
1672 # list has been processed, it is added to the "handled list", so we can avoid
1673 # to process it again.
1675 inmodules="$modules"
1677 while test -n "$inmodules"; do
1678 inmodules_this_round="$inmodules"
1679 inmodules= # Accumulator, queue for next round
1680 for module in $inmodules_this_round; do
1682 if test -n "$module"; then
1683 if func_acceptable $module; then
1684 func_append outmodules " $module"
1685 deps=`func_get_dependencies $module`
1686 # Duplicate dependencies are harmless, but Jim wants a warning.
1687 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1688 if test -n "$duplicated_deps"; then
1689 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1691 for dep in $deps; do
1692 if test -n "$incobsolete" \
1693 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
1694 func_append inmodules " $dep"
1697 if test -n "$inctests"; then
1698 testsmodule=`func_get_tests_module $module`
1699 if test -n "$testsmodule"; then
1700 func_append inmodules " $testsmodule"
1706 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1707 # Remove $handledmodules from $inmodules.
1708 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1709 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1711 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1712 rm -f "$tmp"/queued-modules
1715 # func_modules_add_dummy
1717 # - local_gnulib_dir from --local-dir
1718 # - modules list of modules, including dependencies
1720 # - modules list of modules, including 'dummy' if needed
1721 func_modules_add_dummy ()
1723 # Determine whether any module provides a lib_SOURCES augmentation.
1725 sed_remove_backslash_newline=':a
1732 for module in $modules; do
1733 func_verify_nontests_module
1734 if test -n "$module"; then
1735 # Extract the value of "lib_SOURCES += ...".
1736 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1737 # Ignore .h files since they are not compiled.
1741 have_lib_SOURCES=yes
1748 # Add the dummy module, to make sure the library will be non-empty.
1749 if test -z "$have_lib_SOURCES"; then
1750 if func_acceptable "dummy"; then
1751 func_append modules " dummy"
1756 # func_modules_notice
1758 # - local_gnulib_dir from --local-dir
1759 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1760 # - modules list of modules, including dependencies
1761 func_modules_notice ()
1763 if test $verbose -ge -1; then
1764 for module in $modules; do
1766 if test -n "$module"; then
1767 msg=`func_get_notice $module`
1768 if test -n "$msg"; then
1769 echo "Notice from module $module:"
1770 echo "$msg" | sed -e 's/^/ /'
1777 # func_modules_to_filelist
1779 # - local_gnulib_dir from --local-dir
1780 # - modules list of modules, including dependencies
1782 # - files list of files
1783 func_modules_to_filelist ()
1786 for module in $modules; do
1788 if test -n "$module"; then
1789 fs=`func_get_filelist $module`
1790 func_append files " $fs"
1793 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1796 # func_execute_command command [args...]
1797 # Executes a command.
1798 # Uses also the variables
1799 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1800 func_execute_command ()
1802 if test $verbose -ge 0; then
1806 # Commands like automake produce output to stderr even when they succeed.
1807 # Turn this output off if the command succeeds.
1808 "$@" > "$tmp"/cmdout 2>&1
1810 if test $cmdret = 0; then
1814 cat "$tmp"/cmdout 1>&2
1821 # func_dest_tmpfilename file
1822 # determines the name of a temporary file (file is relative to destdir).
1824 # - destdir target directory
1825 # - doit : if actions shall be executed, false if only to be printed
1826 # - tmp pathname of a temporary directory
1828 # - tmpfile absolute filename of the temporary file
1829 func_dest_tmpfilename ()
1832 # Put the new contents of $file in a file in the same directory (needed
1833 # to guarantee that an 'mv' to "$destdir/$file" works).
1834 tmpfile="$destdir/$1.tmp"
1836 # Put the new contents of $file in a file in a temporary directory
1837 # (because the directory of "$file" might not exist).
1838 tmpfile="$tmp"/`basename "$1"`.tmp
1843 # copies a file from gnulib into the destination directory. The destination
1844 # is known to not exist.
1846 # - destdir target directory
1847 # - local_gnulib_dir from --local-dir
1848 # - f the original file name
1849 # - lookedup_file name of the merged (combined) file
1850 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1851 # - g the rewritten file name
1852 # - tmpfile absolute filename of the temporary file
1853 # - doit : if actions shall be executed, false if only to be printed
1854 # - symbolic true if files should be symlinked, copied otherwise
1855 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1860 echo "Copying file $g"
1861 if { test -n "$symbolic" \
1862 || { test -n "$lsymbolic" \
1863 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1864 && test -z "$lookedup_tmp" \
1865 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1866 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1868 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1876 # copies a file from gnulib into the destination directory. The destination
1877 # is known to exist.
1879 # - destdir target directory
1880 # - local_gnulib_dir from --local-dir
1881 # - f the original file name
1882 # - lookedup_file name of the merged (combined) file
1883 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1884 # - g the rewritten file name
1885 # - tmpfile absolute filename of the temporary file
1886 # - doit : if actions shall be executed, false if only to be printed
1887 # - symbolic true if files should be symlinked, copied otherwise
1888 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1890 # - already_present nonempty if the file should already exist, empty otherwise
1893 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1894 : # The file has not changed.
1898 if test -n "$already_present"; then
1899 echo "Updating file $g (backup in ${g}~)"
1901 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
1903 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1904 if { test -n "$symbolic" \
1905 || { test -n "$lsymbolic" \
1906 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1907 && test -z "$lookedup_tmp" \
1908 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1909 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1911 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1914 if test -n "$already_present"; then
1915 echo "Update file $g (backup in ${g}~)"
1917 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
1923 # func_emit_lib_Makefile_am
1924 # emits the contents of library makefile to standard output.
1926 # - local_gnulib_dir from --local-dir
1927 # - modules list of modules, including dependencies
1928 # - libname library name
1929 # - pobase directory relative to destdir where to place *.po files
1930 # - auxdir directory relative to destdir where to place build aux files
1931 # - makefile_name from --makefile-name
1932 # - libtool true if libtool will be used, false or blank otherwise
1933 # - macro_prefix prefix of gl_LIBOBJS macros to use
1934 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1935 # - actioncmd (optional) command that will reproduce this invocation
1936 # - for_test true if creating a package for testing, false otherwise
1937 # - destfile filename relative to destdir of makefile being generated
1939 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1940 # list of edits to be done to Makefile.am variables
1942 # - uses_subdirs nonempty if object files in subdirs exist
1943 func_emit_lib_Makefile_am ()
1945 # When creating an includable Makefile.am snippet, augment variables with
1946 # += instead of assigning them.
1947 if test -n "$makefile_name"; then
1952 if test "$libtool" = true; then
1955 sed_eliminate_LDFLAGS="$sed_noop"
1959 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1962 # When creating a package for testing: Attempt to provoke failures,
1963 # especially link errors, already during "make" rather than during
1964 # "make check", because "make check" is not possible in a cross-compiling
1965 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1966 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1968 sed_transform_check_PROGRAMS="$sed_noop"
1970 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1971 echo "## Process this file with automake to produce Makefile.in."
1972 func_emit_copyright_notice
1973 if test -n "$actioncmd"; then
1974 # The maximum line length (excluding the terminating newline) of any file
1975 # that is to be preprocessed by config.status is 3070. config.status uses
1976 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
1977 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
1978 len=`echo "$actioncmd" | wc -c`
1979 if test -n "$len" && test "$len" -le 3000; then
1980 echo "# Reproduce by: $actioncmd"
1986 for module in $modules; do
1987 func_verify_nontests_module
1988 if test -n "$module"; then
1990 func_get_automake_snippet "$module" |
1991 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1992 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1993 -e "$sed_eliminate_LDFLAGS" \
1994 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1995 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1996 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1997 -e "$sed_transform_check_PROGRAMS"
1998 if test "$module" = 'alloca'; then
1999 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2000 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2003 # Skip the contents if it's entirely empty.
2004 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
2005 echo "## begin gnulib module $module"
2008 echo "## end gnulib module $module"
2012 # Test whether there are some source files in subdirectories.
2013 for f in `func_get_filelist "$module"`; do
2024 if test -z "$makefile_name"; then
2025 # If there are source files in subdirectories, prevent collision of the
2026 # object files (example: hash.c and libxml/hash.c).
2028 if test -n "$uses_subdirs"; then
2029 subdir_options=' subdir-objects'
2031 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2034 if test -z "$makefile_name"; then
2036 echo "noinst_HEADERS ="
2037 echo "noinst_LIBRARIES ="
2038 echo "noinst_LTLIBRARIES ="
2039 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2040 # if you specify pkgdata_DATA to empty. This is a workaround.
2041 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
2042 echo "pkgdata_DATA ="
2045 echo "BUILT_SOURCES ="
2048 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2049 if test -z "$makefile_name"; then
2050 echo "MOSTLYCLEANDIRS ="
2052 echo "DISTCLEANFILES ="
2053 echo "MAINTAINERCLEANFILES ="
2055 # Execute edits that apply to the Makefile.am being generated.
2057 while test $edit != $makefile_am_edits; do
2058 edit=`expr $edit + 1`
2059 eval dir=\"\$makefile_am_edit${edit}_dir\"
2060 eval var=\"\$makefile_am_edit${edit}_var\"
2061 eval val=\"\$makefile_am_edit${edit}_val\"
2062 if test -n "$var"; then
2063 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2064 echo "${var} += ${val}"
2065 eval "makefile_am_edit${edit}_var="
2069 if test -z "$makefile_name"; then
2071 echo "AM_CPPFLAGS ="
2075 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null \
2076 || { test -n "$makefile_name" \
2077 && test -f "$sourcebase/Makefile.am" \
2078 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2080 # One of the snippets or the user's Makefile.am already specifies an
2081 # installation location for the library. Don't confuse automake by saying
2082 # it should not be installed.
2085 # By default, the generated library should not be installed.
2086 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2089 echo "${libname}_${libext}_SOURCES ="
2090 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2091 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2092 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2093 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2094 echo "EXTRA_${libname}_${libext}_SOURCES ="
2095 if test "$libtool" = true; then
2096 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2099 if test -n "$pobase"; then
2100 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2103 cat allsnippets.tmp \
2104 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2106 echo "mostlyclean-local: mostlyclean-generic"
2107 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2108 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2109 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2113 rm -f allsnippets.tmp
2116 # func_emit_po_Makevars
2117 # emits the contents of po/ makefile parameterization to standard output.
2119 # - local_gnulib_dir from --local-dir
2120 # - sourcebase directory relative to destdir where to place source code
2121 # - pobase directory relative to destdir where to place *.po files
2122 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2123 func_emit_po_Makevars ()
2125 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2126 func_emit_copyright_notice
2128 echo "# Usually the message domain is the same as the package name."
2129 echo "# But here it has a '-gnulib' suffix."
2130 echo "DOMAIN = ${po_domain}-gnulib"
2132 echo "# These two variables depend on the location of this directory."
2133 echo "subdir = ${pobase}"
2134 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2137 # These options get passed to xgettext.
2138 XGETTEXT_OPTIONS = \
2139 --keyword=_ --flag=_:1:pass-c-format \
2140 --keyword=N_ --flag=N_:1:pass-c-format \
2141 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2142 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2143 --flag=error:3:c-format --flag=error_at_line:5:c-format
2145 # This is the copyright holder that gets inserted into the header of the
2146 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2147 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2149 # This is the email address or URL to which the translators shall report
2150 # bugs in the untranslated strings:
2151 # - Strings which are not entire sentences, see the maintainer guidelines
2152 # in the GNU gettext documentation, section 'Preparing Strings'.
2153 # - Strings which use unclear terms or require additional context to be
2155 # - Strings which make invalid assumptions about notation of date, time or
2157 # - Pluralisation problems.
2158 # - Incorrect English spelling.
2159 # - Incorrect formatting.
2160 # It can be your email address, or a mailing list address where translators
2161 # can write to without being subscribed, or the URL of a web page through
2162 # which the translators can contact you.
2163 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2165 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2166 # message catalogs shall be used. It is usually empty.
2167 EXTRA_LOCALE_CATEGORIES =
2169 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2170 # context. Possible values are "yes" and "no". Set this to yes if the
2171 # package uses functions taking also a message context, like pgettext(), or
2172 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2177 # func_emit_po_POTFILES_in
2178 # emits the file list to be passed to xgettext to standard output.
2180 # - local_gnulib_dir from --local-dir
2181 # - sourcebase directory relative to destdir where to place source code
2182 # - files list of new files
2183 func_emit_po_POTFILES_in ()
2185 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2186 func_emit_copyright_notice
2188 echo "# List of files which contain translatable strings."
2189 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2192 # func_emit_tests_Makefile_am
2193 # emits the contents of tests makefile to standard output.
2195 # - local_gnulib_dir from --local-dir
2196 # - modules list of modules, including dependencies
2197 # - libname library name
2198 # - auxdir directory relative to destdir where to place build aux files
2199 # - makefile_name from --makefile-name
2200 # - libtool true if libtool will be used, false or blank otherwise
2201 # - sourcebase relative directory containing lib source code
2202 # - m4base relative directory containing autoconf macros
2203 # - testsbase relative directory containing unit test code
2204 # - macro_prefix prefix of gl_LIBOBJS macros to use
2205 # - for_test true if creating a package for testing, false otherwise
2206 # - use_libtests true if a libtests.a should be built, false otherwise
2207 # - destfile filename relative to destdir of makefile being generated
2209 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2210 # list of edits to be done to Makefile.am variables
2212 # - uses_subdirs nonempty if object files in subdirs exist
2213 func_emit_tests_Makefile_am ()
2215 if test "$libtool" = true; then
2217 sed_eliminate_LDFLAGS="$sed_noop"
2220 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2223 # When creating a package for testing: Attempt to provoke failures,
2224 # especially link errors, already during "make" rather than during
2225 # "make check", because "make check" is not possible in a cross-compiling
2226 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2227 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2229 sed_transform_check_PROGRAMS="$sed_noop"
2231 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2232 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2233 echo "## Process this file with automake to produce Makefile.in."
2234 func_emit_copyright_notice
2238 for module in $modules; do
2240 func_verify_tests_module
2244 if test -n "$module"; then
2246 func_get_automake_snippet "$module" |
2247 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2248 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2249 -e "$sed_eliminate_LDFLAGS" \
2250 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2251 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2252 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2253 -e "$sed_transform_check_PROGRAMS"
2254 if $use_libtests && test "$module" = 'alloca'; then
2255 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2256 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2259 # Skip the contents if it's entirely empty.
2260 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
2261 echo "## begin gnulib module $module"
2264 echo "## end gnulib module $module"
2268 # Test whether there are some source files in subdirectories.
2269 for f in `func_get_filelist "$module"`; do
2271 lib/*/*.c | tests/*/*.c)
2280 # Generate dependencies here, since it eases the debugging of test failures.
2281 # If there are source files in subdirectories, prevent collision of the
2282 # object files (example: hash.c and libxml/hash.c).
2284 if test -n "$uses_subdirs"; then
2285 subdir_options=' subdir-objects'
2287 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2290 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2293 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2294 # variable is needed to avoid an error from automake:
2295 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2298 echo "XFAIL_TESTS ="
2299 echo "TESTS_ENVIRONMENT ="
2300 echo "noinst_PROGRAMS ="
2301 if ! $for_test; then
2302 echo "check_PROGRAMS ="
2304 echo "noinst_HEADERS ="
2305 echo "noinst_LIBRARIES ="
2306 if $use_libtests; then
2308 echo "noinst_LIBRARIES += libtests.a"
2310 echo "check_LIBRARIES = libtests.a"
2313 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2314 # if you specify pkgdata_DATA to empty. This is a workaround.
2315 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
2316 echo "pkgdata_DATA ="
2319 echo "BUILT_SOURCES ="
2321 echo "MOSTLYCLEANFILES = core *.stackdump"
2322 echo "MOSTLYCLEANDIRS ="
2324 echo "DISTCLEANFILES ="
2325 echo "MAINTAINERCLEANFILES ="
2326 # Execute edits that apply to the Makefile.am being generated.
2328 while test $edit != $makefile_am_edits; do
2329 edit=`expr $edit + 1`
2330 eval dir=\"\$makefile_am_edit${edit}_dir\"
2331 eval var=\"\$makefile_am_edit${edit}_var\"
2332 eval val=\"\$makefile_am_edit${edit}_val\"
2333 if test -n "$var"; then
2334 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2335 echo "${var} += ${val}"
2336 eval "makefile_am_edit${edit}_var="
2341 echo "AM_CPPFLAGS = \\"
2342 echo " -I. -I\$(srcdir) \\"
2343 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2344 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2346 local_ldadd_before=''
2347 local_ldadd_after=''
2348 if $use_libtests; then
2349 # All test programs need to be linked with libtests.a.
2350 # It needs to be passed to the linker before ${libname}.${libext}, since
2351 # the tests-related modules depend on the main modules.
2352 # It also needs to be passed to the linker after ${libname}.${libext}
2353 # because the latter might contain incomplete modules (such as the 'error'
2354 # module whose dependency to 'progname' is voluntarily omitted).
2355 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2357 local_ldadd_before=' libtests.a'
2358 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2360 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2362 if $use_libtests; then
2363 echo "libtests_a_SOURCES ="
2364 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2365 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2366 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2367 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2368 echo "EXTRA_libtests_a_SOURCES ="
2369 # The circular dependency in LDADD requires this.
2370 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2373 cat allsnippets.tmp \
2374 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2375 echo "# Clean up after Solaris cc."
2377 echo " rm -rf SunWS_cache"
2379 echo "mostlyclean-local: mostlyclean-generic"
2380 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2381 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2382 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2386 rm -f allsnippets.tmp
2389 # func_emit_initmacro_start macro_prefix
2390 # emits the first few statements of the gl_INIT macro to standard output.
2391 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2392 func_emit_initmacro_start ()
2394 macro_prefix_arg="$1"
2395 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2396 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2397 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2398 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2400 # Furthermore it avoids an automake error like this when a Makefile.am
2401 # that uses pieces of gnulib also uses $(LIBOBJ):
2402 # automatically discovered file `error.c' should not be explicitly mentioned
2403 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2404 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2405 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2406 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2407 # automatically discovered file `error.c' should not be explicitly mentioned
2408 # We let automake know about the files to be distributed through the
2409 # EXTRA_lib_SOURCES variable.
2410 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2411 # Create data variables for checking the presence of files that are mentioned
2412 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2413 # because we want the check to happen when the configure file is created,
2414 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2415 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2416 # in which to expect them.
2417 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2418 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2422 # func_emit_initmacro_end macro_prefix
2423 # emits the last few statements of the gl_INIT macro to standard output.
2424 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2425 func_emit_initmacro_end ()
2427 macro_prefix_arg="$1"
2428 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2429 # The check is performed only when autoconf is run from the directory where
2430 # the configure.ac resides; if it is run from a different directory, the
2432 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2433 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2434 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2435 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2436 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2440 echo " m4_if(m4_sysval, [0], [],"
2441 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2443 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2444 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2445 echo " m4_popdef([AC_LIBSOURCES])"
2446 echo " m4_popdef([AC_REPLACE_FUNCS])"
2447 echo " m4_popdef([AC_LIBOBJ])"
2448 echo " AC_CONFIG_COMMANDS_PRE(["
2449 echo " ${macro_prefix_arg}_libobjs="
2450 echo " ${macro_prefix_arg}_ltlibobjs="
2451 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2452 echo " # Remove the extension."
2453 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2454 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
2455 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2456 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2459 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2460 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2464 # func_emit_initmacro_done macro_prefix sourcebase
2465 # emits a few statements after the gl_INIT macro to standard output.
2466 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2467 # - sourcebase directory relative to destdir where to place source code
2468 func_emit_initmacro_done ()
2470 macro_prefix_arg="$1"
2473 echo "# Like AC_LIBOBJ, except that the module name goes"
2474 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2475 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2476 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2477 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2480 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2481 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2482 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2483 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2484 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2487 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2488 echo "# expected is derived from the gnulib-tool parameterization,"
2489 echo "# and alloca is special cased (for the alloca-opt module)."
2490 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2491 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2492 echo " m4_foreach([_gl_NAME], [\$1], ["
2493 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2494 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2495 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2501 # func_import modules
2502 # Uses also the variables
2503 # - destdir target directory
2504 # - local_gnulib_dir from --local-dir
2505 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2506 # - libname library name
2507 # - sourcebase directory relative to destdir where to place source code
2508 # - m4base directory relative to destdir where to place *.m4 macros
2509 # - pobase directory relative to destdir where to place *.po files
2510 # - docbase directory relative to destdir where to place doc files
2511 # - testsbase directory relative to destdir where to place unit test code
2512 # - auxdir directory relative to destdir where to place build aux files
2513 # - inctests true if --with-tests was given, blank otherwise
2514 # - incobsolete true if --with-obsolete was given, blank otherwise
2515 # - avoidlist list of modules to avoid, from --avoid
2516 # - lgpl yes or a number if library's license shall be LGPL,
2518 # - makefile_name from --makefile-name
2519 # - libtool true if --libtool was given, false if --no-libtool was
2520 # given, blank otherwise
2521 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2522 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2523 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2524 # - vc_files true if --vc-files was given, false if --no-vc-files was
2525 # given, blank otherwise
2526 # - autoconf_minversion minimum supported autoconf version
2527 # - doit : if actions shall be executed, false if only to be printed
2528 # - symbolic true if files should be symlinked, copied otherwise
2529 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2531 # - do_copyrights true if copyright notices in files should be replaced,
2535 # Get the cached settings.
2536 cached_local_gnulib_dir=
2537 cached_specified_modules=
2548 cached_makefile_name=
2550 cached_macro_prefix=
2554 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2555 cached_libtool=false
2561 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
2571 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
2573 /gl_WITH_OBSOLETE/ {
2574 s,^.*$,cached_incobsolete=true,p
2577 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
2580 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
2583 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
2586 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
2589 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
2592 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
2595 s,^.*$,cached_inctests=true,p
2598 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
2601 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
2604 s,^.*$,cached_lgpl=yes,p
2606 /gl_MAKEFILE_NAME(/ {
2607 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
2610 s,^.*$,cached_libtool=true,p
2612 /gl_MACRO_PREFIX(/ {
2613 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
2616 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
2619 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
2621 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2622 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2627 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2628 s,^.*$,cached_files=",p
2641 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2645 # Merge the cached settings with the specified ones.
2646 # The m4base must be the same as expected from the pathname.
2647 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2648 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2650 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2651 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2652 if test -z "$local_gnulib_dir"; then
2653 if test -n "$cached_local_gnulib_dir"; then
2656 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2658 case "$cached_local_gnulib_dir" in
2660 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2662 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2663 local_gnulib_dir="$relconcat" ;;
2668 # Append the cached and the specified module names. So that
2669 # "gnulib-tool --import foo" means to add the module foo.
2670 specified_modules="$cached_specified_modules $1"
2671 # Included obsolete modules among the dependencies if specified either way.
2672 if test -z "$incobsolete"; then
2673 incobsolete="$cached_incobsolete"
2675 # Append the cached and the specified avoidlist. This is probably better
2676 # than dropping the cached one when --avoid is specified at least once.
2677 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2678 avoidlist=`echo $avoidlist`
2680 # The sourcebase defaults to the cached one.
2681 if test -z "$sourcebase"; then
2682 sourcebase="$cached_sourcebase"
2683 if test -z "$sourcebase"; then
2684 func_fatal_error "missing --source-base option"
2687 # The pobase defaults to the cached one.
2688 if test -z "$pobase"; then
2689 pobase="$cached_pobase"
2691 # The docbase defaults to the cached one.
2692 if test -z "$docbase"; then
2693 docbase="$cached_docbase"
2694 if test -z "$docbase"; then
2695 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."
2698 # The testsbase defaults to the cached one.
2699 if test -z "$testsbase"; then
2700 testsbase="$cached_testsbase"
2701 if test -z "$testsbase"; then
2702 func_fatal_error "missing --tests-base option"
2705 # Require the tests if specified either way.
2706 if test -z "$inctests"; then
2707 inctests="$cached_inctests"
2709 # The libname defaults to the cached one.
2710 if test -z "$supplied_libname"; then
2711 libname="$cached_libname"
2712 if test -z "$libname"; then
2713 func_fatal_error "missing --lib option"
2716 # Require LGPL if specified either way.
2717 if test -z "$lgpl"; then
2720 # The makefile_name defaults to the cached one.
2721 if test -z "$makefile_name"; then
2722 makefile_name="$cached_makefile_name"
2724 # Use libtool if specified either way, or if guessed.
2725 if test -z "$libtool"; then
2726 if test -n "$cached_m4base"; then
2727 libtool="$cached_libtool"
2729 libtool="$guessed_libtool"
2732 # The macro_prefix defaults to the cached one.
2733 if test -z "$macro_prefix"; then
2734 macro_prefix="$cached_macro_prefix"
2735 if test -z "$macro_prefix"; then
2736 func_fatal_error "missing --macro-prefix option"
2739 # The po_domain defaults to the cached one.
2740 if test -z "$po_domain"; then
2741 po_domain="$cached_po_domain"
2743 # The vc_files defaults to the cached one.
2744 if test -z "$vc_files"; then
2745 vc_files="$cached_vc_files"
2748 # Canonicalize the list of specified modules.
2749 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2751 # Determine final module list.
2752 modules="$specified_modules"
2753 func_modules_transitive_closure
2754 if test $verbose -ge 0; then
2755 echo "Module list with included dependencies:"
2756 echo "$modules" | sed -e 's/^/ /'
2758 final_modules="$modules"
2760 # Determine main module list and tests-related module list separately.
2761 # The main module list is the transitive closure of the specified modules,
2762 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2763 # is specified, it will consist only of LGPLed source.
2764 # The tests-related module list is the transitive closure of the specified
2765 # modules, including tests modules, minus the main module list excluding
2766 # modules of applicability 'all'. Its lib/* sources (brought in through
2767 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2768 # source, even if --lgpl is specified.
2769 # Determine main module list.
2770 saved_inctests="$inctests"
2772 modules="$specified_modules"
2773 func_modules_transitive_closure
2774 main_modules="$modules"
2775 inctests="$saved_inctests"
2776 if test $verbose -ge 1; then
2777 echo "Main module list:"
2778 echo "$main_modules" | sed -e 's/^/ /'
2780 # Determine tests-related module list.
2781 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2782 testsrelated_modules=`func_reset_sigpipe
2783 for module in $main_modules; do
2784 if test \`func_get_applicability $module\` = main; then
2788 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2789 if test $verbose -ge 1; then
2790 echo "Tests-related module list:"
2791 echo "$testsrelated_modules" | sed -e 's/^/ /'
2794 # Add the dummy module to the main module list if needed.
2795 modules="$main_modules"
2796 func_modules_add_dummy
2797 main_modules="$modules"
2799 # Determine whether a $testsbase/libtests.a is needed.
2801 for module in $testsrelated_modules; do
2802 func_verify_nontests_module
2803 if test -n "$module"; then
2804 all_files=`func_get_filelist $module`
2805 # Test whether some file in $all_files lies in lib/.
2806 for f in $all_files; do
2817 # Add the dummy module to the tests-related module list if needed.
2818 if $use_libtests; then
2819 modules="$testsrelated_modules"
2820 func_modules_add_dummy
2821 testsrelated_modules="$modules"
2824 # If --lgpl, verify that the licenses of modules are compatible.
2825 if test -n "$lgpl"; then
2826 license_incompatibilities=
2827 for module in $main_modules; do
2828 license=`func_get_license $module`
2830 'GPLed build tool') ;;
2831 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2836 LGPL | LGPLv2+ | LGPLv3+) ;;
2837 *) func_append license_incompatibilities "$module $license$nl" ;;
2843 *) func_append license_incompatibilities "$module $license$nl" ;;
2846 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2851 if test -n "$license_incompatibilities"; then
2852 # Format the license incompatibilities as a table.
2853 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
2854 s,^\(.................................................[^ ]*\) *, \1 ,'
2855 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
2856 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
2860 # Show banner notice of every module.
2861 modules="$main_modules"
2864 # Determine script to apply to imported library files.
2865 sed_transform_lib_file=
2866 for module in $main_modules; do
2867 if test $module = config-h; then
2868 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2869 sed_transform_lib_file=$sed_transform_lib_file'
2870 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2875 sed_transform_main_lib_file="$sed_transform_lib_file"
2876 if test -n "$do_copyrights"; then
2877 if test -n "$lgpl"; then
2881 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2882 s/GNU General/GNU Lesser General/g
2886 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2887 s/GNU General/GNU Lesser General/g
2888 s/version [23]\([ ,]\)/version 2.1\1/g
2891 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2895 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2896 s/GNU Lesser General/GNU General/g
2897 s/GNU Library General/GNU General/g
2898 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
2903 # Determine script to apply to auxiliary files that go into $auxdir/.
2904 sed_transform_build_aux_file=
2905 if test -n "$do_copyrights"; then
2907 sed_transform_build_aux_file=$sed_transform_build_aux_file'
2908 s/GNU Lesser General/GNU General/g
2909 s/GNU Library General/GNU General/g
2910 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
2914 # Determine script to apply to library files that go into $testsbase/.
2915 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2916 if test -n "$do_copyrights"; then
2918 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2919 s/GNU Lesser General/GNU General/g
2920 s/GNU Library General/GNU General/g
2921 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
2925 # Determine the final file lists.
2926 # They must be computed separately, because files in lib/* go into
2927 # $sourcebase/ if they are in the main file list but into $testsbase/
2928 # if they are in the tests-related file list. Furthermore lib/dummy.c
2930 # Determine final main file list.
2931 modules="$main_modules"
2932 func_modules_to_filelist
2934 # Determine final tests-related file list.
2935 modules="$testsrelated_modules"
2936 func_modules_to_filelist
2937 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2938 # Merge both file lists.
2939 sed_remove_empty_lines='/^$/d'
2940 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2941 if test $verbose -ge 0; then
2943 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2944 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2948 || func_fatal_error "refusing to do nothing"
2950 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2951 new_files="$files m4/gnulib-tool.m4"
2952 old_files="$cached_files"
2953 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2954 func_append old_files " m4/gnulib-tool.m4"
2957 rewritten='%REWRITTEN%'
2958 sed_rewrite_old_files="\
2959 s,^build-aux/,$rewritten$auxdir/,
2960 s,^doc/,$rewritten$cached_docbase/,
2961 s,^lib/,$rewritten$cached_sourcebase/,
2962 s,^m4/,$rewritten$cached_m4base/,
2963 s,^tests/,$rewritten$cached_testsbase/,
2964 s,^tests=lib/,$rewritten$cached_testsbase/,
2967 sed_rewrite_new_files="\
2968 s,^build-aux/,$rewritten$auxdir/,
2969 s,^doc/,$rewritten$docbase/,
2970 s,^lib/,$rewritten$sourcebase/,
2971 s,^m4/,$rewritten$m4base/,
2972 s,^tests/,$rewritten$testsbase/,
2973 s,^tests=lib/,$rewritten$testsbase/,
2977 # Create directories.
2978 { echo "$sourcebase"
2980 if test -n "$pobase"; then
2983 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2984 if test -n "$docfiles"; then
2987 if test -n "$inctests"; then
2991 for f in $files; do echo $f; done \
2992 | sed -e "$sed_rewrite_new_files" \
2993 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2996 { # Rearrange file descriptors. Needed because "while ... done < ..."
2997 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2998 exec 5<&0 < "$tmp"/dirs
3000 if test ! -d "$destdir/$d"; then
3002 echo "Creating directory $destdir/$d"
3003 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3005 echo "Create directory $destdir/$d"
3012 # Copy files or make symbolic links. Remove obsolete files.
3016 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3017 # representing the files according to the last gnulib-tool invocation.
3018 for f in $old_files; do echo $f; done \
3019 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3022 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3023 # representing the files after this gnulib-tool invocation.
3024 for f in $new_files; do echo $f; done \
3025 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3028 # First the files that are in old-files, but not in new-files:
3029 sed_take_first_column='s,'"$delimiter"'.*,,'
3030 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3031 # Remove the file. Do nothing if the user already removed it.
3032 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3034 echo "Removing file $g (backup in ${g}~)"
3035 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3037 echo "Remove file $g (backup in ${g}~)"
3039 func_append removed_files "$g$nl"
3042 # func_add_or_update handles a file that ought to be present afterwards.
3044 # - f the original file name
3045 # - g the rewritten file name
3046 # - already_present nonempty if the file should already exist, empty
3048 func_add_or_update ()
3052 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3054 func_dest_tmpfilename "$g"
3055 func_lookup_file "$f"
3056 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3057 if test -n "$sed_transform_main_lib_file"; then
3060 sed -e "$sed_transform_main_lib_file" \
3061 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3065 if test -n "$sed_transform_build_aux_file"; then
3068 sed -e "$sed_transform_build_aux_file" \
3069 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3073 if test -n "$sed_transform_testsrelated_lib_file"; then
3076 sed -e "$sed_transform_testsrelated_lib_file" \
3077 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3081 if test -f "$destdir/$g"; then
3082 # The file already exists.
3086 # Don't protest if the file should be there but isn't: it happens
3087 # frequently that developers don't put autogenerated files into CVS.
3089 func_append added_files "$g$nl"
3093 # Then the files that are in new-files, but not in old-files:
3094 sed_take_last_column='s,^.*'"$delimiter"',,'
3096 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3097 | sed -e "$sed_take_last_column" \
3098 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3099 { # Rearrange file descriptors. Needed because "while ... done < ..."
3100 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3101 exec 5<&0 < "$tmp"/added-files
3107 # Then the files that are in new-files and in old-files:
3108 already_present=true
3109 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3110 | sed -e "$sed_take_last_column" \
3111 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3112 { # Rearrange file descriptors. Needed because "while ... done < ..."
3113 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3114 exec 5<&0 < "$tmp"/kept-files
3121 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3122 actioncmd="gnulib-tool --import"
3123 func_append actioncmd " --dir=$destdir"
3124 if test -n "$local_gnulib_dir"; then
3125 func_append actioncmd " --local-dir=$local_gnulib_dir"
3127 func_append actioncmd " --lib=$libname"
3128 func_append actioncmd " --source-base=$sourcebase"
3129 func_append actioncmd " --m4-base=$m4base"
3130 if test -n "$pobase"; then
3131 func_append actioncmd " --po-base=$pobase"
3133 func_append actioncmd " --doc-base=$docbase"
3134 func_append actioncmd " --tests-base=$testsbase"
3135 func_append actioncmd " --aux-dir=$auxdir"
3136 if test -n "$inctests"; then
3137 func_append actioncmd " --with-tests"
3139 if test -n "$incobsolete"; then
3140 func_append actioncmd " --with-obsolete"
3142 for module in $avoidlist; do
3143 func_append actioncmd " --avoid=$module"
3145 if test -n "$lgpl"; then
3146 if test "$lgpl" = yes; then
3147 func_append actioncmd " --lgpl"
3149 func_append actioncmd " --lgpl=$lgpl"
3152 if test -n "$makefile_name"; then
3153 func_append actioncmd " --makefile-name=$makefile_name"
3155 if test "$libtool" = true; then
3156 func_append actioncmd " --libtool"
3158 func_append actioncmd " --no-libtool"
3160 func_append actioncmd " --macro-prefix=$macro_prefix"
3161 if test -n "$po_domain"; then
3162 func_append actioncmd " --po-domain=$po_domain"
3164 if test -n "$vc_files"; then
3165 if test "$vc_files" = true; then
3166 func_append actioncmd " --vc-files"
3168 func_append actioncmd " --no-vc-files"
3171 func_append actioncmd " `echo $specified_modules`"
3173 # Default the makefile name to Makefile.am.
3174 if test -n "$makefile_name"; then
3175 makefile_am=$makefile_name
3177 makefile_am=Makefile.am
3180 # Create normal Makefile.ams.
3183 # Setup list of Makefile.am edits that are to be performed afterwards.
3184 # Some of these edits apply to files that we will generate; others are
3185 # under the responsibility of the developer.
3187 # func_note_Makefile_am_edit dir var value
3188 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3190 func_note_Makefile_am_edit ()
3192 makefile_am_edits=`expr $makefile_am_edits + 1`
3193 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3194 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3195 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3197 if test "$makefile_am" = Makefile.am; then
3198 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3199 sourcebase_base=`basename "$sourcebase"`
3200 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3202 if test -n "$pobase"; then
3203 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3204 pobase_base=`basename "$pobase"`
3205 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3207 if test -n "$inctests"; then
3208 if test "$makefile_am" = Makefile.am; then
3209 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3210 testsbase_base=`basename "$testsbase"`
3211 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3214 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3216 # Find the first parent directory of $m4base that contains or will contain
3218 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3220 sed_butlast='s,[^/][^/]*//*$,,'
3221 dir1="${m4base}/"; dir2=""
3222 while test -n "$dir1" \
3223 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3224 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3225 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3226 || { test -n "$inctests" \
3227 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3228 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3229 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3230 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3232 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3235 # Create library makefile.
3236 func_dest_tmpfilename $sourcebase/$makefile_am
3237 destfile="$sourcebase/$makefile_am"
3238 modules="$main_modules"
3239 func_emit_lib_Makefile_am > "$tmpfile"
3240 if test -f "$destdir"/$sourcebase/$makefile_am; then
3241 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3245 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3246 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3247 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3249 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3255 echo "Creating $sourcebase/$makefile_am"
3256 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3258 echo "Create $sourcebase/$makefile_am"
3261 func_append added_files "$sourcebase/$makefile_am$nl"
3264 # Create po/ directory.
3265 if test -n "$pobase"; then
3266 # Create po makefile and auxiliary files.
3267 for file in Makefile.in.in remove-potcdate.sin; do
3268 func_dest_tmpfilename $pobase/$file
3269 func_lookup_file build-aux/po/$file
3270 cat "$lookedup_file" > "$tmpfile"
3271 if test -f "$destdir"/$pobase/$file; then
3272 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3276 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3277 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3278 mv -f "$tmpfile" "$destdir"/$pobase/$file
3280 echo "Update $pobase/$file (backup in $pobase/$file~)"
3286 echo "Creating $pobase/$file"
3287 mv -f "$tmpfile" "$destdir"/$pobase/$file
3289 echo "Create $pobase/$file"
3292 func_append added_files "$pobase/$file$nl"
3295 # Create po makefile parameterization, part 1.
3296 func_dest_tmpfilename $pobase/Makevars
3297 func_emit_po_Makevars > "$tmpfile"
3298 if test -f "$destdir"/$pobase/Makevars; then
3299 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3303 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3304 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3305 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3307 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3313 echo "Creating $pobase/Makevars"
3314 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3316 echo "Create $pobase/Makevars"
3319 func_append added_files "$pobase/Makevars$nl"
3321 # Create po makefile parameterization, part 2.
3322 func_dest_tmpfilename $pobase/POTFILES.in
3323 func_emit_po_POTFILES_in > "$tmpfile"
3324 if test -f "$destdir"/$pobase/POTFILES.in; then
3325 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3329 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3330 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3331 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3333 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3339 echo "Creating $pobase/POTFILES.in"
3340 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3342 echo "Create $pobase/POTFILES.in"
3345 func_append added_files "$pobase/POTFILES.in$nl"
3348 TP_URL="http://translationproject.org/latest/"
3349 TP_RSYNC_URI="translationproject.org::tp/latest/"
3351 echo "Fetching gnulib PO files from $TP_URL"
3352 (cd "$destdir"/$pobase \
3353 && { # Prefer rsync over wget if it is available, since it consumes
3354 # less network bandwidth, due to compression.
3355 if type rsync 2>/dev/null | grep / > /dev/null; then
3356 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3358 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3363 echo "Fetch gnulib PO files from $TP_URL"
3365 # Create po/LINGUAS.
3367 func_dest_tmpfilename $pobase/LINGUAS
3368 (cd "$destdir"/$pobase \
3369 && { echo '# Set of available languages.'
3370 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3373 if test -f "$destdir"/$pobase/LINGUAS; then
3374 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3377 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3378 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3379 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3382 echo "Creating $pobase/LINGUAS"
3383 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3384 func_append added_files "$pobase/LINGUAS$nl"
3387 if test -f "$destdir"/$pobase/LINGUAS; then
3388 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3390 echo "Create $pobase/LINGUAS"
3395 # Create m4/gnulib-cache.m4.
3396 func_dest_tmpfilename $m4base/gnulib-cache.m4
3398 func_emit_copyright_notice
3400 echo "# This file represents the specification of how gnulib-tool is used."
3401 echo "# It acts as a cache: It is written and read by gnulib-tool."
3402 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3403 echo "# like the configure.ac and various Makefile.am files."
3406 echo "# Specification in the form of a command-line invocation:"
3409 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3410 # Store the local_gnulib_dir relative to destdir.
3411 case "$local_gnulib_dir" in
3413 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3416 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3418 # destdir, local_gnulib_dir are both relative.
3419 func_relativize "$destdir" "$local_gnulib_dir"
3420 relative_local_gnulib_dir="$reldir" ;;
3423 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3425 echo "$specified_modules" | sed -e 's/^/ /g'
3427 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3428 echo "gl_AVOID([$avoidlist])"
3429 echo "gl_SOURCE_BASE([$sourcebase])"
3430 echo "gl_M4_BASE([$m4base])"
3431 echo "gl_PO_BASE([$pobase])"
3432 echo "gl_DOC_BASE([$docbase])"
3433 echo "gl_TESTS_BASE([$testsbase])"
3434 test -z "$inctests" || echo "gl_WITH_TESTS"
3435 echo "gl_LIB([$libname])"
3436 if test -n "$lgpl"; then
3437 if test "$lgpl" = yes; then
3440 echo "gl_LGPL([$lgpl])"
3443 echo "gl_MAKEFILE_NAME([$makefile_name])"
3444 if test "$libtool" = true; then
3447 echo "gl_MACRO_PREFIX([$macro_prefix])"
3448 echo "gl_PO_DOMAIN([$po_domain])"
3449 if test -n "$vc_files"; then
3450 echo "gl_VC_FILES([$vc_files])"
3453 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3454 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3458 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3459 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3460 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3462 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3466 echo "# gnulib-cache.m4 ends here"
3473 echo "Creating $m4base/gnulib-cache.m4"
3474 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3476 echo "Create $m4base/gnulib-cache.m4"
3482 # Create m4/gnulib-comp.m4.
3483 func_dest_tmpfilename $m4base/gnulib-comp.m4
3485 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3486 func_emit_copyright_notice
3488 echo "# This file represents the compiled summary of the specification in"
3489 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3490 echo "# to be invoked from configure.ac."
3491 echo "# In projects using CVS, this file can be treated like other built files."
3494 echo "# This macro should be invoked from $configure_ac, in the section"
3495 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3496 echo "# any checks for libraries, header files, types and library functions."
3497 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3499 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3500 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3501 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3502 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3503 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3504 if test -n "$uses_subdirs"; then
3505 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3507 for module in $final_modules; do
3509 if test -n "$module"; then
3510 func_get_autoconf_early_snippet "$module"
3513 | sed -e '/^$/d;' -e 's/^/ /'
3516 echo "# This macro should be invoked from $configure_ac, in the section"
3517 echo "# \"Check for header files, types and library functions\"."
3518 echo "AC_DEFUN([${macro_prefix}_INIT],"
3520 if test "$libtool" = true; then
3521 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3522 echo " gl_cond_libtool=true"
3524 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3525 echo " gl_cond_libtool=false"
3527 echo " gl_ltlibdeps="
3529 if test "$auxdir" != "build-aux"; then
3530 sed_replace_build_aux='
3532 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3533 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3537 sed_replace_build_aux="$sed_noop"
3539 func_emit_initmacro_start $macro_prefix
3540 echo " gl_source_base='$sourcebase'"
3541 for module in $main_modules; do
3543 if test -n "$module"; then
3544 func_get_autoconf_snippet "$module" \
3545 | sed -e '/^$/d;' -e 's/^/ /' \
3546 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3547 -e "$sed_replace_build_aux"
3548 if test "$module" = 'alloca' && test "$libtool" = true; then
3549 echo 'changequote(,)dnl'
3550 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3551 echo 'changequote([, ])dnl'
3552 echo 'AC_SUBST([LTALLOCA])'
3556 func_emit_initmacro_end $macro_prefix
3557 echo " gltests_libdeps="
3558 echo " gltests_ltlibdeps="
3559 func_emit_initmacro_start ${macro_prefix}tests
3560 echo " gl_source_base='$testsbase'"
3561 for module in $testsrelated_modules; do
3563 if test -n "$module"; then
3564 func_get_autoconf_snippet "$module" \
3565 | sed -e '/^$/d;' -e 's/^/ /' \
3566 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3567 -e "$sed_replace_build_aux" \
3568 -e 's/\$gl_cond_libtool/false/g' \
3569 -e 's/gl_libdeps/gltests_libdeps/g' \
3570 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3573 func_emit_initmacro_end ${macro_prefix}tests
3574 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3575 # created using libtool, because libtool already handles the dependencies.
3576 if test "$libtool" != true; then
3577 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3578 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3579 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3580 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3581 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3583 if $use_libtests; then
3584 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3585 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3588 func_emit_initmacro_done $macro_prefix $sourcebase
3589 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3591 echo "# This macro records the list of files which have been installed by"
3592 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3593 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3594 echo "$files" | sed -e 's,^, ,'
3597 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3598 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3602 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3603 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3604 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3606 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3610 echo "# gnulib-comp.m4 ends here"
3617 echo "Creating $m4base/gnulib-comp.m4"
3618 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3620 echo "Create $m4base/gnulib-comp.m4"
3626 if test -n "$inctests"; then
3627 # Create tests makefile.
3628 func_dest_tmpfilename $testsbase/$makefile_am
3629 destfile="$testsbase/$makefile_am"
3630 modules="$testsrelated_modules"
3631 func_emit_tests_Makefile_am > "$tmpfile"
3632 if test -f "$destdir"/$testsbase/$makefile_am; then
3633 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3637 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3638 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3639 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3641 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3647 echo "Creating $testsbase/$makefile_am"
3648 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3650 echo "Create $testsbase/$makefile_am"
3653 func_append added_files "$testsbase/$makefile_am$nl"
3657 if test "$vc_files" != false; then
3658 # Update the .cvsignore and .gitignore files.
3659 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3660 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3661 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3662 echo "$m4base/|A|gnulib-comp.m4"
3663 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3664 { # Rearrange file descriptors. Needed because "while ... done < ..."
3665 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3666 exec 5<&0 < "$tmp"/fileset-changes
3667 func_update_ignorelist ()
3670 if test "$ignore" = .gitignore; then
3671 # In a .gitignore file, "foo" applies to the current directory and all
3672 # subdirectories, whereas "/foo" applies to the current directory only.
3675 doubly_escaped_anchor='\\/'
3679 doubly_escaped_anchor=''
3681 if test -f "$destdir/$dir$ignore"; then
3682 if test -n "$dir_added" || test -n "$dir_removed"; then
3683 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3685 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3686 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
3687 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3688 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
3690 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3692 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3693 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3694 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3695 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
3696 } > "$tmp"/sed-ignore-removed
3697 { cat "$destdir/$dir$ignore"~
3698 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3699 } | sed -f "$tmp"/sed-ignore-removed \
3700 > "$destdir/$dir$ignore"
3702 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3707 if test -n "$dir_added"; then
3709 echo "Creating $destdir/$dir$ignore"
3711 if test "$ignore" = .cvsignore; then
3713 # Automake generates Makefile rules that create .dirstamp files.
3716 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3717 } > "$destdir/$dir$ignore"
3719 echo "Create $destdir/$dir$ignore"
3729 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3730 func_update_ignorelist .cvsignore
3732 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3733 func_update_ignorelist .gitignore
3740 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3741 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3742 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3743 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3744 if test "$next_dir" != "$last_dir"; then
3745 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3746 last_dir="$next_dir"
3751 A) func_append last_dir_added "$file$nl";;
3752 R) func_append last_dir_removed "$file$nl";;
3755 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3762 echo "You may need to add #include directives for the following .h files."
3763 # Intersect $specified_modules and $main_modules
3764 # (since $specified_modules is not necessarily of subset of $main_modules
3765 # - some may have been skipped through --avoid, and since the elements of
3766 # $main_modules but not in $specified_modules can go away without explicit
3767 # notice - through changes in the module dependencies).
3768 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3769 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3770 # First the #include <...> directives without #ifs, sorted for convenience,
3771 # then the #include "..." directives without #ifs, sorted for convenience,
3772 # then the #include directives that are surrounded by #ifs. Not sorted.
3773 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3774 include_directive=`func_get_include_directive "$module"`
3775 case "$nl$include_directive" in
3777 echo "$include_directive" 1>&5
3780 echo "$include_directive" | grep -v 'include "' 1>&6
3781 echo "$include_directive" | grep 'include "' 1>&7
3784 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3786 LC_ALL=C sort -u "$tmp"/include-angles
3787 LC_ALL=C sort -u "$tmp"/include-quotes
3788 cat "$tmp"/include-if
3789 ) | sed -e '/^$/d' -e 's/^/ /'
3790 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3792 for module in $main_modules; do
3793 func_get_link_directive "$module"
3795 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3796 if test `wc -l < "$tmp"/link` != 0; then
3798 echo "You may need to use the following Makefile variables when linking."
3799 echo "Use them in <program>_LDADD when linking a program, or"
3800 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3806 echo "Don't forget to"
3807 if test "$makefile_am" = Makefile.am; then
3808 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3810 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3812 if test -n "$pobase"; then
3813 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3815 if test -n "$inctests"; then
3816 if test "$makefile_am" = Makefile.am; then
3817 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3819 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3823 while test $edit != $makefile_am_edits; do
3824 edit=`expr $edit + 1`
3825 eval dir=\"\$makefile_am_edit${edit}_dir\"
3826 eval var=\"\$makefile_am_edit${edit}_var\"
3827 eval val=\"\$makefile_am_edit${edit}_val\"
3828 if test -n "$var"; then
3829 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
3832 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3833 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3836 # func_create_testdir testdir modules
3838 # - local_gnulib_dir from --local-dir
3839 # - auxdir directory relative to destdir where to place build aux files
3840 func_create_testdir ()
3844 if test -z "$modules"; then
3845 # All modules together.
3846 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3847 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3848 modules=`func_all_modules`
3849 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3851 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3853 # Check that the license of every module is consistent with the license of
3855 saved_modules="$modules"
3856 saved_inctests="$inctests"
3857 # When computing transitive closures, don't consider $module to depend on
3858 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3859 # on GPL modules - therefore we don't want a warning in this case.
3861 for requested_module in $saved_modules; do
3862 requested_license=`func_get_license "$requested_module"`
3863 if test "$requested_license" != GPL; then
3864 # Here we use func_modules_transitive_closure, not just
3865 # func_get_dependencies, so that we also detect weird situations like
3866 # an LGPL module which depends on a GPLed build tool module which depends
3868 modules="$requested_module"
3869 func_modules_transitive_closure
3870 for module in $modules; do
3871 license=`func_get_license "$module"`
3873 'GPLed build tool') ;;
3874 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3876 case "$requested_license" in
3879 GPLv2+ | LGPLv2+) ;;
3880 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3886 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3892 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3901 modules="$saved_modules"
3902 inctests="$saved_inctests"
3904 # Subdirectory names.
3914 # Determine final module list.
3915 func_modules_transitive_closure
3916 if test $verbose -ge 0; then
3917 echo "Module list with included dependencies:"
3918 echo "$modules" | sed -e 's/^/ /'
3921 # Add the dummy module if needed.
3922 func_modules_add_dummy
3924 # Show banner notice of every module.
3927 # Determine final file list.
3928 func_modules_to_filelist
3929 if test $verbose -ge 0; then
3931 echo "$files" | sed -e 's/^/ /'
3934 rewritten='%REWRITTEN%'
3935 sed_rewrite_files="\
3936 s,^build-aux/,$rewritten$auxdir/,
3937 s,^doc/,$rewritten$docbase/,
3938 s,^lib/,$rewritten$sourcebase/,
3939 s,^m4/,$rewritten$m4base/,
3940 s,^tests/,$rewritten$testsbase/,
3944 # Create directories.
3945 for f in $files; do echo $f; done \
3946 | sed -e "$sed_rewrite_files" \
3947 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3948 | LC_ALL=C sort -u \
3950 { # Rearrange file descriptors. Needed because "while ... done < ..."
3951 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3952 exec 5<&0 < "$tmp"/dirs
3954 mkdir -p "$testdir/$d"
3959 # Copy files or make symbolic links.
3961 for f in $files; do echo $f; done \
3962 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3965 { # Rearrange file descriptors. Needed because "while ... done < ..."
3966 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3967 exec 5<&0 < "$tmp"/files
3969 func_lookup_file "$f"
3970 if test -n "$lookedup_tmp"; then
3971 cp -p "$lookedup_file" "$testdir/$g"
3973 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3974 if { test -n "$symbolic" \
3975 || { test -n "$lsymbolic" \
3976 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3977 func_ln "$lookedup_file" "$testdir/$g"
3979 cp -p "$lookedup_file" "$testdir/$g"
3986 # Create Makefile.ams that are for testing.
3989 # No special edits are needed.
3992 # Create $sourcebase/Makefile.am.
3993 mkdir -p "$testdir/$sourcebase"
3994 destfile="$sourcebase/Makefile.am"
3995 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3996 any_uses_subdirs="$uses_subdirs"
3998 # Create $m4base/Makefile.am.
3999 mkdir -p "$testdir/$m4base"
4000 (echo "## Process this file with automake to produce Makefile.in."
4006 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4009 ) > "$testdir/$m4base/Makefile.am"
4011 subdirs="$sourcebase $m4base"
4012 subdirs_with_configure_ac=""
4014 if false && test -f "$testdir"/$m4base/gettext.m4; then
4015 # Avoid stupid error message from automake:
4016 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4017 mkdir -p "$testdir/po"
4018 (echo "## Process this file with automake to produce Makefile.in."
4019 ) > "$testdir/po/Makefile.am"
4020 func_append subdirs " po"
4023 if test -n "$inctests"; then
4024 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4025 # Viewed from the $testsbase subdirectory, $auxdir is different.
4026 saved_auxdir="$auxdir"
4027 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4028 # Create $testsbase/Makefile.am.
4030 destfile="$testsbase/Makefile.am"
4031 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
4032 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4033 # Create $testsbase/configure.ac.
4034 (echo "# Process this file with autoconf to produce a configure script."
4035 echo "AC_INIT([dummy], [0])"
4036 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4037 echo "AM_INIT_AUTOMAKE"
4039 echo "AC_CONFIG_HEADERS([config.h])"
4042 echo "AC_PROG_INSTALL"
4043 echo "AC_PROG_MAKE_SET"
4044 echo "AC_PROG_RANLIB"
4046 if test -n "$uses_subdirs"; then
4047 echo "AM_PROG_CC_C_O"
4050 for module in $modules; do
4052 if test -n "$module"; then
4054 gnumakefile | maintainer-makefile)
4055 # These modules are meant to be used only in the top-level directory.
4058 func_get_autoconf_early_snippet "$module"
4063 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4064 if test "$libtool" = true; then
4065 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4066 echo "gl_cond_libtool=true"
4068 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4069 echo "gl_cond_libtool=false"
4071 echo "gl_ltlibdeps="
4073 # Wrap the set of autoconf snippets into an autoconf macro that is then
4074 # invoked. This is needed because autoconf does not support AC_REQUIRE
4076 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4077 # but we want the AC_REQUIRE to have its normal meaning (provide one
4078 # expansion of the required macro before the current point, and only one
4080 echo "AC_DEFUN([gl_INIT], ["
4081 sed_replace_build_aux='
4083 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4084 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4087 func_emit_initmacro_start $macro_prefix
4088 # We don't have explicit ordering constraints between the various
4089 # autoconf snippets. It's cleanest to put those of the library before
4090 # those of the tests.
4091 echo "gl_source_base='../$sourcebase'"
4092 for module in $modules; do
4093 func_verify_nontests_module
4094 if test -n "$module"; then
4096 gnumakefile | maintainer-makefile)
4097 # These modules are meant to be used only in the top-level directory.
4100 func_get_autoconf_snippet "$module" \
4101 | sed -e "$sed_replace_build_aux"
4106 echo "gl_source_base='.'"
4107 for module in $modules; do
4108 func_verify_tests_module
4109 if test -n "$module"; then
4110 func_get_autoconf_snippet "$module" \
4111 | sed -e "$sed_replace_build_aux"
4114 func_emit_initmacro_end $macro_prefix
4115 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4116 # created using libtool, because libtool already handles the dependencies.
4117 if test "$libtool" != true; then
4118 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4119 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4120 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4121 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4122 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4125 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4129 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4130 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4131 echo "AH_TOP([#include \"../config.h\"])"
4133 echo "AC_CONFIG_FILES([Makefile])"
4135 ) > "$testdir/$testsbase/configure.ac"
4136 auxdir="$saved_auxdir"
4137 func_append subdirs " $testsbase"
4138 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4141 # Create Makefile.am.
4142 (echo "## Process this file with automake to produce Makefile.in."
4144 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4146 echo "SUBDIRS = $subdirs"
4148 echo "ACLOCAL_AMFLAGS = -I $m4base"
4149 ) > "$testdir/Makefile.am"
4151 # Create configure.ac.
4152 (echo "# Process this file with autoconf to produce a configure script."
4153 echo "AC_INIT([dummy], [0])"
4154 if test "$auxdir" != "."; then
4155 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4157 echo "AM_INIT_AUTOMAKE"
4159 echo "AC_CONFIG_HEADERS([config.h])"
4162 echo "AC_PROG_INSTALL"
4163 echo "AC_PROG_MAKE_SET"
4165 echo "# For autobuild."
4166 echo "AC_CANONICAL_BUILD"
4167 echo "AC_CANONICAL_HOST"
4169 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4170 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4171 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4172 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4174 echo "AC_PROG_RANLIB"
4176 if test -n "$any_uses_subdirs"; then
4177 echo "AM_PROG_CC_C_O"
4180 for module in $modules; do
4181 func_verify_nontests_module
4182 if test -n "$module"; then
4183 func_get_autoconf_early_snippet "$module"
4186 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4187 if test "$libtool" = true; then
4188 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4189 echo "gl_cond_libtool=true"
4191 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4192 echo "gl_cond_libtool=false"
4194 echo "gl_ltlibdeps="
4196 # Wrap the set of autoconf snippets into an autoconf macro that is then
4197 # invoked. This is needed because autoconf does not support AC_REQUIRE
4199 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4200 # but we want the AC_REQUIRE to have its normal meaning (provide one
4201 # expansion of the required macro before the current point, and only one
4203 echo "AC_DEFUN([gl_INIT], ["
4204 if test "$auxdir" != "build-aux"; then
4205 sed_replace_build_aux='
4207 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4208 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4212 sed_replace_build_aux="$sed_noop"
4214 func_emit_initmacro_start $macro_prefix
4215 echo "gl_source_base='$sourcebase'"
4216 for module in $modules; do
4217 func_verify_nontests_module
4218 if test -n "$module"; then
4219 func_get_autoconf_snippet "$module" \
4220 | sed -e "$sed_replace_build_aux"
4223 func_emit_initmacro_end $macro_prefix
4224 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4225 # created using libtool, because libtool already handles the dependencies.
4226 if test "$libtool" != true; then
4227 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4228 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4229 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4230 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4231 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4234 func_emit_initmacro_done $macro_prefix $sourcebase
4238 if test -n "$subdirs_with_configure_ac"; then
4239 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4241 makefiles="Makefile"
4242 for d in $subdirs; do
4243 # For subdirs that have a configure.ac by their own, it's the subdir's
4244 # configure.ac which creates the subdir's Makefile.am, not this one.
4245 case " $subdirs_with_configure_ac " in
4247 *) func_append makefiles " $d/Makefile" ;;
4250 echo "AC_CONFIG_FILES([$makefiles])"
4252 ) > "$testdir/configure.ac"
4254 # Create autogenerated files.
4256 # Do not use "${AUTORECONF} --force --install", because it may invoke
4257 # autopoint, which brings in older versions of some of our .m4 files.
4258 if test -f $m4base/gettext.m4; then
4259 func_execute_command ${AUTOPOINT} --force || func_exit 1
4260 for f in $m4base/*.m4~; do
4262 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4266 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4267 if ! test -d build-aux; then
4268 func_execute_command mkdir build-aux || func_exit 1
4270 func_execute_command ${AUTOCONF} || func_exit 1
4271 func_execute_command ${AUTOHEADER} || func_exit 1
4272 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4274 if test -n "$inctests"; then
4275 # Create autogenerated files.
4276 (cd "$testdir/$testsbase" || func_exit 1
4277 # Do not use "${AUTORECONF} --force --install", because it may invoke
4278 # autopoint, which brings in older versions of some of our .m4 files.
4279 if test -f ../$m4base/gettext.m4; then
4280 func_execute_command ${AUTOPOINT} --force || func_exit 1
4281 for f in ../$m4base/*.m4~; do
4283 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4287 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4288 if ! test -d ../build-aux; then
4289 func_execute_command mkdir ../build-aux
4291 func_execute_command ${AUTOCONF} || func_exit 1
4292 func_execute_command ${AUTOHEADER} || func_exit 1
4293 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4296 # Need to run configure and make once, to create built files that are to be
4297 # distributed (such as getdate.c).
4298 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4299 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4300 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4301 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4302 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4303 # such $(FOO_H) because they don't refer to distributed files.
4304 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4305 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4306 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4307 | sed -e "$sed_remove_make_variables"`
4308 distributed_built_sources=`for file in $built_sources; do
4309 case "$cleaned_files" in
4314 if test -n "$distributed_built_sources"; then
4316 ./configure || func_exit 1
4318 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4319 $MAKE built_sources || func_exit 1
4321 $MAKE distclean || func_exit 1
4326 # func_create_megatestdir megatestdir allmodules
4328 # - local_gnulib_dir from --local-dir
4329 # - auxdir directory relative to destdir where to place build aux files
4330 func_create_megatestdir ()
4334 if test -z "$allmodules"; then
4335 allmodules=`func_all_modules`
4339 # First, all modules one by one.
4340 for onemodule in $allmodules; do
4341 func_create_testdir "$megatestdir/$onemodule" $onemodule
4342 func_append megasubdirs "$onemodule "
4344 # Then, all modules all together.
4345 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4346 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
4347 func_create_testdir "$megatestdir/ALL" "$allmodules"
4348 func_append megasubdirs "ALL"
4351 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4352 vc_witness="$gnulib_dir/CVS/Entries"; \
4354 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4356 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4357 | sed -e 's,January,01,' -e 's,Jan,01,' \
4358 -e 's,February,02,' -e 's,Feb,02,' \
4359 -e 's,March,03,' -e 's,Mar,03,' \
4360 -e 's,April,04,' -e 's,Apr,04,' \
4362 -e 's,June,06,' -e 's,Jun,06,' \
4363 -e 's,July,07,' -e 's,Jul,07,' \
4364 -e 's,August,08,' -e 's,Aug,08,' \
4365 -e 's,September,09,' -e 's,Sep,09,' \
4366 -e 's,October,10,' -e 's,Oct,10,' \
4367 -e 's,November,11,' -e 's,Nov,11,' \
4368 -e 's,December,12,' -e 's,Dec,12,' \
4369 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4370 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4372 echo "CVSDATE=$cvsdate"
4373 echo ": \${MAKE=make}"
4374 echo "test -d logs || mkdir logs"
4375 echo "for module in $megasubdirs; do"
4376 echo " echo \"Working on module \$module...\""
4377 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4378 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4381 echo " : autobuild project... \$module"
4382 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4383 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4384 echo " : autobuild hostname... \`hostname\`"
4385 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
4387 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4389 ) > "$megatestdir/do-autobuild"
4390 chmod a+x "$megatestdir/do-autobuild"
4392 # Create Makefile.am.
4393 (echo "## Process this file with automake to produce Makefile.in."
4395 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4397 echo "SUBDIRS = $megasubdirs"
4399 echo "EXTRA_DIST = do-autobuild"
4400 ) > "$megatestdir/Makefile.am"
4402 # Create configure.ac.
4403 (echo "# Process this file with autoconf to produce a configure script."
4404 echo "AC_INIT([dummy], [0])"
4405 if test "$auxdir" != "."; then
4406 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4408 echo "AM_INIT_AUTOMAKE"
4410 echo "AC_PROG_MAKE_SET"
4412 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4413 echo "AC_CONFIG_FILES([Makefile])"
4415 ) > "$megatestdir/configure.ac"
4417 # Create autogenerated files.
4419 # Do not use "${AUTORECONF} --install", because autoreconf operates
4420 # recursively, but the subdirectories are already finished, therefore
4421 # calling autoreconf here would only waste lots of CPU time.
4422 func_execute_command ${ACLOCAL} || func_exit 1
4423 func_execute_command mkdir build-aux
4424 func_execute_command ${AUTOCONF} || func_exit 1
4425 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4431 func_fatal_error "no mode specified" ;;
4440 if test -z "$destdir"; then
4443 test -d "$destdir" \
4444 || func_fatal_error "destination directory does not exist: $destdir"
4446 # Prefer configure.ac to configure.in.
4447 if test -f "$destdir"/configure.ac; then
4448 configure_ac="$destdir/configure.ac"
4450 if test -f "$destdir"/configure.in; then
4451 configure_ac="$destdir/configure.in"
4453 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
4457 # Analyze configure.ac.
4459 guessed_libtool=false
4464 /AC_CONFIG_AUX_DIR/ {
4465 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
4467 /A[CM]_PROG_LIBTOOL/ {
4468 s,^.*$,guessed_libtool=true,p
4470 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4472 if test -z "$auxdir"; then
4473 auxdir="$guessed_auxdir"
4476 # Determine where to apply func_import.
4477 if test -n "$m4base"; then
4478 # Apply func_import to a particular gnulib directory.
4479 # Any number of additional modules can be given.
4480 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4481 # First use of gnulib in the given m4base.
4482 test -n "$supplied_libname" || supplied_libname=true
4483 test -n "$sourcebase" || sourcebase="lib"
4484 test -n "$docbase" || docbase="doc"
4485 test -n "$testsbase" || testsbase="tests"
4486 test -n "$macro_prefix" || macro_prefix="gl"
4490 # Apply func_import to all gnulib directories.
4491 # To get this list of directories, look at Makefile.am. (Not at
4492 # configure, because it may be omitted from CVS. Also, don't run
4493 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4496 if test -f "$destdir"/Makefile.am; then
4497 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4499 for arg in $aclocal_amflags; do
4500 if test -n "$m4dir_is_next"; then
4501 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4505 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4506 func_append m4dirs " $arg"
4507 m4dirs_count=`expr $m4dirs_count + 1`
4513 if test "X$arg" = "X-I"; then
4521 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4522 if test -f "$destdir"/aclocal.m4; then
4523 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4524 sedexpr2='s,^[^/]*$,.,'
4525 sedexpr3='s,/[^/]*$,,'
4526 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4527 m4dirs_count=`printf %s "$m4dirs" | wc -l`
4530 if test $m4dirs_count = 0; then
4531 # First use of gnulib in a package.
4532 # Any number of additional modules can be given.
4533 test -n "$supplied_libname" || supplied_libname=true
4534 test -n "$sourcebase" || sourcebase="lib"
4536 test -n "$docbase" || docbase="doc"
4537 test -n "$testsbase" || testsbase="tests"
4538 test -n "$macro_prefix" || macro_prefix="gl"
4541 if test $m4dirs_count = 1; then
4542 # There's only one use of gnulib here. Assume the user means it.
4543 # Any number of additional modules can be given.
4544 for m4base in $m4dirs; do
4548 # Ambiguous - guess what the user meant.
4549 if test $# = 0; then
4550 # No further arguments. Guess the user wants to update all of them.
4551 for m4base in $m4dirs; do
4552 # Perform func_import in a subshell, so that variable values
4554 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
4555 # pobase, docbase, testsbase, inctests, libname, lgpl,
4556 # makefile_name, libtool, macro_prefix, po_domain, vc_files
4557 # don't propagate from one directory to another.
4558 (func_import) || func_exit 1
4562 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4570 if test -z "$destdir"; then
4571 func_fatal_error "please specify --dir option"
4574 test -d "$destdir" \
4575 || func_fatal_error "could not create destination directory"
4576 test -n "$auxdir" || auxdir="build-aux"
4577 func_create_testdir "$destdir" "$*"
4580 create-megatestdir )
4581 if test -z "$destdir"; then
4582 func_fatal_error "please specify --dir option"
4584 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4585 test -n "$auxdir" || auxdir="build-aux"
4586 func_create_megatestdir "$destdir" "$*"
4590 test -n "$destdir" || destdir=testdir$$
4591 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4592 test -n "$auxdir" || auxdir="build-aux"
4593 func_create_testdir "$destdir" "$*"
4597 ../configure || func_exit 1
4598 $MAKE || func_exit 1
4599 $MAKE check || func_exit 1
4600 $MAKE distclean || func_exit 1
4601 remaining=`find . -type f -print`
4602 if test -n "$remaining"; then
4603 echo "Remaining files:" $remaining 1>&2
4604 echo "gnulib-tool: *** Stop." 1>&2
4613 test -n "$destdir" || destdir=testdir$$
4614 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4615 test -n "$auxdir" || auxdir="build-aux"
4616 func_create_megatestdir "$destdir" "$*"
4624 remaining=`find . -type f -print`
4625 if test -n "$remaining"; then
4626 echo "Remaining files:" $remaining 1>&2
4627 echo "gnulib-tool: *** Stop." 1>&2
4635 extract-description )
4639 if test -n "$module"; then
4640 func_get_description "$module"
4649 if test -n "$module"; then
4650 func_get_status "$module"
4659 if test -n "$module"; then
4660 func_get_notice "$module"
4665 extract-applicability )
4669 if test -n "$module"; then
4670 func_get_applicability "$module"
4679 if test -n "$module"; then
4680 func_get_filelist "$module"
4685 extract-dependencies )
4689 if test -n "$module"; then
4690 func_get_dependencies "$module"
4695 extract-autoconf-snippet )
4699 if test -n "$module"; then
4700 func_get_autoconf_snippet "$module"
4705 extract-automake-snippet )
4709 if test -n "$module"; then
4710 func_get_automake_snippet "$module"
4715 extract-include-directive )
4719 if test -n "$module"; then
4720 func_get_include_directive "$module"
4725 extract-link-directive )
4729 if test -n "$module"; then
4730 func_get_link_directive "$module"
4739 if test -n "$module"; then
4740 func_get_license "$module"
4745 extract-maintainer )
4749 if test -n "$module"; then
4750 func_get_maintainer "$module"
4755 extract-tests-module )
4759 if test -n "$module"; then
4760 func_get_tests_module "$module"
4766 # Verify the number of arguments.
4767 if test $# -lt 1 || test $# -gt 2; then
4768 func_fatal_error "invalid number of arguments for --$mode"
4771 # The first argument is the file to be copied.
4773 # Verify the file exists.
4774 func_lookup_file "$f"
4776 # The second argument is the destination; either a directory ot a file.
4777 # It defaults to the current directory.
4779 test -n "$dest" || dest='.'
4780 test -n "$sourcebase" || sourcebase="lib"
4781 test -n "$m4base" || m4base="m4"
4782 test -n "$docbase" || docbase="doc"
4783 test -n "$testsbase" || testsbase="tests"
4784 test -n "$auxdir" || auxdir="build-aux"
4785 rewritten='%REWRITTEN%'
4786 sed_rewrite_files="\
4787 s,^build-aux/,$rewritten$auxdir/,
4788 s,^doc/,$rewritten$docbase/,
4789 s,^lib/,$rewritten$sourcebase/,
4790 s,^m4/,$rewritten$m4base/,
4791 s,^tests/,$rewritten$testsbase/,
4794 if test -d "$dest"; then
4796 g=`echo "$f" | sed -e "$sed_rewrite_files"`
4798 destdir=`dirname "$dest"`
4799 g=`basename "$dest"`
4802 # Create the directory for destfile.
4803 d=`dirname "$destdir/$g"`
4805 if test -n "$d" && test ! -d "$d"; then
4806 mkdir -p "$d" || func_fatal_error "failed"
4810 func_dest_tmpfilename "$g"
4811 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4812 already_present=true
4813 if test -f "$destdir/$g"; then
4814 # The file already exists.
4818 # Don't protest if the file should be there but isn't: it happens
4819 # frequently that developers don't put autogenerated files into CVS.
4826 func_fatal_error "unknown operation mode --$mode" ;;
4830 # Undo the effect of the previous 'trap' command. Some shellology:
4831 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4832 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4833 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4834 # 128 + signal number and is set before the trap-registered command is run.
4836 trap 'func_exit $?' 1 2 3 13 15
4841 # indent-tabs-mode: nil
4842 # whitespace-check-buffer-indent: nil