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'
87 # outputs to stdout the --help usage message.
91 Usage: gnulib-tool --list
92 gnulib-tool --import [module1 ... moduleN]
94 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
95 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
96 gnulib-tool --test --dir=directory module1 ... moduleN
97 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
98 gnulib-tool --extract-description module
99 gnulib-tool --extract-notice module
100 gnulib-tool --extract-filelist module
101 gnulib-tool --extract-dependencies module
102 gnulib-tool --extract-autoconf-snippet module
103 gnulib-tool --extract-automake-snippet module
104 gnulib-tool --extract-include-directive module
105 gnulib-tool --extract-link-directive module
106 gnulib-tool --extract-license module
107 gnulib-tool --extract-maintainer module
108 gnulib-tool --extract-tests-module module
111 --list print the available module names
112 --import import the given modules into the current package;
113 if no modules are specified, update the current
114 package from the current gnulib
115 --update update the current package, restore files omitted
117 --create-testdir create a scratch package with the given modules
118 --create-megatestdir create a mega scratch package with the given modules
119 one by one and all together
120 --test test the combination of the given modules
121 (recommended to use CC=\"gcc -Wall\" here)
122 --megatest test the given modules one by one and all together
123 (recommended to use CC=\"gcc -Wall\" here)
124 --extract-description extract the description
125 --extract-notice extract the notice or banner
126 --extract-filelist extract the list of files
127 --extract-dependencies extract the dependencies
128 --extract-autoconf-snippet extract the snippet for configure.ac
129 --extract-automake-snippet extract the snippet for library makefile
130 --extract-include-directive extract the #include directive
131 --extract-link-directive extract the linker directive
132 --extract-license report the license terms of the source files
134 --extract-maintainer report the maintainer(s) inside gnulib
135 --extract-tests-module report the unit test module, if it exists
138 --dir=DIRECTORY Specify the target directory.
139 For --import, this specifies where your
140 configure.ac can be found. Defaults to current
142 --local-dir=DIRECTORY Specify a local override directory where to look
143 up files before looking in gnulib's directory.
144 --verbose Increase verbosity. May be repeated.
145 --quiet Decrease verbosity. May be repeated.
147 Options for --import:
148 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
149 --source-base=DIRECTORY
150 Directory relative to --dir where source code is
151 placed (default \"lib\").
152 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
153 placed (default \"m4\").
154 --po-base=DIRECTORY Directory relative to --dir where *.po files are
155 placed (default \"po\").
156 --doc-base=DIRECTORY Directory relative to --dir where doc files are
157 placed (default \"doc\").
158 --tests-base=DIRECTORY
159 Directory relative to --dir where unit tests are
160 placed (default \"tests\").
161 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
162 tools are placed (default \"build-aux\").
163 --with-tests Include unit tests for the included modules.
164 --avoid=MODULE Avoid including the given MODULE. Useful if you
165 have code that provides equivalent functionality.
166 This option can be repeated.
167 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
168 Also modify license template from GPL to LGPL.
169 The version number of the LGPL can be specified;
170 the default is currently LGPLv3.
171 --makefile-name=NAME Name of makefile in automake syntax in the
172 source-base and tests-base directories
173 (default \"Makefile.am\").
174 --libtool Use libtool rules.
175 --no-libtool Don't use libtool rules.
176 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
177 'gl_INIT'. Default is 'gl'.
178 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
179 the package name. A suffix '-gnulib' is appended.
180 --no-changelog don't update or create ChangeLog files
182 Options for --import and --update:
183 --dry-run For --import, only print what would have been done.
184 -s, --symbolic, --symlink Make symbolic links instead of copying files.
185 --local-symlink Make symbolic links instead of copying files, only
186 for files from the local override directory.
187 -S, --more-symlinks Make symbolic links instead of copying files, and
188 don't replace copyright notices.
190 Report bugs to <bug-gnulib@gnu.org>."
194 # outputs to stdout the --version message.
198 date=`sed 's/ .*//;q' "$gnulib_dir"/ChangeLog`
199 version=`"$gnulib_dir"/build-aux/git-version-gen /dev/null`
200 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
202 gnulib-tool (GNU $package $date) $version
203 Copyright (C) $year Free Software Foundation, Inc.
204 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
205 This is free software: you are free to change and redistribute it.
206 There is NO WARRANTY, to the extent permitted by law.
208 Written by" "Bruno Haible" "and" "Simon Josefsson"
211 # func_emit_copyright_notice
212 # outputs to stdout a header for a generated file.
213 func_emit_copyright_notice ()
215 sed -n '/Copyright/ {
218 }' < "$self_abspathname"
220 echo "# This file is free software, distributed under the terms of the GNU"
221 echo "# General Public License. As a special exception to the GNU General"
222 echo "# Public License, this file may be distributed as part of a program"
223 echo "# that contains a configuration script generated by Autoconf, under"
224 echo "# the same distribution terms as the rest of that program."
226 echo "# Generated by gnulib-tool."
237 # locates the directory where the gnulib repository lives
239 # - self_abspathname absolute pathname of gnulib-tool
240 # - gnulib_dir absolute pathname of gnulib repository
244 /*) self_abspathname="$0" ;;
245 */*) self_abspathname=`pwd`/"$0" ;;
248 # Iterate through the elements of $PATH.
249 # We use IFS=: instead of
250 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
251 # because the latter does not work when some PATH element contains spaces.
252 # We use a canonicalized $pathx instead of $PATH, because empty PATH
253 # elements are by definition equivalent to '.', however field splitting
254 # according to IFS=: loses empty fields in many shells:
255 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
256 # beginning, at the end, and in the middle),
257 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
258 # at the beginning and at the end,
259 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
260 # Solaris lose empty fields at the end.
261 # The 'case' statement is an optimization, to avoid evaluating the
262 # explicit canonicalization command when $PATH contains no empty fields.
264 if test "${PATH_SEPARATOR+set}" != set; then
266 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
267 chmod +x "$tmp"/conf.sh
268 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
275 if test "$PATH_SEPARATOR" = ";"; then
276 # On Windows, programs are searched in "." before $PATH.
279 # On Unix, we have to convert empty PATH elements to ".".
283 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
288 IFS="$PATH_SEPARATOR"
292 if test -x "$d/$0" && test ! -d "$d/$0"; then
293 self_abspathname="$d/$0"
298 if test -z "$self_abspathname"; then
299 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
303 while test -h "$self_abspathname"; do
304 # Resolve symbolic link.
305 linkval=`func_readlink "$self_abspathname"`
306 test -n "$linkval" || break
308 /* ) self_abspathname="$linkval" ;;
309 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
312 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
316 # creates a temporary directory.
318 # - tmp pathname of freshly created temporary directory
321 # Use the environment variable TMPDIR, falling back to /tmp. This allows
322 # users to specify a different temporary directory, for example, if their
323 # /tmp is filled up or too small.
326 # Use the mktemp program if available. If not available, hide the error
328 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
329 test -n "$tmp" && test -d "$tmp"
332 # Use a simple mkdir command. It is guaranteed to fail if the directory
333 # already exists. $RANDOM is bash specific and expands to empty in shells
334 # other than bash, ksh and zsh. Its use does not increase security;
335 # rather, it minimizes the probability of failure in a very cluttered /tmp
337 tmp=$TMPDIR/gl$$-$RANDOM
338 (umask 077 && mkdir "$tmp")
341 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
346 # func_append var value
347 # appends the given value to the shell variable var.
348 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
349 # Use bash's += operator. It reduces complexity of appending repeatedly to
350 # a single variable from O(n^2) to O(n).
358 eval "$1=\"\$$1\$2\""
362 # func_fatal_error message
363 # outputs to stderr a fatal error message, and terminates the program.
366 echo "gnulib-tool: *** $1" 1>&2
367 echo "gnulib-tool: *** Stop." 1>&2
371 # func_readlink SYMLINK
372 # outputs the target of the given symlink.
373 if (type -p readlink) > /dev/null 2>&1; then
376 # Use the readlink program from GNU coreutils.
382 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
383 # would do the wrong thing if the link target contains " -> ".
384 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
388 # func_relativize DIR1 DIR2
389 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
391 # - DIR1 relative pathname, relative to the current directory
392 # - DIR2 relative pathname, relative to the current directory
394 # - reldir relative pathname of DIR2, relative to DIR1
400 sed_first='s,^\([^/]*\)/.*$,\1,'
401 sed_rest='s,^[^/]*/*,,'
402 sed_last='s,^.*/\([^/]*\)$,\1,'
403 sed_butlast='s,/*[^/]*$,,'
404 while test -n "$dir1"; do
405 first=`echo "$dir1" | sed -e "$sed_first"`
406 if test "$first" != "."; then
407 if test "$first" = ".."; then
408 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
409 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
411 first2=`echo "$dir2" | sed -e "$sed_first"`
412 if test "$first2" = "$first"; then
413 dir2=`echo "$dir2" | sed -e "$sed_rest"`
417 dir0="$dir0"/"$first"
420 dir1=`echo "$dir1" | sed -e "$sed_rest"`
425 # func_relconcat DIR1 DIR2
426 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
428 # - DIR1 relative pathname, relative to the current directory
429 # - DIR2 relative pathname, relative to DIR1
431 # - relconcat DIR1/DIR2, relative to the current directory
436 sed_first='s,^\([^/]*\)/.*$,\1,'
437 sed_rest='s,^[^/]*/*,,'
438 sed_last='s,^.*/\([^/]*\)$,\1,'
439 sed_butlast='s,/*[^/]*$,,'
441 first=`echo "$dir2" | sed -e "$sed_first"`
442 if test "$first" = "."; then
443 dir2=`echo "$dir2" | sed -e "$sed_rest"`
444 if test -z "$dir2"; then
449 last=`echo "$dir1" | sed -e "$sed_last"`
450 while test "$last" = "."; do
451 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
452 last=`echo "$dir1" | sed -e "$sed_last"`
454 if test -z "$dir1"; then
458 if test "$first" = ".."; then
459 if test "$last" = ".."; then
460 relconcat="$dir1/$dir2"
463 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
464 dir2=`echo "$dir2" | sed -e "$sed_rest"`
465 if test -z "$dir1"; then
469 if test -z "$dir2"; then
474 relconcat="$dir1/$dir2"
482 # Like ln -s, except that SRC is given relative to the current directory (or
483 # absolute), not given relative to the directory of DEST.
489 *) # SRC is relative.
492 ln -s "`pwd`/$1" "$2" ;;
493 *) # DEST is relative too.
494 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
495 test -n "$ln_destdir" || ln_destdir="."
496 func_relativize "$ln_destdir" "$1"
504 # func_ln_if_changed SRC DEST
505 # Like func_ln, but avoids munging timestamps if the link is correct.
506 func_ln_if_changed ()
508 if test $# -ne 2; then
509 echo "usage: func_ln_if_changed SRC DEST" >&2
511 ln_target=`func_readlink "$2"`
512 if test -h "$2" && test "$1" = "$ln_target"; then
520 # Ensure an 'echo' command that does not interpret backslashes.
522 # echo '\n' | wc -l prints 1 when OK, 2 when KO
523 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
524 # This problem is a weird heritage from SVR4. BSD got it right (except that
525 # BSD echo interprets '-n' as an option, which is also not desirable).
526 # Nowadays the problem occurs in 4 situations:
527 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
528 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
529 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
530 # - in zsh, when sh-emulation is not set,
531 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
532 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
533 # - in Solaris /bin/sh and OSF/1 /bin/sh.
534 # We try the following workarounds:
535 # - for all: respawn using $CONFIG_SHELL if that is set and works.
536 # - for bash >= 2.04: unset the shell option xpg_echo.
537 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
538 # - for bash < 2.0: define echo to a function that uses cat of a here document.
539 # - for zsh: turn sh-emulation on.
540 # - for ksh: alias echo to 'print -r'.
541 # - for ksh: alias echo to a function that uses cat of a here document.
542 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
543 # the ksh workaround.
544 # - otherwise: respawn using /bin/sh and rely on the workarounds.
545 # When respawning, we pass --no-reexec as first argument, so as to avoid
546 # turning this script into a fork bomb in unlucky situations.
548 if echo '\t' | grep t > /dev/null; then
549 have_echo=yes # Lucky!
551 # Try the workarounds.
552 # Respawn using $CONFIG_SHELL if that is set and works.
553 if test -z "$have_echo" \
554 && test "X$1" != "X--no-reexec" \
555 && test -n "$CONFIG_SHELL" \
556 && test -f "$CONFIG_SHELL" \
557 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
558 exec $CONFIG_SHELL "$0" --no-reexec "$@"
561 # For bash >= 2.04: unset the shell option xpg_echo.
562 if test -z "$have_echo" \
563 && test -n "$BASH_VERSION" \
564 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
568 # For bash >= 2.0: define echo to a function that uses the printf built-in.
569 # For bash < 2.0: define echo to a function that uses cat of a here document.
570 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
571 if test -z "$have_echo" \
572 && test -n "$BASH_VERSION"; then \
573 if type printf 2>/dev/null | grep / > /dev/null; then
574 # 'printf' is not a shell built-in.
582 # 'printf' is a shell built-in.
588 if echo '\t' | grep t > /dev/null; then
592 # For zsh: turn sh-emulation on.
593 if test -z "$have_echo" \
594 && test -n "$ZSH_VERSION" \
595 && (emulate sh) >/dev/null 2>&1; then
598 # For ksh: alias echo to 'print -r'.
599 if test -z "$have_echo" \
600 && (type print) >/dev/null 2>&1; then
601 # A 'print' command exists.
602 if type print 2>/dev/null | grep / > /dev/null; then
605 # 'print' is a shell built-in.
606 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
607 # 'print' is the ksh shell built-in.
608 alias echo='print -r'
612 if test -z "$have_echo" \
613 && echo '\t' | grep t > /dev/null; then
616 # For ksh: alias echo to a function that uses cat of a here document.
617 # The ksh manual page says:
618 # "Aliasing is performed when scripts are read, not while they are executed.
619 # Therefore, for an alias to take effect, the alias definition command has
620 # to be executed before the command which references the alias is read."
621 # Because of this, we have to play strange tricks with have_echo, to ensure
622 # that the top-level statement containing the test starts after the 'alias'
624 if test -z "$have_echo"; then
631 alias echo=bsd_echo 2>/dev/null
633 if test -z "$have_echo" \
634 && echo '\t' | grep t > /dev/null; then
637 if test -z "$have_echo"; then
638 unalias echo 2>/dev/null
640 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
641 if test -z "$have_echo" \
642 && test "X$1" != "X--no-reexec" \
643 && test -f /bin/ksh; then
644 exec /bin/ksh "$0" --no-reexec "$@"
647 # Otherwise: respawn using /bin/sh.
648 if test -z "$have_echo" \
649 && test "X$1" != "X--no-reexec" \
650 && test -f /bin/sh; then
651 exec /bin/sh "$0" --no-reexec "$@"
654 if test -z "$have_echo"; then
655 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
657 if echo '\t' | grep t > /dev/null; then
660 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
662 if test "X$1" = "X--no-reexec"; then
666 # Command-line option processing.
667 # Removes the OPTIONS from the arguments. Sets the variables:
668 # - mode list or import or create-testdir or create-megatestdir
669 # - destdir from --dir
670 # - local_gnulib_dir from --local-dir
671 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
672 # - libname, supplied_libname from --lib
673 # - sourcebase from --source-base
674 # - m4base from --m4-base
675 # - pobase from --po-base
676 # - docbase from --doc-base
677 # - testsbase from --tests-base
678 # - auxdir from --aux-dir
679 # - inctests true if --with-tests was given, blank otherwise
680 # - avoidlist list of modules to avoid, from --avoid
681 # - lgpl yes or a number if --lgpl was given, blank otherwise
682 # - makefile_name from --makefile-name
683 # - libtool true if --libtool was given, false if --no-libtool was
684 # given, blank otherwise
685 # - macro_prefix from --macro-prefix
686 # - po_domain from --po-domain
687 # - autoconf_minversion minimum supported autoconf version
688 # - do_changelog false if --no-changelog was given, : otherwise
689 # - doit : if actions shall be executed, false if only to be printed
690 # - symbolic true if --symlink or --more-symlinks was given, blank
692 # - lsymbolic true if --local-symlink was given, blank otherwise
693 # - do_copyrights blank if --more-symlinks was given, true otherwise
722 while test $# -gt 0; do
727 --import | --impor | --impo | --imp | --im | --i )
730 --update | --updat | --upda | --upd | --up | --u )
733 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
736 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
737 mode=create-megatestdir
739 --test | --tes | --te | --t )
742 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
746 mode=`echo "X$1" | sed -e 's/^X--//'`
751 func_fatal_error "missing argument for --dir"
756 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
761 func_fatal_error "missing argument for --local-dir"
766 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
768 --verbose | --verbos | --verbo | --verb )
769 verbose=`expr $verbose + 1`
771 --quiet | --quie | --qui | --qu | --q )
772 verbose=`expr $verbose - 1`
777 func_fatal_error "missing argument for --lib"
780 supplied_libname=true
783 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
784 supplied_libname=true
789 func_fatal_error "missing argument for --source-base"
794 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
799 func_fatal_error "missing argument for --m4-base"
804 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
809 func_fatal_error "missing argument for --po-base"
814 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
819 func_fatal_error "missing argument for --doc-base"
824 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
829 func_fatal_error "missing argument for --tests-base"
834 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
839 func_fatal_error "missing argument for --aux-dir"
844 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
852 func_fatal_error "missing argument for --avoid"
854 func_append avoidlist " $1"
857 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
858 func_append avoidlist " $arg"
864 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
867 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
874 func_fatal_error "missing argument for --makefile-name"
879 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
890 func_fatal_error "missing argument for --macro-prefix"
895 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
900 func_fatal_error "missing argument for --po-domain"
905 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
907 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
913 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
916 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
919 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
923 --help | --hel | --he | --h )
926 --version | --versio | --versi | --vers )
930 # Stop option processing
934 echo "gnulib-tool: unknown option $1" 1>&2
935 echo "Try 'gnulib-tool --help' for more information." 1>&2
942 if test "$mode" = update; then
943 if test $# != 0; then
944 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
945 echo "Try 'gnulib-tool --help' for more information." 1>&2
946 echo "If you really want to modify the gnulib configuration of your project," 1>&2
947 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
950 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
951 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
952 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
953 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
954 || test -n "$makefile_name" || test -n "$macro_prefix" \
955 || test -n "$po_domain"; then
956 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
957 echo "Try 'gnulib-tool --help' for more information." 1>&2
958 echo "If you really want to modify the gnulib configuration of your project," 1>&2
959 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
964 if test -n "$pobase" && test -z "$po_domain"; then
965 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
966 echo "Try 'gnulib-tool --help' for more information." 1>&2
969 if test -z "$pobase" && test -n "$po_domain"; then
970 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
973 # Determine the minimum supported autoconf version from the project's
975 DEFAULT_AUTOCONF_MINVERSION="2.59"
978 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
979 if test -f "$destdir"/configure.ac; then
980 configure_ac="$destdir/configure.ac"
982 if test -f "$destdir"/configure.in; then
983 configure_ac="$destdir/configure.in"
987 if test -f configure.ac; then
988 configure_ac="configure.ac"
990 if test -f configure.in; then
991 configure_ac="configure.in"
995 if test -n "$configure_ac"; then
996 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
997 # because when some m4 files are omitted from a CVS repository,
998 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
999 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1000 # autom4te: m4 failed with exit status: 1
1007 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1009 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1010 if test -n "$prereqs"; then
1011 autoconf_minversion=`
1012 for version in $prereqs; do echo $version; done |
1013 LC_ALL=C sort -nru | sed 1q
1017 if test -z "$autoconf_minversion"; then
1018 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1020 case "$autoconf_minversion" in
1021 1.* | 2.[0-4]* | 2.5[0-8]*)
1022 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1025 # Remove trailing slashes from the directory names. This is necessary for
1026 # m4base (to avoid an error in func_import) and optional for the others.
1027 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1028 case "$local_gnulib_dir" in
1029 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1031 case "$sourcebase" in
1032 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1035 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1038 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1041 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1043 case "$testsbase" in
1044 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1047 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1053 trap 'exit_status=$?
1054 if test "$signal" != 0; then
1055 echo "caught signal $signal" >&2
1058 exit $exit_status' 0
1059 for signal in 1 2 3 13 15; do
1060 trap '{ signal='$signal'; func_exit 1; }' $signal
1064 # func_lookup_file file
1065 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1068 # - local_gnulib_dir from --local-dir
1070 # - lookedup_file name of the merged (combined) file
1071 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1075 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1076 lookedup_file="$local_gnulib_dir/$lkfile"
1079 if test -f "$gnulib_dir/$lkfile"; then
1080 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1081 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1082 rm -f "$tmp/$lkbase"
1083 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1084 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1085 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1086 lookedup_file="$tmp/$lkbase"
1089 lookedup_file="$gnulib_dir/$lkfile"
1093 func_fatal_error "file $gnulib_dir/$lkfile not found"
1100 # - local_gnulib_dir from --local-dir
1103 # Filter out metainformation files like README, which are not modules.
1104 # Filter out unit test modules; they can be retrieved through
1105 # --extract-tests-module if desired.
1107 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1108 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1109 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1112 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1113 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1114 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1115 -e '/^README$/d' -e '/\/README$/d' \
1116 -e '/^TEMPLATE$/d' \
1117 -e '/^TEMPLATE-EXTENDED$/d' \
1118 -e '/^TEMPLATE-TESTS$/d' \
1121 | sed -e '/-tests$/d' \
1125 # func_verify_module
1126 # verifies a module name
1128 # - local_gnulib_dir from --local-dir
1129 # - module module name argument
1130 func_verify_module ()
1132 if { test -f "$gnulib_dir/modules/$module" \
1133 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1134 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1135 && test "CVS" != "$module" \
1136 && test "ChangeLog" != "$module" \
1137 && test "COPYING" != "$module" \
1138 && test "README" != "$module" \
1139 && test "TEMPLATE" != "$module" \
1140 && test "TEMPLATE-EXTENDED" != "$module" \
1141 && test "TEMPLATE-TESTS" != "$module"; then
1142 # OK, $module is a correct module name.
1143 # Verify that building the module description with 'patch' succeeds.
1144 func_lookup_file "modules/$module"
1146 echo "gnulib-tool: module $module doesn't exist" 1>&2
1151 # func_verify_nontests_module
1152 # verifies a module name, excluding tests modules
1154 # - local_gnulib_dir from --local-dir
1155 # - module module name argument
1156 func_verify_nontests_module ()
1159 *-tests ) module= ;;
1160 * ) func_verify_module ;;
1164 # func_verify_tests_module
1165 # verifies a module name, considering only tests modules
1167 # - local_gnulib_dir from --local-dir
1168 # - module module name argument
1169 func_verify_tests_module ()
1172 *-tests ) func_verify_module ;;
1177 sed_extract_prog=':[ ]*$/ {
1180 s/^Description:[ ]*$//
1183 s/^Depends-on:[ ]*$//
1184 s/^configure\.ac-early:[ ]*$//
1185 s/^configure\.ac:[ ]*$//
1186 s/^Makefile\.am:[ ]*$//
1190 s/^Maintainer:[ ]*$//
1197 # func_get_description module
1199 # - local_gnulib_dir from --local-dir
1200 func_get_description ()
1202 func_lookup_file "modules/$1"
1203 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1206 # func_get_notice module
1208 # - local_gnulib_dir from --local-dir
1211 func_lookup_file "modules/$1"
1212 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1215 # func_get_filelist module
1217 # - local_gnulib_dir from --local-dir
1218 func_get_filelist ()
1220 func_lookup_file "modules/$1"
1221 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1222 echo m4/gnulib-common.m4
1223 case "$autoconf_minversion" in
1225 #echo m4/onceonly.m4
1226 echo m4/onceonly_2_57.m4
1231 # func_get_dependencies module
1233 # - local_gnulib_dir from --local-dir
1234 func_get_dependencies ()
1236 # ${module}-tests always implicitly depends on ${module}.
1237 echo "$1" | sed -n -e 's/-tests$//p'
1238 # Then the explicit dependencies listed in the module description.
1239 func_lookup_file "modules/$1"
1240 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1243 # func_get_autoconf_early_snippet module
1245 # - local_gnulib_dir from --local-dir
1246 func_get_autoconf_early_snippet ()
1248 func_lookup_file "modules/$1"
1249 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1252 # func_get_autoconf_snippet module
1254 # - local_gnulib_dir from --local-dir
1255 func_get_autoconf_snippet ()
1257 func_lookup_file "modules/$1"
1258 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1261 # func_get_automake_snippet module
1263 # - local_gnulib_dir from --local-dir
1264 func_get_automake_snippet ()
1266 func_lookup_file "modules/$1"
1267 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1270 # *-tests module live in tests/, not lib/.
1271 # Synthesize an EXTRA_DIST augmentation.
1272 all_files=`func_get_filelist $1`
1273 tests_files=`for f in $all_files; do \
1275 tests/*) echo $f ;; \
1277 done | sed -e 's,^tests/,,'`
1278 extra_files="$tests_files"
1279 if test -n "$extra_files"; then
1280 echo "EXTRA_DIST +=" $extra_files
1285 # Synthesize an EXTRA_DIST augmentation.
1286 sed_combine_lines='/\\$/{
1293 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1294 already_mentioned_files=` \
1295 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1296 | sed -e "$sed_combine_lines" \
1297 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1298 all_files=`func_get_filelist $1`
1299 lib_files=`for f in $all_files; do \
1303 done | sed -e 's,^lib/,,'`
1304 # Remove $already_mentioned_files from $lib_files.
1305 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1306 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1307 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1308 if test -n "$extra_files"; then
1309 echo "EXTRA_DIST +=" $extra_files
1312 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1313 # This is necessary so that automake can generate the right list of
1315 # A possible approach would be to use autom4te --trace of the redefined
1316 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1317 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1318 # inside autoconf's built-in macros are not missed).
1319 # But it's simpler and more robust to do it here, based on the file list.
1320 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1321 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1322 # automake will generate a useless dependency; this is harmless.
1324 relocatable-prog-wrapper) ;;
1326 sed_extract_c_files='/\.c$/p'
1327 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1328 if test -n "$extra_files"; then
1329 echo "EXTRA_lib_SOURCES +=" $extra_files
1334 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1335 buildaux_files=`for f in $all_files; do \
1337 build-aux/*) echo $f ;; \
1339 done | sed -e 's,^build-aux/,,'`
1340 if test -n "$buildaux_files"; then
1341 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1342 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1349 # func_get_include_directive module
1351 # - local_gnulib_dir from --local-dir
1352 func_get_include_directive ()
1354 func_lookup_file "modules/$1"
1355 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1356 sed -e 's/^\(["<]\)/#include \1/'
1359 # func_get_link_directive module
1361 # - local_gnulib_dir from --local-dir
1362 func_get_link_directive ()
1364 func_lookup_file "modules/$1"
1365 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1368 # func_get_license module
1370 # - local_gnulib_dir from --local-dir
1373 func_lookup_file "modules/$1"
1374 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1375 # The default is GPL.
1377 } | sed -e 's,^ *$,,' | sed -e 1q
1380 # func_get_maintainer module
1382 # - local_gnulib_dir from --local-dir
1383 func_get_maintainer ()
1385 func_lookup_file "modules/$1"
1386 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1389 # func_get_tests_module module
1391 # - local_gnulib_dir from --local-dir
1392 func_get_tests_module ()
1394 # The naming convention for tests modules is hardwired: ${module}-tests.
1395 if test -f "$gnulib_dir/modules/$1"-tests \
1396 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1397 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1402 # func_acceptable module
1403 # tests whether a module is acceptable.
1405 # - avoidlist list of modules to avoid
1408 for avoid in $avoidlist; do
1409 if test "$avoid" = "$1"; then
1416 # func_modules_transitive_closure
1418 # - local_gnulib_dir from --local-dir
1419 # - modules list of specified modules
1420 # - inctests true if tests should be included, blank otherwise
1421 # - avoidlist list of modules to avoid
1422 # - tmp pathname of a temporary directory
1424 # - modules list of modules, including dependencies
1425 func_modules_transitive_closure ()
1427 # In order to process every module only once (for speed), process an "input
1428 # list" of modules, producing an "output list" of modules. During each round,
1429 # more modules can be queued in the input list. Once a module on the input
1430 # list has been processed, it is added to the "handled list", so we can avoid
1431 # to process it again.
1433 inmodules="$modules"
1435 while test -n "$inmodules"; do
1436 inmodules_this_round="$inmodules"
1437 inmodules= # Accumulator, queue for next round
1438 for module in $inmodules_this_round; do
1440 if test -n "$module"; then
1441 if func_acceptable $module; then
1442 func_append outmodules " $module"
1443 deps=`func_get_dependencies $module`
1444 # Duplicate dependencies are harmless, but Jim wants a warning.
1445 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1446 if test -n "$duplicated_deps"; then
1447 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1449 func_append inmodules " $deps"
1450 if test -n "$inctests"; then
1451 testsmodule=`func_get_tests_module $module`
1452 if test -n "$testsmodule"; then
1453 func_append inmodules " $testsmodule"
1459 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1460 # Remove $handledmodules from $inmodules.
1461 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1462 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1464 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1465 rm -f "$tmp"/queued-modules
1468 # func_modules_add_dummy
1470 # - local_gnulib_dir from --local-dir
1471 # - modules list of modules, including dependencies
1473 # - modules list of modules, including 'dummy' if needed
1474 func_modules_add_dummy ()
1477 sed_remove_backslash_newline=':a
1484 for module in $modules; do
1485 func_verify_nontests_module
1486 if test -n "$module"; then
1487 # Extract the value of "lib_SOURCES += ...".
1488 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1489 # Ignore .h files since they are not compiled.
1492 *) have_lib_SOURCES=yes ;;
1497 # Add the dummy module, to make sure the library will be non-empty.
1498 if test -z "$have_lib_SOURCES"; then
1499 if func_acceptable "dummy"; then
1500 func_append modules " dummy"
1505 # func_modules_notice
1507 # - local_gnulib_dir from --local-dir
1508 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1509 # - modules list of modules, including dependencies
1510 func_modules_notice ()
1512 if test $verbose -ge -1; then
1513 for module in $modules; do
1515 if test -n "$module"; then
1516 msg=`func_get_notice $module`
1517 if test -n "$msg"; then
1518 echo "Notice from module $module:"
1519 echo "$msg" | sed -e 's/^/ /'
1526 # func_modules_to_filelist
1528 # - local_gnulib_dir from --local-dir
1529 # - modules list of modules, including dependencies
1531 # - files list of files
1532 func_modules_to_filelist ()
1535 for module in $modules; do
1537 if test -n "$module"; then
1538 fs=`func_get_filelist $module`
1539 func_append files " $fs"
1542 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1545 # func_execute_command command [args...]
1546 # Executes a command.
1547 # Uses also the variables
1548 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1549 func_execute_command ()
1551 if test $verbose -ge 0; then
1555 # Commands like automake produce output to stderr even when the succeed.
1556 # Turn this output off if the command succeeds.
1557 "$@" > "$tmp"/cmdout 2>&1
1559 if test $cmdret = 0; then
1563 cat "$tmp"/cmdout 1>&2
1570 # func_emit_lib_Makefile_am
1571 # emits the contents of library makefile to standard output.
1573 # - local_gnulib_dir from --local-dir
1574 # - modules list of modules, including dependencies
1575 # - libname library name
1576 # - pobase directory relative to destdir where to place *.po files
1577 # - auxdir directory relative to destdir where to place build aux files
1578 # - makefile_name from --makefile-name
1579 # - libtool true if libtool will be used, false or blank otherwise
1580 # - macro_prefix prefix of gl_LIBOBJS macros to use
1581 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1582 # - actioncmd (optional) command that will reproduce this invocation
1583 # - for_test true if creating a package for testing, false otherwise
1585 # - uses_subdirs nonempty if object files in subdirs exist
1586 func_emit_lib_Makefile_am ()
1588 # When creating an includable Makefile.am snippet, augment variables with
1589 # += instead of assigning them.
1590 if test -n "$makefile_name"; then
1595 if test "$libtool" = true; then
1598 sed_eliminate_LDFLAGS=
1602 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1605 # When creating a package for testing: Attempt to provoke failures,
1606 # especially link errors, already during "make" rather than during
1607 # "make check", because "make check" is not possible in a cross-compiling
1608 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1609 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1611 sed_transform_check_PROGRAMS=
1613 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1614 echo "## Process this file with automake to produce Makefile.in."
1615 func_emit_copyright_notice
1616 if test -n "$actioncmd"; then
1617 echo "# Reproduce by: $actioncmd"
1622 for module in $modules; do
1623 func_verify_nontests_module
1624 if test -n "$module"; then
1626 func_get_automake_snippet "$module" |
1627 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1628 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1629 -e "$sed_eliminate_LDFLAGS" \
1630 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1631 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1632 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1633 -e "$sed_transform_check_PROGRAMS"
1634 if test "$module" = 'alloca'; then
1635 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1636 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1639 # Skip the contents if its entirely empty.
1640 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1641 echo "## begin gnulib module $module"
1644 echo "## end gnulib module $module"
1648 # Test whether there are some source files in subdirectories.
1649 for f in `func_get_filelist "$module"`; do
1651 lib/*/*.c) uses_subdirs=yes ;;
1657 if test -z "$makefile_name"; then
1658 # If there are source files in subdirectories, prevent collision of the
1659 # object files (example: hash.c and libxml/hash.c).
1661 if test -n "$uses_subdirs"; then
1662 subdir_options=' subdir-objects'
1664 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1667 if test -z "$makefile_name"; then
1668 echo "noinst_HEADERS ="
1669 echo "noinst_LIBRARIES ="
1670 echo "noinst_LTLIBRARIES ="
1671 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1672 # if you specify pkgdata_DATA to empty. This is a workaround.
1673 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1674 echo "pkgdata_DATA ="
1677 echo "BUILT_SOURCES ="
1680 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1681 if test -z "$makefile_name"; then
1682 echo "MOSTLYCLEANDIRS ="
1684 echo "DISTCLEANFILES ="
1685 echo "MAINTAINERCLEANFILES ="
1687 echo "AM_CPPFLAGS ="
1690 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1691 # One of the snippets already specifies an installation location for the
1692 # library. Don't confuse automake by saying it should not be installed.
1695 # By default, the generated library should not be installed.
1696 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1699 echo "${libname}_${libext}_SOURCES ="
1700 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1701 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1702 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1703 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1704 echo "EXTRA_${libname}_${libext}_SOURCES ="
1705 if test "$libtool" = true; then
1706 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1709 if test -n "$pobase"; then
1710 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1713 cat allsnippets.tmp \
1714 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1716 echo "mostlyclean-local: mostlyclean-generic"
1717 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1718 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1719 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1723 rm -f allsnippets.tmp
1726 # func_emit_po_Makevars
1727 # emits the contents of po/ makefile parametrization to standard output.
1729 # - local_gnulib_dir from --local-dir
1730 # - sourcebase directory relative to destdir where to place source code
1731 # - pobase directory relative to destdir where to place *.po files
1732 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1733 func_emit_po_Makevars ()
1735 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1736 func_emit_copyright_notice
1738 echo "# Usually the message domain is the same as the package name."
1739 echo "# But here it has a '-gnulib' suffix."
1740 echo "DOMAIN = ${po_domain}-gnulib"
1742 echo "# These two variables depend on the location of this directory."
1743 echo "subdir = ${pobase}"
1744 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1747 # These options get passed to xgettext.
1748 XGETTEXT_OPTIONS = \
1749 --keyword=_ --flag=_:1:pass-c-format \
1750 --keyword=N_ --flag=N_:1:pass-c-format \
1751 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1752 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1753 --flag=error:3:c-format --flag=error_at_line:5:c-format
1755 # This is the copyright holder that gets inserted into the header of the
1756 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1757 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1759 # This is the email address or URL to which the translators shall report
1760 # bugs in the untranslated strings:
1761 # - Strings which are not entire sentences, see the maintainer guidelines
1762 # in the GNU gettext documentation, section 'Preparing Strings'.
1763 # - Strings which use unclear terms or require additional context to be
1765 # - Strings which make invalid assumptions about notation of date, time or
1767 # - Pluralisation problems.
1768 # - Incorrect English spelling.
1769 # - Incorrect formatting.
1770 # It can be your email address, or a mailing list address where translators
1771 # can write to without being subscribed, or the URL of a web page through
1772 # which the translators can contact you.
1773 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1775 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1776 # message catalogs shall be used. It is usually empty.
1777 EXTRA_LOCALE_CATEGORIES =
1779 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1780 # context. Possible values are "yes" and "no". Set this to yes if the
1781 # package uses functions taking also a message context, like pgettext(), or
1782 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1787 # func_emit_po_POTFILES_in
1788 # emits the file list to be passed to xgettext to standard output.
1790 # - local_gnulib_dir from --local-dir
1791 # - sourcebase directory relative to destdir where to place source code
1792 # - files list of new files
1793 func_emit_po_POTFILES_in ()
1795 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1796 func_emit_copyright_notice
1798 echo "# List of files which contain translatable strings."
1799 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1802 # func_emit_tests_Makefile_am
1803 # emits the contents of tests makefile to standard output.
1805 # - local_gnulib_dir from --local-dir
1806 # - modules list of modules, including dependencies
1807 # - libname library name
1808 # - auxdir directory relative to destdir where to place build aux files
1809 # - makefile_name from --makefile-name
1810 # - libtool true if libtool will be used, false or blank otherwise
1811 # - sourcebase relative directory containing lib source code
1812 # - m4base relative directory containing autoconf macros
1813 # - testsbase relative directory containing unit test code
1814 # - macro_prefix prefix of gl_LIBOBJS macros to use
1815 # - for_test true if creating a package for testing, false otherwise
1816 # - use_libtests true if a libtests.a should be built, false otherwise
1818 # - uses_subdirs nonempty if object files in subdirs exist
1819 func_emit_tests_Makefile_am ()
1821 if test "$libtool" = true; then
1823 sed_eliminate_LDFLAGS=
1826 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1829 # When creating a package for testing: Attempt to provoke failures,
1830 # especially link errors, already during "make" rather than during
1831 # "make check", because "make check" is not possible in a cross-compiling
1832 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1833 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1835 sed_transform_check_PROGRAMS=
1837 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1838 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1839 echo "## Process this file with automake to produce Makefile.in."
1840 func_emit_copyright_notice
1844 for module in $modules; do
1846 func_verify_tests_module
1850 if test -n "$module"; then
1852 func_get_automake_snippet "$module" |
1853 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1854 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1855 -e "$sed_eliminate_LDFLAGS" \
1856 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
1857 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1858 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1859 -e "$sed_transform_check_PROGRAMS"
1860 if $use_libtests && test "$module" = 'alloca'; then
1861 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
1862 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1865 # Skip the contents if its entirely empty.
1866 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1867 echo "## begin gnulib module $module"
1870 echo "## end gnulib module $module"
1874 # Test whether there are some source files in subdirectories.
1875 for f in `func_get_filelist "$module"`; do
1877 lib/*/*.c | tests/*/*.c) uses_subdirs=yes ;;
1883 # Generate dependencies here, since it eases the debugging of test failures.
1884 # If there are source files in subdirectories, prevent collision of the
1885 # object files (example: hash.c and libxml/hash.c).
1887 if test -n "$uses_subdirs"; then
1888 subdir_options=' subdir-objects'
1890 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
1893 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1896 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1897 # variable is needed to avoid an error from automake:
1898 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1901 echo "TESTS_ENVIRONMENT ="
1902 echo "noinst_PROGRAMS ="
1903 if ! $for_test; then
1904 echo "check_PROGRAMS ="
1906 echo "noinst_HEADERS ="
1907 echo "noinst_LIBRARIES ="
1908 if $use_libtests; then
1910 echo "noinst_LIBRARIES += libtests.a"
1912 echo "check_LIBRARIES = libtests.a"
1915 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1916 # if you specify pkgdata_DATA to empty. This is a workaround.
1917 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1918 echo "pkgdata_DATA ="
1921 echo "BUILT_SOURCES ="
1923 echo "MOSTLYCLEANFILES = core *.stackdump"
1924 echo "MOSTLYCLEANDIRS ="
1926 echo "DISTCLEANFILES ="
1927 echo "MAINTAINERCLEANFILES ="
1929 echo "AM_CPPFLAGS = \\"
1930 echo " -I. -I\$(srcdir) \\"
1931 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1932 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1934 local_ldadd_before=''
1935 local_ldadd_after=''
1936 if $use_libtests; then
1937 # All test programs need to be linked with libtests.a.
1938 # It needs to be passed to the linker before ${libname}.${libext}, since
1939 # the tests-related modules depend on the main modules.
1940 # It also needs to be passed to the linker after ${libname}.${libext}
1941 # because the latter might contain incomplete modules (such as the 'error'
1942 # module whose dependency to 'progname' is voluntarily omitted).
1943 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
1945 local_ldadd_before=' libtests.a'
1946 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
1948 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
1950 if $use_libtests; then
1951 echo "libtests_a_SOURCES ="
1952 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1953 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1954 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
1955 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
1956 echo "EXTRA_libtests_a_SOURCES ="
1957 # The circular dependency in LDADD requires this.
1958 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
1961 cat allsnippets.tmp \
1962 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1963 echo "# Clean up after Solaris cc."
1965 echo " rm -rf SunWS_cache"
1967 echo "mostlyclean-local: mostlyclean-generic"
1968 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1969 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1970 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1974 rm -f allsnippets.tmp
1977 # func_emit_initmacro_start macro_prefix
1978 # emits the first few statements of the gl_INIT macro to standard output.
1979 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1980 func_emit_initmacro_start ()
1982 macro_prefix_arg="$1"
1983 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1984 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
1985 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1986 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1988 # Furthermore it avoids an automake error like this when a Makefile.am
1989 # that uses pieces of gnulib also uses $(LIBOBJ):
1990 # automatically discovered file `error.c' should not be explicitly mentioned
1991 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
1992 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
1993 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1994 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1995 # automatically discovered file `error.c' should not be explicitly mentioned
1996 # We let automake know about the files to be distributed through the
1997 # EXTRA_lib_SOURCES variable.
1998 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2001 # func_emit_initmacro_end macro_prefix
2002 # emits the last few statements of the gl_INIT macro to standard output.
2003 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2004 func_emit_initmacro_end ()
2006 macro_prefix_arg="$1"
2007 echo " m4_popdef([AC_LIBSOURCES])"
2008 echo " m4_popdef([AC_REPLACE_FUNCS])"
2009 echo " m4_popdef([AC_LIBOBJ])"
2010 echo " AC_CONFIG_COMMANDS_PRE(["
2011 echo " ${macro_prefix_arg}_libobjs="
2012 echo " ${macro_prefix_arg}_ltlibobjs="
2013 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2014 echo " # Remove the extension."
2015 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2016 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2017 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2018 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2021 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2022 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2026 # func_emit_initmacro_done macro_prefix sourcebase
2027 # emits a few statements after the gl_INIT macro to standard output.
2028 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2029 # - sourcebase directory relative to destdir where to place source code
2030 func_emit_initmacro_done ()
2032 macro_prefix_arg="$1"
2035 echo "# Like AC_LIBOBJ, except that the module name goes"
2036 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2037 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2038 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2039 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2042 echo "# m4_foreach_w is provided by autoconf-2.59c and later."
2043 echo "# This definition is to accommodate developers using versions"
2044 echo "# of autoconf older than that."
2045 echo "m4_ifndef([m4_foreach_w],"
2046 echo " [m4_define([m4_foreach_w],"
2047 echo " [m4_foreach([\$1], m4_split(m4_normalize([\$2]), [ ]), [\$3])])])"
2049 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2050 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2051 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2052 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2053 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2056 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2057 echo "# expected is derived from the gnulib-tool parametrization,"
2058 echo "# and alloca is special cased (for the alloca-opt module)."
2059 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2060 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2061 echo " m4_foreach([_gl_NAME], [\$1], ["
2062 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2063 echo " m4_syscmd([test -r $sourcebase_arg/]_gl_NAME[ || test ! -d $sourcebase_arg])dnl"
2064 echo " m4_if(m4_sysval, [0], [],"
2065 echo " [AC_FATAL([missing $sourcebase_arg/]_gl_NAME)])"
2071 # func_import modules
2072 # Uses also the variables
2073 # - destdir target directory
2074 # - local_gnulib_dir from --local-dir
2075 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2076 # - libname library name
2077 # - sourcebase directory relative to destdir where to place source code
2078 # - m4base directory relative to destdir where to place *.m4 macros
2079 # - pobase directory relative to destdir where to place *.po files
2080 # - docbase directory relative to destdir where to place doc files
2081 # - testsbase directory relative to destdir where to place unit test code
2082 # - auxdir directory relative to destdir where to place build aux files
2083 # - inctests true if --with-tests was given, blank otherwise
2084 # - avoidlist list of modules to avoid, from --avoid
2085 # - lgpl yes or a number if library's license shall be LGPL,
2087 # - makefile_name from --makefile-name
2088 # - libtool true if --libtool was given, false if --no-libtool was
2089 # given, blank otherwise
2090 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2091 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2092 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2093 # - autoconf_minversion minimum supported autoconf version
2094 # - doit : if actions shall be executed, false if only to be printed
2095 # - symbolic true if files should be symlinked, copied otherwise
2096 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2098 # - do_copyrights true if copyright notices in files should be replaced,
2102 # Get the cached settings.
2103 cached_local_gnulib_dir=
2104 cached_specified_modules=
2114 cached_makefile_name=
2116 cached_macro_prefix=
2119 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2120 cached_libtool=false
2126 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2129 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2132 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2135 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2138 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2141 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2144 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2147 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2150 s,^.*$,cached_inctests=true,p
2153 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2156 s,^.*gl_LGPL([[ ]*\([^])]*\).*$,cached_lgpl="\1",p
2159 s,^.*$,cached_lgpl=yes,p
2161 /gl_MAKEFILE_NAME(/ {
2162 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2165 s,^.*$,cached_libtool=true,p
2167 /gl_MACRO_PREFIX(/ {
2168 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2171 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2173 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2174 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2179 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2180 s,^.*$,cached_files=",p
2192 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2196 # Merge the cached settings with the specified ones.
2197 # The m4base must be the same as expected from the pathname.
2198 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2199 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2201 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2202 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2203 if test -z "$local_gnulib_dir"; then
2204 if test -n "$cached_local_gnulib_dir"; then
2207 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2209 case "$cached_local_gnulib_dir" in
2211 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2213 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2214 local_gnulib_dir="$relconcat" ;;
2219 # Append the cached and the specified module names. So that
2220 # "gnulib-tool --import foo" means to add the module foo.
2221 specified_modules="$cached_specified_modules $1"
2222 # Append the cached and the specified avoidlist. This is probably better
2223 # than dropping the cached one when --avoid is specified at least once.
2224 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2225 avoidlist=`echo $avoidlist`
2227 # The sourcebase defaults to the cached one.
2228 if test -z "$sourcebase"; then
2229 sourcebase="$cached_sourcebase"
2230 if test -z "$sourcebase"; then
2231 func_fatal_error "missing --source-base option"
2234 # The pobase defaults to the cached one.
2235 if test -z "$pobase"; then
2236 pobase="$cached_pobase"
2238 # The docbase defaults to the cached one.
2239 if test -z "$docbase"; then
2240 docbase="$cached_docbase"
2241 if test -z "$docbase"; then
2242 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."
2245 # The testsbase defaults to the cached one.
2246 if test -z "$testsbase"; then
2247 testsbase="$cached_testsbase"
2248 if test -z "$testsbase"; then
2249 func_fatal_error "missing --tests-base option"
2252 # Require the tests if specified either way.
2253 if test -z "$inctests"; then
2254 inctests="$cached_inctests"
2256 # The libname defaults to the cached one.
2257 if test -z "$supplied_libname"; then
2258 libname="$cached_libname"
2259 if test -z "$libname"; then
2260 func_fatal_error "missing --lib option"
2263 # Require LGPL if specified either way.
2264 if test -z "$lgpl"; then
2267 # The makefile_name defaults to the cached one.
2268 if test -z "$makefile_name"; then
2269 makefile_name="$cached_makefile_name"
2271 # Use libtool if specified either way, or if guessed.
2272 if test -z "$libtool"; then
2273 if test -n "$cached_m4base"; then
2274 libtool="$cached_libtool"
2276 libtool="$guessed_libtool"
2279 # The macro_prefix defaults to the cached one.
2280 if test -z "$macro_prefix"; then
2281 macro_prefix="$cached_macro_prefix"
2282 if test -z "$macro_prefix"; then
2283 func_fatal_error "missing --macro-prefix option"
2286 # The po_domain defaults to the cached one.
2287 if test -z "$po_domain"; then
2288 po_domain="$cached_po_domain"
2291 # Canonicalize the list of specified modules.
2292 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2294 # Determine final module list.
2295 modules="$specified_modules"
2296 func_modules_transitive_closure
2297 if test $verbose -ge 0; then
2298 echo "Module list with included dependencies:"
2299 echo "$modules" | sed -e 's/^/ /'
2301 final_modules="$modules"
2303 # Determine main module list and tests-related module list separately.
2304 # The main module list is the transitive closure of the specified modules,
2305 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2306 # is specified, it will consist only of LGPLed source.
2307 # The tests-related module list is the transitive closure of the specified
2308 # modules, including tests modules, minus the main module list. Its lib/*
2309 # sources (brought in through dependencies of *-tests modules) go into
2310 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2311 # Determine main module list.
2312 saved_inctests="$inctests"
2314 modules="$specified_modules"
2315 func_modules_transitive_closure
2316 main_modules="$modules"
2317 inctests="$saved_inctests"
2318 if test $verbose -ge 1; then
2319 echo "Main module list:"
2320 echo "$main_modules" | sed -e 's/^/ /'
2322 # Determine tests-related module list.
2323 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2324 testsrelated_modules=`echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2325 if test $verbose -ge 1; then
2326 echo "Tests-related module list:"
2327 echo "$testsrelated_modules" | sed -e 's/^/ /'
2330 # Add the dummy module to the main module list if needed.
2331 modules="$main_modules"
2332 func_modules_add_dummy
2333 main_modules="$modules"
2335 # Determine whether a $testsbase/libtests.a is needed.
2337 for module in $testsrelated_modules; do
2338 func_verify_nontests_module
2339 if test -n "$module"; then
2340 all_files=`func_get_filelist $module`
2341 lib_files=`for f in $all_files; do \
2345 done | sed -e 's,^lib/,,'`
2346 if test -n "$lib_files"; then
2353 # Add the dummy module to the tests-related module list if needed.
2354 if $use_libtests; then
2355 modules="$testsrelated_modules"
2356 func_modules_add_dummy
2357 testsrelated_modules="$modules"
2360 # If --lgpl, verify that the licenses of modules are compatible.
2361 if test -n "$lgpl"; then
2362 for module in $main_modules; do
2363 license=`func_get_license $module`
2365 'GPLed build tool') ;;
2366 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2372 *) func_fatal_error "incompatible license on module $module: $license" ;;
2378 *) func_fatal_error "incompatible license on module $module: $license" ;;
2381 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2388 # Show banner notice of every module.
2389 modules="$main_modules"
2392 # Determine script to apply to imported library files.
2393 sed_transform_lib_file=
2394 for module in $main_modules; do
2395 if test $module = config-h; then
2396 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2397 sed_transform_lib_file=$sed_transform_lib_file'
2398 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2403 sed_transform_main_lib_file="$sed_transform_lib_file"
2404 if test -n "$do_copyrights"; then
2405 if test -n "$lgpl"; then
2409 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2410 s/GNU General/GNU Lesser General/g
2414 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2415 s/GNU General/GNU Lesser General/g
2416 s/version [23]\([ ,]\)/version 2.1\1/g
2419 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2423 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2424 s/GNU Lesser General/GNU General/g
2425 s/GNU Library General/GNU General/g
2426 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2431 # Determine script to apply to library files that go into $testsbase/.
2432 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2433 if test -n "$do_copyrights"; then
2435 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2436 s/GNU Lesser General/GNU General/g
2437 s/GNU Library General/GNU General/g
2438 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2442 # Determine the final file lists.
2443 # They must be computed separately, because files in lib/* go into
2444 # $sourcebase/ if they are in the main file list but into $testsbase/
2445 # if they are in the tests-related file list. Furthermore lib/dummy.c
2447 # Determine final main file list.
2448 modules="$main_modules"
2449 func_modules_to_filelist
2451 # Determine final tests-related file list.
2452 modules="$testsrelated_modules"
2453 func_modules_to_filelist
2454 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2455 # Merge both file lists.
2456 sed_remove_empty_lines='/^$/d'
2457 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2458 if test $verbose -ge 0; then
2460 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2461 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2465 || func_fatal_error "refusing to do nothing"
2467 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2468 new_files="$files m4/gnulib-tool.m4"
2469 old_files="$cached_files"
2470 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2471 func_append old_files " m4/gnulib-tool.m4"
2474 sed_rewrite_old_files="\
2475 s,^build-aux/,$auxdir/,
2476 s,^doc/,$cached_docbase/,
2477 s,^lib/,$cached_sourcebase/,
2478 s,^m4/,$cached_m4base/,
2479 s,^tests/,$cached_testsbase/,
2480 s,^tests=lib/,$cached_testsbase/,"
2481 sed_rewrite_new_files="\
2482 s,^build-aux/,$auxdir/,
2484 s,^lib/,$sourcebase/,
2486 s,^tests/,$testsbase/,
2487 s,^tests=lib/,$testsbase/,"
2489 # Create directories.
2490 { echo "$sourcebase"
2492 if test -n "$pobase"; then
2495 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2496 if test -n "$docfiles"; then
2499 if test -n "$inctests"; then
2503 for f in $files; do echo $f; done \
2504 | sed -e "$sed_rewrite_new_files" \
2505 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2508 { # Rearrange file descriptors. Needed because "while ... done < ..."
2509 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2510 exec 5<&0 < "$tmp"/dirs
2512 if test ! -d "$destdir/$d"; then
2514 echo "Creating directory $destdir/$d"
2515 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2517 echo "Create directory $destdir/$d"
2524 # func_dest_tmpfilename file
2525 # determines the name of a temporary file (file is relative to destdir).
2527 # - tmpfile absolute filename of the temporary file
2528 func_dest_tmpfilename ()
2531 # Put the new contents of $file in a file in the same directory (needed
2532 # to guarantee that an 'mv' to "$destdir/$file" works).
2533 tmpfile="$destdir/$1.tmp"
2535 # Put the new contents of $file in a file in a temporary directory
2536 # (because the directory of "$file" might not exist).
2537 tmpfile="$tmp"/`basename "$1"`.tmp
2541 # Copy files or make symbolic links. Remove obsolete files.
2545 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2546 # representing the files according to the last gnulib-tool invocation.
2547 for f in $old_files; do echo $f; done \
2548 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2551 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2552 # representing the files after this gnulib-tool invocation.
2553 for f in $new_files; do echo $f; done \
2554 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2557 # First the files that are in old-files, but not in new-files:
2558 sed_take_first_column='s,'"$delimiter"'.*,,'
2559 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2560 # Remove the file. Do nothing if the user already removed it.
2561 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2563 echo "Removing file $g (backup in ${g}~)"
2564 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2566 echo "Remove file $g (backup in ${g}~)"
2568 func_append removed_files "$g$nl"
2571 # func_add_or_update handles a file that ought to be present afterwards.
2573 # - f the original file name
2574 # - g the rewritten file name
2575 # - already_present nonempty if the file already exists, empty otherwise
2576 func_add_or_update ()
2580 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2582 func_dest_tmpfilename "$g"
2583 func_lookup_file "$f"
2584 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2585 if test -n "$sed_transform_main_lib_file"; then
2588 sed -e "$sed_transform_main_lib_file" \
2589 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2593 if test -n "$sed_transform_testsrelated_lib_file"; then
2596 sed -e "$sed_transform_testsrelated_lib_file" \
2597 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2601 if test -f "$destdir/$g"; then
2602 # The file already exists.
2603 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2604 : # The file has not changed.
2608 if test -n "$already_present"; then
2609 echo "Updating file $g (backup in ${g}~)"
2611 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2613 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2614 if { test -n "$symbolic" \
2615 || { test -n "$lsymbolic" \
2616 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2617 && test -z "$lookedup_tmp" \
2618 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2619 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2621 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2624 if test -n "$already_present"; then
2625 echo "Update file $g (backup in ${g}~)"
2627 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2633 # Don't protest if the file should be there but isn't: it happens
2634 # frequently that developers don't put autogenerated files into CVS.
2636 echo "Copying file $g"
2637 if { test -n "$symbolic" \
2638 || { test -n "$lsymbolic" \
2639 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2640 && test -z "$lookedup_tmp" \
2641 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2642 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2644 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2649 func_append added_files "$g$nl"
2653 # Then the files that are in new-files, but not in old-files:
2654 sed_take_last_column='s,^.*'"$delimiter"',,'
2656 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2657 | sed -e "$sed_take_last_column" \
2658 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2659 { # Rearrange file descriptors. Needed because "while ... done < ..."
2660 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2661 exec 5<&0 < "$tmp"/added-files
2667 # Then the files that are in new-files and in old-files:
2668 already_present=true
2669 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2670 | sed -e "$sed_take_last_column" \
2671 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2672 { # Rearrange file descriptors. Needed because "while ... done < ..."
2673 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2674 exec 5<&0 < "$tmp"/kept-files
2681 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2682 actioncmd="gnulib-tool --import"
2683 func_append actioncmd " --dir=$destdir"
2684 if test -n "$local_gnulib_dir"; then
2685 func_append actioncmd " --local-dir=$local_gnulib_dir"
2687 func_append actioncmd " --lib=$libname"
2688 func_append actioncmd " --source-base=$sourcebase"
2689 func_append actioncmd " --m4-base=$m4base"
2690 if test -n "$pobase"; then
2691 func_append actioncmd " --po-base=$pobase"
2693 func_append actioncmd " --doc-base=$docbase"
2694 func_append actioncmd " --aux-dir=$auxdir"
2695 if test -n "$inctests"; then
2696 func_append actioncmd " --with-tests"
2698 for module in $avoidlist; do
2699 func_append actioncmd " --avoid=$module"
2701 if test -n "$lgpl"; then
2702 if test "$lgpl" = yes; then
2703 func_append actioncmd " --lgpl"
2705 func_append actioncmd " --lgpl=$lgpl"
2708 if test -n "$makefile_name"; then
2709 func_append actioncmd " --makefile-name=$makefile_name"
2711 if test "$libtool" = true; then
2712 func_append actioncmd " --libtool"
2714 func_append actioncmd " --no-libtool"
2716 func_append actioncmd " --macro-prefix=$macro_prefix"
2717 if test -n "$po_domain"; then
2718 func_append actioncmd " --po-domain=$po_domain"
2720 func_append actioncmd " `echo $specified_modules`"
2722 # Default the makefile name to Makefile.am.
2723 if test -n "$makefile_name"; then
2724 makefile_am=$makefile_name
2726 makefile_am=Makefile.am
2729 # Create normal Makefile.ams.
2732 # Create library makefile.
2733 func_dest_tmpfilename $sourcebase/$makefile_am
2734 modules="$main_modules"
2735 func_emit_lib_Makefile_am > "$tmpfile"
2736 if test -f "$destdir"/$sourcebase/$makefile_am; then
2737 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2741 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2742 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2743 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2745 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2751 echo "Creating $sourcebase/$makefile_am"
2752 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2754 echo "Create $sourcebase/$makefile_am"
2757 func_append added_files "$sourcebase/$makefile_am$nl"
2760 # Create po/ directory.
2761 if test -n "$pobase"; then
2762 # Create po makefile and auxiliary files.
2763 for file in Makefile.in.in remove-potcdate.sin; do
2764 func_dest_tmpfilename $pobase/$file
2765 func_lookup_file build-aux/po/$file
2766 cat "$lookedup_file" > "$tmpfile"
2767 if test -f "$destdir"/$pobase/$file; then
2768 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2772 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2773 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2774 mv -f "$tmpfile" "$destdir"/$pobase/$file
2776 echo "Update $pobase/$file (backup in $pobase/$file~)"
2782 echo "Creating $pobase/$file"
2783 mv -f "$tmpfile" "$destdir"/$pobase/$file
2785 echo "Create $pobase/$file"
2788 func_append added_files "$pobase/$file$nl"
2791 # Create po makefile parametrization, part 1.
2792 func_dest_tmpfilename $pobase/Makevars
2793 func_emit_po_Makevars > "$tmpfile"
2794 if test -f "$destdir"/$pobase/Makevars; then
2795 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2799 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2800 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2801 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2803 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2809 echo "Creating $pobase/Makevars"
2810 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2812 echo "Create $pobase/Makevars"
2815 func_append added_files "$pobase/Makevars$nl"
2817 # Create po makefile parametrization, part 2.
2818 func_dest_tmpfilename $pobase/POTFILES.in
2819 func_emit_po_POTFILES_in > "$tmpfile"
2820 if test -f "$destdir"/$pobase/POTFILES.in; then
2821 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2825 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2826 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2827 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2829 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2835 echo "Creating $pobase/POTFILES.in"
2836 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2838 echo "Create $pobase/POTFILES.in"
2841 func_append added_files "$pobase/POTFILES.in$nl"
2844 TP_URL="http://translationproject.org/latest/"
2845 TP_RSYNC_URI="translationproject.org::tp/latest/"
2847 echo "Fetching gnulib PO files from $TP_URL"
2848 (cd "$destdir"/$pobase \
2849 && { # Prefer rsync over wget if it is available, since it consumes
2850 # less network bandwidth, due to compression.
2851 if type rsync 2>/dev/null | grep / > /dev/null; then
2852 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2854 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2859 echo "Fetch gnulib PO files from $TP_URL"
2861 # Create po/LINGUAS.
2863 func_dest_tmpfilename $pobase/LINGUAS
2864 (cd "$destdir"/$pobase \
2865 && { echo '# Set of available languages.'
2866 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2869 if test -f "$destdir"/$pobase/LINGUAS; then
2870 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2873 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2874 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2875 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2878 echo "Creating $pobase/LINGUAS"
2879 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2880 func_append added_files "$pobase/LINGUAS$nl"
2883 if test -f "$destdir"/$pobase/LINGUAS; then
2884 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2886 echo "Create $pobase/LINGUAS"
2891 # Create m4/gnulib-cache.m4.
2892 func_dest_tmpfilename $m4base/gnulib-cache.m4
2894 func_emit_copyright_notice
2896 echo "# This file represents the specification of how gnulib-tool is used."
2897 echo "# It acts as a cache: It is written and read by gnulib-tool."
2898 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2899 echo "# like the configure.ac and various Makefile.am files."
2902 echo "# Specification in the form of a command-line invocation:"
2905 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2906 # Store the local_gnulib_dir relative to destdir.
2907 case "$local_gnulib_dir" in
2909 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2912 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2914 # destdir, local_gnulib_dir are both relative.
2915 func_relativize "$destdir" "$local_gnulib_dir"
2916 relative_local_gnulib_dir="$reldir" ;;
2919 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2920 echo "gl_MODULES(["`echo $specified_modules`"])"
2921 echo "gl_AVOID([$avoidlist])"
2922 echo "gl_SOURCE_BASE([$sourcebase])"
2923 echo "gl_M4_BASE([$m4base])"
2924 echo "gl_PO_BASE([$pobase])"
2925 echo "gl_DOC_BASE([$docbase])"
2926 echo "gl_TESTS_BASE([$testsbase])"
2927 test -z "$inctests" || echo "gl_WITH_TESTS"
2928 echo "gl_LIB([$libname])"
2929 if test -n "$lgpl"; then
2930 if test "$lgpl" = yes; then
2933 echo "gl_LGPL([$lgpl])"
2936 echo "gl_MAKEFILE_NAME([$makefile_name])"
2937 if test "$libtool" = true; then
2940 echo "gl_MACRO_PREFIX([$macro_prefix])"
2941 echo "gl_PO_DOMAIN([$po_domain])"
2943 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2944 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2948 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2949 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2950 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2952 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2956 echo "# gnulib-cache.m4 ends here"
2963 echo "Creating $m4base/gnulib-cache.m4"
2964 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2966 echo "Create $m4base/gnulib-cache.m4"
2972 # Create m4/gnulib-comp.m4.
2973 func_dest_tmpfilename $m4base/gnulib-comp.m4
2975 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2976 func_emit_copyright_notice
2978 echo "# This file represents the compiled summary of the specification in"
2979 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2980 echo "# to be invoked from configure.ac."
2981 echo "# In projects using CVS, this file can be treated like other built files."
2984 echo "# This macro should be invoked from $configure_ac, in the section"
2985 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2986 echo "# any checks for libraries, header files, types and library functions."
2987 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2989 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2990 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2991 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2992 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2993 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2994 if test -n "$uses_subdirs"; then
2995 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2997 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2998 echo " AC_REQUIRE([AC_GNU_SOURCE])"
3000 for module in $final_modules; do
3002 if test -n "$module"; then
3003 func_get_autoconf_early_snippet "$module"
3006 | sed -e '/^$/d;' -e 's/^/ /'
3009 echo "# This macro should be invoked from $configure_ac, in the section"
3010 echo "# \"Check for header files, types and library functions\"."
3011 echo "AC_DEFUN([${macro_prefix}_INIT],"
3013 if test "$libtool" = true; then
3014 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3015 echo " gl_cond_libtool=true"
3017 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3018 echo " gl_cond_libtool=false"
3020 echo " gl_ltlibdeps="
3022 if test "$auxdir" != "build-aux"; then
3023 sed_replace_build_aux='
3025 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3026 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3030 sed_replace_build_aux=
3032 func_emit_initmacro_start $macro_prefix
3033 echo " gl_source_base='$sourcebase'"
3034 for module in $main_modules; do
3036 if test -n "$module"; then
3037 func_get_autoconf_snippet "$module" \
3038 | sed -e '/^$/d;' -e 's/^/ /' \
3039 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3040 -e "$sed_replace_build_aux"
3041 if test "$module" = 'alloca' && test "$libtool" = true; then
3042 echo 'changequote(,)dnl'
3043 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3044 echo 'changequote([, ])dnl'
3045 echo 'AC_SUBST([LTALLOCA])'
3049 func_emit_initmacro_end $macro_prefix
3050 echo " gltests_libdeps="
3051 echo " gltests_ltlibdeps="
3052 func_emit_initmacro_start ${macro_prefix}tests
3053 echo " gl_source_base='$testsbase'"
3054 for module in $testsrelated_modules; do
3056 if test -n "$module"; then
3057 func_get_autoconf_snippet "$module" \
3058 | sed -e '/^$/d;' -e 's/^/ /' \
3059 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3060 -e "$sed_replace_build_aux" \
3061 -e 's/\$gl_cond_libtool/false/g' \
3062 -e 's/gl_libdeps/gltests_libdeps/g' \
3063 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3066 func_emit_initmacro_end ${macro_prefix}tests
3067 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3068 # created using libtool, because libtool already handles the dependencies.
3069 if test "$libtool" != true; then
3070 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3071 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3072 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3073 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3074 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3076 if $use_libtests; then
3077 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3078 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3081 func_emit_initmacro_done $macro_prefix $sourcebase
3082 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3084 echo "# This macro records the list of files which have been installed by"
3085 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3086 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3087 echo "$files" | sed -e 's,^, ,'
3090 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3091 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3095 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3096 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3097 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3099 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3103 echo "# gnulib-comp.m4 ends here"
3110 echo "Creating $m4base/gnulib-comp.m4"
3111 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3113 echo "Create $m4base/gnulib-comp.m4"
3119 if test -n "$inctests"; then
3120 # Create tests makefile.
3121 func_dest_tmpfilename $testsbase/$makefile_am
3122 modules="$testsrelated_modules"
3123 func_emit_tests_Makefile_am > "$tmpfile"
3124 if test -f "$destdir"/$testsbase/$makefile_am; then
3125 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3129 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3130 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3131 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3133 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3139 echo "Creating $testsbase/$makefile_am"
3140 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3142 echo "Create $testsbase/$makefile_am"
3145 func_append added_files "$testsbase/$makefile_am$nl"
3149 # Update the .cvsignore and .gitignore files.
3150 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3151 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3152 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3153 { # Rearrange file descriptors. Needed because "while ... done < ..."
3154 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3155 exec 5<&0 < "$tmp"/fileset-changes
3156 func_update_ignorelist ()
3159 if test -f "$destdir/$dir$ignore"; then
3160 if test -n "$dir_added" || test -n "$dir_removed"; then
3161 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
3162 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3163 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
3164 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3165 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
3166 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3168 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3169 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3170 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
3171 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
3172 | sed -f "$tmp"/sed-ignore-removed \
3173 > "$destdir/$dir$ignore"
3175 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3180 if test -n "$dir_added"; then
3182 echo "Creating $destdir/$dir$ignore"
3184 if test "$ignore" = .cvsignore; then
3186 # Automake generates Makefile rules that create .dirstamp files.
3189 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u
3190 } > "$destdir/$dir$ignore"
3192 echo "Create $destdir/$dir$ignore"
3202 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3203 func_update_ignorelist .cvsignore
3205 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3206 func_update_ignorelist .gitignore
3213 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3214 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3215 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3216 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3217 if test "$next_dir" != "$last_dir"; then
3218 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3219 last_dir="$next_dir"
3224 A) func_append last_dir_added "$file$nl";;
3225 R) func_append last_dir_removed "$file$nl";;
3228 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3234 echo "You may need to add #include directives for the following .h files."
3235 # Intersect $specified_modules and $main_modules
3236 # (since $specified_modules is not necessarily of subset of $main_modules
3237 # - some may have been skipped through --avoid, and since the elements of
3238 # $main_modules but not in $specified_modules can go away without explicit
3239 # notice - through changes in the module dependencies).
3240 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3241 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3242 # First the #include <...> directives without #ifs, sorted for convenience,
3243 # then the #include "..." directives without #ifs, sorted for convenience,
3244 # then the #include directives that are surrounded by #ifs. Not sorted.
3245 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3246 include_directive=`func_get_include_directive "$module"`
3247 case "$nl$include_directive" in
3249 echo "$include_directive" 1>&5
3252 echo "$include_directive" | grep -v 'include "' 1>&6
3253 echo "$include_directive" | grep 'include "' 1>&7
3256 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3258 LC_ALL=C sort -u "$tmp"/include-angles
3259 LC_ALL=C sort -u "$tmp"/include-quotes
3260 cat "$tmp"/include-if
3261 ) | sed -e '/^$/d' -e 's/^/ /'
3262 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3264 for module in $main_modules; do
3265 func_get_link_directive "$module"
3267 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3268 if test `wc -l < "$tmp"/link` != 0; then
3270 echo "You may need to use the following Makefile variables when linking."
3271 echo "Use them in <program>_LDADD when linking a program, or"
3272 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3278 echo "Don't forget to"
3279 if test "$makefile_am" = Makefile.am; then
3280 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3282 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3284 if test -n "$pobase"; then
3285 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3287 if test -n "$inctests"; then
3288 if test "$makefile_am" = Makefile.am; then
3289 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3291 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3294 if test "$makefile_am" = Makefile.am; then
3295 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3296 sourcebase_base=`basename "$sourcebase"`
3297 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
3299 if test -n "$pobase"; then
3300 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3301 pobase_base=`basename "$pobase"`
3302 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
3304 if test -n "$inctests"; then
3305 if test "$makefile_am" = Makefile.am; then
3306 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3307 testsbase_base=`basename "$testsbase"`
3308 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
3311 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
3312 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3313 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3316 # func_create_testdir testdir modules
3318 # - local_gnulib_dir from --local-dir
3319 # - auxdir directory relative to destdir where to place build aux files
3320 func_create_testdir ()
3324 if test -z "$modules"; then
3325 # All modules together.
3326 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3327 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3328 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3329 modules=`func_all_modules`
3330 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3332 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3334 # Check that the license of every module is consistent with the license of
3336 saved_modules="$modules"
3337 saved_inctests="$inctests"
3338 # When computing transitive closures, don't consider $module to depend on
3339 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3340 # on GPL modules - therefore we don't want a warning in this case.
3342 for requested_module in $saved_modules; do
3343 requested_license=`func_get_license "$requested_module"`
3344 if test "$requested_license" != GPL; then
3345 # Here we use func_modules_transitive_closure, not just
3346 # func_get_dependencies, so that we also detect weird situations like
3347 # an LGPL module which depends on a GPLed build tool module which depends
3349 modules="$requested_module"
3350 func_modules_transitive_closure
3351 for module in $modules; do
3352 license=`func_get_license "$module"`
3354 'GPLed build tool') ;;
3355 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3357 case "$requested_license" in
3360 GPLv2+ | LGPLv2+) ;;
3361 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3367 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3373 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3382 modules="$saved_modules"
3383 inctests="$saved_inctests"
3385 # Subdirectory names.
3394 # Determine final module list.
3395 func_modules_transitive_closure
3396 if test $verbose -ge 0; then
3397 echo "Module list with included dependencies:"
3398 echo "$modules" | sed -e 's/^/ /'
3401 # Add the dummy module if needed.
3402 func_modules_add_dummy
3404 # Show banner notice of every module.
3407 # Determine final file list.
3408 func_modules_to_filelist
3409 if test $verbose -ge 0; then
3411 echo "$files" | sed -e 's/^/ /'
3414 sed_rewrite_files="\
3415 s,^build-aux/,$auxdir/,
3417 s,^lib/,$sourcebase/,
3419 s,^tests/,$testsbase/,"
3421 # Create directories.
3422 for f in $files; do echo $f; done \
3423 | sed -e "$sed_rewrite_files" \
3424 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3425 | LC_ALL=C sort -u \
3427 { # Rearrange file descriptors. Needed because "while ... done < ..."
3428 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3429 exec 5<&0 < "$tmp"/dirs
3431 mkdir -p "$testdir/$d"
3436 # Copy files or make symbolic links.
3438 for f in $files; do echo $f; done \
3439 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3442 { # Rearrange file descriptors. Needed because "while ... done < ..."
3443 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3444 exec 5<&0 < "$tmp"/files
3446 func_lookup_file "$f"
3447 if test -n "$lookedup_tmp"; then
3448 cp -p "$lookedup_file" "$testdir/$g"
3450 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3451 if { test -n "$symbolic" \
3452 || { test -n "$lsymbolic" \
3453 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3454 func_ln "$lookedup_file" "$testdir/$g"
3456 cp -p "$lookedup_file" "$testdir/$g"
3463 # Create Makefile.ams that are for testing.
3466 # Create $sourcebase/Makefile.am.
3467 mkdir -p "$testdir/$sourcebase"
3468 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3469 any_uses_subdirs="$uses_subdirs"
3471 # Create $m4base/Makefile.am.
3472 mkdir -p "$testdir/$m4base"
3473 (echo "## Process this file with automake to produce Makefile.in."
3479 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3482 ) > "$testdir/$m4base/Makefile.am"
3484 subdirs="$sourcebase $m4base"
3485 subdirs_with_configure_ac=""
3487 if false && test -f "$testdir"/$m4base/gettext.m4; then
3488 # Avoid stupid error message from automake:
3489 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3490 mkdir -p "$testdir/po"
3491 (echo "## Process this file with automake to produce Makefile.in."
3492 ) > "$testdir/po/Makefile.am"
3493 func_append subdirs " po"
3496 if test -n "$inctests"; then
3497 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3498 # Viewed from the $testsbase subdirectory, $auxdir is different.
3499 saved_auxdir="$auxdir"
3500 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3501 # Create $testsbase/Makefile.am.
3503 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3504 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3505 # Create $testsbase/configure.ac.
3506 (echo "# Process this file with autoconf to produce a configure script."
3507 echo "AC_INIT([dummy], [0])"
3508 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3509 echo "AM_INIT_AUTOMAKE"
3511 echo "AM_CONFIG_HEADER([config.h])"
3514 echo "AC_PROG_INSTALL"
3515 echo "AC_PROG_MAKE_SET"
3516 echo "AC_PROG_RANLIB"
3518 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3519 echo "AC_GNU_SOURCE"
3522 for module in $modules; do
3524 if test -n "$module"; then
3525 func_get_autoconf_early_snippet "$module"
3528 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3529 if test "$libtool" = true; then
3530 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3531 echo "gl_cond_libtool=true"
3533 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3534 echo "gl_cond_libtool=false"
3536 echo "gl_ltlibdeps="
3538 # Wrap the set of autoconf snippets into an autoconf macro that is then
3539 # invoked. This is needed because autoconf does not support AC_REQUIRE
3541 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3542 # but we want the AC_REQUIRE to have its normal meaning (provide one
3543 # expansion of the required macro before the current point, and only one
3545 echo "AC_DEFUN([gl_INIT], ["
3546 sed_replace_build_aux='
3548 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3549 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3552 func_emit_initmacro_start $macro_prefix
3553 # We don't have explicit ordering constraints between the various
3554 # autoconf snippets. It's cleanest to put those of the library before
3555 # those of the tests.
3556 echo "gl_source_base='../$sourcebase'"
3557 for module in $modules; do
3558 func_verify_nontests_module
3559 if test -n "$module"; then
3560 func_get_autoconf_snippet "$module" \
3561 | sed -e "$sed_replace_build_aux"
3564 echo "gl_source_base='.'"
3565 for module in $modules; do
3566 func_verify_tests_module
3567 if test -n "$module"; then
3568 func_get_autoconf_snippet "$module" \
3569 | sed -e "$sed_replace_build_aux"
3572 func_emit_initmacro_end $macro_prefix
3573 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3574 # created using libtool, because libtool already handles the dependencies.
3575 if test "$libtool" != true; then
3576 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3577 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3578 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3579 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3580 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3583 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3587 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3588 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3589 echo "AH_TOP([#include \"../config.h\"])"
3591 echo "AC_OUTPUT([Makefile])"
3592 ) > "$testdir/$testsbase/configure.ac"
3593 auxdir="$saved_auxdir"
3594 func_append subdirs " $testsbase"
3595 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3598 # Create Makefile.am.
3599 (echo "## Process this file with automake to produce Makefile.in."
3601 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3603 echo "SUBDIRS = $subdirs"
3605 echo "ACLOCAL_AMFLAGS = -I $m4base"
3606 ) > "$testdir/Makefile.am"
3608 # Create configure.ac.
3609 (echo "# Process this file with autoconf to produce a configure script."
3610 echo "AC_INIT([dummy], [0])"
3611 if test "$auxdir" != "."; then
3612 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3614 echo "AM_INIT_AUTOMAKE"
3616 echo "AM_CONFIG_HEADER([config.h])"
3619 echo "AC_PROG_INSTALL"
3620 echo "AC_PROG_MAKE_SET"
3622 echo "# For autobuild."
3623 echo "AC_CANONICAL_BUILD"
3624 echo "AC_CANONICAL_HOST"
3626 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3627 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3628 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3629 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3631 echo "AC_PROG_RANLIB"
3633 if test -n "$any_uses_subdirs"; then
3634 echo "AM_PROG_CC_C_O"
3637 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3638 echo "AC_GNU_SOURCE"
3641 for module in $modules; do
3642 func_verify_nontests_module
3643 if test -n "$module"; then
3644 func_get_autoconf_early_snippet "$module"
3647 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3648 if test "$libtool" = true; then
3649 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3650 echo "gl_cond_libtool=true"
3652 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3653 echo "gl_cond_libtool=false"
3655 echo "gl_ltlibdeps="
3657 # Wrap the set of autoconf snippets into an autoconf macro that is then
3658 # invoked. This is needed because autoconf does not support AC_REQUIRE
3660 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3661 # but we want the AC_REQUIRE to have its normal meaning (provide one
3662 # expansion of the required macro before the current point, and only one
3664 echo "AC_DEFUN([gl_INIT], ["
3665 if test "$auxdir" != "build-aux"; then
3666 sed_replace_build_aux='
3668 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3669 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3673 sed_replace_build_aux=
3675 func_emit_initmacro_start $macro_prefix
3676 echo "gl_source_base='$sourcebase'"
3677 for module in $modules; do
3678 func_verify_nontests_module
3679 if test -n "$module"; then
3680 func_get_autoconf_snippet "$module" \
3681 | sed -e "$sed_replace_build_aux"
3684 func_emit_initmacro_end $macro_prefix
3685 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3686 # created using libtool, because libtool already handles the dependencies.
3687 if test "$libtool" != true; then
3688 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3689 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3690 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3691 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3692 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3695 func_emit_initmacro_done $macro_prefix $sourcebase
3699 if test -n "$subdirs_with_configure_ac"; then
3700 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3702 makefiles="Makefile"
3703 for d in $subdirs; do
3704 # For subdirs that have a configure.ac by their own, it's the subdir's
3705 # configure.ac which creates the subdir's Makefile.am, not this one.
3706 case " $subdirs_with_configure_ac " in
3708 *) func_append makefiles " $d/Makefile" ;;
3711 echo "AC_OUTPUT([$makefiles])"
3712 ) > "$testdir/configure.ac"
3714 # Create autogenerated files.
3716 # Do not use "${AUTORECONF} --force --install", because it may invoke
3717 # autopoint, which brings in older versions of some of our .m4 files.
3718 if test -f $m4base/gettext.m4; then
3719 func_execute_command ${AUTOPOINT} --force || func_exit 1
3720 for f in $m4base/*.m4~; do
3721 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3724 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3725 if ! test -d build-aux; then
3726 func_execute_command mkdir build-aux || func_exit 1
3728 func_execute_command ${AUTOCONF} || func_exit 1
3729 func_execute_command ${AUTOHEADER} || func_exit 1
3730 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3732 if test -n "$inctests"; then
3733 # Create autogenerated files.
3734 (cd "$testdir/$testsbase" || func_exit 1
3735 # Do not use "${AUTORECONF} --force --install", because it may invoke
3736 # autopoint, which brings in older versions of some of our .m4 files.
3737 if test -f ../$m4base/gettext.m4; then
3738 func_execute_command ${AUTOPOINT} --force || func_exit 1
3739 for f in ../$m4base/*.m4~; do
3740 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3743 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3744 if ! test -d ../build-aux; then
3745 func_execute_command mkdir ../build-aux
3747 func_execute_command ${AUTOCONF} || func_exit 1
3748 func_execute_command ${AUTOHEADER} || func_exit 1
3749 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3752 # Need to run configure and make once, to create built files that are to be
3753 # distributed (such as getdate.c).
3754 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3755 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3756 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3757 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3758 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3759 # such $(FOO_H) because they don't refer to distributed files.
3760 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3761 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3762 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3763 | sed -e "$sed_remove_make_variables"`
3764 distributed_built_sources=`for file in $built_sources; do
3765 case "$cleaned_files" in
3770 if test -n "$distributed_built_sources"; then
3772 ./configure || func_exit 1
3774 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3775 make built_sources || func_exit 1
3777 make distclean || func_exit 1
3782 # func_create_megatestdir megatestdir allmodules
3784 # - local_gnulib_dir from --local-dir
3785 # - auxdir directory relative to destdir where to place build aux files
3786 func_create_megatestdir ()
3790 if test -z "$allmodules"; then
3791 allmodules=`func_all_modules`
3795 # First, all modules one by one.
3796 for onemodule in $allmodules; do
3797 func_create_testdir "$megatestdir/$onemodule" $onemodule
3798 func_append megasubdirs "$onemodule "
3800 # Then, all modules all together.
3801 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3802 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3803 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3804 func_create_testdir "$megatestdir/ALL" "$allmodules"
3805 func_append megasubdirs "ALL"
3808 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
3809 vc_witness="$gnulib_dir/CVS/Entries"; \
3811 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
3813 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
3814 | sed -e 's,January,01,' -e 's,Jan,01,' \
3815 -e 's,February,02,' -e 's,Feb,02,' \
3816 -e 's,March,03,' -e 's,Mar,03,' \
3817 -e 's,April,04,' -e 's,Apr,04,' \
3819 -e 's,June,06,' -e 's,Jun,06,' \
3820 -e 's,July,07,' -e 's,Jul,07,' \
3821 -e 's,August,08,' -e 's,Aug,08,' \
3822 -e 's,September,09,' -e 's,Sep,09,' \
3823 -e 's,October,10,' -e 's,Oct,10,' \
3824 -e 's,November,11,' -e 's,Nov,11,' \
3825 -e 's,December,12,' -e 's,Dec,12,' \
3826 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3827 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3829 echo "CVSDATE=$cvsdate"
3830 echo "test -d logs || mkdir logs"
3831 echo "for module in $megasubdirs; do"
3832 echo " echo \"Working on module \$module...\""
3833 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3834 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3837 echo " : autobuild project... \$module"
3838 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3839 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3840 echo " : autobuild hostname... \`hostname\`"
3841 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3843 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3845 ) > "$megatestdir/do-autobuild"
3846 chmod a+x "$megatestdir/do-autobuild"
3848 # Create Makefile.am.
3849 (echo "## Process this file with automake to produce Makefile.in."
3851 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3853 echo "SUBDIRS = $megasubdirs"
3855 echo "EXTRA_DIST = do-autobuild"
3856 ) > "$megatestdir/Makefile.am"
3858 # Create configure.ac.
3859 (echo "# Process this file with autoconf to produce a configure script."
3860 echo "AC_INIT([dummy], [0])"
3861 if test "$auxdir" != "."; then
3862 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3864 echo "AM_INIT_AUTOMAKE"
3866 echo "AC_PROG_MAKE_SET"
3868 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3869 echo "AC_OUTPUT([Makefile])"
3870 ) > "$megatestdir/configure.ac"
3872 # Create autogenerated files.
3874 # Do not use "${AUTORECONF} --install", because autoreconf operates
3875 # recursively, but the subdirectories are already finished, therefore
3876 # calling autoreconf here would only waste lots of CPU time.
3877 func_execute_command ${ACLOCAL} || func_exit 1
3878 func_execute_command mkdir build-aux
3879 func_execute_command ${AUTOCONF} || func_exit 1
3880 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3886 func_fatal_error "no mode specified" ;;
3895 if test -z "$destdir"; then
3898 test -d "$destdir" \
3899 || func_fatal_error "destination directory does not exist: $destdir"
3901 # Prefer configure.ac to configure.in.
3902 if test -f "$destdir"/configure.ac; then
3903 configure_ac="$destdir/configure.ac"
3905 if test -f "$destdir"/configure.in; then
3906 configure_ac="$destdir/configure.in"
3908 func_fatal_error "cannot find $destdir/configure.ac"
3912 # Analyze configure.ac.
3914 guessed_libtool=false
3919 /AC_CONFIG_AUX_DIR/ {
3920 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3922 /A[CM]_PROG_LIBTOOL/ {
3923 s,^.*$,guessed_libtool=true,p
3925 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3927 if test -z "$auxdir"; then
3928 auxdir="$guessed_auxdir"
3931 # Determine where to apply func_import.
3932 if test -n "$m4base"; then
3933 # Apply func_import to a particular gnulib directory.
3934 # Any number of additional modules can be given.
3935 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3936 # First use of gnulib in the given m4base.
3937 test -n "$supplied_libname" || supplied_libname=true
3938 test -n "$sourcebase" || sourcebase="lib"
3939 test -n "$docbase" || docbase="doc"
3940 test -n "$testsbase" || testsbase="tests"
3941 test -n "$macro_prefix" || macro_prefix="gl"
3945 # Apply func_import to all gnulib directories.
3946 # To get this list of directories, look at Makefile.am. (Not at
3947 # configure, because it may be omitted from CVS. Also, don't run
3948 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3951 if test -f "$destdir"/Makefile.am; then
3952 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3954 for arg in $aclocal_amflags; do
3955 if test -n "$m4dir_is_next"; then
3956 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3960 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3961 func_append m4dirs " $arg"
3962 m4dirs_count=`expr $m4dirs_count + 1`
3968 if test "X$arg" = "X-I"; then
3976 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3977 if test -f "$destdir"/aclocal.m4; then
3978 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3979 sedexpr2='s,^[^/]*$,.,'
3980 sedexpr3='s,/[^/]*$,,'
3981 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3982 m4dirs_count=`echo "$m4dirs" | wc -l`
3985 if test $m4dirs_count = 0; then
3986 # First use of gnulib in a package.
3987 # Any number of additional modules can be given.
3988 test -n "$supplied_libname" || supplied_libname=true
3989 test -n "$sourcebase" || sourcebase="lib"
3991 test -n "$docbase" || docbase="doc"
3992 test -n "$testsbase" || testsbase="tests"
3993 test -n "$macro_prefix" || macro_prefix="gl"
3996 if test $m4dirs_count = 1; then
3997 # There's only one use of gnulib here. Assume the user means it.
3998 # Any number of additional modules can be given.
3999 for m4base in $m4dirs; do
4003 # Ambiguous - guess what the user meant.
4004 if test $# = 0; then
4005 # No further arguments. Guess the user wants to update all of them.
4006 for m4base in $m4dirs; do
4007 # Perform func_import in a subshell, so that variable values
4009 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
4010 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
4011 # libtool, macro_prefix, po_domain
4012 # don't propagate from one directory to another.
4013 (func_import) || func_exit 1
4017 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4025 if test -z "$destdir"; then
4026 func_fatal_error "please specify --dir option"
4029 test -d "$destdir" \
4030 || func_fatal_error "could not create destination directory"
4031 test -n "$auxdir" || auxdir="build-aux"
4032 func_create_testdir "$destdir" "$*"
4035 create-megatestdir )
4036 if test -z "$destdir"; then
4037 func_fatal_error "please specify --dir option"
4039 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4040 test -n "$auxdir" || auxdir="build-aux"
4041 func_create_megatestdir "$destdir" "$*"
4045 test -n "$destdir" || destdir=testdir$$
4046 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4047 test -n "$auxdir" || auxdir="build-aux"
4048 func_create_testdir "$destdir" "$*"
4052 ../configure || func_exit 1
4054 make check || func_exit 1
4055 make distclean || func_exit 1
4056 remaining=`find . -type f -print`
4057 if test -n "$remaining"; then
4058 echo "Remaining files:" $remaining 1>&2
4059 echo "gnulib-tool: *** Stop." 1>&2
4068 test -n "$destdir" || destdir=testdir$$
4069 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4070 test -n "$auxdir" || auxdir="build-aux"
4071 func_create_megatestdir "$destdir" "$*"
4079 remaining=`find . -type f -print`
4080 if test -n "$remaining"; then
4081 echo "Remaining files:" $remaining 1>&2
4082 echo "gnulib-tool: *** Stop." 1>&2
4090 extract-description )
4094 if test -n "$module"; then
4095 func_get_description "$module"
4104 if test -n "$module"; then
4105 func_get_notice "$module"
4114 if test -n "$module"; then
4115 func_get_filelist "$module"
4120 extract-dependencies )
4124 if test -n "$module"; then
4125 func_get_dependencies "$module"
4130 extract-autoconf-snippet )
4134 if test -n "$module"; then
4135 func_get_autoconf_snippet "$module"
4140 extract-automake-snippet )
4144 if test -n "$module"; then
4145 func_get_automake_snippet "$module"
4150 extract-include-directive )
4154 if test -n "$module"; then
4155 func_get_include_directive "$module"
4160 extract-link-directive )
4164 if test -n "$module"; then
4165 func_get_link_directive "$module"
4174 if test -n "$module"; then
4175 func_get_license "$module"
4180 extract-maintainer )
4184 if test -n "$module"; then
4185 func_get_maintainer "$module"
4190 extract-tests-module )
4194 if test -n "$module"; then
4195 func_get_tests_module "$module"
4201 func_fatal_error "unknown operation mode --$mode" ;;
4205 # Undo the effect of the previous 'trap' command. Some shellology:
4206 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4207 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4208 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4209 # 128 + signal number and is set before the trap-registered command is run.
4211 trap 'func_exit $?' 1 2 3 13 15
4216 # indent-tabs-mode: nil
4217 # whitespace-check-buffer-indent: nil