3 # Copyright (C) 2002-2007 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: 2007-01-14 20:45:45 $'
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 # When using GNU sed, turn off as many GNU extensions as possible,
70 # to minimize the risk of accidentally using non-portable features.
71 # However, do this only for gnulib-tool itself, not for the code that
72 # gnulib-tool generates, since we don't want "sed --posix" to leak
74 if (alias) > /dev/null 2>&1 && echo | sed --posix d >/dev/null 2>&1; then
75 alias sed='sed --posix'
79 # outputs to stdout the --help usage message.
83 Usage: gnulib-tool --list
84 gnulib-tool --import [module1 ... moduleN]
86 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
87 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
88 gnulib-tool --test --dir=directory module1 ... moduleN
89 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
90 gnulib-tool --extract-description module
91 gnulib-tool --extract-filelist module
92 gnulib-tool --extract-dependencies module
93 gnulib-tool --extract-autoconf-snippet module
94 gnulib-tool --extract-automake-snippet module
95 gnulib-tool --extract-include-directive module
96 gnulib-tool --extract-license module
97 gnulib-tool --extract-maintainer module
98 gnulib-tool --extract-tests-module module
101 --list print the available module names
102 --import import the given modules into the current package;
103 if no modules are specified, update the current
104 package from the current gnulib
105 --update update the current package, restore files omitted
107 --create-testdir create a scratch package with the given modules
108 --create-megatestdir create a mega scratch package with the given modules
109 one by one and all together
110 --test test the combination of the given modules
111 (recommended to use CC=\"gcc -Wall\" here)
112 --megatest test the given modules one by one and all together
113 (recommended to use CC=\"gcc -Wall\" here)
114 --extract-description extract the description
115 --extract-filelist extract the list of files
116 --extract-dependencies extract the dependencies
117 --extract-autoconf-snippet extract the snippet for configure.ac
118 --extract-automake-snippet extract the snippet for library makefile
119 --extract-include-directive extract the #include directive
120 --extract-license report the license terms of the source files
122 --extract-maintainer report the maintainer(s) inside gnulib
123 --extract-tests-module report the unit test module, if it exists
126 --dir=DIRECTORY Specify the target directory.
127 For --import, this specifies where your
128 configure.ac can be found. Defaults to current
130 --local-dir=DIRECTORY Specify a local override directory where to look
131 up files before looking in gnulib's directory.
133 Options for --import:
134 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
135 --source-base=DIRECTORY
136 Directory relative to --dir where source code is
137 placed (default \"lib\").
138 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
139 placed (default \"m4\").
140 --doc-base=DIRECTORY Directory relative to --dir where doc files are
141 placed (default \"doc\").
142 --tests-base=DIRECTORY
143 Directory relative to --dir where unit tests are
144 placed (default \"tests\").
145 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
146 tools are placed (default \"build-aux\").
147 --with-tests Include unit tests for the included modules.
148 --avoid=MODULE Avoid including the given MODULE. Useful if you
149 have code that provides equivalent functionality.
150 This option can be repeated.
151 --lgpl Abort if modules aren't available under the LGPL.
152 Also modify license template from GPL to LGPL.
153 --makefile-name=NAME Name of makefile in automake syntax in the
154 source-base and tests-base directories
155 (default \"Makefile.am\").
156 --libtool Use libtool rules.
157 --no-libtool Don't use libtool rules.
158 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
159 'gl_INIT'. Default is 'gl'.
160 --no-changelog don't update or create ChangeLog files
162 Options for --import and --update:
163 --dry-run For --import, only print what would have been done.
164 -s, --symbolic, --symlink Make symbolic links instead of copying files.
165 --local-symlink Make symbolic links instead of copying files, only
166 for files from the local override directory.
168 Report bugs to <bug-gnulib@gnu.org>."
172 # outputs to stdout the --version message.
175 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
177 $progname (GNU $package) $version
178 Copyright (C) $year Free Software Foundation, Inc.
179 This is free software; see the source for copying conditions. There is NO
180 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
181 Written by" "Bruno Haible" "and" "Simon Josefsson"
184 # func_emit_copyright_notice
185 # outputs to stdout a header for a generated file.
186 func_emit_copyright_notice ()
188 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
190 echo "# This file is free software, distributed under the terms of the GNU"
191 echo "# General Public License. As a special exception to the GNU General"
192 echo "# Public License, this file may be distributed as part of a program"
193 echo "# that contains a configuration script generated by Autoconf, under"
194 echo "# the same distribution terms as the rest of that program."
196 echo "# Generated by gnulib-tool."
207 # creates a temporary directory.
209 # - tmp pathname of freshly created temporary directory
212 # Use the environment variable TMPDIR, falling back to /tmp. This allows
213 # users to specify a different temporary directory, for example, if their
214 # /tmp is filled up or too small.
217 # Use the mktemp program if available. If not available, hide the error
219 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
220 test -n "$tmp" && test -d "$tmp"
223 # Use a simple mkdir command. It is guaranteed to fail if the directory
224 # already exists. $RANDOM is bash specific and expands to empty in shells
225 # other than bash, ksh and zsh. Its use does not increase security;
226 # rather, it minimizes the probability of failure in a very cluttered /tmp
228 tmp=$TMPDIR/gl$$-$RANDOM
229 (umask 077 && mkdir "$tmp")
232 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
237 # func_append var value
238 # appends the given value to the shell variable var.
239 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
240 # Use bash's += operator. It reduces complexity of appending repeatedly to
241 # a single variable from O(n^2) to O(n).
249 eval "$1=\"\$$1\$2\""
253 # func_fatal_error message
254 # outputs to stderr a fatal error message, and terminates the program.
257 echo "gnulib-tool: *** $1" 1>&2
258 echo "gnulib-tool: *** Stop." 1>&2
262 # func_readlink SYMLINK
263 # outputs the target of the given symlink.
264 if (type -p readlink) > /dev/null 2>&1; then
267 # Use the readlink program from GNU coreutils.
273 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
274 # would do the wrong thing if the link target contains " -> ".
275 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
279 # func_relativize DIR1 DIR2
280 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
282 # - DIR1 relative pathname, relative to the current directory
283 # - DIR2 relative pathname, relative to the current directory
285 # - reldir relative pathname of DIR2, relative to DIR1
291 sed_first='s,^\([^/]*\)/.*$,\1,'
292 sed_rest='s,^[^/]*/*,,'
293 sed_last='s,^.*/\([^/]*\)$,\1,'
294 sed_butlast='s,/*[^/]*$,,'
295 while test -n "$dir1"; do
296 first=`echo "$dir1" | sed -e "$sed_first"`
297 if test "$first" != "."; then
298 if test "$first" = ".."; then
299 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
300 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
302 first2=`echo "$dir2" | sed -e "$sed_first"`
303 if test "$first2" = "$first"; then
304 dir2=`echo "$dir2" | sed -e "$sed_rest"`
308 dir0="$dir0"/"$first"
311 dir1=`echo "$dir1" | sed -e "$sed_rest"`
316 # func_relconcat DIR1 DIR2
317 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
319 # - DIR1 relative pathname, relative to the current directory
320 # - DIR2 relative pathname, relative to DIR1
322 # - relconcat DIR1/DIR2, relative to the current directory
327 sed_first='s,^\([^/]*\)/.*$,\1,'
328 sed_rest='s,^[^/]*/*,,'
329 sed_last='s,^.*/\([^/]*\)$,\1,'
330 sed_butlast='s,/*[^/]*$,,'
332 first=`echo "$dir2" | sed -e "$sed_first"`
333 if test "$first" = "."; then
334 dir2=`echo "$dir2" | sed -e "$sed_rest"`
335 if test -z "$dir2"; then
340 last=`echo "$dir1" | sed -e "$sed_last"`
341 while test "$last" = "."; do
342 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
343 last=`echo "$dir1" | sed -e "$sed_last"`
345 if test -z "$dir1"; then
349 if test "$first" = ".."; then
350 if test "$last" = ".."; then
351 relconcat="$dir1/$dir2"
354 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
355 dir2=`echo "$dir2" | sed -e "$sed_rest"`
356 if test -z "$dir1"; then
360 if test -z "$dir2"; then
365 relconcat="$dir1/$dir2"
373 # Like ln -s, except that SRC is given relative to the current directory (or
374 # absolute), not given relative to the directory of DEST.
380 *) # SRC is relative.
383 ln -s "`pwd`/$1" "$2" ;;
384 *) # DEST is relative too.
385 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
386 test -n "$ln_destdir" || ln_destdir="."
387 func_relativize "$ln_destdir" "$1"
395 # func_ln_if_changed SRC DEST
396 # Like func_ln, but avoids munging timestamps if the link is correct.
397 func_ln_if_changed ()
399 if test $# -ne 2; then
400 echo "usage: func_ln_if_changed SRC DEST" >&2
402 ln_target=`func_readlink "$2"`
403 if test -L "$2" && test "$1" = "$ln_target"; then
411 # Command-line option processing.
412 # Removes the OPTIONS from the arguments. Sets the variables:
413 # - mode list or import or create-testdir or create-megatestdir
414 # - destdir from --dir
415 # - local_gnulib_dir from --local-dir
416 # - libname, supplied_libname from --lib
417 # - sourcebase from --source-base
418 # - m4base from --m4-base
419 # - docbase from --doc-base
420 # - testsbase from --tests-base
421 # - auxdir from --aux-dir
422 # - inctests true if --with-tests was given, blank otherwise
423 # - avoidlist list of modules to avoid, from --avoid
424 # - lgpl true if --lgpl was given, blank otherwise
425 # - makefile_name from --makefile-name
426 # - libtool true if --libtool was given, false if --no-libtool was
427 # given, blank otherwise
428 # - macro_prefix from --macro-prefix
429 # - autoconf_minversion minimum supported autoconf version
430 # - do_changelog false if --no-changelog was given, : otherwise
431 # - doit : if actions shall be executed, false if only to be printed
432 # - symbolic true if --symlink was given, blank otherwise
433 # - lsymbolic true if --local-symlink was given, blank otherwise
458 while test $# -gt 0; do
463 --import | --impor | --impo | --imp | --im | --i )
466 --update | --updat | --upda | --upd | --up | --u )
469 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
472 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
473 mode=create-megatestdir
475 --test | --tes | --te | --t )
478 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
482 mode=`echo "X$1" | sed -e 's/^X--//'`
487 func_fatal_error "missing argument for --dir"
492 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
497 func_fatal_error "missing argument for --local-dir"
502 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
507 func_fatal_error "missing argument for --lib"
510 supplied_libname=true
513 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
514 supplied_libname=true
519 func_fatal_error "missing argument for --source-base"
524 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
529 func_fatal_error "missing argument for --m4-base"
534 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
539 func_fatal_error "missing argument for --doc-base"
544 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
549 func_fatal_error "missing argument for --tests-base"
554 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
559 func_fatal_error "missing argument for --aux-dir"
564 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
572 func_fatal_error "missing argument for --avoid"
574 func_append avoidlist " $1"
577 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
578 func_append avoidlist " $arg"
586 func_fatal_error "missing argument for --makefile-name"
591 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
602 func_fatal_error "missing argument for --macro-prefix"
607 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
609 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
615 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
618 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
621 --help | --hel | --he | --h )
624 --version | --versio | --versi | --vers | --ver | --ve | --v )
628 # Stop option processing
632 echo "gnulib-tool: unknown option $1" 1>&2
633 echo "Try 'gnulib-tool --help' for more information." 1>&2
640 if test "$mode" = update; then
641 if test $# != 0; then
642 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
643 echo "Try 'gnulib-tool --help' for more information." 1>&2
644 echo "If you really want to modify the gnulib configuration of your project," 1>&2
645 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
648 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
649 || test -n "$sourcebase" || test -n "$m4base" \
650 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
651 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
652 || test -n "$makefile_name" || test -n "$macro_prefix"; then
653 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
654 echo "Try 'gnulib-tool --help' for more information." 1>&2
655 echo "If you really want to modify the gnulib configuration of your project," 1>&2
656 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
662 # Determine the minimum supported autoconf version from the project's
664 DEFAULT_AUTOCONF_MINVERSION="2.59"
667 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
668 if test -f "$destdir"/configure.ac; then
669 configure_ac="$destdir/configure.ac"
671 if test -f "$destdir"/configure.in; then
672 configure_ac="$destdir/configure.in"
676 if test -f configure.ac; then
677 configure_ac="configure.ac"
679 if test -f configure.in; then
680 configure_ac="configure.in"
684 if test -n "$configure_ac"; then
685 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
686 # because when some m4 files are omitted from a CVS repository,
687 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
688 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
689 # autom4te: m4 failed with exit status: 1
696 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
698 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
699 if test -n "$prereqs"; then
700 autoconf_minversion=`
701 for version in $prereqs; do echo $version; done |
702 LC_ALL=C sort -nru | sed 1q
706 if test -z "$autoconf_minversion"; then
707 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
709 case "$autoconf_minversion" in
710 1.* | 2.[0-4]* | 2.5[0-8]*)
711 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
714 # Remove trailing slashes from the directory names. This is necessary for
715 # m4base (to avoid an error in func_import) and optional for the others.
716 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
717 case "$local_gnulib_dir" in
718 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
720 case "$sourcebase" in
721 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
724 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
727 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
730 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
733 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
738 /*) self_abspathname="$0" ;;
739 */*) self_abspathname=`pwd`/"$0" ;;
740 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
741 if test -x "$d/$0" && test ! -d "$d/$0"; then
742 self_abspathname="$d/$0"
746 if test -z "$self_abspathname"; then
747 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
751 while test -h "$self_abspathname"; do
752 # Resolve symbolic link.
753 linkval=`func_readlink "$self_abspathname"`
754 test -n "$linkval" || break
756 /* ) self_abspathname="$linkval" ;;
757 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
760 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
764 if test "$signal" != 0; then
765 echo "caught signal $signal" >&2
769 for signal in 1 2 3 13 15; do
770 trap '{ signal='$signal'; func_exit 1; }' $signal
774 # func_lookup_file file
775 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
778 # - local_gnulib_dir from --local-dir
780 # - lookedup_file name of the merged (combined) file
781 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
785 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
786 lookedup_file="$local_gnulib_dir/$lkfile"
789 if test -f "$gnulib_dir/$lkfile"; then
790 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
791 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
793 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
794 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
795 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
796 lookedup_file="$tmp/$lkbase"
799 lookedup_file="$gnulib_dir/$lkfile"
803 func_fatal_error "file $gnulib_dir/$lkfile not found"
810 # - local_gnulib_dir from --local-dir
813 # Filter out metainformation files like README, which are not modules.
814 # Filter out unit test modules; they can be retrieved through
815 # --extract-tests-module if desired.
817 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
818 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
819 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
822 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
823 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
824 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
825 -e '/^README$/d' -e '/\/README$/d' \
827 -e '/^TEMPLATE-TESTS$/d' \
830 | sed -e '/-tests$/d' \
835 # verifies a module name
837 # - local_gnulib_dir from --local-dir
838 # - module module name argument
839 func_verify_module ()
841 if { test -f "$gnulib_dir/modules/$module" \
842 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
843 && test -f "$local_gnulib_dir/modules/$module"; }; } \
844 && test "CVS" != "$module" \
845 && test "ChangeLog" != "$module" \
846 && test "COPYING" != "$module" \
847 && test "README" != "$module" \
848 && test "TEMPLATE" != "$module" \
849 && test "TEMPLATE-TESTS" != "$module"; then
850 # OK, $module is a correct module name.
851 # Verify that building the module description with 'patch' succeeds.
852 func_lookup_file "modules/$module"
854 echo "gnulib-tool: module $module doesn't exist" 1>&2
859 # func_verify_nontests_module
860 # verifies a module name, excluding tests modules
862 # - local_gnulib_dir from --local-dir
863 # - module module name argument
864 func_verify_nontests_module ()
868 * ) func_verify_module ;;
872 # func_verify_tests_module
873 # verifies a module name, considering only tests modules
875 # - local_gnulib_dir from --local-dir
876 # - module module name argument
877 func_verify_tests_module ()
880 *-tests ) func_verify_module ;;
885 sed_extract_prog=':[ ]*$/ {
888 s/^Description:[ ]*$//
890 s/^Depends-on:[ ]*$//
891 s/^configure\.ac:[ ]*$//
892 s/^Makefile\.am:[ ]*$//
895 s/^Maintainer:[ ]*$//
902 # func_get_description module
904 # - local_gnulib_dir from --local-dir
905 func_get_description ()
907 func_lookup_file "modules/$1"
908 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
911 # func_get_filelist module
913 # - local_gnulib_dir from --local-dir
916 func_lookup_file "modules/$1"
917 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
918 echo m4/gnulib-common.m4
919 case "$autoconf_minversion" in
922 echo m4/onceonly_2_57.m4
927 # func_get_dependencies module
929 # - local_gnulib_dir from --local-dir
930 func_get_dependencies ()
932 # ${module}-tests always implicitly depends on ${module}.
933 echo "$1" | sed -n -e 's/-tests//p'
934 # Then the explicit dependencies listed in the module description.
935 func_lookup_file "modules/$1"
936 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
939 # func_get_autoconf_snippet module
941 # - local_gnulib_dir from --local-dir
942 func_get_autoconf_snippet ()
944 func_lookup_file "modules/$1"
945 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
948 # func_get_automake_snippet module
950 # - local_gnulib_dir from --local-dir
951 func_get_automake_snippet ()
953 func_lookup_file "modules/$1"
954 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
957 # *-tests module live in tests/, not lib/.
960 # Synthesize an EXTRA_DIST augmentation.
961 sed_combine_lines='/\\$/{
968 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
969 already_mentioned_files=` \
970 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
971 | sed -e "$sed_combine_lines" \
972 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
973 all_files=`func_get_filelist $1`
974 lib_files=`for f in $all_files; do \
978 done | sed -e 's,^lib/,,'`
979 # Remove $already_mentioned_files from $lib_files.
980 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
981 extra_files=`for f in $already_mentioned_files; do echo $f; done \
982 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
983 if test -n "$extra_files"; then
984 echo "EXTRA_DIST +=" $extra_files
987 # Synthesize also an EXTRA_lib_SOURCES augmentation.
988 # This is necessary so that automake can generate the right list of
990 # A possible approach would be to use autom4te --trace of the redefined
991 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
992 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
993 # inside autoconf's built-in macros are not missed).
994 # But it's simpler and more robust to do it here, based on the file list.
995 # If some .c file exists and is not used with AC_LIBOBJ - for example,
996 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
997 # automake will generate a useless dependency; this is harmless.
998 sed_extract_c_files='/\.c$/p'
999 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1000 if test -n "$extra_files"; then
1001 echo "EXTRA_lib_SOURCES +=" $extra_files
1008 # func_get_include_directive module
1010 # - local_gnulib_dir from --local-dir
1011 func_get_include_directive ()
1013 func_lookup_file "modules/$1"
1014 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1015 sed -e 's/^\(["<]\)/#include \1/'
1018 # func_get_license module
1020 # - local_gnulib_dir from --local-dir
1023 func_lookup_file "modules/$1"
1024 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1027 # func_get_maintainer module
1029 # - local_gnulib_dir from --local-dir
1030 func_get_maintainer ()
1032 func_lookup_file "modules/$1"
1033 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1036 # func_get_tests_module module
1038 # - local_gnulib_dir from --local-dir
1039 func_get_tests_module ()
1041 # The naming convention for tests modules is hardwired: ${module}-tests.
1042 if test -f "$gnulib_dir/modules/$1"-tests \
1043 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1044 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1049 # func_acceptable module
1050 # tests whether a module is acceptable.
1052 # - avoidlist list of modules to avoid
1055 for avoid in $avoidlist; do
1056 if test "$avoid" = "$1"; then
1063 # func_modules_transitive_closure
1065 # - local_gnulib_dir from --local-dir
1066 # - modules list of specified modules
1067 # - inctests true if tests should be included, blank otherwise
1068 # - avoidlist list of modules to avoid
1069 # - tmp pathname of a temporary directory
1071 # - modules list of modules, including dependencies
1072 func_modules_transitive_closure ()
1074 # In order to process every module only once (for speed), process an "input
1075 # list" of modules, producing an "output list" of modules. During each round,
1076 # more modules can be queued in the input list. Once a module on the input
1077 # list has been processed, it is added to the "handled list", so we can avoid
1078 # to process it again.
1080 inmodules="$modules"
1082 while test -n "$inmodules"; do
1083 inmodules_this_round="$inmodules"
1084 inmodules= # Accumulator, queue for next round
1085 for module in $inmodules_this_round; do
1087 if test -n "$module"; then
1088 if func_acceptable $module; then
1089 func_append outmodules " $module"
1090 deps=`func_get_dependencies $module`
1091 # Duplicate dependencies are harmless, but Jim wants a warning.
1092 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1093 if test -n "$duplicated_deps"; then
1094 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1096 func_append inmodules " $deps"
1097 if test -n "$inctests"; then
1098 testsmodule=`func_get_tests_module $module`
1099 if test -n "$testsmodule"; then
1100 func_append inmodules " $testsmodule"
1106 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1107 # Remove $handledmodules from $inmodules.
1108 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1109 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1111 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1112 rm -f "$tmp"/queued-modules
1115 # func_modules_add_dummy
1117 # - local_gnulib_dir from --local-dir
1118 # - modules list of modules, including dependencies
1120 # - modules list of modules, including 'dummy' if needed
1121 func_modules_add_dummy ()
1124 sed_remove_backslash_newline=':a
1131 for module in $modules; do
1132 func_verify_nontests_module
1133 if test -n "$module"; then
1134 # Extract the value of "lib_SOURCES += ...".
1135 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1136 # Ignore .h files since they are not compiled.
1139 *) have_lib_SOURCES=yes ;;
1144 # Add the dummy module, to make sure the library will be non-empty.
1145 if test -z "$have_lib_SOURCES"; then
1146 func_append modules " dummy"
1150 # func_modules_to_filelist
1152 # - local_gnulib_dir from --local-dir
1153 # - modules list of modules, including dependencies
1155 # - files list of files
1156 func_modules_to_filelist ()
1159 for module in $modules; do
1161 if test -n "$module"; then
1162 fs=`func_get_filelist $module`
1163 func_append files " $fs"
1166 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1169 # func_emit_lib_Makefile_am
1170 # emits the contents of library makefile to standard output.
1172 # - local_gnulib_dir from --local-dir
1173 # - modules list of modules, including dependencies
1174 # - libname library name
1175 # - auxdir directory relative to destdir where to place build aux files
1176 # - makefile_name from --makefile-name
1177 # - libtool true if libtool will be used, false or blank otherwise
1178 # - macro_prefix prefix of gl_LIBOBJS macros to use
1179 # - actioncmd (optional) command that will reproduce this invocation
1181 # - uses_subdirs nonempty if object files in subdirs exist
1182 func_emit_lib_Makefile_am ()
1184 # When creating an includable Makefile.am snippet, augment variables with
1185 # += instead of assigning them.
1186 if test -n "$makefile_name"; then
1191 if test "$libtool" = true; then
1194 sed_eliminate_LDFLAGS=
1198 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1200 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1201 echo "## Process this file with automake to produce Makefile.in."
1202 func_emit_copyright_notice
1203 if test -n "$actioncmd"; then
1204 echo "# Reproduce by: $actioncmd"
1209 for module in $modules; do
1210 func_verify_nontests_module
1211 if test -n "$module"; then
1213 func_get_automake_snippet "$module" |
1214 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1215 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1216 sed -e "$sed_eliminate_LDFLAGS" |
1217 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1218 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1219 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1220 if test "$module" = 'alloca'; then
1221 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1222 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1225 # Skip the contents if its entirely empty.
1226 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1227 echo "## begin gnulib module $module"
1230 echo "## end gnulib module $module"
1234 # Test whether there are some source files in subdirectories.
1235 for f in `func_get_filelist "$module"`; do
1237 lib/*/*.c) uses_subdirs=yes ;;
1243 if test -z "$makefile_name"; then
1244 # If there are source files in subdirectories, prevent collision of the
1245 # object files (example: hash.c and libxml/hash.c).
1247 if test -n "$uses_subdirs"; then
1248 subdir_options=' subdir-objects'
1250 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1253 if test -z "$makefile_name"; then
1254 echo "noinst_HEADERS ="
1255 echo "noinst_LIBRARIES ="
1256 echo "noinst_LTLIBRARIES ="
1257 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1258 # if you specify pkgdata_DATA to empty. This is a workaround.
1259 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1260 echo "pkgdata_DATA ="
1263 echo "BUILT_SOURCES ="
1266 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1267 if test -z "$makefile_name"; then
1268 echo "MOSTLYCLEANDIRS ="
1270 echo "DISTCLEANFILES ="
1271 echo "MAINTAINERCLEANFILES ="
1273 echo "AM_CPPFLAGS ="
1276 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1277 # One of the snippets already specifies an installation location for the
1278 # library. Don't confuse automake by saying it should not be installed.
1281 # By default, the generated library should not be installed.
1282 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1285 echo "${libname}_${libext}_SOURCES ="
1286 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1287 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1288 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1289 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1290 echo "EXTRA_${libname}_${libext}_SOURCES ="
1291 if test "$libtool" = true; then
1292 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1295 cat allsnippets.tmp \
1296 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1298 echo "mostlyclean-local: mostlyclean-generic"
1299 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1300 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1301 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1304 rm -f allsnippets.tmp
1307 # func_emit_tests_Makefile_am
1308 # emits the contents of tests makefile to standard output.
1310 # - local_gnulib_dir from --local-dir
1311 # - modules list of modules, including dependencies
1312 # - libname library name
1313 # - makefile_name from --makefile-name
1314 # - libtool true if libtool will be used, false or blank otherwise
1315 # - sourcebase relative directory containing lib source code
1316 # - m4base relative directory containing autoconf macros
1317 # - testsbase relative directory containing unit test code
1318 func_emit_tests_Makefile_am ()
1320 if test "$libtool" = true; then
1325 if test "$libtool" = true; then
1327 sed_eliminate_LDFLAGS=
1330 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1332 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1333 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1334 echo "## Process this file with automake to produce Makefile.in."
1335 func_emit_copyright_notice
1337 # Generate dependencies here, since it eases the debugging of test failures.
1338 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1340 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1343 for module in $modules; do
1344 func_verify_tests_module
1345 if test -n "$module"; then
1347 func_get_automake_snippet "$module" |
1348 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1349 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1350 sed -e "$sed_eliminate_LDFLAGS" |
1351 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1352 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1353 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1355 # Skip the contents if its entirely empty.
1356 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1357 echo "## begin gnulib module $module"
1360 echo "## end gnulib module $module"
1367 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1368 # variable is needed to avoid an error from automake:
1369 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1372 echo "TESTS_ENVIRONMENT ="
1373 echo "noinst_PROGRAMS ="
1374 echo "check_PROGRAMS ="
1375 echo "noinst_HEADERS ="
1376 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1377 echo "pkgdata_DATA ="
1380 echo "BUILT_SOURCES ="
1382 echo "MOSTLYCLEANFILES = core *.stackdump"
1383 echo "MOSTLYCLEANDIRS ="
1385 echo "DISTCLEANFILES ="
1386 echo "MAINTAINERCLEANFILES ="
1388 echo "AM_CPPFLAGS = \\"
1389 echo " -I. -I\$(srcdir) \\"
1390 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1391 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1393 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1396 echo "# Clean up after Solaris cc."
1398 echo " rm -rf SunWS_cache"
1400 echo "mostlyclean-local: mostlyclean-generic"
1401 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1402 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1403 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1406 rm -f allsnippets.tmp
1409 # func_emit_initmacro_start
1410 # emits the first few statements of the gl_INIT macro to standard output.
1411 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1412 func_emit_initmacro_start ()
1414 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1415 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1416 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1417 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1419 # Furthermore it avoids an automake error like this when a Makefile.am
1420 # that uses pieces of gnulib also uses $(LIBOBJ):
1421 # automatically discovered file `error.c' should not be explicitly mentioned
1422 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1423 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1424 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1425 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1426 # automatically discovered file `error.c' should not be explicitly mentioned
1427 # We let automake know about the files to be distributed through the
1428 # EXTRA_lib_SOURCES variable.
1429 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1432 # func_emit_initmacro_end
1433 # emits the last few statements of the gl_INIT macro to standard output.
1434 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1435 func_emit_initmacro_end ()
1437 echo " m4_popdef([AC_LIBSOURCES])"
1438 echo " m4_popdef([AC_REPLACE_FUNCS])"
1439 echo " m4_popdef([AC_LIBOBJ])"
1440 echo " AC_CONFIG_COMMANDS_PRE(["
1441 echo " ${macro_prefix}_libobjs="
1442 echo " ${macro_prefix}_ltlibobjs="
1443 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1444 echo " # Remove the extension."
1445 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1446 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1447 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1448 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1451 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1452 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1456 # func_emit_initmacro_done
1457 # emits a few statements after the gl_INIT macro to standard output.
1458 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1459 func_emit_initmacro_done ()
1462 echo "# Like AC_LIBOBJ, except that the module name goes"
1463 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1464 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1465 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1467 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1468 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1469 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1470 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1472 echo "# Like AC_LIBSOURCES, except that it does nothing."
1473 echo "# We rely on EXTRA_lib..._SOURCES instead."
1474 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1478 # func_import modules
1479 # Uses also the variables
1480 # - destdir target directory
1481 # - local_gnulib_dir from --local-dir
1482 # - libname library name
1483 # - sourcebase directory relative to destdir where to place source code
1484 # - m4base directory relative to destdir where to place *.m4 macros
1485 # - docbase directory relative to destdir where to place doc files
1486 # - testsbase directory relative to destdir where to place unit test code
1487 # - auxdir directory relative to destdir where to place build aux files
1488 # - inctests true if --with-tests was given, blank otherwise
1489 # - avoidlist list of modules to avoid, from --avoid
1490 # - lgpl true if library's license shall be LGPL, blank otherwise
1491 # - makefile_name from --makefile-name
1492 # - libtool true if --libtool was given, false if --no-libtool was
1493 # given, blank otherwise
1494 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1495 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1496 # - autoconf_minversion minimum supported autoconf version
1497 # - doit : if actions shall be executed, false if only to be printed
1498 # - symbolic true if files should be symlinked, copied otherwise
1499 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1503 # Get the cached settings.
1504 cached_local_gnulib_dir=
1505 cached_specified_modules=
1513 cached_makefile_name=
1515 cached_macro_prefix=
1517 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1518 cached_libtool=false
1524 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1527 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1530 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1533 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1536 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1539 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1542 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1545 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1548 s,^.*$,cached_lgpl=true,p
1550 /gl_MAKEFILE_NAME(/ {
1551 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1554 s,^.*$,cached_libtool=true,p
1556 /gl_MACRO_PREFIX(/ {
1557 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1559 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1560 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1565 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1566 s,^.*$,cached_files=",p
1578 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1582 # Merge the cached settings with the specified ones.
1583 # The m4base must be the same as expected from the pathname.
1584 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1585 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1587 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1588 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1589 if test -z "$local_gnulib_dir"; then
1590 if test -n "$cached_local_gnulib_dir"; then
1593 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1595 case "$cached_local_gnulib_dir" in
1597 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1599 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1600 local_gnulib_dir="$relconcat" ;;
1605 # Append the cached and the specified module names. So that
1606 # "gnulib-tool --import foo" means to add the module foo.
1607 specified_modules="$cached_specified_modules $1"
1608 # Append the cached and the specified avoidlist. This is probably better
1609 # than dropping the cached one when --avoid is specified at least once.
1610 avoidlist=`echo $cached_avoidlist $avoidlist`
1611 # The sourcebase defaults to the cached one.
1612 if test -z "$sourcebase"; then
1613 sourcebase="$cached_sourcebase"
1614 if test -z "$sourcebase"; then
1615 func_fatal_error "missing --source-base option"
1618 # The docbase defaults to the cached one.
1619 if test -z "$docbase"; then
1620 docbase="$cached_docbase"
1621 if test -z "$docbase"; then
1622 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."
1625 # The testsbase defaults to the cached one.
1626 if test -z "$testsbase"; then
1627 testsbase="$cached_testsbase"
1628 if test -z "$testsbase"; then
1629 func_fatal_error "missing --tests-base option"
1632 # The libname defaults to the cached one.
1633 if test -z "$supplied_libname"; then
1634 libname="$cached_libname"
1635 if test -z "$libname"; then
1636 func_fatal_error "missing --lib option"
1639 # Require LGPL if specified either way.
1640 if test -z "$lgpl"; then
1643 # The makefile_name defaults to the cached one.
1644 if test -z "$makefile_name"; then
1645 makefile_name="$cached_makefile_name"
1647 # Use libtool if specified either way, or if guessed.
1648 if test -z "$libtool"; then
1649 if test -n "$cached_m4base"; then
1650 libtool="$cached_libtool"
1652 libtool="$guessed_libtool"
1655 # The macro_prefix defaults to the cached one.
1656 if test -z "$macro_prefix"; then
1657 macro_prefix="$cached_macro_prefix"
1658 if test -z "$macro_prefix"; then
1659 func_fatal_error "missing --macro-prefix option"
1663 # Canonicalize the list of specified modules.
1664 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1666 # Determine final module list.
1667 modules="$specified_modules"
1668 func_modules_transitive_closure
1669 echo "Module list with included dependencies:"
1670 echo "$modules" | sed -e 's/^/ /'
1672 # Add the dummy module if needed.
1673 func_modules_add_dummy
1675 # If --lgpl, verify that the licenses of modules are compatible.
1676 if test -n "$lgpl"; then
1677 for module in $modules; do
1678 license=`func_get_license $module`
1680 LGPL | 'GPLed build tool') ;;
1681 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1682 *) func_fatal_error "incompatible license on module $module: $license" ;;
1687 # Determine script to apply to imported library files.
1688 sed_transform_lib_file=
1689 for module in $modules; do
1690 if test $module = config-h; then
1691 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1692 sed_transform_lib_file=$sed_transform_lib_file'
1693 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1698 if test -n "$lgpl"; then
1700 sed_transform_lib_file=$sed_transform_lib_file'
1701 s/GNU General/GNU Lesser General/g
1702 s/version 2\([ ,]\)/version 2.1\1/g
1706 # Determine final file list.
1707 func_modules_to_filelist
1709 echo "$files" | sed -e 's/^/ /'
1712 || func_fatal_error "refusing to do nothing"
1714 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1715 new_files="$files m4/gnulib-tool.m4"
1716 old_files="$cached_files"
1717 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1718 func_append old_files " m4/gnulib-tool.m4"
1721 sed_rewrite_old_files="\
1722 s,^build-aux/,$auxdir/,
1723 s,^doc/,$cached_docbase/,
1724 s,^lib/,$cached_sourcebase/,
1725 s,^m4/,$cached_m4base/,
1726 s,^tests/,$cached_testsbase/,"
1727 sed_rewrite_new_files="\
1728 s,^build-aux/,$auxdir/,
1730 s,^lib/,$sourcebase/,
1732 s,^tests/,$testsbase/,"
1734 # Create directories.
1735 { echo "$sourcebase"
1737 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1738 if test -n "$docfiles"; then
1741 if test -n "$inctests"; then
1745 for f in $files; do echo $f; done \
1746 | sed -e "$sed_rewrite_new_files" \
1747 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1750 { # Rearrange file descriptors. Needed because "while ... done < ..."
1751 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1752 exec 5<&0 < "$tmp"/dirs
1754 if test ! -d "$destdir/$d"; then
1756 echo "Creating directory $destdir/$d"
1757 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1759 echo "Create directory $destdir/$d"
1766 # func_dest_tmpfilename file
1767 # determines the name of a temporary file (file is relative to destdir).
1769 # - tmpfile absolute filename of the temporary file
1770 func_dest_tmpfilename ()
1773 # Put the new contents of $file in a file in the same directory (needed
1774 # to guarantee that an 'mv' to "$destdir/$file" works).
1775 tmpfile="$destdir/$1.tmp"
1777 # Put the new contents of $file in a file in a temporary directory
1778 # (because the directory of "$file" might not exist).
1779 tmpfile="$tmp"/`basename "$1"`.tmp
1783 # Copy files or make symbolic links. Remove obsolete files.
1785 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1786 # representing the files according to the last gnulib-tool invocation.
1787 for f in $old_files; do echo $f; done \
1788 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1791 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1792 # representing the files after this gnulib-tool invocation.
1793 for f in $new_files; do echo $f; done \
1794 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1797 # First the files that are in old-files, but not in new-files:
1798 sed_take_first_column='s,'"$delimiter"'.*,,'
1799 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1800 # Remove the file. Do nothing if the user already removed it.
1801 if test -f "$destdir/$g"; then
1803 echo "Removing file $g (backup in ${g}~)"
1804 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1806 echo "Remove file $g (backup in ${g}~)"
1810 # func_add_or_update handles a file that ought to be present afterwards.
1812 # - f the original file name
1813 # - g the rewritten file name
1814 # - already_present nonempty if the file already exists, empty otherwise
1815 func_add_or_update ()
1817 func_dest_tmpfilename "$g"
1818 func_lookup_file "$f"
1819 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1820 if test -n "$sed_transform_lib_file"; then
1823 sed -e "$sed_transform_lib_file" \
1824 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1828 if test -f "$destdir/$g"; then
1829 # The file already exists.
1830 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1831 : # The file has not changed.
1835 if test -n "$already_present"; then
1836 echo "Updating file $g (backup in ${g}~)"
1838 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1840 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1841 if { test -n "$symbolic" \
1842 || { test -n "$lsymbolic" \
1843 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1844 && test -z "$lookedup_tmp" \
1845 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1846 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1848 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1851 if test -n "$already_present"; then
1852 echo "Update file $g (backup in ${g}~)"
1854 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1860 # Don't protest if the file should be there but isn't: it happens
1861 # frequently that developers don't put autogenerated files into CVS.
1863 echo "Copying file $g"
1864 if { test -n "$symbolic" \
1865 || { test -n "$lsymbolic" \
1866 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1867 && test -z "$lookedup_tmp" \
1868 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1869 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1871 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1879 # Then the files that are in new-files, but not in old-files:
1880 sed_take_last_column='s,^.*'"$delimiter"',,'
1882 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1883 | sed -e "$sed_take_last_column" \
1884 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1885 { # Rearrange file descriptors. Needed because "while ... done < ..."
1886 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1887 exec 5<&0 < "$tmp"/added-files
1893 # Then the files that are in new-files and in old-files:
1894 already_present=true
1895 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1896 | sed -e "$sed_take_last_column" \
1897 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1898 { # Rearrange file descriptors. Needed because "while ... done < ..."
1899 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1900 exec 5<&0 < "$tmp"/kept-files
1907 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1908 actioncmd="gnulib-tool --import"
1909 func_append actioncmd " --dir=$destdir"
1910 if test -n "$local_gnulib_dir"; then
1911 func_append actioncmd " --local-dir=$local_gnulib_dir"
1913 func_append actioncmd " --lib=$libname"
1914 func_append actioncmd " --source-base=$sourcebase"
1915 func_append actioncmd " --m4-base=$m4base"
1916 func_append actioncmd " --doc-base=$docbase"
1917 func_append actioncmd " --aux-dir=$auxdir"
1918 for module in $avoidlist; do
1919 func_append actioncmd " --avoid=$module"
1921 if test -n "$lgpl"; then
1922 func_append actioncmd " --lgpl"
1924 if test -n "$makefile_name"; then
1925 func_append actioncmd " --makefile-name=$makefile_name"
1927 if test "$libtool" = true; then
1928 func_append actioncmd " --libtool"
1930 func_append actioncmd " --no-libtool"
1932 func_append actioncmd " --macro-prefix=$macro_prefix"
1933 func_append actioncmd " `echo $specified_modules`"
1935 # Default the makefile name to Makefile.am.
1936 if test -n "$makefile_name"; then
1937 makefile_am=$makefile_name
1939 makefile_am=Makefile.am
1942 # Create library makefile.
1943 func_dest_tmpfilename $sourcebase/$makefile_am
1944 func_emit_lib_Makefile_am > "$tmpfile"
1945 if test -f "$destdir"/$sourcebase/$makefile_am; then
1946 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1950 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1951 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1952 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1954 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1960 echo "Creating $sourcebase/$makefile_am"
1961 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1963 echo "Create $sourcebase/$makefile_am"
1968 # Create m4/gnulib-cache.m4.
1969 func_dest_tmpfilename $m4base/gnulib-cache.m4
1971 func_emit_copyright_notice
1973 echo "# This file represents the specification of how gnulib-tool is used."
1974 echo "# It acts as a cache: It is written and read by gnulib-tool."
1975 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1976 echo "# like the configure.ac and various Makefile.am files."
1979 echo "# Specification in the form of a command-line invocation:"
1982 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1983 # Store the local_gnulib_dir relative to destdir.
1984 case "$local_gnulib_dir" in
1986 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1989 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1991 # destdir, local_gnulib_dir are both relative.
1992 func_relativize "$destdir" "$local_gnulib_dir"
1993 relative_local_gnulib_dir="$reldir" ;;
1996 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1997 echo "gl_MODULES(["`echo $specified_modules`"])"
1998 echo "gl_AVOID([$avoidlist])"
1999 echo "gl_SOURCE_BASE([$sourcebase])"
2000 echo "gl_M4_BASE([$m4base])"
2001 echo "gl_DOC_BASE([$docbase])"
2002 echo "gl_TESTS_BASE([$testsbase])"
2003 echo "gl_LIB([$libname])"
2004 test -z "$lgpl" || echo "gl_LGPL"
2005 echo "gl_MAKEFILE_NAME([$makefile_name])"
2006 if test "$libtool" = true; then
2009 echo "gl_MACRO_PREFIX([$macro_prefix])"
2011 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2012 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2016 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2017 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2018 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2020 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2024 echo "# gnulib-cache.m4 ends here"
2031 echo "Creating $m4base/gnulib-cache.m4"
2032 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2034 echo "Create $m4base/gnulib-cache.m4"
2040 # Create m4/gnulib-comp.m4.
2041 func_dest_tmpfilename $m4base/gnulib-comp.m4
2043 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2044 func_emit_copyright_notice
2046 echo "# This file represents the compiled summary of the specification in"
2047 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2048 echo "# to be invoked from configure.ac."
2049 echo "# In projects using CVS, this file can be treated like other built files."
2052 echo "# This macro should be invoked from $configure_ac, in the section"
2053 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2054 echo "# any checks for libraries, header files, types and library functions."
2055 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2057 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2058 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2059 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2060 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2061 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2062 if test -n "$uses_subdirs"; then
2063 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2065 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2066 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2068 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2069 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
2071 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2072 echo " AC_REQUIRE([gl_LOCK_EARLY])"
2076 echo "# This macro should be invoked from $configure_ac, in the section"
2077 echo "# \"Check for header files, types and library functions\"."
2078 echo "AC_DEFUN([${macro_prefix}_INIT],"
2080 func_emit_initmacro_start
2081 if test "$libtool" = true; then
2082 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2083 echo " gl_cond_libtool=true"
2085 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2086 echo " gl_cond_libtool=false"
2088 echo " gl_ltlibdeps="
2090 echo " gl_source_base='$sourcebase'"
2091 if test "$auxdir" != "build-aux"; then
2092 sed_replace_build_aux='
2094 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2095 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2098 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2100 sed_replace_build_aux=
2102 for module in $modules; do
2104 if test -n "$module"; then
2105 func_get_autoconf_snippet "$module" \
2106 | sed -e '/^$/d;' -e 's/^/ /' \
2107 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2108 -e "$sed_replace_build_aux"
2109 if test "$module" = 'alloca' && test "$libtool" = true; then
2110 echo 'changequote(,)dnl'
2111 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2112 echo 'changequote([, ])dnl'
2113 echo 'AC_SUBST([LTALLOCA])'
2117 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2118 # created using libtool, because libtool already handles the dependencies.
2119 if test "$libtool" != true; then
2120 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2121 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2122 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2123 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2124 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2126 func_emit_initmacro_end
2128 func_emit_initmacro_done
2130 echo "# This macro records the list of files which have been installed by"
2131 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2132 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2133 echo "$files" | sed -e 's,^, ,'
2136 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2137 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2141 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2142 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2143 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2145 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2149 echo "# gnulib-comp.m4 ends here"
2156 echo "Creating $m4base/gnulib-comp.m4"
2157 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2159 echo "Create $m4base/gnulib-comp.m4"
2165 if test -n "$inctests"; then
2166 # Create tests makefile.
2167 func_dest_tmpfilename $testsbase/$makefile_am
2168 func_emit_tests_Makefile_am > "$tmpfile"
2169 if test -f "$destdir"/$testsbase/$makefile_am; then
2170 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2174 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2175 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2176 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2178 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2184 echo "Creating $testsbase/$makefile_am"
2185 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2187 echo "Create $testsbase/$makefile_am"
2195 echo "You may need to add #include directives for the following .h files."
2196 # Intersect $specified_modules and $modules
2197 # (since $specified_modules is not necessarily of subset of $modules - some
2198 # may have been skipped through --avoid, and since the elements of $modules
2199 # but not in $specified_modules can go away without explicit notice - through
2200 # changes in the module dependencies).
2201 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2202 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2203 # First the #include <...> directives without #ifs, sorted for convenience,
2204 # then the #include "..." directives without #ifs, sorted for convenience,
2205 # then the #include directives that are surrounded by #ifs. Not sorted.
2206 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2207 include_directive=`func_get_include_directive "$module"`
2208 case "$nl$include_directive" in
2210 echo "$include_directive" 1>&5
2213 echo "$include_directive" | grep -v 'include "' 1>&6
2214 echo "$include_directive" | grep 'include "' 1>&7
2217 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2219 LC_ALL=C sort -u "$tmp"/include-angles
2220 LC_ALL=C sort -u "$tmp"/include-quotes
2221 cat "$tmp"/include-if
2222 ) | sed -e '/^$/d' -e 's/^/ /'
2223 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2226 echo "Don't forget to"
2227 if test "$makefile_am" = Makefile.am; then
2228 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2230 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2232 if test -n "$inctests"; then
2233 if test "$makefile_am" = Makefile.am; then
2234 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2236 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2239 if test "$makefile_am" = Makefile.am; then
2240 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2241 sourcebase_base=`basename "$sourcebase"`
2242 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2244 if test -n "$inctests"; then
2245 if test "$makefile_am" = Makefile.am; then
2246 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2247 testsbase_base=`basename "$testsbase"`
2248 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2251 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2252 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2253 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2256 # func_create_testdir testdir modules
2258 # - local_gnulib_dir from --local-dir
2259 # - auxdir directory relative to destdir where to place build aux files
2260 func_create_testdir ()
2264 if test -z "$modules"; then
2265 # All modules together.
2266 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2267 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2268 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2269 modules=`func_all_modules`
2270 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2272 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2274 # Check that the license of every module is consistent with the license of
2276 saved_modules="$modules"
2277 for requested_module in $saved_modules; do
2278 requested_license=`func_get_license "$requested_module"`
2279 if test "$requested_license" != GPL; then
2280 # Here we use func_modules_transitive_closure, not just
2281 # func_get_dependencies, so that we also detect weird situations like
2282 # an LGPL module which depends on a GPLed build tool module which depends
2284 modules="$requested_module"
2285 func_modules_transitive_closure
2286 for module in $modules; do
2287 license=`func_get_license "$module"`
2289 LGPL | 'GPLed build tool') ;;
2290 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2291 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2296 modules="$saved_modules"
2298 # Subdirectory names.
2305 # Determine final module list.
2306 func_modules_transitive_closure
2307 echo "Module list with included dependencies:"
2308 echo "$modules" | sed -e 's/^/ /'
2310 # Add the dummy module if needed.
2311 func_modules_add_dummy
2313 # Determine final file list.
2314 func_modules_to_filelist
2316 echo "$files" | sed -e 's/^/ /'
2318 sed_rewrite_files="\
2319 s,^build-aux/,$auxdir/,
2321 s,^lib/,$sourcebase/,
2323 s,^tests/,$testsbase/,"
2325 # Create directories.
2326 for f in $files; do echo $f; done \
2327 | sed -e "$sed_rewrite_files" \
2328 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2329 | LC_ALL=C sort -u \
2331 { # Rearrange file descriptors. Needed because "while ... done < ..."
2332 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2333 exec 5<&0 < "$tmp"/dirs
2335 mkdir -p "$testdir/$d"
2340 # Copy files or make symbolic links.
2342 for f in $files; do echo $f; done \
2343 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2346 { # Rearrange file descriptors. Needed because "while ... done < ..."
2347 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2348 exec 5<&0 < "$tmp"/files
2350 func_lookup_file "$f"
2351 if test -n "$lookedup_tmp"; then
2352 cp -p "$lookedup_file" "$testdir/$g"
2354 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2355 if { test -n "$symbolic" \
2356 || { test -n "$lsymbolic" \
2357 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2358 func_ln "$lookedup_file" "$testdir/$g"
2360 cp -p "$lookedup_file" "$testdir/$g"
2367 # Create $sourcebase/Makefile.am.
2368 mkdir -p "$testdir/$sourcebase"
2369 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2371 # Create $m4base/Makefile.am.
2372 mkdir -p "$testdir/$m4base"
2373 (echo "## Process this file with automake to produce Makefile.in."
2379 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2382 ) > "$testdir/$m4base/Makefile.am"
2384 subdirs="$sourcebase $m4base"
2385 subdirs_with_configure_ac=""
2387 if false && test -f "$testdir"/$m4base/gettext.m4; then
2388 # Avoid stupid error message from automake:
2389 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2390 mkdir -p "$testdir/po"
2391 (echo "## Process this file with automake to produce Makefile.in."
2392 ) > "$testdir/po/Makefile.am"
2393 func_append subdirs " po"
2396 if test -n "$inctests"; then
2397 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2398 # Create $testsbase/Makefile.am.
2399 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2400 # Create $testsbase/configure.ac.
2401 (echo "# Process this file with autoconf to produce a configure script."
2402 echo "AC_INIT([dummy], [0])"
2403 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2404 echo "AM_INIT_AUTOMAKE"
2406 echo "AM_CONFIG_HEADER([config.h])"
2409 echo "AC_PROG_INSTALL"
2410 echo "AC_PROG_MAKE_SET"
2411 echo "AC_PROG_RANLIB"
2413 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2414 echo "AC_GNU_SOURCE"
2417 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2418 echo "gl_USE_SYSTEM_EXTENSIONS"
2421 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2422 echo "gl_LOCK_EARLY"
2425 if test "$libtool" = true; then
2426 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2427 echo "gl_cond_libtool=true"
2429 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2430 echo "gl_cond_libtool=false"
2432 echo "gl_ltlibdeps="
2434 # Wrap the set of autoconf snippets into an autoconf macro that is then
2435 # invoked. This is needed because autoconf does not support AC_REQUIRE
2437 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2438 # but we want the AC_REQUIRE to have its normal meaning (provide one
2439 # expansion of the required macro before the current point, and only one
2441 echo "AC_DEFUN([gl_INIT], ["
2442 func_emit_initmacro_start
2443 sed_replace_build_aux='
2445 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2446 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2449 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2450 # We don't have explicit ordering constraints between the various
2451 # autoconf snippets. It's cleanest to put those of the library before
2452 # those of the tests.
2453 echo "gl_source_base='../$sourcebase'"
2454 for module in $modules; do
2455 func_verify_nontests_module
2456 if test -n "$module"; then
2457 func_get_autoconf_snippet "$module" \
2458 | sed -e "$sed_replace_build_aux"
2461 echo "gl_source_base='.'"
2462 for module in $modules; do
2463 func_verify_tests_module
2464 if test -n "$module"; then
2465 func_get_autoconf_snippet "$module" \
2466 | sed -e "$sed_replace_build_aux"
2469 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2470 # created using libtool, because libtool already handles the dependencies.
2471 if test "$libtool" != true; then
2472 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2473 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2474 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2475 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2476 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2478 func_emit_initmacro_end
2480 func_emit_initmacro_done
2484 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2485 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2486 echo "AH_TOP([#include \"../config.h\"])"
2488 echo "AC_OUTPUT([Makefile])"
2489 ) > "$testdir/$testsbase/configure.ac"
2490 func_append subdirs " $testsbase"
2491 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2494 # Create Makefile.am.
2495 (echo "## Process this file with automake to produce Makefile.in."
2497 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2499 echo "SUBDIRS = $subdirs"
2501 echo "ACLOCAL_AMFLAGS = -I $m4base"
2502 ) > "$testdir/Makefile.am"
2504 # Create configure.ac.
2505 (echo "# Process this file with autoconf to produce a configure script."
2506 echo "AC_INIT([dummy], [0])"
2507 if test "$auxdir" != "."; then
2508 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2510 echo "AM_INIT_AUTOMAKE"
2512 echo "AM_CONFIG_HEADER([config.h])"
2515 echo "AC_PROG_INSTALL"
2516 echo "AC_PROG_MAKE_SET"
2518 echo "# For autobuild."
2519 echo "AC_CANONICAL_BUILD"
2520 echo "AC_CANONICAL_HOST"
2522 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2523 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2524 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2525 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2527 echo "AC_PROG_RANLIB"
2529 if test -n "$uses_subdirs"; then
2530 echo "AM_PROG_CC_C_O"
2533 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2534 echo "AC_GNU_SOURCE"
2537 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2538 echo "gl_USE_SYSTEM_EXTENSIONS"
2541 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2542 echo "gl_LOCK_EARLY"
2545 if test "$libtool" = true; then
2546 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2547 echo "gl_cond_libtool=true"
2549 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2550 echo "gl_cond_libtool=false"
2552 echo "gl_ltlibdeps="
2554 echo "gl_source_base='$sourcebase'"
2555 # Wrap the set of autoconf snippets into an autoconf macro that is then
2556 # invoked. This is needed because autoconf does not support AC_REQUIRE
2558 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2559 # but we want the AC_REQUIRE to have its normal meaning (provide one
2560 # expansion of the required macro before the current point, and only one
2562 echo "AC_DEFUN([gl_INIT], ["
2563 func_emit_initmacro_start
2564 if test "$auxdir" != "build-aux"; then
2565 sed_replace_build_aux='
2567 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2568 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2571 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2573 sed_replace_build_aux=
2575 for module in $modules; do
2576 func_verify_nontests_module
2577 if test -n "$module"; then
2578 func_get_autoconf_snippet "$module" \
2579 | sed -e "$sed_replace_build_aux"
2582 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2583 # created using libtool, because libtool already handles the dependencies.
2584 if test "$libtool" != true; then
2585 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2586 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2587 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2588 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2589 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2591 func_emit_initmacro_end
2593 func_emit_initmacro_done
2597 if test -n "$subdirs_with_configure_ac"; then
2598 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2600 makefiles="Makefile"
2601 for d in $subdirs; do
2602 # For subdirs that have a configure.ac by their own, it's the subdir's
2603 # configure.ac which creates the subdir's Makefile.am, not this one.
2604 case " $subdirs_with_configure_ac " in
2606 *) func_append makefiles " $d/Makefile" ;;
2609 echo "AC_OUTPUT([$makefiles])"
2610 ) > "$testdir/configure.ac"
2612 # Create autogenerated files.
2614 # Do not use "${AUTORECONF} --force --install", because it may invoke
2615 # autopoint, which brings in older versions of some of our .m4 files.
2616 if test -f $m4base/gettext.m4; then
2617 echo "executing ${AUTOPOINT} --force"
2618 ${AUTOPOINT} --force || func_exit 1
2619 for f in $m4base/*.m4~; do
2620 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2623 echo "executing ${ACLOCAL} -I $m4base"
2624 ${ACLOCAL} -I $m4base || func_exit 1
2625 if ! test -d build-aux; then
2626 echo "executing mkdir build-aux"
2627 mkdir build-aux || func_exit 1
2629 echo "executing ${AUTOCONF}"
2630 ${AUTOCONF} || func_exit 1
2631 echo "executing ${AUTOHEADER}"
2632 ${AUTOHEADER} || func_exit 1
2633 echo "executing ${AUTOMAKE} --add-missing --copy"
2634 ${AUTOMAKE} --add-missing --copy || func_exit 1
2636 if test -n "$inctests"; then
2637 # Create autogenerated files.
2638 (cd "$testdir/$testsbase" || func_exit 1
2639 # Do not use "${AUTORECONF} --force --install", because it may invoke
2640 # autopoint, which brings in older versions of some of our .m4 files.
2641 if test -f ../$m4base/gettext.m4; then
2642 echo "executing ${AUTOPOINT} --force"
2643 ${AUTOPOINT} --force || func_exit 1
2644 for f in ../$m4base/*.m4~; do
2645 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2648 echo "executing ${ACLOCAL} -I ../$m4base"
2649 ${ACLOCAL} -I ../$m4base || func_exit 1
2650 if ! test -d ../build-aux; then
2651 echo "executing mkdir ../build-aux"
2654 echo "executing ${AUTOCONF}"
2655 ${AUTOCONF} || func_exit 1
2656 echo "executing ${AUTOHEADER}"
2657 ${AUTOHEADER} || func_exit 1
2658 echo "executing ${AUTOMAKE} --add-missing --copy"
2659 ${AUTOMAKE} --add-missing --copy || func_exit 1
2662 # Need to run configure and make once, to create built files that are to be
2663 # distributed (such as getdate.c).
2664 # Extract the value of "CLEANFILES += ...".
2665 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2666 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
2667 cleaned_files=" "`for file in $cleaned_files; do echo "$file"; done`" "
2668 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
2669 # such $(FOO_H) because they don't refer to distributed files.
2670 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
2671 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2672 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
2673 | sed -e "$sed_remove_make_variables"`
2674 distributed_built_sources=`for file in $built_sources; do
2675 case "$cleaned_files" in
2680 if test -n "$distributed_built_sources"; then
2682 ./configure || func_exit 1
2684 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2685 make built_sources || func_exit 1
2687 make distclean || func_exit 1
2692 # func_create_megatestdir megatestdir allmodules
2694 # - local_gnulib_dir from --local-dir
2695 # - auxdir directory relative to destdir where to place build aux files
2696 func_create_megatestdir ()
2700 if test -z "$allmodules"; then
2701 allmodules=`func_all_modules`
2705 # First, all modules one by one.
2706 for onemodule in $allmodules; do
2707 func_create_testdir "$megatestdir/$onemodule" $onemodule
2708 func_append megasubdirs "$onemodule "
2710 # Then, all modules all together.
2711 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2712 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2713 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2714 func_create_testdir "$megatestdir/ALL" "$allmodules"
2715 func_append megasubdirs "ALL"
2717 # Create Makefile.am.
2718 (echo "## Process this file with automake to produce Makefile.in."
2720 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2722 echo "SUBDIRS = $megasubdirs"
2723 ) > "$megatestdir/Makefile.am"
2725 # Create configure.ac.
2726 (echo "# Process this file with autoconf to produce a configure script."
2727 echo "AC_INIT([dummy], [0])"
2728 if test "$auxdir" != "."; then
2729 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2731 echo "AM_INIT_AUTOMAKE"
2733 echo "AC_PROG_MAKE_SET"
2735 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2736 echo "AC_OUTPUT([Makefile])"
2737 ) > "$megatestdir/configure.ac"
2739 # Create autogenerated files.
2741 # Do not use "${AUTORECONF} --install", because autoreconf operates
2742 # recursively, but the subdirectories are already finished, therefore
2743 # calling autoreconf here would only waste lots of CPU time.
2744 echo "executing ${ACLOCAL}"
2745 ${ACLOCAL} || func_exit 1
2746 echo "executing mkdir build-aux"
2748 echo "executing ${AUTOCONF}"
2749 ${AUTOCONF} || func_exit 1
2750 echo "executing ${AUTOMAKE} --add-missing --copy"
2751 ${AUTOMAKE} --add-missing --copy || func_exit 1
2757 func_fatal_error "no mode specified" ;;
2766 if test -z "$destdir"; then
2769 test -d "$destdir" \
2770 || func_fatal_error "destination directory does not exist: $destdir"
2772 # Prefer configure.ac to configure.in.
2773 if test -f "$destdir"/configure.ac; then
2774 configure_ac="$destdir/configure.ac"
2776 if test -f "$destdir"/configure.in; then
2777 configure_ac="$destdir/configure.in"
2779 func_fatal_error "cannot find $destdir/configure.ac"
2783 # Analyze configure.ac.
2785 guessed_libtool=false
2790 /AC_CONFIG_AUX_DIR/ {
2791 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2793 /A[CM]_PROG_LIBTOOL/ {
2794 s,^.*$,guessed_libtool=true,p
2796 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2798 if test -z "$auxdir"; then
2799 auxdir="$guessed_auxdir"
2802 # Determine where to apply func_import.
2803 if test -n "$m4base"; then
2804 # Apply func_import to a particular gnulib directory.
2805 # Any number of additional modules can be given.
2806 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2807 # First use of gnulib in the given m4base.
2808 test -n "$supplied_libname" || supplied_libname=true
2809 test -n "$sourcebase" || sourcebase="lib"
2810 test -n "$docbase" || docbase="doc"
2811 test -n "$testsbase" || testsbase="tests"
2812 test -n "$macro_prefix" || macro_prefix="gl"
2816 # Apply func_import to all gnulib directories.
2817 # To get this list of directories, look at Makefile.am. (Not at
2818 # configure, because it may be omitted from CVS. Also, don't run
2819 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2822 if test -f "$destdir"/Makefile.am; then
2823 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2825 for arg in $aclocal_amflags; do
2826 if test -n "$m4dir_is_next"; then
2827 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2831 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2832 func_append m4dirs " $arg"
2833 m4dirs_count=`expr $m4dirs_count + 1`
2838 if test "X$arg" = "X-I"; then
2846 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2847 if test -f "$destdir"/aclocal.m4; then
2848 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2849 sedexpr2='s,^[^/]*$,.,'
2850 sedexpr3='s,/[^/]*$,,'
2851 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
2852 m4dirs_count=`echo "$m4dirs" | wc -l`
2855 if test $m4dirs_count = 0; then
2856 # First use of gnulib in a package.
2857 # Any number of additional modules can be given.
2858 test -n "$supplied_libname" || supplied_libname=true
2859 test -n "$sourcebase" || sourcebase="lib"
2861 test -n "$docbase" || docbase="doc"
2862 test -n "$testsbase" || testsbase="tests"
2863 test -n "$macro_prefix" || macro_prefix="gl"
2866 if test $m4dirs_count = 1; then
2867 # There's only one use of gnulib here. Assume the user means it.
2868 # Any number of additional modules can be given.
2869 for m4base in $m4dirs; do
2873 # Ambiguous - guess what the user meant.
2874 if test $# = 0; then
2875 # No further arguments. Guess the user wants to update all of them.
2876 for m4base in $m4dirs; do
2877 # Perform func_import in a subshell, so that variable values
2879 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2880 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2881 # don't propagate from one directory to another.
2882 (func_import) || func_exit 1
2886 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2894 if test -z "$destdir"; then
2895 func_fatal_error "please specify --dir option"
2898 test -d "$destdir" \
2899 || func_fatal_error "could not create destination directory"
2900 test -n "$auxdir" || auxdir="build-aux"
2901 func_create_testdir "$destdir" "$*"
2904 create-megatestdir )
2905 if test -z "$destdir"; then
2906 func_fatal_error "please specify --dir option"
2908 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2909 test -n "$auxdir" || auxdir="build-aux"
2910 func_create_megatestdir "$destdir" "$*"
2914 test -n "$destdir" || destdir=testdir$$
2915 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2916 test -n "$auxdir" || auxdir="build-aux"
2917 func_create_testdir "$destdir" "$*"
2921 ../configure || func_exit 1
2923 make check || func_exit 1
2924 make distclean || func_exit 1
2925 remaining=`find . -type f -print`
2926 if test -n "$remaining"; then
2927 echo "Remaining files:" $remaining 1>&2
2928 echo "gnulib-tool: *** Stop." 1>&2
2937 test -n "$destdir" || destdir=testdir$$
2938 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2939 test -n "$auxdir" || auxdir="build-aux"
2940 func_create_megatestdir "$destdir" "$*"
2948 remaining=`find . -type f -print`
2949 if test -n "$remaining"; then
2950 echo "Remaining files:" $remaining 1>&2
2951 echo "gnulib-tool: *** Stop." 1>&2
2959 extract-description )
2963 if test -n "$module"; then
2964 func_get_description "$module"
2973 if test -n "$module"; then
2974 func_get_filelist "$module"
2979 extract-dependencies )
2983 if test -n "$module"; then
2984 func_get_dependencies "$module"
2989 extract-autoconf-snippet )
2993 if test -n "$module"; then
2994 func_get_autoconf_snippet "$module"
2999 extract-automake-snippet )
3003 if test -n "$module"; then
3004 func_get_automake_snippet "$module"
3009 extract-include-directive )
3013 if test -n "$module"; then
3014 func_get_include_directive "$module"
3023 if test -n "$module"; then
3024 func_get_license "$module"
3029 extract-maintainer )
3033 if test -n "$module"; then
3034 func_get_maintainer "$module"
3039 extract-tests-module )
3043 if test -n "$module"; then
3044 func_get_tests_module "$module"
3050 func_fatal_error "unknown operation mode --$mode" ;;
3054 # Undo the effect of the previous 'trap' command. Some shellology:
3055 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3056 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3057 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3058 # 128 + signal number and is set before the trap-registered command is run.
3060 trap 'func_exit $?' 1 2 3 13 15
3065 # indent-tabs-mode: nil
3066 # whitespace-check-buffer-indent: nil