3 # Copyright (C) 2002-2006 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 2, or (at your option)
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, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages.
25 cvsdatestamp='$Date: 2006-12-22 12:49:38 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
31 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
35 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
36 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
40 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
43 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # GNU sort is needed. Set SORT to its location (not needed if it's called
70 # 'sort' and already in the PATH).
71 if test -z "$SORT"; then
75 # A sed program is needed. When using GNU sed, turn off a maximum of GNU
76 # extensions, to minimize the risk of accidentally using non-portable features
78 if test -z "$SED"; then
81 if echo | $SED --posix d >/dev/null 2>&1; then
86 # outputs to stdout the --help usage message.
90 Usage: gnulib-tool --list
91 gnulib-tool --import [module1 ... moduleN]
93 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
94 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
95 gnulib-tool --test --dir=directory module1 ... moduleN
96 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
97 gnulib-tool --extract-description module
98 gnulib-tool --extract-filelist module
99 gnulib-tool --extract-dependencies module
100 gnulib-tool --extract-autoconf-snippet module
101 gnulib-tool --extract-automake-snippet module
102 gnulib-tool --extract-include-directive module
103 gnulib-tool --extract-license module
104 gnulib-tool --extract-maintainer module
105 gnulib-tool --extract-tests-module module
108 --list print the available module names
109 --import import the given modules into the current package;
110 if no modules are specified, update the current
111 package from the current gnulib
112 --update update the current package, restore files omitted
114 --create-testdir create a scratch package with the given modules
115 --create-megatestdir create a mega scratch package with the given modules
116 one by one and all together
117 --test test the combination of the given modules
118 (recommended to use CC=\"gcc -Wall\" here)
119 --megatest test the given modules one by one and all together
120 (recommended to use CC=\"gcc -Wall\" here)
121 --extract-description extract the description
122 --extract-filelist extract the list of files
123 --extract-dependencies extract the dependencies
124 --extract-autoconf-snippet extract the snippet for configure.ac
125 --extract-automake-snippet extract the snippet for library makefile
126 --extract-include-directive extract the #include directive
127 --extract-license report the license terms of the source files
129 --extract-maintainer report the maintainer(s) inside gnulib
130 --extract-tests-module report the unit test module, if it exists
133 --dir=DIRECTORY Specify the target directory.
134 For --import, this specifies where your
135 configure.ac can be found. Defaults to current
137 --local-dir=DIRECTORY Specify a local override directory where to look
138 up files before looking in gnulib's directory.
140 Options for --import:
141 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
142 --source-base=DIRECTORY
143 Directory relative to --dir where source code is
144 placed (default \"lib\").
145 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
146 placed (default \"m4\").
147 --doc-base=DIRECTORY Directory relative to --dir where doc files are
148 placed (default \"doc\").
149 --tests-base=DIRECTORY
150 Directory relative to --dir where unit tests are
151 placed (default \"tests\").
152 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
153 tools are placed (default \"build-aux\").
154 --with-tests Include unit tests for the included modules.
155 --avoid=MODULE Avoid including the given MODULE. Useful if you
156 have code that provides equivalent functionality.
157 This option can be repeated.
158 --lgpl Abort if modules aren't available under the LGPL.
159 Also modify license template from GPL to LGPL.
160 --makefile-name=NAME Name of makefile in automake syntax in the
161 source-base and tests-base directories
162 (default \"Makefile.am\").
163 --libtool Use libtool rules.
164 --no-libtool Don't use libtool rules.
165 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
166 'gl_INIT'. Default is 'gl'.
167 --no-changelog don't update or create ChangeLog files
169 Options for --import and --update:
170 --dry-run For --import, only print what would have been done.
171 -s, --symbolic, --symlink Make symbolic links instead of copying files.
172 --local-symlink Make symbolic links instead of copying files, only
173 for files from the local override directory.
175 Report bugs to <bug-gnulib@gnu.org>."
179 # outputs to stdout the --version message.
182 year=`echo "$last_checkin_date" | $SED -e 's,/.*$,,'`
184 $progname (GNU $package) $version
185 Copyright (C) $year Free Software Foundation, Inc.
186 This is free software; see the source for copying conditions. There is NO
187 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
188 Written by" "Bruno Haible" "and" "Simon Josefsson"
191 # func_emit_copyright_notice
192 # outputs to stdout a header for a generated file.
193 func_emit_copyright_notice ()
195 echo "# Copyright (C) 2004-2006 Free Software Foundation, Inc."
197 echo "# This file is free software, distributed under the terms of the GNU"
198 echo "# General Public License. As a special exception to the GNU General"
199 echo "# Public License, this file may be distributed as part of a program"
200 echo "# that contains a configuration script generated by Autoconf, under"
201 echo "# the same distribution terms as the rest of that program."
203 echo "# Generated by gnulib-tool."
214 # creates a temporary directory.
216 # - tmp pathname of freshly created temporary directory
219 # Use the environment variable TMPDIR, falling back to /tmp. This allows
220 # users to specify a different temporary directory, for example, if their
221 # /tmp is filled up or too small.
224 # Use the mktemp program if available. If not available, hide the error
226 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
227 test -n "$tmp" && test -d "$tmp"
230 # Use a simple mkdir command. It is guaranteed to fail if the directory
231 # already exists. $RANDOM is bash specific and expands to empty in shells
232 # other than bash, ksh and zsh. Its use does not increase security;
233 # rather, it minimizes the probability of failure in a very cluttered /tmp
235 tmp=$TMPDIR/gl$$-$RANDOM
236 (umask 077 && mkdir "$tmp")
239 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
244 # func_append var value
245 # appends the given value to the shell variable var.
246 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
247 # Use bash's += operator. It reduces complexity of appending repeatedly to
248 # a single variable from O(n^2) to O(n).
256 eval "$1=\"\$$1\$2\""
260 # func_fatal_error message
261 # outputs to stderr a fatal error message, and terminates the program.
264 echo "gnulib-tool: *** $1" 1>&2
265 echo "gnulib-tool: *** Stop." 1>&2
269 # func_readlink SYMLINK
270 # outputs the target of the given symlink.
271 if (type -p readlink) > /dev/null 2>&1; then
274 # Use the readlink program from GNU coreutils.
280 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
281 # would do the wrong thing if the link target contains " -> ".
282 LC_ALL=C ls -l "$1" | $SED -e 's, -> ,#%%#,' | $SED -n -e 's,^.*#%%#\(.*\)$,\1,p'
286 # func_relativize DIR1 DIR2
287 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
289 # - DIR1 relative pathname, relative to the current directory
290 # - DIR2 relative pathname, relative to the current directory
292 # - reldir relative pathname of DIR2, relative to DIR1
298 sed_first='s,^\([^/]*\)/.*$,\1,'
299 sed_rest='s,^[^/]*/*,,'
300 sed_last='s,^.*/\([^/]*\)$,\1,'
301 sed_butlast='s,/*[^/]*$,,'
302 while test -n "$dir1"; do
303 first=`echo "$dir1" | $SED -e "$sed_first"`
304 if test "$first" != "."; then
305 if test "$first" = ".."; then
306 dir2=`echo "$dir0" | $SED -e "$sed_last"`/"$dir2"
307 dir0=`echo "$dir0" | $SED -e "$sed_butlast"`
309 first2=`echo "$dir2" | $SED -e "$sed_first"`
310 if test "$first2" = "$first"; then
311 dir2=`echo "$dir2" | $SED -e "$sed_rest"`
315 dir0="$dir0"/"$first"
318 dir1=`echo "$dir1" | $SED -e "$sed_rest"`
323 # func_relconcat DIR1 DIR2
324 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
326 # - DIR1 relative pathname, relative to the current directory
327 # - DIR2 relative pathname, relative to DIR1
329 # - relconcat DIR1/DIR2, relative to the current directory
334 sed_first='s,^\([^/]*\)/.*$,\1,'
335 sed_rest='s,^[^/]*/*,,'
336 sed_last='s,^.*/\([^/]*\)$,\1,'
337 sed_butlast='s,/*[^/]*$,,'
339 first=`echo "$dir2" | $SED -e "$sed_first"`
340 if test "$first" = "."; then
341 dir2=`echo "$dir2" | $SED -e "$sed_rest"`
342 if test -z "$dir2"; then
347 last=`echo "$dir1" | $SED -e "$sed_last"`
348 while test "$last" = "."; do
349 dir1=`echo "$dir1" | $SED -e "$sed_butlast"`
350 last=`echo "$dir1" | $SED -e "$sed_last"`
352 if test -z "$dir1"; then
356 if test "$first" = ".."; then
357 if test "$last" = ".."; then
358 relconcat="$dir1/$dir2"
361 dir1=`echo "$dir1" | $SED -e "$sed_butlast"`
362 dir2=`echo "$dir2" | $SED -e "$sed_rest"`
363 if test -z "$dir1"; then
367 if test -z "$dir2"; then
372 relconcat="$dir1/$dir2"
380 # Like ln -s, except that SRC is given relative to the current directory (or
381 # absolute), not given relative to the directory of DEST.
387 *) # SRC is relative.
390 ln -s "`pwd`/$1" "$2" ;;
391 *) # DEST is relative too.
392 ln_destdir=`echo "$2" | $SED -e 's,[^/]*$,,'`
393 test -n "$ln_destdir" || ln_destdir="."
394 func_relativize "$ln_destdir" "$1"
402 # func_ln_if_changed SRC DEST
403 # Like func_ln, but avoids munging timestamps if the link is correct.
404 func_ln_if_changed ()
406 if test $# -ne 2; then
407 echo "usage: func_ln_if_changed SRC DEST" >&2
409 ln_target=`func_readlink "$2"`
410 if test -L "$2" && test "$1" = "$ln_target"; then
418 # Command-line option processing.
419 # Removes the OPTIONS from the arguments. Sets the variables:
420 # - mode list or import or create-testdir or create-megatestdir
421 # - destdir from --dir
422 # - local_gnulib_dir from --local-dir
423 # - libname, supplied_libname from --lib
424 # - sourcebase from --source-base
425 # - m4base from --m4-base
426 # - docbase from --doc-base
427 # - testsbase from --tests-base
428 # - auxdir from --aux-dir
429 # - inctests true if --with-tests was given, blank otherwise
430 # - avoidlist list of modules to avoid, from --avoid
431 # - lgpl true if --lgpl was given, blank otherwise
432 # - makefile_name from --makefile-name
433 # - libtool true if --libtool was given, false if --no-libtool was
434 # given, blank otherwise
435 # - macro_prefix from --macro-prefix
436 # - autoconf_minversion minimum supported autoconf version
437 # - do_changelog false if --no-changelog was given, : otherwise
438 # - doit : if actions shall be executed, false if only to be printed
439 # - symbolic true if --symlink was given, blank otherwise
440 # - lsymbolic true if --local-symlink was given, blank otherwise
465 while test $# -gt 0; do
470 --import | --impor | --impo | --imp | --im | --i )
473 --update | --updat | --upda | --upd | --up | --u )
476 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
479 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
480 mode=create-megatestdir
482 --test | --tes | --te | --t )
485 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
489 mode=`echo "X$1" | $SED -e 's/^X--//'`
494 func_fatal_error "missing argument for --dir"
499 destdir=`echo "X$1" | $SED -e 's/^X--dir=//'`
504 func_fatal_error "missing argument for --local-dir"
509 local_gnulib_dir=`echo "X$1" | $SED -e 's/^X--local-dir=//'`
514 func_fatal_error "missing argument for --lib"
517 supplied_libname=true
520 libname=`echo "X$1" | $SED -e 's/^X--lib=//'`
521 supplied_libname=true
526 func_fatal_error "missing argument for --source-base"
531 sourcebase=`echo "X$1" | $SED -e 's/^X--source-base=//'`
536 func_fatal_error "missing argument for --m4-base"
541 m4base=`echo "X$1" | $SED -e 's/^X--m4-base=//'`
546 func_fatal_error "missing argument for --doc-base"
551 docbase=`echo "X$1" | $SED -e 's/^X--doc-base=//'`
556 func_fatal_error "missing argument for --tests-base"
561 testsbase=`echo "X$1" | $SED -e 's/^X--tests-base=//'`
566 func_fatal_error "missing argument for --aux-dir"
571 auxdir=`echo "X$1" | $SED -e 's/^X--aux-dir=//'`
579 func_fatal_error "missing argument for --avoid"
581 func_append avoidlist " $1"
584 arg=`echo "X$1" | $SED -e 's/^X--avoid=//'`
585 func_append avoidlist " $arg"
593 func_fatal_error "missing argument for --makefile-name"
598 makefile_name=`echo "X$1" | $SED -e 's/^X--makefile-name=//'`
609 func_fatal_error "missing argument for --macro-prefix"
614 macro_prefix=`echo "X$1" | $SED -e 's/^X--macro-prefix=//'`
616 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
622 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
625 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
628 --help | --hel | --he | --h )
631 --version | --versio | --versi | --vers | --ver | --ve | --v )
635 # Stop option processing
639 echo "gnulib-tool: unknown option $1" 1>&2
640 echo "Try 'gnulib-tool --help' for more information." 1>&2
647 if test "$mode" = update; then
648 if test $# != 0; then
649 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
650 echo "Try 'gnulib-tool --help' for more information." 1>&2
651 echo "If you really want to modify the gnulib configuration of your project," 1>&2
652 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
655 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
656 || test -n "$sourcebase" || test -n "$m4base" \
657 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
658 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
659 || test -n "$makefile_name" || test -n "$macro_prefix"; then
660 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
661 echo "Try 'gnulib-tool --help' for more information." 1>&2
662 echo "If you really want to modify the gnulib configuration of your project," 1>&2
663 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
669 # Determine the minimum supported autoconf version from the project's
671 DEFAULT_AUTOCONF_MINVERSION="2.59"
674 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
675 if test -f "$destdir"/configure.ac; then
676 configure_ac="$destdir/configure.ac"
678 if test -f "$destdir"/configure.in; then
679 configure_ac="$destdir/configure.in"
683 if test -f configure.ac; then
684 configure_ac="configure.ac"
686 if test -f configure.in; then
687 configure_ac="configure.in"
691 if test -n "$configure_ac"; then
692 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
693 # because when some m4 files are omitted from a CVS repository,
694 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
695 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
696 # autom4te: m4 failed with exit status: 1
703 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,prereqs="$prereqs \1",p
705 eval `$SED -n -e "$my_sed_traces" < "$configure_ac"`
706 if test -n "$prereqs"; then
707 autoconf_minversion=`for version in $prereqs; do echo $version; done | $SORT -g -u | tail -1`
710 if test -z "$autoconf_minversion"; then
711 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
713 case "$autoconf_minversion" in
714 1.* | 2.[0-4]* | 2.5[0-8]*)
715 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
718 # Remove trailing slashes from the directory names. This is necessary for
719 # m4base (to avoid an error in func_import) and optional for the others.
720 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
721 case "$local_gnulib_dir" in
722 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | $SED -e "$sed_trimtrailingslashes"` ;;
724 case "$sourcebase" in
725 */ ) sourcebase=`echo "$sourcebase" | $SED -e "$sed_trimtrailingslashes"` ;;
728 */ ) m4base=`echo "$m4base" | $SED -e "$sed_trimtrailingslashes"` ;;
731 */ ) docbase=`echo "$docbase" | $SED -e "$sed_trimtrailingslashes"` ;;
734 */ ) testsbase=`echo "$testsbase" | $SED -e "$sed_trimtrailingslashes"` ;;
737 */ ) auxdir=`echo "$auxdir" | $SED -e "$sed_trimtrailingslashes"` ;;
742 /*) self_abspathname="$0" ;;
743 */*) self_abspathname=`pwd`/"$0" ;;
744 *) for d in `echo ":$PATH:" | $SED -e 's/:::*/:.:/g' | $SED -e 's/:/ /g'`; do
745 if test -x "$d/$0" && test ! -d "$d/$0"; then
746 self_abspathname="$d/$0"
750 if test -z "$self_abspathname"; then
751 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
755 while test -h "$self_abspathname"; do
756 # Resolve symbolic link.
757 linkval=`func_readlink "$self_abspathname"`
758 test -n "$linkval" || break
760 /* ) self_abspathname="$linkval" ;;
761 * ) self_abspathname=`echo "$self_abspathname" | $SED -e 's,/[^/]*$,,'`/"$linkval" ;;
764 gnulib_dir=`echo "$self_abspathname" | $SED -e 's,/[^/]*$,,'`
768 if test "$signal" != 0; then
769 echo "caught signal $signal" >&2
773 for signal in 1 2 3 13 15; do
774 trap '{ signal='$signal'; func_exit 1; }' $signal
778 # func_lookup_file file
779 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
782 # - local_gnulib_dir from --local-dir
784 # - lookedup_file name of the merged (combined) file
785 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
789 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
790 lookedup_file="$local_gnulib_dir/$lkfile"
793 if test -f "$gnulib_dir/$lkfile"; then
794 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
795 lkbase=`echo "$lkfile" | $SED -e 's,^.*/,,'`
797 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
798 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
799 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
800 lookedup_file="$tmp/$lkbase"
803 lookedup_file="$gnulib_dir/$lkfile"
807 func_fatal_error "file $gnulib_dir/$lkfile not found"
814 # - local_gnulib_dir from --local-dir
817 # Filter out metainformation files like README, which are not modules.
818 # Filter out unit test modules; they can be retrieved through
819 # --extract-tests-module if desired.
821 (cd "$gnulib_dir/modules" && ls -1)
822 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
823 (cd "$local_gnulib_dir/modules" && ls -1 | $SED -e 's,\.diff$,,')
826 | $SED -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
827 | $SED -e '/-tests$/d' \
832 # verifies a module name
834 # - local_gnulib_dir from --local-dir
835 # - module module name argument
836 func_verify_module ()
838 if { test -f "$gnulib_dir/modules/$module" \
839 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
840 && test -f "$local_gnulib_dir/modules/$module"; }; } \
841 && test "CVS" != "$module" \
842 && test "ChangeLog" != "$module" \
843 && test "COPYING" != "$module" \
844 && test "README" != "$module" \
845 && test "TEMPLATE" != "$module" \
846 && test "TEMPLATE-TESTS" != "$module"; then
847 # OK, $module is a correct module name.
848 # Verify that building the module description with 'patch' succeeds.
849 func_lookup_file "modules/$module"
851 echo "gnulib-tool: module $module doesn't exist" 1>&2
856 # func_verify_nontests_module
857 # verifies a module name, excluding tests modules
859 # - local_gnulib_dir from --local-dir
860 # - module module name argument
861 func_verify_nontests_module ()
865 * ) func_verify_module ;;
869 # func_verify_tests_module
870 # verifies a module name, considering only tests modules
872 # - local_gnulib_dir from --local-dir
873 # - module module name argument
874 func_verify_tests_module ()
877 *-tests ) func_verify_module ;;
882 sed_extract_prog=':[ ]*$/ {
885 s/^Description:[ ]*$//
887 s/^Depends-on:[ ]*$//
888 s/^configure\.ac:[ ]*$//
889 s/^Makefile\.am:[ ]*$//
892 s/^Maintainer:[ ]*$//
899 # func_get_description module
901 # - local_gnulib_dir from --local-dir
902 func_get_description ()
904 func_lookup_file "modules/$1"
905 $SED -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
908 # func_get_filelist module
910 # - local_gnulib_dir from --local-dir
913 func_lookup_file "modules/$1"
914 $SED -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
915 case "$autoconf_minversion" in
918 echo m4/onceonly_2_57.m4
923 # func_get_dependencies module
925 # - local_gnulib_dir from --local-dir
926 func_get_dependencies ()
928 # ${module}-tests always implicitly depends on ${module}.
929 echo "$1" | $SED -n -e 's/-tests//p'
930 # Then the explicit dependencies listed in the module description.
931 func_lookup_file "modules/$1"
932 $SED -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
935 # func_get_autoconf_snippet module
937 # - local_gnulib_dir from --local-dir
938 func_get_autoconf_snippet ()
940 func_lookup_file "modules/$1"
941 $SED -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
944 # func_get_automake_snippet module
946 # - local_gnulib_dir from --local-dir
947 func_get_automake_snippet ()
949 func_lookup_file "modules/$1"
950 $SED -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
953 # *-tests module live in tests/, not lib/.
956 # Synthesize an EXTRA_DIST augmentation.
957 sed_combine_lines='/\\$/{
964 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
965 already_mentioned_files=` \
966 $SED -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
967 | $SED -e "$sed_combine_lines" \
968 | $SED -n -e "$sed_extract_mentioned_files" | $SED -e 's/#.*//'`
969 all_files=`func_get_filelist $1`
970 lib_files=`for f in $all_files; do \
974 done | $SED -e 's,^lib/,,'`
975 # Remove $already_mentioned_files from $lib_files.
976 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
977 extra_files=`for f in $already_mentioned_files; do echo $f; done \
978 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
979 if test -n "$extra_files"; then
980 echo "EXTRA_DIST +=" $extra_files
983 # Synthesize also an EXTRA_lib_SOURCES augmentation.
984 # This is necessary so that automake can generate the right list of
986 # A possible approach would be to use autom4te --trace of the redefined
987 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
988 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
989 # inside autoconf's built-in macros are not missed).
990 # But it's simpler and more robust to do it here, based on the file list.
991 # If some .c file exists and is not used with AC_LIBOBJ - for example,
992 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
993 # automake will generate a useless dependency; this is harmless.
994 sed_extract_c_files='/\.c$/p'
995 extra_files=`echo "$extra_files" | $SED -n -e "$sed_extract_c_files"`
996 if test -n "$extra_files"; then
997 echo "EXTRA_lib_SOURCES +=" $extra_files
1004 # func_get_include_directive module
1006 # - local_gnulib_dir from --local-dir
1007 func_get_include_directive ()
1009 func_lookup_file "modules/$1"
1010 $SED -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1011 $SED -e 's/^\(["<]\)/#include \1/'
1014 # func_get_license module
1016 # - local_gnulib_dir from --local-dir
1019 func_lookup_file "modules/$1"
1020 $SED -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1023 # func_get_maintainer module
1025 # - local_gnulib_dir from --local-dir
1026 func_get_maintainer ()
1028 func_lookup_file "modules/$1"
1029 $SED -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1032 # func_get_tests_module module
1034 # - local_gnulib_dir from --local-dir
1035 func_get_tests_module ()
1037 # The naming convention for tests modules is hardwired: ${module}-tests.
1038 if test -f "$gnulib_dir/modules/$1"-tests \
1039 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1040 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1045 # func_acceptable module
1046 # tests whether a module is acceptable.
1048 # - avoidlist list of modules to avoid
1051 for avoid in $avoidlist; do
1052 if test "$avoid" = "$1"; then
1059 # func_modules_transitive_closure
1061 # - local_gnulib_dir from --local-dir
1062 # - modules list of specified modules
1063 # - inctests true if tests should be included, blank otherwise
1064 # - avoidlist list of modules to avoid
1065 # - tmp pathname of a temporary directory
1067 # - modules list of modules, including dependencies
1068 func_modules_transitive_closure ()
1070 # In order to process every module only once (for speed), process an "input
1071 # list" of modules, producing an "output list" of modules. During each round,
1072 # more modules can be queued in the input list. Once a module on the input
1073 # list has been processed, it is added to the "handled list", so we can avoid
1074 # to process it again.
1076 inmodules="$modules"
1078 while test -n "$inmodules"; do
1079 inmodules_this_round="$inmodules"
1080 inmodules= # Accumulator, queue for next round
1081 for module in $inmodules_this_round; do
1083 if test -n "$module"; then
1084 if func_acceptable $module; then
1085 func_append outmodules " $module"
1086 deps=`func_get_dependencies $module`
1087 # Duplicate dependencies are harmless, but Jim wants a warning.
1088 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1089 if test -n "$duplicated_deps"; then
1090 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1092 func_append inmodules " $deps"
1093 if test -n "$inctests"; then
1094 testsmodule=`func_get_tests_module $module`
1095 if test -n "$testsmodule"; then
1096 func_append inmodules " $testsmodule"
1102 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1103 # Remove $handledmodules from $inmodules.
1104 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1105 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1107 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1108 rm -f "$tmp"/queued-modules
1111 # func_modules_add_dummy
1113 # - local_gnulib_dir from --local-dir
1114 # - modules list of modules, including dependencies
1116 # - modules list of modules, including 'dummy' if needed
1117 func_modules_add_dummy ()
1120 sed_remove_backslash_newline=':a
1127 for module in $modules; do
1128 func_verify_nontests_module
1129 if test -n "$module"; then
1130 # Extract the value of "lib_SOURCES += ...".
1131 for file in `func_get_automake_snippet "$module" | $SED -e "$sed_remove_backslash_newline" | $SED -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1132 # Ignore .h files since they are not compiled.
1135 *) have_lib_SOURCES=yes ;;
1140 # Add the dummy module, to make sure the library will be non-empty.
1141 if test -z "$have_lib_SOURCES"; then
1142 func_append modules " dummy"
1146 # func_modules_to_filelist
1148 # - local_gnulib_dir from --local-dir
1149 # - modules list of modules, including dependencies
1151 # - files list of files
1152 func_modules_to_filelist ()
1155 for module in $modules; do
1157 if test -n "$module"; then
1158 fs=`func_get_filelist $module`
1159 func_append files " $fs"
1162 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1165 # func_emit_lib_Makefile_am
1166 # emits the contents of library makefile to standard output.
1168 # - local_gnulib_dir from --local-dir
1169 # - modules list of modules, including dependencies
1170 # - libname library name
1171 # - auxdir directory relative to destdir where to place build aux files
1172 # - makefile_name from --makefile-name
1173 # - libtool true if libtool will be used, false or blank otherwise
1174 # - macro_prefix prefix of gl_LIBOBJS macros to use
1175 # - actioncmd (optional) command that will reproduce this invocation
1177 # - uses_subdirs nonempty if object files in subdirs exist
1178 func_emit_lib_Makefile_am ()
1180 # When creating an includable Makefile.am snippet, augment variables with
1181 # += instead of assigning them.
1182 if test -n "$makefile_name"; then
1187 if test "$libtool" = true; then
1190 sed_eliminate_LDFLAGS=
1194 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1196 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1197 echo "## Process this file with automake to produce Makefile.in."
1198 func_emit_copyright_notice
1199 if test -n "$actioncmd"; then
1200 echo "# Reproduce by: $actioncmd"
1205 for module in $modules; do
1206 func_verify_nontests_module
1207 if test -n "$module"; then
1209 func_get_automake_snippet "$module" |
1210 $SED -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1211 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1212 $SED -e "$sed_eliminate_LDFLAGS" |
1213 $SED -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1214 $SED -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1215 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1216 if test "$module" = 'alloca'; then
1217 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1218 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1221 # Skip the contents if its entirely empty.
1222 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1223 echo "## begin gnulib module $module"
1226 echo "## end gnulib module $module"
1230 # Test whether there are some source files in subdirectories.
1231 for f in `func_get_filelist "$module"`; do
1233 lib/*/*.c) uses_subdirs=yes ;;
1239 if test -z "$makefile_name"; then
1240 # If there are source files in subdirectories, prevent collision of the
1241 # object files (example: hash.c and libxml/hash.c).
1243 if test -n "$uses_subdirs"; then
1244 subdir_options=' subdir-objects'
1246 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1249 if test -z "$makefile_name"; then
1250 echo "noinst_HEADERS ="
1251 echo "noinst_LIBRARIES ="
1252 echo "noinst_LTLIBRARIES ="
1253 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1254 # if you specify pkgdata_DATA to empty. This is a workaround.
1255 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1256 echo "pkgdata_DATA ="
1259 echo "BUILT_SOURCES ="
1262 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1263 if test -z "$makefile_name"; then
1264 echo "MOSTLYCLEANDIRS ="
1266 echo "DISTCLEANFILES ="
1267 echo "MAINTAINERCLEANFILES ="
1269 echo "AM_CPPFLAGS ="
1272 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1273 # One of the snippets already specifies an installation location for the
1274 # library. Don't confuse automake by saying it should not be installed.
1277 # By default, the generated library should not be installed.
1278 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1281 echo "${libname}_${libext}_SOURCES ="
1282 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1283 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1284 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1285 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1286 echo "EXTRA_${libname}_${libext}_SOURCES ="
1287 if test "$libtool" = true; then
1288 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1291 cat allsnippets.tmp \
1292 | $SED -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1294 echo "mostlyclean-local: mostlyclean-generic"
1295 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1296 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1297 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1300 rm -f allsnippets.tmp
1303 # func_emit_tests_Makefile_am
1304 # emits the contents of tests makefile to standard output.
1306 # - local_gnulib_dir from --local-dir
1307 # - modules list of modules, including dependencies
1308 # - libname library name
1309 # - makefile_name from --makefile-name
1310 # - libtool true if libtool will be used, false or blank otherwise
1311 # - sourcebase relative directory containing lib source code
1312 # - m4base relative directory containing autoconf macros
1313 # - testsbase relative directory containing unit test code
1314 func_emit_tests_Makefile_am ()
1316 if test "$libtool" = true; then
1321 if test "$libtool" = true; then
1323 sed_eliminate_LDFLAGS=
1326 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1328 testsbase_inverse=`echo "$testsbase" | $SED -e 's,/$,,' | $SED -e 's,[^/][^/]*,..,g'`
1329 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1330 echo "## Process this file with automake to produce Makefile.in."
1331 func_emit_copyright_notice
1333 # Generate dependencies here, since it eases the debugging of test failures.
1334 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1336 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1339 for module in $modules; do
1340 func_verify_tests_module
1341 if test -n "$module"; then
1343 func_get_automake_snippet "$module" |
1344 $SED -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1345 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1346 $SED -e "$sed_eliminate_LDFLAGS" |
1347 $SED -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1348 $SED -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1349 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1351 # Skip the contents if its entirely empty.
1352 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1353 echo "## begin gnulib module $module"
1356 echo "## end gnulib module $module"
1363 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1364 # variable is needed to avoid an error from automake:
1365 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1368 echo "TESTS_ENVIRONMENT ="
1369 echo "noinst_PROGRAMS ="
1370 echo "check_PROGRAMS ="
1371 echo "noinst_HEADERS ="
1372 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1373 echo "pkgdata_DATA ="
1376 echo "BUILT_SOURCES ="
1378 echo "MOSTLYCLEANFILES = core *.stackdump"
1379 echo "MOSTLYCLEANDIRS ="
1381 echo "DISTCLEANFILES ="
1382 echo "MAINTAINERCLEANFILES ="
1384 echo "AM_CPPFLAGS = \\"
1385 echo " -I. -I\$(srcdir) \\"
1386 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1387 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1389 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1392 echo "# Clean up after Solaris cc."
1394 echo " rm -rf SunWS_cache"
1396 echo "mostlyclean-local: mostlyclean-generic"
1397 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1398 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1399 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1402 rm -f allsnippets.tmp
1405 # func_emit_initmacro_start
1406 # emits the first few statements of the gl_INIT macro to standard output.
1407 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1408 func_emit_initmacro_start ()
1410 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1411 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1412 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1413 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1415 # Furthermore it avoids an automake error like this when a Makefile.am
1416 # that uses pieces of gnulib also uses $(LIBOBJ):
1417 # automatically discovered file `error.c' should not be explicitly mentioned
1418 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1419 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1420 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1421 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1422 # automatically discovered file `error.c' should not be explicitly mentioned
1423 # We let automake know about the files to be distributed through the
1424 # EXTRA_lib_SOURCES variable.
1425 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1428 # func_emit_initmacro_end
1429 # emits the last few statements of the gl_INIT macro to standard output.
1430 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1431 func_emit_initmacro_end ()
1433 echo " m4_popdef([AC_LIBSOURCES])"
1434 echo " m4_popdef([AC_REPLACE_FUNCS])"
1435 echo " m4_popdef([AC_LIBOBJ])"
1436 echo " AC_CONFIG_COMMANDS_PRE(["
1437 echo " ${macro_prefix}_libobjs="
1438 echo " ${macro_prefix}_ltlibobjs="
1439 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1440 echo " # Remove the extension."
1441 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1442 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | $SED \"\$sed_drop_objext\" | sort | uniq\`; do"
1443 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1444 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1447 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1448 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1452 # func_emit_initmacro_done
1453 # emits a few statements after the gl_INIT macro to standard output.
1454 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1455 func_emit_initmacro_done ()
1458 echo "# Like AC_LIBOBJ, except that the module name goes"
1459 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1460 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1461 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1463 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1464 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1465 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1466 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1468 echo "# Like AC_LIBSOURCES, except that it does nothing."
1469 echo "# We rely on EXTRA_lib..._SOURCES instead."
1470 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1474 # func_import modules
1475 # Uses also the variables
1476 # - destdir target directory
1477 # - local_gnulib_dir from --local-dir
1478 # - libname library name
1479 # - sourcebase directory relative to destdir where to place source code
1480 # - m4base directory relative to destdir where to place *.m4 macros
1481 # - docbase directory relative to destdir where to place doc files
1482 # - testsbase directory relative to destdir where to place unit test code
1483 # - auxdir directory relative to destdir where to place build aux files
1484 # - inctests true if --with-tests was given, blank otherwise
1485 # - avoidlist list of modules to avoid, from --avoid
1486 # - lgpl true if library's license shall be LGPL, blank otherwise
1487 # - makefile_name from --makefile-name
1488 # - libtool true if --libtool was given, false if --no-libtool was
1489 # given, blank otherwise
1490 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1491 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1492 # - autoconf_minversion minimum supported autoconf version
1493 # - doit : if actions shall be executed, false if only to be printed
1494 # - symbolic true if files should be symlinked, copied otherwise
1495 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1499 # Get the cached settings.
1500 cached_local_gnulib_dir=
1501 cached_specified_modules=
1509 cached_makefile_name=
1511 cached_macro_prefix=
1513 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1514 cached_libtool=false
1520 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1523 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1526 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1529 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1532 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1535 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1538 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1541 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1544 s,^.*$,cached_lgpl=true,p
1546 /gl_MAKEFILE_NAME(/ {
1547 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1550 s,^.*$,cached_libtool=true,p
1552 /gl_MACRO_PREFIX(/ {
1553 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1555 eval `$SED -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1556 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1561 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1562 s,^.*$,cached_files=",p
1574 eval `$SED -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1578 # Merge the cached settings with the specified ones.
1579 # The m4base must be the same as expected from the pathname.
1580 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1581 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1583 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1584 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1585 if test -z "$local_gnulib_dir"; then
1586 if test -n "$cached_local_gnulib_dir"; then
1589 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1591 case "$cached_local_gnulib_dir" in
1593 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1595 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1596 local_gnulib_dir="$relconcat" ;;
1601 # Append the cached and the specified module names. So that
1602 # "gnulib-tool --import foo" means to add the module foo.
1603 specified_modules="$cached_specified_modules $1"
1604 # Append the cached and the specified avoidlist. This is probably better
1605 # than dropping the cached one when --avoid is specified at least once.
1606 avoidlist=`echo $cached_avoidlist $avoidlist`
1607 # The sourcebase defaults to the cached one.
1608 if test -z "$sourcebase"; then
1609 sourcebase="$cached_sourcebase"
1610 if test -z "$sourcebase"; then
1611 func_fatal_error "missing --source-base option"
1614 # The docbase defaults to the cached one.
1615 if test -z "$docbase"; then
1616 docbase="$cached_docbase"
1617 if test -z "$docbase"; then
1618 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."
1621 # The testsbase defaults to the cached one.
1622 if test -z "$testsbase"; then
1623 testsbase="$cached_testsbase"
1624 if test -z "$testsbase"; then
1625 func_fatal_error "missing --tests-base option"
1628 # The libname defaults to the cached one.
1629 if test -z "$supplied_libname"; then
1630 libname="$cached_libname"
1631 if test -z "$libname"; then
1632 func_fatal_error "missing --lib option"
1635 # Require LGPL if specified either way.
1636 if test -z "$lgpl"; then
1639 # The makefile_name defaults to the cached one.
1640 if test -z "$makefile_name"; then
1641 makefile_name="$cached_makefile_name"
1643 # Use libtool if specified either way, or if guessed.
1644 if test -z "$libtool"; then
1645 if test -n "$cached_m4base"; then
1646 libtool="$cached_libtool"
1648 libtool="$guessed_libtool"
1651 # The macro_prefix defaults to the cached one.
1652 if test -z "$macro_prefix"; then
1653 macro_prefix="$cached_macro_prefix"
1654 if test -z "$macro_prefix"; then
1655 func_fatal_error "missing --macro-prefix option"
1659 # Canonicalize the list of specified modules.
1660 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1662 # Determine final module list.
1663 modules="$specified_modules"
1664 func_modules_transitive_closure
1665 echo "Module list with included dependencies:"
1666 echo "$modules" | $SED -e 's/^/ /'
1668 # Add the dummy module if needed.
1669 func_modules_add_dummy
1671 # If --lgpl, verify that the licenses of modules are compatible.
1672 if test -n "$lgpl"; then
1673 for module in $modules; do
1674 license=`func_get_license $module`
1676 LGPL | 'GPLed build tool') ;;
1677 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1678 *) func_fatal_error "incompatible license on module $module: $license" ;;
1683 # Determine script to apply to imported library files.
1684 sed_transform_lib_file=
1685 for module in $modules; do
1686 if test $module = config-h; then
1687 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1688 sed_transform_lib_file=$sed_transform_lib_file'
1689 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1694 if test -n "$lgpl"; then
1696 sed_transform_lib_file=$sed_transform_lib_file'
1697 s/GNU General/GNU Lesser General/g
1698 s/version 2\([ ,]\)/version 2.1\1/g
1702 # Determine final file list.
1703 func_modules_to_filelist
1705 echo "$files" | $SED -e 's/^/ /'
1708 || func_fatal_error "refusing to do nothing"
1710 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1711 new_files="$files m4/gnulib-tool.m4"
1712 old_files="$cached_files"
1713 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1714 func_append old_files " m4/gnulib-tool.m4"
1717 sed_rewrite_old_files="\
1718 s,^build-aux/,$auxdir/,
1719 s,^doc/,$cached_docbase/,
1720 s,^lib/,$cached_sourcebase/,
1721 s,^m4/,$cached_m4base/,
1722 s,^tests/,$cached_testsbase/,"
1723 sed_rewrite_new_files="\
1724 s,^build-aux/,$auxdir/,
1726 s,^lib/,$sourcebase/,
1728 s,^tests/,$testsbase/,"
1730 # Create directories.
1731 { echo "$sourcebase"
1733 docfiles=`echo "$files" | $SED -n -e 's,^doc/,,p'`
1734 if test -n "$docfiles"; then
1737 if test -n "$inctests"; then
1741 for f in $files; do echo $f; done \
1742 | $SED -e "$sed_rewrite_new_files" \
1743 | $SED -n -e 's,^\(.*\)/[^/]*,\1,p' \
1746 { # Rearrange file descriptors. Needed because "while ... done < ..."
1747 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1748 exec 5<&0 < "$tmp"/dirs
1750 if test ! -d "$destdir/$d"; then
1752 echo "Creating directory $destdir/$d"
1753 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1755 echo "Create directory $destdir/$d"
1762 # func_dest_tmpfilename file
1763 # determines the name of a temporary file (file is relative to destdir).
1765 # - tmpfile absolute filename of the temporary file
1766 func_dest_tmpfilename ()
1769 # Put the new contents of $file in a file in the same directory (needed
1770 # to guarantee that an 'mv' to "$destdir/$file" works).
1771 tmpfile="$destdir/$1.tmp"
1773 # Put the new contents of $file in a file in a temporary directory
1774 # (because the directory of "$file" might not exist).
1775 tmpfile="$tmp"/`basename "$1"`.tmp
1779 # Copy files or make symbolic links. Remove obsolete files.
1781 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1782 # representing the files according to the last gnulib-tool invocation.
1783 for f in $old_files; do echo $f; done \
1784 | $SED -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1787 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1788 # representing the files after this gnulib-tool invocation.
1789 for f in $new_files; do echo $f; done \
1790 | $SED -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1793 # First the files that are in old-files, but not in new-files:
1794 sed_take_first_column='s,'"$delimiter"'.*,,'
1795 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | $SED -e "$sed_take_first_column"`; do
1796 # Remove the file. Do nothing if the user already removed it.
1797 if test -f "$destdir/$g"; then
1799 echo "Removing file $g (backup in ${g}~)"
1800 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1802 echo "Remove file $g (backup in ${g}~)"
1806 # func_add_or_update handles a file that ought to be present afterwards.
1808 # - f the original file name
1809 # - g the rewritten file name
1810 # - already_present nonempty if the file already exists, empty otherwise
1811 func_add_or_update ()
1813 func_dest_tmpfilename "$g"
1814 func_lookup_file "$f"
1815 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1816 if test -n "$sed_transform_lib_file"; then
1819 $SED -e "$sed_transform_lib_file" \
1820 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1824 if test -f "$destdir/$g"; then
1825 # The file already exists.
1826 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1827 : # The file has not changed.
1831 if test -n "$already_present"; then
1832 echo "Updating file $g (backup in ${g}~)"
1834 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1836 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1837 if { test -n "$symbolic" \
1838 || { test -n "$lsymbolic" \
1839 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1840 && test -z "$lookedup_tmp" \
1841 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1842 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1844 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1847 if test -n "$already_present"; then
1848 echo "Update file $g (backup in ${g}~)"
1850 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1856 # Don't protest if the file should be there but isn't: it happens
1857 # frequently that developers don't put autogenerated files into CVS.
1859 echo "Copying file $g"
1860 if { test -n "$symbolic" \
1861 || { test -n "$lsymbolic" \
1862 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1863 && test -z "$lookedup_tmp" \
1864 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1865 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1867 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1875 # Then the files that are in new-files, but not in old-files:
1876 sed_take_last_column='s,^.*'"$delimiter"',,'
1878 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1879 | $SED -e "$sed_take_last_column" \
1880 | $SED -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1881 { # Rearrange file descriptors. Needed because "while ... done < ..."
1882 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1883 exec 5<&0 < "$tmp"/added-files
1889 # Then the files that are in new-files and in old-files:
1890 already_present=true
1891 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1892 | $SED -e "$sed_take_last_column" \
1893 | $SED -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1894 { # Rearrange file descriptors. Needed because "while ... done < ..."
1895 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1896 exec 5<&0 < "$tmp"/kept-files
1903 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1904 actioncmd="gnulib-tool --import"
1905 func_append actioncmd " --dir=$destdir"
1906 if test -n "$local_gnulib_dir"; then
1907 func_append actioncmd " --local-dir=$local_gnulib_dir"
1909 func_append actioncmd " --lib=$libname"
1910 func_append actioncmd " --source-base=$sourcebase"
1911 func_append actioncmd " --m4-base=$m4base"
1912 func_append actioncmd " --doc-base=$docbase"
1913 func_append actioncmd " --aux-dir=$auxdir"
1914 for module in $avoidlist; do
1915 func_append actioncmd " --avoid=$module"
1917 if test -n "$lgpl"; then
1918 func_append actioncmd " --lgpl"
1920 if test -n "$makefile_name"; then
1921 func_append actioncmd " --makefile-name=$makefile_name"
1923 if test "$libtool" = true; then
1924 func_append actioncmd " --libtool"
1926 func_append actioncmd " --no-libtool"
1928 func_append actioncmd " --macro-prefix=$macro_prefix"
1929 func_append actioncmd " `echo $specified_modules`"
1931 # Default the makefile name to Makefile.am.
1932 if test -n "$makefile_name"; then
1933 makefile_am=$makefile_name
1935 makefile_am=Makefile.am
1938 # Create library makefile.
1939 func_dest_tmpfilename $sourcebase/$makefile_am
1940 func_emit_lib_Makefile_am > "$tmpfile"
1941 if test -f "$destdir"/$sourcebase/$makefile_am; then
1942 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1946 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1947 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1948 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1950 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1956 echo "Creating $sourcebase/$makefile_am"
1957 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1959 echo "Create $sourcebase/$makefile_am"
1964 # Create m4/gnulib-cache.m4.
1965 func_dest_tmpfilename $m4base/gnulib-cache.m4
1967 func_emit_copyright_notice
1969 echo "# This file represents the specification of how gnulib-tool is used."
1970 echo "# It acts as a cache: It is written and read by gnulib-tool."
1971 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1972 echo "# like the configure.ac and various Makefile.am files."
1975 echo "# Specification in the form of a command-line invocation:"
1978 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1979 # Store the local_gnulib_dir relative to destdir.
1980 case "$local_gnulib_dir" in
1982 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1985 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1987 # destdir, local_gnulib_dir are both relative.
1988 func_relativize "$destdir" "$local_gnulib_dir"
1989 relative_local_gnulib_dir="$reldir" ;;
1992 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1993 echo "gl_MODULES(["`echo $specified_modules`"])"
1994 echo "gl_AVOID([$avoidlist])"
1995 echo "gl_SOURCE_BASE([$sourcebase])"
1996 echo "gl_M4_BASE([$m4base])"
1997 echo "gl_DOC_BASE([$docbase])"
1998 echo "gl_TESTS_BASE([$testsbase])"
1999 echo "gl_LIB([$libname])"
2000 test -z "$lgpl" || echo "gl_LGPL"
2001 echo "gl_MAKEFILE_NAME([$makefile_name])"
2002 if test "$libtool" = true; then
2005 echo "gl_MACRO_PREFIX([$macro_prefix])"
2007 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2008 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2012 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2013 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2014 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2016 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2020 echo "# gnulib-cache.m4 ends here"
2027 echo "Creating $m4base/gnulib-cache.m4"
2028 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2030 echo "Create $m4base/gnulib-cache.m4"
2036 # Create m4/gnulib-comp.m4.
2037 func_dest_tmpfilename $m4base/gnulib-comp.m4
2039 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2040 func_emit_copyright_notice
2042 echo "# This file represents the compiled summary of the specification in"
2043 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2044 echo "# to be invoked from configure.ac."
2045 echo "# In projects using CVS, this file can be treated like other built files."
2048 echo "# This macro should be invoked from $configure_ac, in the section"
2049 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2050 echo "# any checks for libraries, header files, types and library functions."
2051 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2053 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2054 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2055 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2056 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2057 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2058 if test -n "$uses_subdirs"; then
2059 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2061 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2062 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2064 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2065 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
2067 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2068 echo " AC_REQUIRE([gl_LOCK_EARLY])"
2072 echo "# This macro should be invoked from $configure_ac, in the section"
2073 echo "# \"Check for header files, types and library functions\"."
2074 echo "AC_DEFUN([${macro_prefix}_INIT],"
2076 func_emit_initmacro_start
2077 if test "$libtool" = true; then
2078 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2079 echo " gl_cond_libtool=true"
2081 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2082 echo " gl_cond_libtool=false"
2084 echo " gl_ltlibdeps="
2086 echo " gl_source_base='$sourcebase'"
2087 if test "$auxdir" != "build-aux"; then
2088 sed_replace_build_aux='
2090 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2091 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2094 sed_replace_build_aux=`echo "$sed_replace_build_aux" | $SED -e 1d -e 's/^ *//'`
2096 sed_replace_build_aux=
2098 for module in $modules; do
2100 if test -n "$module"; then
2101 func_get_autoconf_snippet "$module" \
2102 | $SED -e '/^$/d;' -e 's/^/ /' \
2103 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2104 -e "$sed_replace_build_aux"
2105 if test "$module" = 'alloca' && test "$libtool" = true; then
2106 echo 'changequote(,)dnl'
2107 echo 'LTALLOCA=`echo "$ALLOCA" | $SED '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2108 echo 'changequote([, ])dnl'
2109 echo 'AC_SUBST([LTALLOCA])'
2113 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2114 # created using libtool, because libtool already handles the dependencies.
2115 if test "$libtool" != true; then
2116 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2117 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2118 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2119 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2120 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2122 func_emit_initmacro_end
2124 func_emit_initmacro_done
2126 echo "# This macro records the list of files which have been installed by"
2127 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2128 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2129 echo "$files" | $SED -e 's,^, ,'
2132 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2133 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2137 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2138 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2139 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2141 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2145 echo "# gnulib-comp.m4 ends here"
2152 echo "Creating $m4base/gnulib-comp.m4"
2153 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2155 echo "Create $m4base/gnulib-comp.m4"
2161 if test -n "$inctests"; then
2162 # Create tests makefile.
2163 func_dest_tmpfilename $testsbase/$makefile_am
2164 func_emit_tests_Makefile_am > "$tmpfile"
2165 if test -f "$destdir"/$testsbase/$makefile_am; then
2166 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2170 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2171 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2172 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2174 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2180 echo "Creating $testsbase/$makefile_am"
2181 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2183 echo "Create $testsbase/$makefile_am"
2191 echo "You may need to add #include directives for the following .h files."
2192 # Intersect $specified_modules and $modules
2193 # (since $specified_modules is not necessarily of subset of $modules - some
2194 # may have been skipped through --avoid, and since the elements of $modules
2195 # but not in $specified_modules can go away without explicit notice - through
2196 # changes in the module dependencies).
2197 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2198 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2199 # First the #include <...> directives without #ifs, sorted for convenience,
2200 # then the #include "..." directives without #ifs, sorted for convenience,
2201 # then the #include directives that are surrounded by #ifs. Not sorted.
2202 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2203 include_directive=`func_get_include_directive "$module"`
2204 case "$nl$include_directive" in
2206 echo "$include_directive" 1>&5
2209 echo "$include_directive" | grep -v 'include "' 1>&6
2210 echo "$include_directive" | grep 'include "' 1>&7
2213 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2215 LC_ALL=C sort -u "$tmp"/include-angles
2216 LC_ALL=C sort -u "$tmp"/include-quotes
2217 cat "$tmp"/include-if
2218 ) | $SED -e '/^$/d' -e 's/^/ /'
2219 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2222 echo "Don't forget to"
2223 if test "$makefile_am" = Makefile.am; then
2224 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2226 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2228 if test -n "$inctests"; then
2229 if test "$makefile_am" = Makefile.am; then
2230 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2232 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2235 if test "$makefile_am" = Makefile.am; then
2236 sourcebase_dir=`echo "$sourcebase" | $SED -n -e 's,/[^/]*$,/,p'`
2237 sourcebase_base=`basename "$sourcebase"`
2238 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2240 if test -n "$inctests"; then
2241 if test "$makefile_am" = Makefile.am; then
2242 testsbase_dir=`echo "$testsbase" | $SED -n -e 's,/[^/]*$,/,p'`
2243 testsbase_base=`basename "$testsbase"`
2244 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2247 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2248 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2249 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2252 # func_create_testdir testdir modules
2254 # - local_gnulib_dir from --local-dir
2255 # - auxdir directory relative to destdir where to place build aux files
2256 func_create_testdir ()
2260 if test -z "$modules"; then
2261 # All modules together.
2262 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2263 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2264 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2265 modules=`func_all_modules`
2266 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2268 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2270 # Check that the license of every module is consistent with the license of
2272 saved_modules="$modules"
2273 for requested_module in $saved_modules; do
2274 requested_license=`func_get_license "$requested_module"`
2275 if test "$requested_license" != GPL; then
2276 # Here we use func_modules_transitive_closure, not just
2277 # func_get_dependencies, so that we also detect weird situations like
2278 # an LGPL module which depends on a GPLed build tool module which depends
2280 modules="$requested_module"
2281 func_modules_transitive_closure
2282 for module in $modules; do
2283 license=`func_get_license "$module"`
2285 LGPL | 'GPLed build tool') ;;
2286 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2287 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2292 modules="$saved_modules"
2294 # Subdirectory names.
2301 # Determine final module list.
2302 func_modules_transitive_closure
2303 echo "Module list with included dependencies:"
2304 echo "$modules" | $SED -e 's/^/ /'
2306 # Add the dummy module if needed.
2307 func_modules_add_dummy
2309 # Determine final file list.
2310 func_modules_to_filelist
2312 echo "$files" | $SED -e 's/^/ /'
2314 sed_rewrite_files="\
2315 s,^build-aux/,$auxdir/,
2317 s,^lib/,$sourcebase/,
2319 s,^tests/,$testsbase/,"
2321 # Create directories.
2322 for f in $files; do echo $f; done \
2323 | $SED -e "$sed_rewrite_files" \
2324 | $SED -n -e 's,^\(.*\)/[^/]*,\1,p' \
2325 | LC_ALL=C sort -u \
2327 { # Rearrange file descriptors. Needed because "while ... done < ..."
2328 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2329 exec 5<&0 < "$tmp"/dirs
2331 mkdir -p "$testdir/$d"
2336 # Copy files or make symbolic links.
2338 for f in $files; do echo $f; done \
2339 | $SED -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2342 { # Rearrange file descriptors. Needed because "while ... done < ..."
2343 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2344 exec 5<&0 < "$tmp"/files
2346 func_lookup_file "$f"
2347 if test -n "$lookedup_tmp"; then
2348 cp -p "$lookedup_file" "$testdir/$g"
2350 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2351 if { test -n "$symbolic" \
2352 || { test -n "$lsymbolic" \
2353 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2354 func_ln "$lookedup_file" "$testdir/$g"
2356 cp -p "$lookedup_file" "$testdir/$g"
2363 # Create $sourcebase/Makefile.am.
2364 mkdir -p "$testdir/$sourcebase"
2365 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2367 # Create $m4base/Makefile.am.
2368 mkdir -p "$testdir/$m4base"
2369 (echo "## Process this file with automake to produce Makefile.in."
2375 echo "EXTRA_DIST += "`echo "$f" | $SED -e 's,^m4/,,'` ;;
2378 ) > "$testdir/$m4base/Makefile.am"
2380 subdirs="$sourcebase $m4base"
2381 subdirs_with_configure_ac=""
2383 if false && test -f "$testdir"/$m4base/gettext.m4; then
2384 # Avoid stupid error message from automake:
2385 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2386 mkdir -p "$testdir/po"
2387 (echo "## Process this file with automake to produce Makefile.in."
2388 ) > "$testdir/po/Makefile.am"
2389 func_append subdirs " po"
2392 if test -n "$inctests"; then
2393 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2394 # Create $testsbase/Makefile.am.
2395 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2396 # Create $testsbase/configure.ac.
2397 (echo "# Process this file with autoconf to produce a configure script."
2398 echo "AC_INIT([dummy], [0])"
2399 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2400 echo "AM_INIT_AUTOMAKE"
2402 echo "AM_CONFIG_HEADER([config.h])"
2405 echo "AC_PROG_INSTALL"
2406 echo "AC_PROG_MAKE_SET"
2407 echo "AC_PROG_RANLIB"
2409 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2410 echo "AC_GNU_SOURCE"
2413 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2414 echo "gl_USE_SYSTEM_EXTENSIONS"
2417 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2418 echo "gl_LOCK_EARLY"
2421 if test "$libtool" = true; then
2422 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2423 echo "gl_cond_libtool=true"
2425 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2426 echo "gl_cond_libtool=false"
2428 echo "gl_ltlibdeps="
2430 # Wrap the set of autoconf snippets into an autoconf macro that is then
2431 # invoked. This is needed because autoconf does not support AC_REQUIRE
2433 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2434 # but we want the AC_REQUIRE to have its normal meaning (provide one
2435 # expansion of the required macro before the current point, and only one
2437 echo "AC_DEFUN([gl_INIT], ["
2438 func_emit_initmacro_start
2439 sed_replace_build_aux='
2441 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2442 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2445 sed_replace_build_aux=`echo "$sed_replace_build_aux" | $SED -e 1d -e 's/^ *//'`
2446 # We don't have explicit ordering constraints between the various
2447 # autoconf snippets. It's cleanest to put those of the library before
2448 # those of the tests.
2449 echo "gl_source_base='../$sourcebase'"
2450 for module in $modules; do
2451 func_verify_nontests_module
2452 if test -n "$module"; then
2453 func_get_autoconf_snippet "$module" \
2454 | $SED -e "$sed_replace_build_aux"
2457 echo "gl_source_base='.'"
2458 for module in $modules; do
2459 func_verify_tests_module
2460 if test -n "$module"; then
2461 func_get_autoconf_snippet "$module" \
2462 | $SED -e "$sed_replace_build_aux"
2465 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2466 # created using libtool, because libtool already handles the dependencies.
2467 if test "$libtool" != true; then
2468 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2469 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2470 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2471 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2472 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2474 func_emit_initmacro_end
2476 func_emit_initmacro_done
2480 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2481 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2482 echo "AH_TOP([#include \"../config.h\"])"
2484 echo "AC_OUTPUT([Makefile])"
2485 ) > "$testdir/$testsbase/configure.ac"
2486 func_append subdirs " $testsbase"
2487 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2490 # Create Makefile.am.
2491 (echo "## Process this file with automake to produce Makefile.in."
2493 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2495 echo "SUBDIRS = $subdirs"
2497 echo "ACLOCAL_AMFLAGS = -I $m4base"
2498 ) > "$testdir/Makefile.am"
2500 # Create configure.ac.
2501 (echo "# Process this file with autoconf to produce a configure script."
2502 echo "AC_INIT([dummy], [0])"
2503 if test "$auxdir" != "."; then
2504 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2506 echo "AM_INIT_AUTOMAKE"
2508 echo "AM_CONFIG_HEADER([config.h])"
2511 echo "AC_PROG_INSTALL"
2512 echo "AC_PROG_MAKE_SET"
2514 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2515 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2516 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2517 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2519 echo "AC_PROG_RANLIB"
2521 if test -n "$uses_subdirs"; then
2522 echo "AM_PROG_CC_C_O"
2525 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2526 echo "AC_GNU_SOURCE"
2529 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2530 echo "gl_USE_SYSTEM_EXTENSIONS"
2533 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2534 echo "gl_LOCK_EARLY"
2537 if test "$libtool" = true; then
2538 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2539 echo "gl_cond_libtool=true"
2541 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2542 echo "gl_cond_libtool=false"
2544 echo "gl_ltlibdeps="
2546 echo "gl_source_base='$sourcebase'"
2547 # Wrap the set of autoconf snippets into an autoconf macro that is then
2548 # invoked. This is needed because autoconf does not support AC_REQUIRE
2550 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2551 # but we want the AC_REQUIRE to have its normal meaning (provide one
2552 # expansion of the required macro before the current point, and only one
2554 echo "AC_DEFUN([gl_INIT], ["
2555 func_emit_initmacro_start
2556 if test "$auxdir" != "build-aux"; then
2557 sed_replace_build_aux='
2559 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2560 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2563 sed_replace_build_aux=`echo "$sed_replace_build_aux" | $SED -e 1d -e 's/^ *//'`
2565 sed_replace_build_aux=
2567 for module in $modules; do
2568 func_verify_nontests_module
2569 if test -n "$module"; then
2570 func_get_autoconf_snippet "$module" \
2571 | $SED -e "$sed_replace_build_aux"
2574 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2575 # created using libtool, because libtool already handles the dependencies.
2576 if test "$libtool" != true; then
2577 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2578 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2579 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2580 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2581 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2583 func_emit_initmacro_end
2585 func_emit_initmacro_done
2589 if test -n "$subdirs_with_configure_ac"; then
2590 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2592 makefiles="Makefile"
2593 for d in $subdirs; do
2594 # For subdirs that have a configure.ac by their own, it's the subdir's
2595 # configure.ac which creates the subdir's Makefile.am, not this one.
2596 case " $subdirs_with_configure_ac " in
2598 *) func_append makefiles " $d/Makefile" ;;
2601 echo "AC_OUTPUT([$makefiles])"
2602 ) > "$testdir/configure.ac"
2604 # Create autogenerated files.
2606 # Do not use "${AUTORECONF} --force --install", because it may invoke
2607 # autopoint, which brings in older versions of some of our .m4 files.
2608 if test -f $m4base/gettext.m4; then
2609 echo "executing ${AUTOPOINT} --force"
2610 ${AUTOPOINT} --force || func_exit 1
2611 for f in $m4base/*.m4~; do
2612 mv -f $f `echo $f | $SED -e 's,~$,,'` || func_exit 1
2615 echo "executing ${ACLOCAL} -I $m4base"
2616 ${ACLOCAL} -I $m4base || func_exit 1
2617 if ! test -d build-aux; then
2618 echo "executing mkdir build-aux"
2619 mkdir build-aux || func_exit 1
2621 echo "executing ${AUTOCONF}"
2622 ${AUTOCONF} || func_exit 1
2623 echo "executing ${AUTOHEADER}"
2624 ${AUTOHEADER} || func_exit 1
2625 echo "executing ${AUTOMAKE} --add-missing --copy"
2626 ${AUTOMAKE} --add-missing --copy || func_exit 1
2628 if test -n "$inctests"; then
2629 # Create autogenerated files.
2630 (cd "$testdir/$testsbase" || func_exit 1
2631 # Do not use "${AUTORECONF} --force --install", because it may invoke
2632 # autopoint, which brings in older versions of some of our .m4 files.
2633 if test -f ../$m4base/gettext.m4; then
2634 echo "executing ${AUTOPOINT} --force"
2635 ${AUTOPOINT} --force || func_exit 1
2636 for f in ../$m4base/*.m4~; do
2637 mv -f $f `echo $f | $SED -e 's,~$,,'` || func_exit 1
2640 echo "executing ${ACLOCAL} -I ../$m4base"
2641 ${ACLOCAL} -I ../$m4base || func_exit 1
2642 if ! test -d ../build-aux; then
2643 echo "executing mkdir ../build-aux"
2646 echo "executing ${AUTOCONF}"
2647 ${AUTOCONF} || func_exit 1
2648 echo "executing ${AUTOHEADER}"
2649 ${AUTOHEADER} || func_exit 1
2650 echo "executing ${AUTOMAKE} --add-missing --copy"
2651 ${AUTOMAKE} --add-missing --copy || func_exit 1
2654 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2656 ./configure || func_exit 1
2658 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2659 make built_sources || func_exit 1
2661 make distclean || func_exit 1
2666 # func_create_megatestdir megatestdir allmodules
2668 # - local_gnulib_dir from --local-dir
2669 # - auxdir directory relative to destdir where to place build aux files
2670 func_create_megatestdir ()
2674 if test -z "$allmodules"; then
2675 allmodules=`func_all_modules`
2679 # First, all modules one by one.
2680 for onemodule in $allmodules; do
2681 func_create_testdir "$megatestdir/$onemodule" $onemodule
2682 func_append megasubdirs "$onemodule "
2684 # Then, all modules all together.
2685 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2686 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2687 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2688 func_create_testdir "$megatestdir/ALL" "$allmodules"
2689 func_append megasubdirs "ALL"
2691 # Create Makefile.am.
2692 (echo "## Process this file with automake to produce Makefile.in."
2694 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2696 echo "SUBDIRS = $megasubdirs"
2697 ) > "$megatestdir/Makefile.am"
2699 # Create configure.ac.
2700 (echo "# Process this file with autoconf to produce a configure script."
2701 echo "AC_INIT([dummy], [0])"
2702 if test "$auxdir" != "."; then
2703 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2705 echo "AM_INIT_AUTOMAKE"
2707 echo "AC_PROG_MAKE_SET"
2709 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2710 echo "AC_OUTPUT([Makefile])"
2711 ) > "$megatestdir/configure.ac"
2713 # Create autogenerated files.
2715 # Do not use "${AUTORECONF} --install", because autoreconf operates
2716 # recursively, but the subdirectories are already finished, therefore
2717 # calling autoreconf here would only waste lots of CPU time.
2718 echo "executing ${ACLOCAL}"
2719 ${ACLOCAL} || func_exit 1
2720 echo "executing mkdir build-aux"
2722 echo "executing ${AUTOCONF}"
2723 ${AUTOCONF} || func_exit 1
2724 echo "executing ${AUTOMAKE} --add-missing --copy"
2725 ${AUTOMAKE} --add-missing --copy || func_exit 1
2731 func_fatal_error "no mode specified" ;;
2740 if test -z "$destdir"; then
2743 test -d "$destdir" \
2744 || func_fatal_error "destination directory does not exist: $destdir"
2746 # Prefer configure.ac to configure.in.
2747 if test -f "$destdir"/configure.ac; then
2748 configure_ac="$destdir/configure.ac"
2750 if test -f "$destdir"/configure.in; then
2751 configure_ac="$destdir/configure.in"
2753 func_fatal_error "cannot find $destdir/configure.ac"
2757 # Analyze configure.ac.
2759 guessed_libtool=false
2764 /AC_CONFIG_AUX_DIR/ {
2765 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2767 /A[CM]_PROG_LIBTOOL/ {
2768 s,^.*$,guessed_libtool=true,p
2770 eval `$SED -n -e "$my_sed_traces" < "$configure_ac"`
2772 if test -z "$auxdir"; then
2773 auxdir="$guessed_auxdir"
2776 # Determine where to apply func_import.
2777 if test -n "$m4base"; then
2778 # Apply func_import to a particular gnulib directory.
2779 # Any number of additional modules can be given.
2780 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2781 # First use of gnulib in the given m4base.
2782 test -n "$supplied_libname" || supplied_libname=true
2783 test -n "$sourcebase" || sourcebase="lib"
2784 test -n "$docbase" || docbase="doc"
2785 test -n "$testsbase" || testsbase="tests"
2786 test -n "$macro_prefix" || macro_prefix="gl"
2790 # Apply func_import to all gnulib directories.
2791 # To get this list of directories, look at Makefile.am. (Not at
2792 # configure, because it may be omitted from CVS. Also, don't run
2793 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2796 if test -f "$destdir"/Makefile.am; then
2797 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | $SED -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2799 for arg in $aclocal_amflags; do
2800 if test -n "$m4dir_is_next"; then
2801 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2805 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2806 func_append m4dirs " $arg"
2807 m4dirs_count=`expr $m4dirs_count + 1`
2812 if test "X$arg" = "X-I"; then
2820 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2821 if test -f "$destdir"/aclocal.m4; then
2822 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2823 sedexpr2='s,^[^/]*$,.,'
2824 sedexpr3='s,/[^/]*$,,'
2825 m4dirs=`$SED -n -e "$sedexpr1" aclocal.m4 | $SED -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
2826 m4dirs_count=`echo "$m4dirs" | wc -l`
2829 if test $m4dirs_count = 0; then
2830 # First use of gnulib in a package.
2831 # Any number of additional modules can be given.
2832 test -n "$supplied_libname" || supplied_libname=true
2833 test -n "$sourcebase" || sourcebase="lib"
2835 test -n "$docbase" || docbase="doc"
2836 test -n "$testsbase" || testsbase="tests"
2837 test -n "$macro_prefix" || macro_prefix="gl"
2840 if test $m4dirs_count = 1; then
2841 # There's only one use of gnulib here. Assume the user means it.
2842 # Any number of additional modules can be given.
2843 for m4base in $m4dirs; do
2847 # Ambiguous - guess what the user meant.
2848 if test $# = 0; then
2849 # No further arguments. Guess the user wants to update all of them.
2850 for m4base in $m4dirs; do
2851 # Perform func_import in a subshell, so that variable values
2853 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2854 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2855 # don't propagate from one directory to another.
2856 (func_import) || func_exit 1
2860 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2868 if test -z "$destdir"; then
2869 func_fatal_error "please specify --dir option"
2872 test -d "$destdir" \
2873 || func_fatal_error "could not create destination directory"
2874 test -n "$auxdir" || auxdir="build-aux"
2875 func_create_testdir "$destdir" "$*"
2878 create-megatestdir )
2879 if test -z "$destdir"; then
2880 func_fatal_error "please specify --dir option"
2882 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2883 test -n "$auxdir" || auxdir="build-aux"
2884 func_create_megatestdir "$destdir" "$*"
2888 test -n "$destdir" || destdir=testdir$$
2889 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2890 test -n "$auxdir" || auxdir="build-aux"
2891 func_create_testdir "$destdir" "$*"
2895 ../configure || func_exit 1
2897 make check || func_exit 1
2898 make distclean || func_exit 1
2899 remaining=`find . -type f -print`
2900 if test -n "$remaining"; then
2901 echo "Remaining files:" $remaining 1>&2
2902 echo "gnulib-tool: *** Stop." 1>&2
2911 test -n "$destdir" || destdir=testdir$$
2912 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2913 test -n "$auxdir" || auxdir="build-aux"
2914 func_create_megatestdir "$destdir" "$*"
2922 remaining=`find . -type f -print`
2923 if test -n "$remaining"; then
2924 echo "Remaining files:" $remaining 1>&2
2925 echo "gnulib-tool: *** Stop." 1>&2
2933 extract-description )
2937 if test -n "$module"; then
2938 func_get_description "$module"
2947 if test -n "$module"; then
2948 func_get_filelist "$module"
2953 extract-dependencies )
2957 if test -n "$module"; then
2958 func_get_dependencies "$module"
2963 extract-autoconf-snippet )
2967 if test -n "$module"; then
2968 func_get_autoconf_snippet "$module"
2973 extract-automake-snippet )
2977 if test -n "$module"; then
2978 func_get_automake_snippet "$module"
2983 extract-include-directive )
2987 if test -n "$module"; then
2988 func_get_include_directive "$module"
2997 if test -n "$module"; then
2998 func_get_license "$module"
3003 extract-maintainer )
3007 if test -n "$module"; then
3008 func_get_maintainer "$module"
3013 extract-tests-module )
3017 if test -n "$module"; then
3018 func_get_tests_module "$module"
3024 func_fatal_error "unknown operation mode --$mode" ;;
3028 # Undo the effect of the previous 'trap' command. Some shellology:
3029 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3030 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3031 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3032 # 128 + signal number and is set before the trap-registered command is run.
3034 trap 'func_exit $?' 1 2 3 13 15
3039 # indent-tabs-mode: nil
3040 # whitespace-check-buffer-indent: nil