3 # Copyright (C) 2002-2008 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
44 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
45 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
46 AUTOCONF="${AUTOCONFPATH}autoconf"
48 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
49 AUTOHEADER="${AUTOCONFPATH}autoheader"
51 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
52 ACLOCAL="${AUTOMAKEPATH}aclocal"
54 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
55 AUTOMAKE="${AUTOMAKEPATH}automake"
57 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
58 AUTORECONF="${AUTOCONFPATH}autoreconf"
61 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
62 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
63 AUTOPOINT="${GETTEXTPATH}autopoint"
66 # When using GNU sed, turn off as many GNU extensions as possible,
67 # to minimize the risk of accidentally using non-portable features.
68 # However, do this only for gnulib-tool itself, not for the code that
69 # gnulib-tool generates, since we don't want "sed --posix" to leak
71 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
72 # Define sed as an alias.
73 # It is not always possible to use aliases. Aliases are guaranteed to work
74 # if the executing shell is bash and either it is invoked as /bin/sh or
75 # is a version >= 2.0, supporting shopt. This is the common case.
76 # Two other approaches (use of a variable $sed or of a function func_sed
77 # instead of an alias) require massive, fragile code changes.
78 # An other approach (use of function sed) requires `which sed` - but 'which'
79 # is hard to emulate, due to missing "test -x" on some platforms.
80 if test -n "$BASH_VERSION"; then
81 shopt -s expand_aliases >/dev/null 2>&1
83 alias sed='sed --posix'
86 # sed_noop is a sed expression that does nothing.
87 # An empty expression does not work with the native 'sed' on AIX 6.1.
91 # outputs to stdout the --help usage message.
95 Usage: gnulib-tool --list
96 gnulib-tool --import [module1 ... moduleN]
98 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
99 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
100 gnulib-tool --test --dir=directory module1 ... moduleN
101 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
102 gnulib-tool --extract-description module
103 gnulib-tool --extract-notice module
104 gnulib-tool --extract-filelist module
105 gnulib-tool --extract-dependencies module
106 gnulib-tool --extract-autoconf-snippet module
107 gnulib-tool --extract-automake-snippet module
108 gnulib-tool --extract-include-directive module
109 gnulib-tool --extract-link-directive module
110 gnulib-tool --extract-license module
111 gnulib-tool --extract-maintainer module
112 gnulib-tool --extract-tests-module module
115 --list print the available module names
116 --import import the given modules into the current package;
117 if no modules are specified, update the current
118 package from the current gnulib
119 --update update the current package, restore files omitted
121 --create-testdir create a scratch package with the given modules
122 --create-megatestdir create a mega scratch package with the given modules
123 one by one and all together
124 --test test the combination of the given modules
125 (recommended to use CC=\"gcc -Wall\" here)
126 --megatest test the given modules one by one and all together
127 (recommended to use CC=\"gcc -Wall\" here)
128 --extract-description extract the description
129 --extract-notice extract the notice or banner
130 --extract-filelist extract the list of files
131 --extract-dependencies extract the dependencies
132 --extract-autoconf-snippet extract the snippet for configure.ac
133 --extract-automake-snippet extract the snippet for library makefile
134 --extract-include-directive extract the #include directive
135 --extract-link-directive extract the linker directive
136 --extract-license report the license terms of the source files
138 --extract-maintainer report the maintainer(s) inside gnulib
139 --extract-tests-module report the unit test module, if it exists
142 --dir=DIRECTORY Specify the target directory.
143 For --import, this specifies where your
144 configure.ac can be found. Defaults to current
146 --local-dir=DIRECTORY Specify a local override directory where to look
147 up files before looking in gnulib's directory.
148 --verbose Increase verbosity. May be repeated.
149 --quiet Decrease verbosity. May be repeated.
151 Options for --import:
152 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
153 --source-base=DIRECTORY
154 Directory relative to --dir where source code is
155 placed (default \"lib\").
156 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
157 placed (default \"m4\").
158 --po-base=DIRECTORY Directory relative to --dir where *.po files are
159 placed (default \"po\").
160 --doc-base=DIRECTORY Directory relative to --dir where doc files are
161 placed (default \"doc\").
162 --tests-base=DIRECTORY
163 Directory relative to --dir where unit tests are
164 placed (default \"tests\").
165 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
166 tools are placed (default \"build-aux\").
167 --with-tests Include unit tests for the included modules.
168 --avoid=MODULE Avoid including the given MODULE. Useful if you
169 have code that provides equivalent functionality.
170 This option can be repeated.
171 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
172 Also modify license template from GPL to LGPL.
173 The version number of the LGPL can be specified;
174 the default is currently LGPLv3.
175 --makefile-name=NAME Name of makefile in automake syntax in the
176 source-base and tests-base directories
177 (default \"Makefile.am\").
178 --libtool Use libtool rules.
179 --no-libtool Don't use libtool rules.
180 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
181 'gl_INIT'. Default is 'gl'.
182 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
183 the package name. A suffix '-gnulib' is appended.
184 --vc-files Update version control related files.
185 --no-vc-files Don't update version control related files
186 (.gitignore and/or .cvsignore).
187 --no-changelog Don't update or create ChangeLog files.
189 Options for --import and --update:
190 --dry-run For --import, only print what would have been done.
191 -s, --symbolic, --symlink Make symbolic links instead of copying files.
192 --local-symlink Make symbolic links instead of copying files, only
193 for files from the local override directory.
194 -S, --more-symlinks Make symbolic links instead of copying files, and
195 don't replace copyright notices.
197 Report bugs to <bug-gnulib@gnu.org>."
201 # outputs to stdout the --version message.
205 if test -d "$gnulib_dir"/.git \
206 && (git --version) >/dev/null 2>/dev/null \
207 && (date --version) >/dev/null 2>/dev/null; then
208 # gnulib checked out from git.
209 sed_extract_first_date='/^Date/{
213 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
214 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
215 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
216 date=`echo "$date" | sed -e "$sed_year_before_time"`
217 # Use GNU date to compute the time in GMT.
218 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
219 version=' '`"$gnulib_dir"/build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
221 if test -d "$gnulib_dir"/CVS \
222 && (cvs --version) >/dev/null 2>/dev/null; then
223 # gnulib checked out from CVS.
224 sed_extract_first_date='/^date: /{
225 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
228 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
230 # gnulib copy without versioning information.
231 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
235 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
237 gnulib-tool (GNU $package $date)$version
238 Copyright (C) $year Free Software Foundation, Inc.
239 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
240 This is free software: you are free to change and redistribute it.
241 There is NO WARRANTY, to the extent permitted by law.
243 Written by" "Bruno Haible" "and" "Simon Josefsson"
246 # func_emit_copyright_notice
247 # outputs to stdout a header for a generated file.
248 func_emit_copyright_notice ()
250 sed -n '/Copyright/ {
253 }' < "$self_abspathname"
255 echo "# This file is free software, distributed under the terms of the GNU"
256 echo "# General Public License. As a special exception to the GNU General"
257 echo "# Public License, this file may be distributed as part of a program"
258 echo "# that contains a configuration script generated by Autoconf, under"
259 echo "# the same distribution terms as the rest of that program."
261 echo "# Generated by gnulib-tool."
272 # locates the directory where the gnulib repository lives
274 # - self_abspathname absolute pathname of gnulib-tool
275 # - gnulib_dir absolute pathname of gnulib repository
279 /*) self_abspathname="$0" ;;
280 */*) self_abspathname=`pwd`/"$0" ;;
283 # Iterate through the elements of $PATH.
284 # We use IFS=: instead of
285 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
286 # because the latter does not work when some PATH element contains spaces.
287 # We use a canonicalized $pathx instead of $PATH, because empty PATH
288 # elements are by definition equivalent to '.', however field splitting
289 # according to IFS=: loses empty fields in many shells:
290 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
291 # beginning, at the end, and in the middle),
292 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
293 # at the beginning and at the end,
294 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
295 # Solaris lose empty fields at the end.
296 # The 'case' statement is an optimization, to avoid evaluating the
297 # explicit canonicalization command when $PATH contains no empty fields.
299 if test "${PATH_SEPARATOR+set}" != set; then
301 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
302 chmod +x "$tmp"/conf.sh
303 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
310 if test "$PATH_SEPARATOR" = ";"; then
311 # On Windows, programs are searched in "." before $PATH.
314 # On Unix, we have to convert empty PATH elements to ".".
318 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
323 IFS="$PATH_SEPARATOR"
327 if test -x "$d/$0" && test ! -d "$d/$0"; then
328 self_abspathname="$d/$0"
333 if test -z "$self_abspathname"; then
334 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
338 while test -h "$self_abspathname"; do
339 # Resolve symbolic link.
340 linkval=`func_readlink "$self_abspathname"`
341 test -n "$linkval" || break
343 /* ) self_abspathname="$linkval" ;;
344 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
347 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
351 # creates a temporary directory.
353 # - tmp pathname of freshly created temporary directory
356 # Use the environment variable TMPDIR, falling back to /tmp. This allows
357 # users to specify a different temporary directory, for example, if their
358 # /tmp is filled up or too small.
361 # Use the mktemp program if available. If not available, hide the error
363 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
364 test -n "$tmp" && test -d "$tmp"
367 # Use a simple mkdir command. It is guaranteed to fail if the directory
368 # already exists. $RANDOM is bash specific and expands to empty in shells
369 # other than bash, ksh and zsh. Its use does not increase security;
370 # rather, it minimizes the probability of failure in a very cluttered /tmp
372 tmp=$TMPDIR/gl$$-$RANDOM
373 (umask 077 && mkdir "$tmp")
376 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
381 # func_append var value
382 # appends the given value to the shell variable var.
383 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
384 # Use bash's += operator. It reduces complexity of appending repeatedly to
385 # a single variable from O(n^2) to O(n).
393 eval "$1=\"\$$1\$2\""
397 # func_fatal_error message
398 # outputs to stderr a fatal error message, and terminates the program.
401 echo "gnulib-tool: *** $1" 1>&2
402 echo "gnulib-tool: *** Stop." 1>&2
406 # func_readlink SYMLINK
407 # outputs the target of the given symlink.
408 if (type -p readlink) > /dev/null 2>&1; then
411 # Use the readlink program from GNU coreutils.
417 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
418 # would do the wrong thing if the link target contains " -> ".
419 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
423 # func_relativize DIR1 DIR2
424 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
426 # - DIR1 relative pathname, relative to the current directory
427 # - DIR2 relative pathname, relative to the current directory
429 # - reldir relative pathname of DIR2, relative to DIR1
435 sed_first='s,^\([^/]*\)/.*$,\1,'
436 sed_rest='s,^[^/]*/*,,'
437 sed_last='s,^.*/\([^/]*\)$,\1,'
438 sed_butlast='s,/*[^/]*$,,'
439 while test -n "$dir1"; do
440 first=`echo "$dir1" | sed -e "$sed_first"`
441 if test "$first" != "."; then
442 if test "$first" = ".."; then
443 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
444 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
446 first2=`echo "$dir2" | sed -e "$sed_first"`
447 if test "$first2" = "$first"; then
448 dir2=`echo "$dir2" | sed -e "$sed_rest"`
452 dir0="$dir0"/"$first"
455 dir1=`echo "$dir1" | sed -e "$sed_rest"`
460 # func_relconcat DIR1 DIR2
461 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
463 # - DIR1 relative pathname, relative to the current directory
464 # - DIR2 relative pathname, relative to DIR1
466 # - relconcat DIR1/DIR2, relative to the current directory
471 sed_first='s,^\([^/]*\)/.*$,\1,'
472 sed_rest='s,^[^/]*/*,,'
473 sed_last='s,^.*/\([^/]*\)$,\1,'
474 sed_butlast='s,/*[^/]*$,,'
476 first=`echo "$dir2" | sed -e "$sed_first"`
477 if test "$first" = "."; then
478 dir2=`echo "$dir2" | sed -e "$sed_rest"`
479 if test -z "$dir2"; then
484 last=`echo "$dir1" | sed -e "$sed_last"`
485 while test "$last" = "."; do
486 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
487 last=`echo "$dir1" | sed -e "$sed_last"`
489 if test -z "$dir1"; then
493 if test "$first" = ".."; then
494 if test "$last" = ".."; then
495 relconcat="$dir1/$dir2"
498 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
499 dir2=`echo "$dir2" | sed -e "$sed_rest"`
500 if test -z "$dir1"; then
504 if test -z "$dir2"; then
509 relconcat="$dir1/$dir2"
517 # Like ln -s, except that SRC is given relative to the current directory (or
518 # absolute), not given relative to the directory of DEST.
524 *) # SRC is relative.
527 ln -s "`pwd`/$1" "$2" ;;
528 *) # DEST is relative too.
529 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
530 test -n "$ln_destdir" || ln_destdir="."
531 func_relativize "$ln_destdir" "$1"
539 # func_ln_if_changed SRC DEST
540 # Like func_ln, but avoids munging timestamps if the link is correct.
541 func_ln_if_changed ()
543 if test $# -ne 2; then
544 echo "usage: func_ln_if_changed SRC DEST" >&2
546 ln_target=`func_readlink "$2"`
547 if test -h "$2" && test "$1" = "$ln_target"; then
556 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
557 # writes into a pipe with no readers, i.e. a pipe where all readers have
558 # already closed their file descriptor that read from it or exited entirely.
559 # The default behaviour is to terminate the current process without an error
561 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
562 # terminate the current process with an error message.
563 # This function should be called at the beginning of a command that only
564 # produces output to stdout (i.e. no side effects!), when the command that
565 # will read from this pipe might prematurely exit or close its standard input
567 if test -n "$BASH_VERSION"; then
568 # The problem has only been reported with bash.
569 # Note that Solaris sh does not understand "trap - SIGPIPE".
570 func_reset_sigpipe ()
575 func_reset_sigpipe ()
581 # Ensure an 'echo' command that does not interpret backslashes.
583 # echo '\n' | wc -l prints 1 when OK, 2 when KO
584 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
585 # This problem is a weird heritage from SVR4. BSD got it right (except that
586 # BSD echo interprets '-n' as an option, which is also not desirable).
587 # Nowadays the problem occurs in 4 situations:
588 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
589 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
590 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
591 # - in zsh, when sh-emulation is not set,
592 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
593 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
594 # - in Solaris /bin/sh and OSF/1 /bin/sh.
595 # We try the following workarounds:
596 # - for all: respawn using $CONFIG_SHELL if that is set and works.
597 # - for bash >= 2.04: unset the shell option xpg_echo.
598 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
599 # - for bash < 2.0: define echo to a function that uses cat of a here document.
600 # - for zsh: turn sh-emulation on.
601 # - for ksh: alias echo to 'print -r'.
602 # - for ksh: alias echo to a function that uses cat of a here document.
603 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
604 # the ksh workaround.
605 # - otherwise: respawn using /bin/sh and rely on the workarounds.
606 # When respawning, we pass --no-reexec as first argument, so as to avoid
607 # turning this script into a fork bomb in unlucky situations.
609 if echo '\t' | grep t > /dev/null; then
610 have_echo=yes # Lucky!
612 # Try the workarounds.
613 # Respawn using $CONFIG_SHELL if that is set and works.
614 if test -z "$have_echo" \
615 && test "X$1" != "X--no-reexec" \
616 && test -n "$CONFIG_SHELL" \
617 && test -f "$CONFIG_SHELL" \
618 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
619 exec $CONFIG_SHELL "$0" --no-reexec "$@"
622 # For bash >= 2.04: unset the shell option xpg_echo.
623 if test -z "$have_echo" \
624 && test -n "$BASH_VERSION" \
625 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
629 # For bash >= 2.0: define echo to a function that uses the printf built-in.
630 # For bash < 2.0: define echo to a function that uses cat of a here document.
631 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
632 if test -z "$have_echo" \
633 && test -n "$BASH_VERSION"; then \
634 if type printf 2>/dev/null | grep / > /dev/null; then
635 # 'printf' is not a shell built-in.
643 # 'printf' is a shell built-in.
649 if echo '\t' | grep t > /dev/null; then
653 # For zsh: turn sh-emulation on.
654 if test -z "$have_echo" \
655 && test -n "$ZSH_VERSION" \
656 && (emulate sh) >/dev/null 2>&1; then
659 # For ksh: alias echo to 'print -r'.
660 if test -z "$have_echo" \
661 && (type print) >/dev/null 2>&1; then
662 # A 'print' command exists.
663 if type print 2>/dev/null | grep / > /dev/null; then
666 # 'print' is a shell built-in.
667 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
668 # 'print' is the ksh shell built-in.
669 alias echo='print -r'
673 if test -z "$have_echo" \
674 && echo '\t' | grep t > /dev/null; then
677 # For ksh: alias echo to a function that uses cat of a here document.
678 # The ksh manual page says:
679 # "Aliasing is performed when scripts are read, not while they are executed.
680 # Therefore, for an alias to take effect, the alias definition command has
681 # to be executed before the command which references the alias is read."
682 # Because of this, we have to play strange tricks with have_echo, to ensure
683 # that the top-level statement containing the test starts after the 'alias'
685 if test -z "$have_echo"; then
692 alias echo=bsd_echo 2>/dev/null
694 if test -z "$have_echo" \
695 && echo '\t' | grep t > /dev/null; then
698 if test -z "$have_echo"; then
699 unalias echo 2>/dev/null
701 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
702 if test -z "$have_echo" \
703 && test "X$1" != "X--no-reexec" \
704 && test -f /bin/ksh; then
705 exec /bin/ksh "$0" --no-reexec "$@"
708 # Otherwise: respawn using /bin/sh.
709 if test -z "$have_echo" \
710 && test "X$1" != "X--no-reexec" \
711 && test -f /bin/sh; then
712 exec /bin/sh "$0" --no-reexec "$@"
715 if test -z "$have_echo"; then
716 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
718 if echo '\t' | grep t > /dev/null; then
721 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
723 if test "X$1" = "X--no-reexec"; then
727 # Command-line option processing.
728 # Removes the OPTIONS from the arguments. Sets the variables:
729 # - mode list or import or create-testdir or create-megatestdir
730 # - destdir from --dir
731 # - local_gnulib_dir from --local-dir
732 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
733 # - libname, supplied_libname from --lib
734 # - sourcebase from --source-base
735 # - m4base from --m4-base
736 # - pobase from --po-base
737 # - docbase from --doc-base
738 # - testsbase from --tests-base
739 # - auxdir from --aux-dir
740 # - inctests true if --with-tests was given, blank otherwise
741 # - avoidlist list of modules to avoid, from --avoid
742 # - lgpl yes or a number if --lgpl was given, blank otherwise
743 # - makefile_name from --makefile-name
744 # - libtool true if --libtool was given, false if --no-libtool was
745 # given, blank otherwise
746 # - macro_prefix from --macro-prefix
747 # - po_domain from --po-domain
748 # - vc_files true if --vc-files was given, false if --no-vc-files was
749 # given, blank otherwise
750 # - autoconf_minversion minimum supported autoconf version
751 # - do_changelog false if --no-changelog was given, : otherwise
752 # - doit : if actions shall be executed, false if only to be printed
753 # - symbolic true if --symlink or --more-symlinks was given, blank
755 # - lsymbolic true if --local-symlink was given, blank otherwise
756 # - do_copyrights blank if --more-symlinks was given, true otherwise
786 while test $# -gt 0; do
791 --import | --impor | --impo | --imp | --im | --i )
794 --update | --updat | --upda | --upd | --up | --u )
797 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
800 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
801 mode=create-megatestdir
803 --test | --tes | --te | --t )
806 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
810 mode=`echo "X$1" | sed -e 's/^X--//'`
815 func_fatal_error "missing argument for --dir"
820 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
825 func_fatal_error "missing argument for --local-dir"
830 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
832 --verbose | --verbos | --verbo | --verb )
833 verbose=`expr $verbose + 1`
835 --quiet | --quie | --qui | --qu | --q )
836 verbose=`expr $verbose - 1`
841 func_fatal_error "missing argument for --lib"
844 supplied_libname=true
847 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
848 supplied_libname=true
853 func_fatal_error "missing argument for --source-base"
858 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
863 func_fatal_error "missing argument for --m4-base"
868 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
873 func_fatal_error "missing argument for --po-base"
878 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
883 func_fatal_error "missing argument for --doc-base"
888 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
893 func_fatal_error "missing argument for --tests-base"
898 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
903 func_fatal_error "missing argument for --aux-dir"
908 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
916 func_fatal_error "missing argument for --avoid"
918 func_append avoidlist " $1"
921 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
922 func_append avoidlist " $arg"
928 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
931 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
938 func_fatal_error "missing argument for --makefile-name"
943 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
954 func_fatal_error "missing argument for --macro-prefix"
959 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
964 func_fatal_error "missing argument for --po-domain"
969 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
977 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
983 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
986 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
989 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
993 --help | --hel | --he | --h )
996 --version | --versio | --versi | --vers )
1000 # Stop option processing
1004 echo "gnulib-tool: unknown option $1" 1>&2
1005 echo "Try 'gnulib-tool --help' for more information." 1>&2
1012 if test "$mode" = update; then
1013 if test $# != 0; then
1014 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1015 echo "Try 'gnulib-tool --help' for more information." 1>&2
1016 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1017 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1020 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1021 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1022 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1023 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
1024 || test -n "$makefile_name" || test -n "$macro_prefix" \
1025 || test -n "$po_domain" || test -n "$vc_files"; then
1026 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1027 echo "Try 'gnulib-tool --help' for more information." 1>&2
1028 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1029 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1034 if test -n "$pobase" && test -z "$po_domain"; then
1035 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1036 echo "Try 'gnulib-tool --help' for more information." 1>&2
1039 if test -z "$pobase" && test -n "$po_domain"; then
1040 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1043 # Determine the minimum supported autoconf version from the project's
1045 DEFAULT_AUTOCONF_MINVERSION="2.59"
1046 autoconf_minversion=
1048 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1049 if test -f "$destdir"/configure.ac; then
1050 configure_ac="$destdir/configure.ac"
1052 if test -f "$destdir"/configure.in; then
1053 configure_ac="$destdir/configure.in"
1057 if test -f configure.ac; then
1058 configure_ac="configure.ac"
1060 if test -f configure.in; then
1061 configure_ac="configure.in"
1065 if test -n "$configure_ac"; then
1066 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1067 # because when some m4 files are omitted from a CVS repository,
1068 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1069 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1070 # autom4te: m4 failed with exit status: 1
1077 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1079 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1080 if test -n "$prereqs"; then
1081 autoconf_minversion=`
1082 for version in $prereqs; do echo $version; done |
1083 LC_ALL=C sort -nru | sed 1q
1087 if test -z "$autoconf_minversion"; then
1088 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1090 case "$autoconf_minversion" in
1091 1.* | 2.[0-4]* | 2.5[0-8]*)
1092 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1095 # Remove trailing slashes from the directory names. This is necessary for
1096 # m4base (to avoid an error in func_import) and optional for the others.
1097 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1098 case "$local_gnulib_dir" in
1099 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1101 case "$sourcebase" in
1102 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1105 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1108 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1111 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1113 case "$testsbase" in
1114 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1117 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1123 trap 'exit_status=$?
1124 if test "$signal" != 0; then
1125 echo "caught signal $signal" >&2
1128 exit $exit_status' 0
1129 for signal in 1 2 3 13 15; do
1130 trap '{ signal='$signal'; func_exit 1; }' $signal
1134 # func_lookup_file file
1135 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1138 # - local_gnulib_dir from --local-dir
1140 # - lookedup_file name of the merged (combined) file
1141 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1145 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1146 lookedup_file="$local_gnulib_dir/$lkfile"
1149 if test -f "$gnulib_dir/$lkfile"; then
1150 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1151 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1152 rm -f "$tmp/$lkbase"
1153 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1154 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1155 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1156 lookedup_file="$tmp/$lkbase"
1159 lookedup_file="$gnulib_dir/$lkfile"
1163 func_fatal_error "file $gnulib_dir/$lkfile not found"
1170 # - local_gnulib_dir from --local-dir
1173 # Filter out metainformation files like README, which are not modules.
1174 # Filter out unit test modules; they can be retrieved through
1175 # --extract-tests-module if desired.
1177 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1178 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1179 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1182 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1183 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1184 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1185 -e '/^README$/d' -e '/\/README$/d' \
1186 -e '/^TEMPLATE$/d' \
1187 -e '/^TEMPLATE-EXTENDED$/d' \
1188 -e '/^TEMPLATE-TESTS$/d' \
1191 | sed -e '/-tests$/d' \
1195 # func_verify_module
1196 # verifies a module name
1198 # - local_gnulib_dir from --local-dir
1199 # - module module name argument
1200 func_verify_module ()
1202 if { test -f "$gnulib_dir/modules/$module" \
1203 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1204 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1205 && test "CVS" != "$module" \
1206 && test "ChangeLog" != "$module" \
1207 && test "COPYING" != "$module" \
1208 && test "README" != "$module" \
1209 && test "TEMPLATE" != "$module" \
1210 && test "TEMPLATE-EXTENDED" != "$module" \
1211 && test "TEMPLATE-TESTS" != "$module"; then
1212 # OK, $module is a correct module name.
1213 # Verify that building the module description with 'patch' succeeds.
1214 func_lookup_file "modules/$module"
1216 echo "gnulib-tool: module $module doesn't exist" 1>&2
1221 # func_verify_nontests_module
1222 # verifies a module name, excluding tests modules
1224 # - local_gnulib_dir from --local-dir
1225 # - module module name argument
1226 func_verify_nontests_module ()
1229 *-tests ) module= ;;
1230 * ) func_verify_module ;;
1234 # func_verify_tests_module
1235 # verifies a module name, considering only tests modules
1237 # - local_gnulib_dir from --local-dir
1238 # - module module name argument
1239 func_verify_tests_module ()
1242 *-tests ) func_verify_module ;;
1247 sed_extract_prog=':[ ]*$/ {
1250 s/^Description:[ ]*$//
1253 s/^Depends-on:[ ]*$//
1254 s/^configure\.ac-early:[ ]*$//
1255 s/^configure\.ac:[ ]*$//
1256 s/^Makefile\.am:[ ]*$//
1260 s/^Maintainer:[ ]*$//
1267 # func_get_description module
1269 # - local_gnulib_dir from --local-dir
1270 func_get_description ()
1272 func_lookup_file "modules/$1"
1273 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1276 # func_get_notice module
1278 # - local_gnulib_dir from --local-dir
1281 func_lookup_file "modules/$1"
1282 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1285 # func_get_filelist module
1287 # - local_gnulib_dir from --local-dir
1288 func_get_filelist ()
1290 func_lookup_file "modules/$1"
1291 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1292 echo m4/gnulib-common.m4
1293 case "$autoconf_minversion" in
1300 # func_get_dependencies module
1302 # - local_gnulib_dir from --local-dir
1303 func_get_dependencies ()
1305 # ${module}-tests always implicitly depends on ${module}.
1306 echo "$1" | sed -n -e 's/-tests$//p'
1307 # Then the explicit dependencies listed in the module description.
1308 func_lookup_file "modules/$1"
1309 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1312 # func_get_autoconf_early_snippet module
1314 # - local_gnulib_dir from --local-dir
1315 func_get_autoconf_early_snippet ()
1317 func_lookup_file "modules/$1"
1318 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1321 # func_get_autoconf_snippet module
1323 # - local_gnulib_dir from --local-dir
1324 func_get_autoconf_snippet ()
1326 func_lookup_file "modules/$1"
1327 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1330 # func_get_automake_snippet module
1332 # - local_gnulib_dir from --local-dir
1333 func_get_automake_snippet ()
1335 func_lookup_file "modules/$1"
1336 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1339 # *-tests module live in tests/, not lib/.
1340 # Synthesize an EXTRA_DIST augmentation.
1341 all_files=`func_get_filelist $1`
1342 tests_files=`for f in $all_files; do \
1344 tests/*) echo $f ;; \
1346 done | sed -e 's,^tests/,,'`
1347 extra_files="$tests_files"
1348 if test -n "$extra_files"; then
1349 echo "EXTRA_DIST +=" $extra_files
1354 # Synthesize an EXTRA_DIST augmentation.
1355 sed_combine_lines='/\\$/{
1362 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1363 already_mentioned_files=` \
1364 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1365 | sed -e "$sed_combine_lines" \
1366 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1367 all_files=`func_get_filelist $1`
1368 lib_files=`for f in $all_files; do \
1372 done | sed -e 's,^lib/,,'`
1373 # Remove $already_mentioned_files from $lib_files.
1374 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1375 extra_files=`func_reset_sigpipe; \
1376 for f in $already_mentioned_files; do echo $f; done \
1377 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1378 if test -n "$extra_files"; then
1379 echo "EXTRA_DIST +=" $extra_files
1382 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1383 # This is necessary so that automake can generate the right list of
1385 # A possible approach would be to use autom4te --trace of the redefined
1386 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1387 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1388 # inside autoconf's built-in macros are not missed).
1389 # But it's simpler and more robust to do it here, based on the file list.
1390 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1391 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1392 # automake will generate a useless dependency; this is harmless.
1394 relocatable-prog-wrapper) ;;
1396 sed_extract_c_files='/\.c$/p'
1397 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1398 if test -n "$extra_files"; then
1399 echo "EXTRA_lib_SOURCES +=" $extra_files
1404 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1405 buildaux_files=`for f in $all_files; do \
1407 build-aux/*) echo $f ;; \
1409 done | sed -e 's,^build-aux/,,'`
1410 if test -n "$buildaux_files"; then
1411 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1412 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1415 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1416 top_files=`for f in $all_files; do \
1420 done | sed -e 's,^top/,,'`
1421 if test -n "$top_files"; then
1422 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1423 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1430 # func_get_include_directive module
1432 # - local_gnulib_dir from --local-dir
1433 func_get_include_directive ()
1435 func_lookup_file "modules/$1"
1436 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1437 sed -e 's/^\(["<]\)/#include \1/'
1440 # func_get_link_directive module
1442 # - local_gnulib_dir from --local-dir
1443 func_get_link_directive ()
1445 func_lookup_file "modules/$1"
1446 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1449 # func_get_license module
1451 # - local_gnulib_dir from --local-dir
1454 func_lookup_file "modules/$1"
1455 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1456 # The default is GPL.
1458 } | sed -e 's,^ *$,,' | sed -e 1q
1461 # func_get_maintainer module
1463 # - local_gnulib_dir from --local-dir
1464 func_get_maintainer ()
1466 func_lookup_file "modules/$1"
1467 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1470 # func_get_tests_module module
1472 # - local_gnulib_dir from --local-dir
1473 func_get_tests_module ()
1475 # The naming convention for tests modules is hardwired: ${module}-tests.
1476 if test -f "$gnulib_dir/modules/$1"-tests \
1477 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1478 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1483 # func_acceptable module
1484 # tests whether a module is acceptable.
1486 # - avoidlist list of modules to avoid
1489 for avoid in $avoidlist; do
1490 if test "$avoid" = "$1"; then
1497 # func_modules_transitive_closure
1499 # - local_gnulib_dir from --local-dir
1500 # - modules list of specified modules
1501 # - inctests true if tests should be included, blank otherwise
1502 # - avoidlist list of modules to avoid
1503 # - tmp pathname of a temporary directory
1505 # - modules list of modules, including dependencies
1506 func_modules_transitive_closure ()
1508 # In order to process every module only once (for speed), process an "input
1509 # list" of modules, producing an "output list" of modules. During each round,
1510 # more modules can be queued in the input list. Once a module on the input
1511 # list has been processed, it is added to the "handled list", so we can avoid
1512 # to process it again.
1514 inmodules="$modules"
1516 while test -n "$inmodules"; do
1517 inmodules_this_round="$inmodules"
1518 inmodules= # Accumulator, queue for next round
1519 for module in $inmodules_this_round; do
1521 if test -n "$module"; then
1522 if func_acceptable $module; then
1523 func_append outmodules " $module"
1524 deps=`func_get_dependencies $module`
1525 # Duplicate dependencies are harmless, but Jim wants a warning.
1526 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1527 if test -n "$duplicated_deps"; then
1528 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1530 func_append inmodules " $deps"
1531 if test -n "$inctests"; then
1532 testsmodule=`func_get_tests_module $module`
1533 if test -n "$testsmodule"; then
1534 func_append inmodules " $testsmodule"
1540 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1541 # Remove $handledmodules from $inmodules.
1542 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1543 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1545 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1546 rm -f "$tmp"/queued-modules
1549 # func_modules_add_dummy
1551 # - local_gnulib_dir from --local-dir
1552 # - modules list of modules, including dependencies
1554 # - modules list of modules, including 'dummy' if needed
1555 func_modules_add_dummy ()
1558 sed_remove_backslash_newline=':a
1565 for module in $modules; do
1566 func_verify_nontests_module
1567 if test -n "$module"; then
1568 # Extract the value of "lib_SOURCES += ...".
1569 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1570 # Ignore .h files since they are not compiled.
1573 *) have_lib_SOURCES=yes ;;
1578 # Add the dummy module, to make sure the library will be non-empty.
1579 if test -z "$have_lib_SOURCES"; then
1580 if func_acceptable "dummy"; then
1581 func_append modules " dummy"
1586 # func_modules_notice
1588 # - local_gnulib_dir from --local-dir
1589 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1590 # - modules list of modules, including dependencies
1591 func_modules_notice ()
1593 if test $verbose -ge -1; then
1594 for module in $modules; do
1596 if test -n "$module"; then
1597 msg=`func_get_notice $module`
1598 if test -n "$msg"; then
1599 echo "Notice from module $module:"
1600 echo "$msg" | sed -e 's/^/ /'
1607 # func_modules_to_filelist
1609 # - local_gnulib_dir from --local-dir
1610 # - modules list of modules, including dependencies
1612 # - files list of files
1613 func_modules_to_filelist ()
1616 for module in $modules; do
1618 if test -n "$module"; then
1619 fs=`func_get_filelist $module`
1620 func_append files " $fs"
1623 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1626 # func_execute_command command [args...]
1627 # Executes a command.
1628 # Uses also the variables
1629 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1630 func_execute_command ()
1632 if test $verbose -ge 0; then
1636 # Commands like automake produce output to stderr even when they succeed.
1637 # Turn this output off if the command succeeds.
1638 "$@" > "$tmp"/cmdout 2>&1
1640 if test $cmdret = 0; then
1644 cat "$tmp"/cmdout 1>&2
1651 # func_emit_lib_Makefile_am
1652 # emits the contents of library makefile to standard output.
1654 # - local_gnulib_dir from --local-dir
1655 # - modules list of modules, including dependencies
1656 # - libname library name
1657 # - pobase directory relative to destdir where to place *.po files
1658 # - auxdir directory relative to destdir where to place build aux files
1659 # - makefile_name from --makefile-name
1660 # - libtool true if libtool will be used, false or blank otherwise
1661 # - macro_prefix prefix of gl_LIBOBJS macros to use
1662 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1663 # - actioncmd (optional) command that will reproduce this invocation
1664 # - for_test true if creating a package for testing, false otherwise
1666 # - uses_subdirs nonempty if object files in subdirs exist
1667 func_emit_lib_Makefile_am ()
1669 # When creating an includable Makefile.am snippet, augment variables with
1670 # += instead of assigning them.
1671 if test -n "$makefile_name"; then
1676 if test "$libtool" = true; then
1679 sed_eliminate_LDFLAGS="$sed_noop"
1683 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1686 # When creating a package for testing: Attempt to provoke failures,
1687 # especially link errors, already during "make" rather than during
1688 # "make check", because "make check" is not possible in a cross-compiling
1689 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1690 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1692 sed_transform_check_PROGRAMS="$sed_noop"
1694 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1695 echo "## Process this file with automake to produce Makefile.in."
1696 func_emit_copyright_notice
1697 if test -n "$actioncmd"; then
1698 echo "# Reproduce by: $actioncmd"
1703 for module in $modules; do
1704 func_verify_nontests_module
1705 if test -n "$module"; then
1707 func_get_automake_snippet "$module" |
1708 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1709 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1710 -e "$sed_eliminate_LDFLAGS" \
1711 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1712 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1713 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1714 -e "$sed_transform_check_PROGRAMS"
1715 if test "$module" = 'alloca'; then
1716 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1717 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1720 # Skip the contents if it's entirely empty.
1721 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1722 echo "## begin gnulib module $module"
1725 echo "## end gnulib module $module"
1729 # Test whether there are some source files in subdirectories.
1730 for f in `func_get_filelist "$module"`; do
1732 lib/*/*.c) uses_subdirs=yes ;;
1738 if test -z "$makefile_name"; then
1739 # If there are source files in subdirectories, prevent collision of the
1740 # object files (example: hash.c and libxml/hash.c).
1742 if test -n "$uses_subdirs"; then
1743 subdir_options=' subdir-objects'
1745 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1748 if test -z "$makefile_name"; then
1749 echo "noinst_HEADERS ="
1750 echo "noinst_LIBRARIES ="
1751 echo "noinst_LTLIBRARIES ="
1752 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1753 # if you specify pkgdata_DATA to empty. This is a workaround.
1754 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1755 echo "pkgdata_DATA ="
1758 echo "BUILT_SOURCES ="
1761 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1762 if test -z "$makefile_name"; then
1763 echo "MOSTLYCLEANDIRS ="
1765 echo "DISTCLEANFILES ="
1766 echo "MAINTAINERCLEANFILES ="
1768 echo "AM_CPPFLAGS ="
1771 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1772 # One of the snippets already specifies an installation location for the
1773 # library. Don't confuse automake by saying it should not be installed.
1776 # By default, the generated library should not be installed.
1777 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1780 echo "${libname}_${libext}_SOURCES ="
1781 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1782 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
1783 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1784 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1785 echo "EXTRA_${libname}_${libext}_SOURCES ="
1786 if test "$libtool" = true; then
1787 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1790 if test -n "$pobase"; then
1791 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1794 cat allsnippets.tmp \
1795 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1797 echo "mostlyclean-local: mostlyclean-generic"
1798 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1799 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1800 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1804 rm -f allsnippets.tmp
1807 # func_emit_po_Makevars
1808 # emits the contents of po/ makefile parameterization to standard output.
1810 # - local_gnulib_dir from --local-dir
1811 # - sourcebase directory relative to destdir where to place source code
1812 # - pobase directory relative to destdir where to place *.po files
1813 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1814 func_emit_po_Makevars ()
1816 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1817 func_emit_copyright_notice
1819 echo "# Usually the message domain is the same as the package name."
1820 echo "# But here it has a '-gnulib' suffix."
1821 echo "DOMAIN = ${po_domain}-gnulib"
1823 echo "# These two variables depend on the location of this directory."
1824 echo "subdir = ${pobase}"
1825 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1828 # These options get passed to xgettext.
1829 XGETTEXT_OPTIONS = \
1830 --keyword=_ --flag=_:1:pass-c-format \
1831 --keyword=N_ --flag=N_:1:pass-c-format \
1832 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1833 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1834 --flag=error:3:c-format --flag=error_at_line:5:c-format
1836 # This is the copyright holder that gets inserted into the header of the
1837 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1838 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1840 # This is the email address or URL to which the translators shall report
1841 # bugs in the untranslated strings:
1842 # - Strings which are not entire sentences, see the maintainer guidelines
1843 # in the GNU gettext documentation, section 'Preparing Strings'.
1844 # - Strings which use unclear terms or require additional context to be
1846 # - Strings which make invalid assumptions about notation of date, time or
1848 # - Pluralisation problems.
1849 # - Incorrect English spelling.
1850 # - Incorrect formatting.
1851 # It can be your email address, or a mailing list address where translators
1852 # can write to without being subscribed, or the URL of a web page through
1853 # which the translators can contact you.
1854 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1856 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1857 # message catalogs shall be used. It is usually empty.
1858 EXTRA_LOCALE_CATEGORIES =
1860 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1861 # context. Possible values are "yes" and "no". Set this to yes if the
1862 # package uses functions taking also a message context, like pgettext(), or
1863 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1868 # func_emit_po_POTFILES_in
1869 # emits the file list to be passed to xgettext to standard output.
1871 # - local_gnulib_dir from --local-dir
1872 # - sourcebase directory relative to destdir where to place source code
1873 # - files list of new files
1874 func_emit_po_POTFILES_in ()
1876 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1877 func_emit_copyright_notice
1879 echo "# List of files which contain translatable strings."
1880 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1883 # func_emit_tests_Makefile_am
1884 # emits the contents of tests makefile to standard output.
1886 # - local_gnulib_dir from --local-dir
1887 # - modules list of modules, including dependencies
1888 # - libname library name
1889 # - auxdir directory relative to destdir where to place build aux files
1890 # - makefile_name from --makefile-name
1891 # - libtool true if libtool will be used, false or blank otherwise
1892 # - sourcebase relative directory containing lib source code
1893 # - m4base relative directory containing autoconf macros
1894 # - testsbase relative directory containing unit test code
1895 # - macro_prefix prefix of gl_LIBOBJS macros to use
1896 # - for_test true if creating a package for testing, false otherwise
1897 # - use_libtests true if a libtests.a should be built, false otherwise
1899 # - uses_subdirs nonempty if object files in subdirs exist
1900 func_emit_tests_Makefile_am ()
1902 if test "$libtool" = true; then
1904 sed_eliminate_LDFLAGS="$sed_noop"
1907 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1910 # When creating a package for testing: Attempt to provoke failures,
1911 # especially link errors, already during "make" rather than during
1912 # "make check", because "make check" is not possible in a cross-compiling
1913 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1914 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1916 sed_transform_check_PROGRAMS="$sed_noop"
1918 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1919 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1920 echo "## Process this file with automake to produce Makefile.in."
1921 func_emit_copyright_notice
1925 for module in $modules; do
1927 func_verify_tests_module
1931 if test -n "$module"; then
1933 func_get_automake_snippet "$module" |
1934 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1935 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1936 -e "$sed_eliminate_LDFLAGS" \
1937 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
1938 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1939 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1940 -e "$sed_transform_check_PROGRAMS"
1941 if $use_libtests && test "$module" = 'alloca'; then
1942 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
1943 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1946 # Skip the contents if it's entirely empty.
1947 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1948 echo "## begin gnulib module $module"
1951 echo "## end gnulib module $module"
1955 # Test whether there are some source files in subdirectories.
1956 for f in `func_get_filelist "$module"`; do
1958 lib/*/*.c | tests/*/*.c) uses_subdirs=yes ;;
1964 # Generate dependencies here, since it eases the debugging of test failures.
1965 # If there are source files in subdirectories, prevent collision of the
1966 # object files (example: hash.c and libxml/hash.c).
1968 if test -n "$uses_subdirs"; then
1969 subdir_options=' subdir-objects'
1971 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
1974 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1977 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1978 # variable is needed to avoid an error from automake:
1979 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1982 echo "TESTS_ENVIRONMENT ="
1983 echo "noinst_PROGRAMS ="
1984 if ! $for_test; then
1985 echo "check_PROGRAMS ="
1987 echo "noinst_HEADERS ="
1988 echo "noinst_LIBRARIES ="
1989 if $use_libtests; then
1991 echo "noinst_LIBRARIES += libtests.a"
1993 echo "check_LIBRARIES = libtests.a"
1996 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1997 # if you specify pkgdata_DATA to empty. This is a workaround.
1998 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1999 echo "pkgdata_DATA ="
2002 echo "BUILT_SOURCES ="
2004 echo "MOSTLYCLEANFILES = core *.stackdump"
2005 echo "MOSTLYCLEANDIRS ="
2007 echo "DISTCLEANFILES ="
2008 echo "MAINTAINERCLEANFILES ="
2010 echo "AM_CPPFLAGS = \\"
2011 echo " -I. -I\$(srcdir) \\"
2012 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2013 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2015 local_ldadd_before=''
2016 local_ldadd_after=''
2017 if $use_libtests; then
2018 # All test programs need to be linked with libtests.a.
2019 # It needs to be passed to the linker before ${libname}.${libext}, since
2020 # the tests-related modules depend on the main modules.
2021 # It also needs to be passed to the linker after ${libname}.${libext}
2022 # because the latter might contain incomplete modules (such as the 'error'
2023 # module whose dependency to 'progname' is voluntarily omitted).
2024 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2026 local_ldadd_before=' libtests.a'
2027 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2029 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2031 if $use_libtests; then
2032 echo "libtests_a_SOURCES ="
2033 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2034 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2035 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2036 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2037 echo "EXTRA_libtests_a_SOURCES ="
2038 # The circular dependency in LDADD requires this.
2039 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2042 cat allsnippets.tmp \
2043 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2044 echo "# Clean up after Solaris cc."
2046 echo " rm -rf SunWS_cache"
2048 echo "mostlyclean-local: mostlyclean-generic"
2049 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2050 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2051 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2055 rm -f allsnippets.tmp
2058 # func_emit_initmacro_start macro_prefix
2059 # emits the first few statements of the gl_INIT macro to standard output.
2060 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2061 func_emit_initmacro_start ()
2063 macro_prefix_arg="$1"
2064 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2065 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2066 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2067 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2069 # Furthermore it avoids an automake error like this when a Makefile.am
2070 # that uses pieces of gnulib also uses $(LIBOBJ):
2071 # automatically discovered file `error.c' should not be explicitly mentioned
2072 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2073 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2074 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2075 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2076 # automatically discovered file `error.c' should not be explicitly mentioned
2077 # We let automake know about the files to be distributed through the
2078 # EXTRA_lib_SOURCES variable.
2079 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2080 # Create data variables for checking the presence of files that are mentioned
2081 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2082 # because we want the check to happen when the configure file is created,
2083 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2084 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2085 # in which to expect them.
2086 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2087 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2091 # func_emit_initmacro_end macro_prefix
2092 # emits the last few statements of the gl_INIT macro to standard output.
2093 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2094 func_emit_initmacro_end ()
2096 macro_prefix_arg="$1"
2097 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2098 # The check is performed only when autoconf is run from the directory where
2099 # the configure.ac resides; if it is run from a different directory, the
2101 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2102 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2103 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2104 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2105 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2109 echo " m4_if(m4_sysval, [0], [],"
2110 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2112 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2113 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2114 echo " m4_popdef([AC_LIBSOURCES])"
2115 echo " m4_popdef([AC_REPLACE_FUNCS])"
2116 echo " m4_popdef([AC_LIBOBJ])"
2117 echo " AC_CONFIG_COMMANDS_PRE(["
2118 echo " ${macro_prefix_arg}_libobjs="
2119 echo " ${macro_prefix_arg}_ltlibobjs="
2120 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2121 echo " # Remove the extension."
2122 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2123 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2124 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2125 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2128 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2129 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2133 # func_emit_initmacro_done macro_prefix sourcebase
2134 # emits a few statements after the gl_INIT macro to standard output.
2135 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2136 # - sourcebase directory relative to destdir where to place source code
2137 func_emit_initmacro_done ()
2139 macro_prefix_arg="$1"
2142 echo "# Like AC_LIBOBJ, except that the module name goes"
2143 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2144 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2145 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2146 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2149 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2150 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2151 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2152 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2153 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2156 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2157 echo "# expected is derived from the gnulib-tool parameterization,"
2158 echo "# and alloca is special cased (for the alloca-opt module)."
2159 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2160 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2161 echo " m4_foreach([_gl_NAME], [\$1], ["
2162 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2163 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2164 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2170 # func_import modules
2171 # Uses also the variables
2172 # - destdir target directory
2173 # - local_gnulib_dir from --local-dir
2174 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2175 # - libname library name
2176 # - sourcebase directory relative to destdir where to place source code
2177 # - m4base directory relative to destdir where to place *.m4 macros
2178 # - pobase directory relative to destdir where to place *.po files
2179 # - docbase directory relative to destdir where to place doc files
2180 # - testsbase directory relative to destdir where to place unit test code
2181 # - auxdir directory relative to destdir where to place build aux files
2182 # - inctests true if --with-tests was given, blank otherwise
2183 # - avoidlist list of modules to avoid, from --avoid
2184 # - lgpl yes or a number if library's license shall be LGPL,
2186 # - makefile_name from --makefile-name
2187 # - libtool true if --libtool was given, false if --no-libtool was
2188 # given, blank otherwise
2189 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2190 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2191 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2192 # - vc_files true if --vc-files was given, false if --no-vc-files was
2193 # given, blank otherwise
2194 # - autoconf_minversion minimum supported autoconf version
2195 # - doit : if actions shall be executed, false if only to be printed
2196 # - symbolic true if files should be symlinked, copied otherwise
2197 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2199 # - do_copyrights true if copyright notices in files should be replaced,
2203 # Get the cached settings.
2204 cached_local_gnulib_dir=
2205 cached_specified_modules=
2215 cached_makefile_name=
2217 cached_macro_prefix=
2221 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2222 cached_libtool=false
2228 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2238 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2241 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2244 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2247 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2250 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2253 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2256 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2259 s,^.*$,cached_inctests=true,p
2262 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2265 s,^.*gl_LGPL([[ ]*\([^])]*\).*$,cached_lgpl="\1",p
2268 s,^.*$,cached_lgpl=yes,p
2270 /gl_MAKEFILE_NAME(/ {
2271 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2274 s,^.*$,cached_libtool=true,p
2276 /gl_MACRO_PREFIX(/ {
2277 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2280 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2283 s,^.*gl_VC_FILES([[ ]*\([^])]*\).*$,cached_vc_files="\1",p
2285 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2286 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2291 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2292 s,^.*$,cached_files=",p
2304 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2308 # Merge the cached settings with the specified ones.
2309 # The m4base must be the same as expected from the pathname.
2310 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2311 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2313 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2314 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2315 if test -z "$local_gnulib_dir"; then
2316 if test -n "$cached_local_gnulib_dir"; then
2319 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2321 case "$cached_local_gnulib_dir" in
2323 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2325 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2326 local_gnulib_dir="$relconcat" ;;
2331 # Append the cached and the specified module names. So that
2332 # "gnulib-tool --import foo" means to add the module foo.
2333 specified_modules="$cached_specified_modules $1"
2334 # Append the cached and the specified avoidlist. This is probably better
2335 # than dropping the cached one when --avoid is specified at least once.
2336 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2337 avoidlist=`echo $avoidlist`
2339 # The sourcebase defaults to the cached one.
2340 if test -z "$sourcebase"; then
2341 sourcebase="$cached_sourcebase"
2342 if test -z "$sourcebase"; then
2343 func_fatal_error "missing --source-base option"
2346 # The pobase defaults to the cached one.
2347 if test -z "$pobase"; then
2348 pobase="$cached_pobase"
2350 # The docbase defaults to the cached one.
2351 if test -z "$docbase"; then
2352 docbase="$cached_docbase"
2353 if test -z "$docbase"; then
2354 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."
2357 # The testsbase defaults to the cached one.
2358 if test -z "$testsbase"; then
2359 testsbase="$cached_testsbase"
2360 if test -z "$testsbase"; then
2361 func_fatal_error "missing --tests-base option"
2364 # Require the tests if specified either way.
2365 if test -z "$inctests"; then
2366 inctests="$cached_inctests"
2368 # The libname defaults to the cached one.
2369 if test -z "$supplied_libname"; then
2370 libname="$cached_libname"
2371 if test -z "$libname"; then
2372 func_fatal_error "missing --lib option"
2375 # Require LGPL if specified either way.
2376 if test -z "$lgpl"; then
2379 # The makefile_name defaults to the cached one.
2380 if test -z "$makefile_name"; then
2381 makefile_name="$cached_makefile_name"
2383 # Use libtool if specified either way, or if guessed.
2384 if test -z "$libtool"; then
2385 if test -n "$cached_m4base"; then
2386 libtool="$cached_libtool"
2388 libtool="$guessed_libtool"
2391 # The macro_prefix defaults to the cached one.
2392 if test -z "$macro_prefix"; then
2393 macro_prefix="$cached_macro_prefix"
2394 if test -z "$macro_prefix"; then
2395 func_fatal_error "missing --macro-prefix option"
2398 # The po_domain defaults to the cached one.
2399 if test -z "$po_domain"; then
2400 po_domain="$cached_po_domain"
2402 # The vc_files defaults to the cached one.
2403 if test -z "$vc_files"; then
2404 vc_files="$cached_vc_files"
2407 # Canonicalize the list of specified modules.
2408 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2410 # Determine final module list.
2411 modules="$specified_modules"
2412 func_modules_transitive_closure
2413 if test $verbose -ge 0; then
2414 echo "Module list with included dependencies:"
2415 echo "$modules" | sed -e 's/^/ /'
2417 final_modules="$modules"
2419 # Determine main module list and tests-related module list separately.
2420 # The main module list is the transitive closure of the specified modules,
2421 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2422 # is specified, it will consist only of LGPLed source.
2423 # The tests-related module list is the transitive closure of the specified
2424 # modules, including tests modules, minus the main module list. Its lib/*
2425 # sources (brought in through dependencies of *-tests modules) go into
2426 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2427 # Determine main module list.
2428 saved_inctests="$inctests"
2430 modules="$specified_modules"
2431 func_modules_transitive_closure
2432 main_modules="$modules"
2433 inctests="$saved_inctests"
2434 if test $verbose -ge 1; then
2435 echo "Main module list:"
2436 echo "$main_modules" | sed -e 's/^/ /'
2438 # Determine tests-related module list.
2439 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2440 testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2441 if test $verbose -ge 1; then
2442 echo "Tests-related module list:"
2443 echo "$testsrelated_modules" | sed -e 's/^/ /'
2446 # Add the dummy module to the main module list if needed.
2447 modules="$main_modules"
2448 func_modules_add_dummy
2449 main_modules="$modules"
2451 # Determine whether a $testsbase/libtests.a is needed.
2453 for module in $testsrelated_modules; do
2454 func_verify_nontests_module
2455 if test -n "$module"; then
2456 all_files=`func_get_filelist $module`
2457 lib_files=`for f in $all_files; do \
2461 done | sed -e 's,^lib/,,'`
2462 if test -n "$lib_files"; then
2469 # Add the dummy module to the tests-related module list if needed.
2470 if $use_libtests; then
2471 modules="$testsrelated_modules"
2472 func_modules_add_dummy
2473 testsrelated_modules="$modules"
2476 # If --lgpl, verify that the licenses of modules are compatible.
2477 if test -n "$lgpl"; then
2478 for module in $main_modules; do
2479 license=`func_get_license $module`
2481 'GPLed build tool') ;;
2482 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2488 *) func_fatal_error "incompatible license on module $module: $license" ;;
2494 *) func_fatal_error "incompatible license on module $module: $license" ;;
2497 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2504 # Show banner notice of every module.
2505 modules="$main_modules"
2508 # Determine script to apply to imported library files.
2509 sed_transform_lib_file=
2510 for module in $main_modules; do
2511 if test $module = config-h; then
2512 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2513 sed_transform_lib_file=$sed_transform_lib_file'
2514 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2519 sed_transform_main_lib_file="$sed_transform_lib_file"
2520 if test -n "$do_copyrights"; then
2521 if test -n "$lgpl"; then
2525 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2526 s/GNU General/GNU Lesser General/g
2530 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2531 s/GNU General/GNU Lesser General/g
2532 s/version [23]\([ ,]\)/version 2.1\1/g
2535 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2539 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2540 s/GNU Lesser General/GNU General/g
2541 s/GNU Library General/GNU General/g
2542 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2547 # Determine script to apply to library files that go into $testsbase/.
2548 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2549 if test -n "$do_copyrights"; then
2551 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2552 s/GNU Lesser General/GNU General/g
2553 s/GNU Library General/GNU General/g
2554 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2558 # Determine the final file lists.
2559 # They must be computed separately, because files in lib/* go into
2560 # $sourcebase/ if they are in the main file list but into $testsbase/
2561 # if they are in the tests-related file list. Furthermore lib/dummy.c
2563 # Determine final main file list.
2564 modules="$main_modules"
2565 func_modules_to_filelist
2567 # Determine final tests-related file list.
2568 modules="$testsrelated_modules"
2569 func_modules_to_filelist
2570 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2571 # Merge both file lists.
2572 sed_remove_empty_lines='/^$/d'
2573 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2574 if test $verbose -ge 0; then
2576 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2577 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2581 || func_fatal_error "refusing to do nothing"
2583 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2584 new_files="$files m4/gnulib-tool.m4"
2585 old_files="$cached_files"
2586 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2587 func_append old_files " m4/gnulib-tool.m4"
2590 sed_rewrite_old_files="\
2591 s,^build-aux/,$auxdir/,
2592 s,^doc/,$cached_docbase/,
2593 s,^lib/,$cached_sourcebase/,
2594 s,^m4/,$cached_m4base/,
2595 s,^tests/,$cached_testsbase/,
2596 s,^tests=lib/,$cached_testsbase/,
2598 sed_rewrite_new_files="\
2599 s,^build-aux/,$auxdir/,
2601 s,^lib/,$sourcebase/,
2603 s,^tests/,$testsbase/,
2604 s,^tests=lib/,$testsbase/,
2607 # Create directories.
2608 { echo "$sourcebase"
2610 if test -n "$pobase"; then
2613 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2614 if test -n "$docfiles"; then
2617 if test -n "$inctests"; then
2621 for f in $files; do echo $f; done \
2622 | sed -e "$sed_rewrite_new_files" \
2623 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2626 { # Rearrange file descriptors. Needed because "while ... done < ..."
2627 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2628 exec 5<&0 < "$tmp"/dirs
2630 if test ! -d "$destdir/$d"; then
2632 echo "Creating directory $destdir/$d"
2633 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2635 echo "Create directory $destdir/$d"
2642 # func_dest_tmpfilename file
2643 # determines the name of a temporary file (file is relative to destdir).
2645 # - tmpfile absolute filename of the temporary file
2646 func_dest_tmpfilename ()
2649 # Put the new contents of $file in a file in the same directory (needed
2650 # to guarantee that an 'mv' to "$destdir/$file" works).
2651 tmpfile="$destdir/$1.tmp"
2653 # Put the new contents of $file in a file in a temporary directory
2654 # (because the directory of "$file" might not exist).
2655 tmpfile="$tmp"/`basename "$1"`.tmp
2659 # Copy files or make symbolic links. Remove obsolete files.
2663 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2664 # representing the files according to the last gnulib-tool invocation.
2665 for f in $old_files; do echo $f; done \
2666 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2669 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2670 # representing the files after this gnulib-tool invocation.
2671 for f in $new_files; do echo $f; done \
2672 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2675 # First the files that are in old-files, but not in new-files:
2676 sed_take_first_column='s,'"$delimiter"'.*,,'
2677 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2678 # Remove the file. Do nothing if the user already removed it.
2679 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2681 echo "Removing file $g (backup in ${g}~)"
2682 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2684 echo "Remove file $g (backup in ${g}~)"
2686 func_append removed_files "$g$nl"
2689 # func_add_or_update handles a file that ought to be present afterwards.
2691 # - f the original file name
2692 # - g the rewritten file name
2693 # - already_present nonempty if the file already exists, empty otherwise
2694 func_add_or_update ()
2698 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2700 func_dest_tmpfilename "$g"
2701 func_lookup_file "$f"
2702 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2703 if test -n "$sed_transform_main_lib_file"; then
2706 sed -e "$sed_transform_main_lib_file" \
2707 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2711 if test -n "$sed_transform_testsrelated_lib_file"; then
2714 sed -e "$sed_transform_testsrelated_lib_file" \
2715 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2719 if test -f "$destdir/$g"; then
2720 # The file already exists.
2721 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2722 : # The file has not changed.
2726 if test -n "$already_present"; then
2727 echo "Updating file $g (backup in ${g}~)"
2729 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2731 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2732 if { test -n "$symbolic" \
2733 || { test -n "$lsymbolic" \
2734 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2735 && test -z "$lookedup_tmp" \
2736 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2737 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2739 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2742 if test -n "$already_present"; then
2743 echo "Update file $g (backup in ${g}~)"
2745 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2751 # Don't protest if the file should be there but isn't: it happens
2752 # frequently that developers don't put autogenerated files into CVS.
2754 echo "Copying file $g"
2755 if { test -n "$symbolic" \
2756 || { test -n "$lsymbolic" \
2757 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2758 && test -z "$lookedup_tmp" \
2759 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2760 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2762 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2767 func_append added_files "$g$nl"
2771 # Then the files that are in new-files, but not in old-files:
2772 sed_take_last_column='s,^.*'"$delimiter"',,'
2774 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2775 | sed -e "$sed_take_last_column" \
2776 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2777 { # Rearrange file descriptors. Needed because "while ... done < ..."
2778 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2779 exec 5<&0 < "$tmp"/added-files
2785 # Then the files that are in new-files and in old-files:
2786 already_present=true
2787 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2788 | sed -e "$sed_take_last_column" \
2789 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2790 { # Rearrange file descriptors. Needed because "while ... done < ..."
2791 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2792 exec 5<&0 < "$tmp"/kept-files
2799 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2800 actioncmd="gnulib-tool --import"
2801 func_append actioncmd " --dir=$destdir"
2802 if test -n "$local_gnulib_dir"; then
2803 func_append actioncmd " --local-dir=$local_gnulib_dir"
2805 func_append actioncmd " --lib=$libname"
2806 func_append actioncmd " --source-base=$sourcebase"
2807 func_append actioncmd " --m4-base=$m4base"
2808 if test -n "$pobase"; then
2809 func_append actioncmd " --po-base=$pobase"
2811 func_append actioncmd " --doc-base=$docbase"
2812 func_append actioncmd " --aux-dir=$auxdir"
2813 if test -n "$inctests"; then
2814 func_append actioncmd " --with-tests"
2816 for module in $avoidlist; do
2817 func_append actioncmd " --avoid=$module"
2819 if test -n "$lgpl"; then
2820 if test "$lgpl" = yes; then
2821 func_append actioncmd " --lgpl"
2823 func_append actioncmd " --lgpl=$lgpl"
2826 if test -n "$makefile_name"; then
2827 func_append actioncmd " --makefile-name=$makefile_name"
2829 if test "$libtool" = true; then
2830 func_append actioncmd " --libtool"
2832 func_append actioncmd " --no-libtool"
2834 func_append actioncmd " --macro-prefix=$macro_prefix"
2835 if test -n "$po_domain"; then
2836 func_append actioncmd " --po-domain=$po_domain"
2838 if test -n "$vc_files"; then
2839 if test "$vc_files" = true; then
2840 func_append actioncmd " --vc-files"
2842 func_append actioncmd " --no-vc-files"
2845 func_append actioncmd " `echo $specified_modules`"
2847 # Default the makefile name to Makefile.am.
2848 if test -n "$makefile_name"; then
2849 makefile_am=$makefile_name
2851 makefile_am=Makefile.am
2854 # Create normal Makefile.ams.
2857 # Create library makefile.
2858 func_dest_tmpfilename $sourcebase/$makefile_am
2859 modules="$main_modules"
2860 func_emit_lib_Makefile_am > "$tmpfile"
2861 if test -f "$destdir"/$sourcebase/$makefile_am; then
2862 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2866 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2867 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2868 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2870 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2876 echo "Creating $sourcebase/$makefile_am"
2877 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2879 echo "Create $sourcebase/$makefile_am"
2882 func_append added_files "$sourcebase/$makefile_am$nl"
2885 # Create po/ directory.
2886 if test -n "$pobase"; then
2887 # Create po makefile and auxiliary files.
2888 for file in Makefile.in.in remove-potcdate.sin; do
2889 func_dest_tmpfilename $pobase/$file
2890 func_lookup_file build-aux/po/$file
2891 cat "$lookedup_file" > "$tmpfile"
2892 if test -f "$destdir"/$pobase/$file; then
2893 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2897 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2898 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2899 mv -f "$tmpfile" "$destdir"/$pobase/$file
2901 echo "Update $pobase/$file (backup in $pobase/$file~)"
2907 echo "Creating $pobase/$file"
2908 mv -f "$tmpfile" "$destdir"/$pobase/$file
2910 echo "Create $pobase/$file"
2913 func_append added_files "$pobase/$file$nl"
2916 # Create po makefile parameterization, part 1.
2917 func_dest_tmpfilename $pobase/Makevars
2918 func_emit_po_Makevars > "$tmpfile"
2919 if test -f "$destdir"/$pobase/Makevars; then
2920 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2924 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2925 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2926 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2928 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2934 echo "Creating $pobase/Makevars"
2935 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2937 echo "Create $pobase/Makevars"
2940 func_append added_files "$pobase/Makevars$nl"
2942 # Create po makefile parameterization, part 2.
2943 func_dest_tmpfilename $pobase/POTFILES.in
2944 func_emit_po_POTFILES_in > "$tmpfile"
2945 if test -f "$destdir"/$pobase/POTFILES.in; then
2946 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2950 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2951 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2952 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2954 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2960 echo "Creating $pobase/POTFILES.in"
2961 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2963 echo "Create $pobase/POTFILES.in"
2966 func_append added_files "$pobase/POTFILES.in$nl"
2969 TP_URL="http://translationproject.org/latest/"
2970 TP_RSYNC_URI="translationproject.org::tp/latest/"
2972 echo "Fetching gnulib PO files from $TP_URL"
2973 (cd "$destdir"/$pobase \
2974 && { # Prefer rsync over wget if it is available, since it consumes
2975 # less network bandwidth, due to compression.
2976 if type rsync 2>/dev/null | grep / > /dev/null; then
2977 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2979 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2984 echo "Fetch gnulib PO files from $TP_URL"
2986 # Create po/LINGUAS.
2988 func_dest_tmpfilename $pobase/LINGUAS
2989 (cd "$destdir"/$pobase \
2990 && { echo '# Set of available languages.'
2991 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2994 if test -f "$destdir"/$pobase/LINGUAS; then
2995 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2998 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2999 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3000 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3003 echo "Creating $pobase/LINGUAS"
3004 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3005 func_append added_files "$pobase/LINGUAS$nl"
3008 if test -f "$destdir"/$pobase/LINGUAS; then
3009 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3011 echo "Create $pobase/LINGUAS"
3016 # Create m4/gnulib-cache.m4.
3017 func_dest_tmpfilename $m4base/gnulib-cache.m4
3019 func_emit_copyright_notice
3021 echo "# This file represents the specification of how gnulib-tool is used."
3022 echo "# It acts as a cache: It is written and read by gnulib-tool."
3023 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3024 echo "# like the configure.ac and various Makefile.am files."
3027 echo "# Specification in the form of a command-line invocation:"
3030 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3031 # Store the local_gnulib_dir relative to destdir.
3032 case "$local_gnulib_dir" in
3034 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3037 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3039 # destdir, local_gnulib_dir are both relative.
3040 func_relativize "$destdir" "$local_gnulib_dir"
3041 relative_local_gnulib_dir="$reldir" ;;
3044 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3046 echo "$specified_modules" | sed 's/^/ /g'
3048 echo "gl_AVOID([$avoidlist])"
3049 echo "gl_SOURCE_BASE([$sourcebase])"
3050 echo "gl_M4_BASE([$m4base])"
3051 echo "gl_PO_BASE([$pobase])"
3052 echo "gl_DOC_BASE([$docbase])"
3053 echo "gl_TESTS_BASE([$testsbase])"
3054 test -z "$inctests" || echo "gl_WITH_TESTS"
3055 echo "gl_LIB([$libname])"
3056 if test -n "$lgpl"; then
3057 if test "$lgpl" = yes; then
3060 echo "gl_LGPL([$lgpl])"
3063 echo "gl_MAKEFILE_NAME([$makefile_name])"
3064 if test "$libtool" = true; then
3067 echo "gl_MACRO_PREFIX([$macro_prefix])"
3068 echo "gl_PO_DOMAIN([$po_domain])"
3069 if test -n "$vc_files"; then
3070 echo "gl_VC_FILES([$vc_files])"
3073 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3074 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3078 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3079 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3080 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3082 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3086 echo "# gnulib-cache.m4 ends here"
3093 echo "Creating $m4base/gnulib-cache.m4"
3094 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3096 echo "Create $m4base/gnulib-cache.m4"
3102 # Create m4/gnulib-comp.m4.
3103 func_dest_tmpfilename $m4base/gnulib-comp.m4
3105 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3106 func_emit_copyright_notice
3108 echo "# This file represents the compiled summary of the specification in"
3109 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3110 echo "# to be invoked from configure.ac."
3111 echo "# In projects using CVS, this file can be treated like other built files."
3114 echo "# This macro should be invoked from $configure_ac, in the section"
3115 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3116 echo "# any checks for libraries, header files, types and library functions."
3117 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3119 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3120 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3121 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3122 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3123 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3124 if test -n "$uses_subdirs"; then
3125 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3127 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
3128 echo " AC_REQUIRE([AC_GNU_SOURCE])"
3130 for module in $final_modules; do
3132 if test -n "$module"; then
3133 func_get_autoconf_early_snippet "$module"
3136 | sed -e '/^$/d;' -e 's/^/ /'
3139 echo "# This macro should be invoked from $configure_ac, in the section"
3140 echo "# \"Check for header files, types and library functions\"."
3141 echo "AC_DEFUN([${macro_prefix}_INIT],"
3143 if test "$libtool" = true; then
3144 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3145 echo " gl_cond_libtool=true"
3147 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3148 echo " gl_cond_libtool=false"
3150 echo " gl_ltlibdeps="
3152 if test "$auxdir" != "build-aux"; then
3153 sed_replace_build_aux='
3155 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3156 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3160 sed_replace_build_aux="$sed_noop"
3162 func_emit_initmacro_start $macro_prefix
3163 echo " gl_source_base='$sourcebase'"
3164 for module in $main_modules; do
3166 if test -n "$module"; then
3167 func_get_autoconf_snippet "$module" \
3168 | sed -e '/^$/d;' -e 's/^/ /' \
3169 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3170 -e "$sed_replace_build_aux"
3171 if test "$module" = 'alloca' && test "$libtool" = true; then
3172 echo 'changequote(,)dnl'
3173 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3174 echo 'changequote([, ])dnl'
3175 echo 'AC_SUBST([LTALLOCA])'
3179 func_emit_initmacro_end $macro_prefix
3180 echo " gltests_libdeps="
3181 echo " gltests_ltlibdeps="
3182 func_emit_initmacro_start ${macro_prefix}tests
3183 echo " gl_source_base='$testsbase'"
3184 for module in $testsrelated_modules; do
3186 if test -n "$module"; then
3187 func_get_autoconf_snippet "$module" \
3188 | sed -e '/^$/d;' -e 's/^/ /' \
3189 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3190 -e "$sed_replace_build_aux" \
3191 -e 's/\$gl_cond_libtool/false/g' \
3192 -e 's/gl_libdeps/gltests_libdeps/g' \
3193 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3196 func_emit_initmacro_end ${macro_prefix}tests
3197 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3198 # created using libtool, because libtool already handles the dependencies.
3199 if test "$libtool" != true; then
3200 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3201 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3202 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3203 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3204 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3206 if $use_libtests; then
3207 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3208 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3211 func_emit_initmacro_done $macro_prefix $sourcebase
3212 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3214 echo "# This macro records the list of files which have been installed by"
3215 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3216 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3217 echo "$files" | sed -e 's,^, ,'
3220 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3221 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3225 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3226 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3227 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3229 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3233 echo "# gnulib-comp.m4 ends here"
3240 echo "Creating $m4base/gnulib-comp.m4"
3241 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3243 echo "Create $m4base/gnulib-comp.m4"
3249 if test -n "$inctests"; then
3250 # Create tests makefile.
3251 func_dest_tmpfilename $testsbase/$makefile_am
3252 modules="$testsrelated_modules"
3253 func_emit_tests_Makefile_am > "$tmpfile"
3254 if test -f "$destdir"/$testsbase/$makefile_am; then
3255 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3259 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3260 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3261 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3263 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3269 echo "Creating $testsbase/$makefile_am"
3270 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3272 echo "Create $testsbase/$makefile_am"
3275 func_append added_files "$testsbase/$makefile_am$nl"
3279 if test "$vc_files" != false; then
3280 # Update the .cvsignore and .gitignore files.
3281 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3282 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3283 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3284 echo "$m4base/|A|gnulib-comp.m4"
3285 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3286 { # Rearrange file descriptors. Needed because "while ... done < ..."
3287 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3288 exec 5<&0 < "$tmp"/fileset-changes
3289 func_update_ignorelist ()
3292 if test "$ignore" = .gitignore; then
3293 # In a .gitignore file, "foo" applies to the current directory and all
3294 # subdirectories, whereas "/foo" applies to the current directory only.
3297 doubly_escaped_anchor='\\/'
3301 doubly_escaped_anchor=''
3303 if test -f "$destdir/$dir$ignore"; then
3304 if test -n "$dir_added" || test -n "$dir_removed"; then
3305 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3307 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3308 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
3309 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3310 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
3312 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3314 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3315 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3316 { sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3317 if test -n "$anchor"; then sed -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,\$/d,' < "$tmp"/ignore-removed; fi
3318 } > "$tmp"/sed-ignore-removed
3319 { cat "$destdir/$dir$ignore"~
3320 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3321 } | sed -f "$tmp"/sed-ignore-removed \
3322 > "$destdir/$dir$ignore"
3324 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3329 if test -n "$dir_added"; then
3331 echo "Creating $destdir/$dir$ignore"
3333 if test "$ignore" = .cvsignore; then
3335 # Automake generates Makefile rules that create .dirstamp files.
3338 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3339 } > "$destdir/$dir$ignore"
3341 echo "Create $destdir/$dir$ignore"
3351 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3352 func_update_ignorelist .cvsignore
3354 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3355 func_update_ignorelist .gitignore
3362 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3363 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3364 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3365 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3366 if test "$next_dir" != "$last_dir"; then
3367 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3368 last_dir="$next_dir"
3373 A) func_append last_dir_added "$file$nl";;
3374 R) func_append last_dir_removed "$file$nl";;
3377 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3384 echo "You may need to add #include directives for the following .h files."
3385 # Intersect $specified_modules and $main_modules
3386 # (since $specified_modules is not necessarily of subset of $main_modules
3387 # - some may have been skipped through --avoid, and since the elements of
3388 # $main_modules but not in $specified_modules can go away without explicit
3389 # notice - through changes in the module dependencies).
3390 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3391 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3392 # First the #include <...> directives without #ifs, sorted for convenience,
3393 # then the #include "..." directives without #ifs, sorted for convenience,
3394 # then the #include directives that are surrounded by #ifs. Not sorted.
3395 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3396 include_directive=`func_get_include_directive "$module"`
3397 case "$nl$include_directive" in
3399 echo "$include_directive" 1>&5
3402 echo "$include_directive" | grep -v 'include "' 1>&6
3403 echo "$include_directive" | grep 'include "' 1>&7
3406 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3408 LC_ALL=C sort -u "$tmp"/include-angles
3409 LC_ALL=C sort -u "$tmp"/include-quotes
3410 cat "$tmp"/include-if
3411 ) | sed -e '/^$/d' -e 's/^/ /'
3412 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3414 for module in $main_modules; do
3415 func_get_link_directive "$module"
3417 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3418 if test `wc -l < "$tmp"/link` != 0; then
3420 echo "You may need to use the following Makefile variables when linking."
3421 echo "Use them in <program>_LDADD when linking a program, or"
3422 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3428 echo "Don't forget to"
3429 if test "$makefile_am" = Makefile.am; then
3430 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3432 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3434 if test -n "$pobase"; then
3435 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3437 if test -n "$inctests"; then
3438 if test "$makefile_am" = Makefile.am; then
3439 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3441 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3444 if test "$makefile_am" = Makefile.am; then
3445 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3446 sourcebase_base=`basename "$sourcebase"`
3447 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
3449 if test -n "$pobase"; then
3450 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3451 pobase_base=`basename "$pobase"`
3452 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
3454 if test -n "$inctests"; then
3455 if test "$makefile_am" = Makefile.am; then
3456 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3457 testsbase_base=`basename "$testsbase"`
3458 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
3461 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
3463 # Find the first parent directory of $m4base that contains a Makefile.am.
3464 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3466 sed_butlast='s,[^/][^/]*//*$,,'
3467 dir1="${m4base}/"; dir2=""
3468 while test -n "$dir1" && test ! -f "${destdir}/${dir1}Makefile.am"; do
3469 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3470 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3472 echo " - mention ${dir2}gnulib-cache.m4 in EXTRA_DIST in ${dir1}Makefile.am."
3474 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3475 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3478 # func_create_testdir testdir modules
3480 # - local_gnulib_dir from --local-dir
3481 # - auxdir directory relative to destdir where to place build aux files
3482 func_create_testdir ()
3486 if test -z "$modules"; then
3487 # All modules together.
3488 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3489 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3490 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3491 modules=`func_all_modules`
3492 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3494 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3496 # Check that the license of every module is consistent with the license of
3498 saved_modules="$modules"
3499 saved_inctests="$inctests"
3500 # When computing transitive closures, don't consider $module to depend on
3501 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3502 # on GPL modules - therefore we don't want a warning in this case.
3504 for requested_module in $saved_modules; do
3505 requested_license=`func_get_license "$requested_module"`
3506 if test "$requested_license" != GPL; then
3507 # Here we use func_modules_transitive_closure, not just
3508 # func_get_dependencies, so that we also detect weird situations like
3509 # an LGPL module which depends on a GPLed build tool module which depends
3511 modules="$requested_module"
3512 func_modules_transitive_closure
3513 for module in $modules; do
3514 license=`func_get_license "$module"`
3516 'GPLed build tool') ;;
3517 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3519 case "$requested_license" in
3522 GPLv2+ | LGPLv2+) ;;
3523 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3529 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3535 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3544 modules="$saved_modules"
3545 inctests="$saved_inctests"
3547 # Subdirectory names.
3557 # Determine final module list.
3558 func_modules_transitive_closure
3559 if test $verbose -ge 0; then
3560 echo "Module list with included dependencies:"
3561 echo "$modules" | sed -e 's/^/ /'
3564 # Add the dummy module if needed.
3565 func_modules_add_dummy
3567 # Show banner notice of every module.
3570 # Determine final file list.
3571 func_modules_to_filelist
3572 if test $verbose -ge 0; then
3574 echo "$files" | sed -e 's/^/ /'
3577 sed_rewrite_files="\
3578 s,^build-aux/,$auxdir/,
3580 s,^lib/,$sourcebase/,
3582 s,^tests/,$testsbase/,
3585 # Create directories.
3586 for f in $files; do echo $f; done \
3587 | sed -e "$sed_rewrite_files" \
3588 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3589 | LC_ALL=C sort -u \
3591 { # Rearrange file descriptors. Needed because "while ... done < ..."
3592 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3593 exec 5<&0 < "$tmp"/dirs
3595 mkdir -p "$testdir/$d"
3600 # Copy files or make symbolic links.
3602 for f in $files; do echo $f; done \
3603 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3606 { # Rearrange file descriptors. Needed because "while ... done < ..."
3607 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3608 exec 5<&0 < "$tmp"/files
3610 func_lookup_file "$f"
3611 if test -n "$lookedup_tmp"; then
3612 cp -p "$lookedup_file" "$testdir/$g"
3614 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3615 if { test -n "$symbolic" \
3616 || { test -n "$lsymbolic" \
3617 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3618 func_ln "$lookedup_file" "$testdir/$g"
3620 cp -p "$lookedup_file" "$testdir/$g"
3627 # Create Makefile.ams that are for testing.
3630 # Create $sourcebase/Makefile.am.
3631 mkdir -p "$testdir/$sourcebase"
3632 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3633 any_uses_subdirs="$uses_subdirs"
3635 # Create $m4base/Makefile.am.
3636 mkdir -p "$testdir/$m4base"
3637 (echo "## Process this file with automake to produce Makefile.in."
3643 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3646 ) > "$testdir/$m4base/Makefile.am"
3648 subdirs="$sourcebase $m4base"
3649 subdirs_with_configure_ac=""
3651 if false && test -f "$testdir"/$m4base/gettext.m4; then
3652 # Avoid stupid error message from automake:
3653 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3654 mkdir -p "$testdir/po"
3655 (echo "## Process this file with automake to produce Makefile.in."
3656 ) > "$testdir/po/Makefile.am"
3657 func_append subdirs " po"
3660 if test -n "$inctests"; then
3661 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3662 # Viewed from the $testsbase subdirectory, $auxdir is different.
3663 saved_auxdir="$auxdir"
3664 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3665 # Create $testsbase/Makefile.am.
3667 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3668 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3669 # Create $testsbase/configure.ac.
3670 (echo "# Process this file with autoconf to produce a configure script."
3671 echo "AC_INIT([dummy], [0])"
3672 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3673 echo "AM_INIT_AUTOMAKE"
3675 echo "AM_CONFIG_HEADER([config.h])"
3678 echo "AC_PROG_INSTALL"
3679 echo "AC_PROG_MAKE_SET"
3680 echo "AC_PROG_RANLIB"
3682 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3683 echo "AC_GNU_SOURCE"
3686 for module in $modules; do
3688 if test -n "$module"; then
3689 func_get_autoconf_early_snippet "$module"
3692 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3693 if test "$libtool" = true; then
3694 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3695 echo "gl_cond_libtool=true"
3697 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3698 echo "gl_cond_libtool=false"
3700 echo "gl_ltlibdeps="
3702 # Wrap the set of autoconf snippets into an autoconf macro that is then
3703 # invoked. This is needed because autoconf does not support AC_REQUIRE
3705 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3706 # but we want the AC_REQUIRE to have its normal meaning (provide one
3707 # expansion of the required macro before the current point, and only one
3709 echo "AC_DEFUN([gl_INIT], ["
3710 sed_replace_build_aux='
3712 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3713 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3716 func_emit_initmacro_start $macro_prefix
3717 # We don't have explicit ordering constraints between the various
3718 # autoconf snippets. It's cleanest to put those of the library before
3719 # those of the tests.
3720 echo "gl_source_base='../$sourcebase'"
3721 for module in $modules; do
3722 func_verify_nontests_module
3723 if test -n "$module"; then
3724 func_get_autoconf_snippet "$module" \
3725 | sed -e "$sed_replace_build_aux"
3728 echo "gl_source_base='.'"
3729 for module in $modules; do
3730 func_verify_tests_module
3731 if test -n "$module"; then
3732 func_get_autoconf_snippet "$module" \
3733 | sed -e "$sed_replace_build_aux"
3736 func_emit_initmacro_end $macro_prefix
3737 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3738 # created using libtool, because libtool already handles the dependencies.
3739 if test "$libtool" != true; then
3740 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3741 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3742 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3743 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3744 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3747 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3751 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3752 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3753 echo "AH_TOP([#include \"../config.h\"])"
3755 echo "AC_OUTPUT([Makefile])"
3756 ) > "$testdir/$testsbase/configure.ac"
3757 auxdir="$saved_auxdir"
3758 func_append subdirs " $testsbase"
3759 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3762 # Create Makefile.am.
3763 (echo "## Process this file with automake to produce Makefile.in."
3765 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3767 echo "SUBDIRS = $subdirs"
3769 echo "ACLOCAL_AMFLAGS = -I $m4base"
3770 ) > "$testdir/Makefile.am"
3772 # Create configure.ac.
3773 (echo "# Process this file with autoconf to produce a configure script."
3774 echo "AC_INIT([dummy], [0])"
3775 if test "$auxdir" != "."; then
3776 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3778 echo "AM_INIT_AUTOMAKE"
3780 echo "AM_CONFIG_HEADER([config.h])"
3783 echo "AC_PROG_INSTALL"
3784 echo "AC_PROG_MAKE_SET"
3786 echo "# For autobuild."
3787 echo "AC_CANONICAL_BUILD"
3788 echo "AC_CANONICAL_HOST"
3790 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3791 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3792 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3793 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3795 echo "AC_PROG_RANLIB"
3797 if test -n "$any_uses_subdirs"; then
3798 echo "AM_PROG_CC_C_O"
3801 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3802 echo "AC_GNU_SOURCE"
3805 for module in $modules; do
3806 func_verify_nontests_module
3807 if test -n "$module"; then
3808 func_get_autoconf_early_snippet "$module"
3811 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3812 if test "$libtool" = true; then
3813 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3814 echo "gl_cond_libtool=true"
3816 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3817 echo "gl_cond_libtool=false"
3819 echo "gl_ltlibdeps="
3821 # Wrap the set of autoconf snippets into an autoconf macro that is then
3822 # invoked. This is needed because autoconf does not support AC_REQUIRE
3824 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3825 # but we want the AC_REQUIRE to have its normal meaning (provide one
3826 # expansion of the required macro before the current point, and only one
3828 echo "AC_DEFUN([gl_INIT], ["
3829 if test "$auxdir" != "build-aux"; then
3830 sed_replace_build_aux='
3832 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3833 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3837 sed_replace_build_aux="$sed_noop"
3839 func_emit_initmacro_start $macro_prefix
3840 echo "gl_source_base='$sourcebase'"
3841 for module in $modules; do
3842 func_verify_nontests_module
3843 if test -n "$module"; then
3844 func_get_autoconf_snippet "$module" \
3845 | sed -e "$sed_replace_build_aux"
3848 func_emit_initmacro_end $macro_prefix
3849 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3850 # created using libtool, because libtool already handles the dependencies.
3851 if test "$libtool" != true; then
3852 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3853 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3854 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3855 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3856 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3859 func_emit_initmacro_done $macro_prefix $sourcebase
3863 if test -n "$subdirs_with_configure_ac"; then
3864 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3866 makefiles="Makefile"
3867 for d in $subdirs; do
3868 # For subdirs that have a configure.ac by their own, it's the subdir's
3869 # configure.ac which creates the subdir's Makefile.am, not this one.
3870 case " $subdirs_with_configure_ac " in
3872 *) func_append makefiles " $d/Makefile" ;;
3875 echo "AC_OUTPUT([$makefiles])"
3876 ) > "$testdir/configure.ac"
3878 # Create autogenerated files.
3880 # Do not use "${AUTORECONF} --force --install", because it may invoke
3881 # autopoint, which brings in older versions of some of our .m4 files.
3882 if test -f $m4base/gettext.m4; then
3883 func_execute_command ${AUTOPOINT} --force || func_exit 1
3884 for f in $m4base/*.m4~; do
3885 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3888 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3889 if ! test -d build-aux; then
3890 func_execute_command mkdir build-aux || func_exit 1
3892 func_execute_command ${AUTOCONF} || func_exit 1
3893 func_execute_command ${AUTOHEADER} || func_exit 1
3894 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3896 if test -n "$inctests"; then
3897 # Create autogenerated files.
3898 (cd "$testdir/$testsbase" || func_exit 1
3899 # Do not use "${AUTORECONF} --force --install", because it may invoke
3900 # autopoint, which brings in older versions of some of our .m4 files.
3901 if test -f ../$m4base/gettext.m4; then
3902 func_execute_command ${AUTOPOINT} --force || func_exit 1
3903 for f in ../$m4base/*.m4~; do
3904 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3907 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3908 if ! test -d ../build-aux; then
3909 func_execute_command mkdir ../build-aux
3911 func_execute_command ${AUTOCONF} || func_exit 1
3912 func_execute_command ${AUTOHEADER} || func_exit 1
3913 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3916 # Need to run configure and make once, to create built files that are to be
3917 # distributed (such as getdate.c).
3918 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3919 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3920 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3921 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3922 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3923 # such $(FOO_H) because they don't refer to distributed files.
3924 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3925 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3926 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3927 | sed -e "$sed_remove_make_variables"`
3928 distributed_built_sources=`for file in $built_sources; do
3929 case "$cleaned_files" in
3934 if test -n "$distributed_built_sources"; then
3936 ./configure || func_exit 1
3938 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3939 make built_sources || func_exit 1
3941 make distclean || func_exit 1
3946 # func_create_megatestdir megatestdir allmodules
3948 # - local_gnulib_dir from --local-dir
3949 # - auxdir directory relative to destdir where to place build aux files
3950 func_create_megatestdir ()
3954 if test -z "$allmodules"; then
3955 allmodules=`func_all_modules`
3959 # First, all modules one by one.
3960 for onemodule in $allmodules; do
3961 func_create_testdir "$megatestdir/$onemodule" $onemodule
3962 func_append megasubdirs "$onemodule "
3964 # Then, all modules all together.
3965 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3966 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3967 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3968 func_create_testdir "$megatestdir/ALL" "$allmodules"
3969 func_append megasubdirs "ALL"
3972 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
3973 vc_witness="$gnulib_dir/CVS/Entries"; \
3975 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
3977 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
3978 | sed -e 's,January,01,' -e 's,Jan,01,' \
3979 -e 's,February,02,' -e 's,Feb,02,' \
3980 -e 's,March,03,' -e 's,Mar,03,' \
3981 -e 's,April,04,' -e 's,Apr,04,' \
3983 -e 's,June,06,' -e 's,Jun,06,' \
3984 -e 's,July,07,' -e 's,Jul,07,' \
3985 -e 's,August,08,' -e 's,Aug,08,' \
3986 -e 's,September,09,' -e 's,Sep,09,' \
3987 -e 's,October,10,' -e 's,Oct,10,' \
3988 -e 's,November,11,' -e 's,Nov,11,' \
3989 -e 's,December,12,' -e 's,Dec,12,' \
3990 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3991 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3993 echo "CVSDATE=$cvsdate"
3994 echo "test -d logs || mkdir logs"
3995 echo "for module in $megasubdirs; do"
3996 echo " echo \"Working on module \$module...\""
3997 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3998 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4001 echo " : autobuild project... \$module"
4002 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4003 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4004 echo " : autobuild hostname... \`hostname\`"
4005 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
4007 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4009 ) > "$megatestdir/do-autobuild"
4010 chmod a+x "$megatestdir/do-autobuild"
4012 # Create Makefile.am.
4013 (echo "## Process this file with automake to produce Makefile.in."
4015 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4017 echo "SUBDIRS = $megasubdirs"
4019 echo "EXTRA_DIST = do-autobuild"
4020 ) > "$megatestdir/Makefile.am"
4022 # Create configure.ac.
4023 (echo "# Process this file with autoconf to produce a configure script."
4024 echo "AC_INIT([dummy], [0])"
4025 if test "$auxdir" != "."; then
4026 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4028 echo "AM_INIT_AUTOMAKE"
4030 echo "AC_PROG_MAKE_SET"
4032 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4033 echo "AC_OUTPUT([Makefile])"
4034 ) > "$megatestdir/configure.ac"
4036 # Create autogenerated files.
4038 # Do not use "${AUTORECONF} --install", because autoreconf operates
4039 # recursively, but the subdirectories are already finished, therefore
4040 # calling autoreconf here would only waste lots of CPU time.
4041 func_execute_command ${ACLOCAL} || func_exit 1
4042 func_execute_command mkdir build-aux
4043 func_execute_command ${AUTOCONF} || func_exit 1
4044 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4050 func_fatal_error "no mode specified" ;;
4059 if test -z "$destdir"; then
4062 test -d "$destdir" \
4063 || func_fatal_error "destination directory does not exist: $destdir"
4065 # Prefer configure.ac to configure.in.
4066 if test -f "$destdir"/configure.ac; then
4067 configure_ac="$destdir/configure.ac"
4069 if test -f "$destdir"/configure.in; then
4070 configure_ac="$destdir/configure.in"
4072 func_fatal_error "cannot find $destdir/configure.ac"
4076 # Analyze configure.ac.
4078 guessed_libtool=false
4083 /AC_CONFIG_AUX_DIR/ {
4084 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
4086 /A[CM]_PROG_LIBTOOL/ {
4087 s,^.*$,guessed_libtool=true,p
4089 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4091 if test -z "$auxdir"; then
4092 auxdir="$guessed_auxdir"
4095 # Determine where to apply func_import.
4096 if test -n "$m4base"; then
4097 # Apply func_import to a particular gnulib directory.
4098 # Any number of additional modules can be given.
4099 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4100 # First use of gnulib in the given m4base.
4101 test -n "$supplied_libname" || supplied_libname=true
4102 test -n "$sourcebase" || sourcebase="lib"
4103 test -n "$docbase" || docbase="doc"
4104 test -n "$testsbase" || testsbase="tests"
4105 test -n "$macro_prefix" || macro_prefix="gl"
4109 # Apply func_import to all gnulib directories.
4110 # To get this list of directories, look at Makefile.am. (Not at
4111 # configure, because it may be omitted from CVS. Also, don't run
4112 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4115 if test -f "$destdir"/Makefile.am; then
4116 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4118 for arg in $aclocal_amflags; do
4119 if test -n "$m4dir_is_next"; then
4120 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4124 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4125 func_append m4dirs " $arg"
4126 m4dirs_count=`expr $m4dirs_count + 1`
4132 if test "X$arg" = "X-I"; then
4140 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4141 if test -f "$destdir"/aclocal.m4; then
4142 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4143 sedexpr2='s,^[^/]*$,.,'
4144 sedexpr3='s,/[^/]*$,,'
4145 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4146 m4dirs_count=`echo "$m4dirs" | wc -l`
4149 if test $m4dirs_count = 0; then
4150 # First use of gnulib in a package.
4151 # Any number of additional modules can be given.
4152 test -n "$supplied_libname" || supplied_libname=true
4153 test -n "$sourcebase" || sourcebase="lib"
4155 test -n "$docbase" || docbase="doc"
4156 test -n "$testsbase" || testsbase="tests"
4157 test -n "$macro_prefix" || macro_prefix="gl"
4160 if test $m4dirs_count = 1; then
4161 # There's only one use of gnulib here. Assume the user means it.
4162 # Any number of additional modules can be given.
4163 for m4base in $m4dirs; do
4167 # Ambiguous - guess what the user meant.
4168 if test $# = 0; then
4169 # No further arguments. Guess the user wants to update all of them.
4170 for m4base in $m4dirs; do
4171 # Perform func_import in a subshell, so that variable values
4173 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
4174 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
4175 # libtool, macro_prefix, po_domain, vc_files
4176 # don't propagate from one directory to another.
4177 (func_import) || func_exit 1
4181 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4189 if test -z "$destdir"; then
4190 func_fatal_error "please specify --dir option"
4193 test -d "$destdir" \
4194 || func_fatal_error "could not create destination directory"
4195 test -n "$auxdir" || auxdir="build-aux"
4196 func_create_testdir "$destdir" "$*"
4199 create-megatestdir )
4200 if test -z "$destdir"; then
4201 func_fatal_error "please specify --dir option"
4203 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4204 test -n "$auxdir" || auxdir="build-aux"
4205 func_create_megatestdir "$destdir" "$*"
4209 test -n "$destdir" || destdir=testdir$$
4210 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4211 test -n "$auxdir" || auxdir="build-aux"
4212 func_create_testdir "$destdir" "$*"
4216 ../configure || func_exit 1
4218 make check || func_exit 1
4219 make distclean || func_exit 1
4220 remaining=`find . -type f -print`
4221 if test -n "$remaining"; then
4222 echo "Remaining files:" $remaining 1>&2
4223 echo "gnulib-tool: *** Stop." 1>&2
4232 test -n "$destdir" || destdir=testdir$$
4233 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4234 test -n "$auxdir" || auxdir="build-aux"
4235 func_create_megatestdir "$destdir" "$*"
4243 remaining=`find . -type f -print`
4244 if test -n "$remaining"; then
4245 echo "Remaining files:" $remaining 1>&2
4246 echo "gnulib-tool: *** Stop." 1>&2
4254 extract-description )
4258 if test -n "$module"; then
4259 func_get_description "$module"
4268 if test -n "$module"; then
4269 func_get_notice "$module"
4278 if test -n "$module"; then
4279 func_get_filelist "$module"
4284 extract-dependencies )
4288 if test -n "$module"; then
4289 func_get_dependencies "$module"
4294 extract-autoconf-snippet )
4298 if test -n "$module"; then
4299 func_get_autoconf_snippet "$module"
4304 extract-automake-snippet )
4308 if test -n "$module"; then
4309 func_get_automake_snippet "$module"
4314 extract-include-directive )
4318 if test -n "$module"; then
4319 func_get_include_directive "$module"
4324 extract-link-directive )
4328 if test -n "$module"; then
4329 func_get_link_directive "$module"
4338 if test -n "$module"; then
4339 func_get_license "$module"
4344 extract-maintainer )
4348 if test -n "$module"; then
4349 func_get_maintainer "$module"
4354 extract-tests-module )
4358 if test -n "$module"; then
4359 func_get_tests_module "$module"
4365 func_fatal_error "unknown operation mode --$mode" ;;
4369 # Undo the effect of the previous 'trap' command. Some shellology:
4370 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4371 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4372 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4373 # 128 + signal number and is set before the trap-registered command is run.
4375 trap 'func_exit $?' 1 2 3 13 15
4380 # indent-tabs-mode: nil
4381 # whitespace-check-buffer-indent: nil