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
17 # Foundation, 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-01-10 13:37:12 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
29 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
33 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
34 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
38 AUTORECONF="${AUTOCONFPATH}autoreconf"
41 # outputs to stdout the --help usage message.
45 Usage: gnulib-tool --list
46 gnulib-tool --import [module1 ... moduleN]
48 gnulib-tool --create-testdir --dir=directory module1 ... moduleN
49 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
50 gnulib-tool --test --dir=directory module1 ... moduleN
51 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
52 gnulib-tool --extract-description module
53 gnulib-tool --extract-filelist module
54 gnulib-tool --extract-dependencies module
55 gnulib-tool --extract-autoconf-snippet module
56 gnulib-tool --extract-automake-snippet module
57 gnulib-tool --extract-include-directive module
58 gnulib-tool --extract-license module
59 gnulib-tool --extract-maintainer module
60 gnulib-tool --extract-tests-module module
63 --list print the available module names
64 --import import the given modules into the current package
65 --create-testdir create a scratch package with the given modules
66 --create-megatestdir create a mega scratch package with the given modules
67 one by one and all together
68 --test test the combination of the given modules
69 (recommended to use CC=\"gcc -Wall\" here)
70 --megatest test the given modules one by one and all together
71 (recommended to use CC=\"gcc -Wall\" here)
72 --extract-description extract the description
73 --extract-filelist extract the list of files
74 --extract-dependencies extract the dependencies
75 --extract-autoconf-snippet extract the snippet for configure.ac
76 --extract-automake-snippet extract the snippet for lib/Makefile.am
77 --extract-include-directive extract the #include directive
78 --extract-license report the license terms of the source files
80 --extract-maintainer report the maintainer(s) inside gnulib
81 --extract-tests-module report the unit test module, if it exists
84 --dir=DIRECTORY specify the target directory
85 For --import, this specifies where your
86 configure.ac can be found. Defaults to current
88 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
89 --source-base=DIRECTORY
90 Directory relative --dir where source code is
91 placed (default \"lib\"), for --import.
92 --m4-base=DIRECTORY Directory relative --dir where *.m4 macros are
93 placed (default \"m4\"), for --import.
94 --tests-base=DIRECTORY
95 Directory relative --dir where unit tests are
96 placed (default \"tests\"), for --import.
97 --aux-dir=DIRECTORY Directory relative --dir where auxiliary build
98 tools are placed (default \"build-aux\").
99 --with-tests Include unit tests for the included modules.
100 --avoid=MODULE Avoid including the given MODULE. Useful if you
101 have code that provides equivalent functionality.
102 This option can be repeated.
103 --lgpl Abort if modules aren't available under the LGPL.
104 Also modify license template from GPL to LGPL.
105 --libtool Use libtool rules, for --import.
106 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
107 'gl_INIT'. Default is 'gl'.
108 --no-changelog don't update or create ChangeLog files
109 --dry-run For --import, only print what would have been done.
110 -s, --symbolic, --symlink Make symbolic links instead of copying files.
112 Report bugs to <bug-gnulib@gnu.org>."
116 # outputs to stdout the --version message.
119 echo "$progname (GNU $package) $version"
120 echo "Copyright (C) 2002-2005 Free Software Foundation, Inc.
121 This is free software; see the source for copying conditions. There is NO
122 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
123 echo "Written by" "Bruno Haible" "and" "Simon Josefsson"
127 # creates a temporary directory.
129 # - tmp pathname of freshly created temporary directory
132 # Use the environment variable TMPDIR, falling back to /tmp. This allows
133 # users to specify a different temporary directory, for example, if their
134 # /tmp is filled up or too small.
137 # Use the mktemp program if available. If not available, hide the error
139 tmp=`(umask 077 && mktemp -d -q "$TMPDIR/glXXXXXX") 2>/dev/null` &&
140 test -n "$tmp" && test -d "$tmp"
143 # Use a simple mkdir command. It is guaranteed to fail if the directory
144 # already exists. $RANDOM is bash specific and expands to empty in shells
145 # other than bash, ksh and zsh. Its use does not increase security;
146 # rather, it minimizes the probability of failure in a very cluttered /tmp
148 tmp=$TMPDIR/gl$$-$RANDOM
149 (umask 077 && mkdir "$tmp")
152 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
153 { (exit 1); exit 1; }
157 # func_fatal_error message
158 # outputs to stderr a fatal error message, and terminates the program.
161 echo "gnulib-tool: *** $1" 1>&2
162 echo "gnulib-tool: *** Stop." 1>&2
166 # func_readlink SYMLINK
167 # outputs the target of the given symlink.
168 if (type -p readlink) > /dev/null 2>&1; then
171 # Use the readlink program from GNU coreutils.
177 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
178 # would do the wrong thing if the link target contains " -> ".
179 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
183 # func_ln_if_changed SRC DEST
184 # Like ln -s, but avoids munging timestamps if the link is correct.
185 func_ln_if_changed ()
187 if test $# -ne 2; then
188 echo "usage: func_ln_if_changed SRC DEST" >&2
190 if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then
198 # Command-line option processing.
199 # Removes the OPTIONS from the arguments. Sets the variables:
200 # - mode list or import or create-testdir or create-megatestdir
201 # - destdir from --dir
202 # - libname, supplied_libname from --lib
203 # - sourcebase from --source-base
204 # - m4base from --m4-base
205 # - testsbase from --tests-base
206 # - auxdir from --aux-dir
207 # - inctests true if --with-tests was given, blank otherwise
208 # - avoidlist list of modules to avoid, from --avoid
209 # - lgpl true if --lgpl was given, blank otherwise
210 # - libtool true if --libtool was given, blank otherwise
211 # - do_changelog false if --no-changelog was given, : otherwise
212 # - doit : if actions shall be executed, false if only to be printed
233 while test $# -gt 0; do
238 --import | --impor | --impo | --imp | --im | --i )
241 --update | --updat | --upda | --upd | --up | --u )
244 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
247 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
248 mode=create-megatestdir
250 --test | --tes | --te | --t )
253 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
257 mode=`echo "X$1" | sed -e 's/^X--//'`
262 func_fatal_error "missing argument for --dir"
267 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
272 func_fatal_error "missing argument for --lib"
275 supplied_libname=true
278 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
279 supplied_libname=true
284 func_fatal_error "missing argument for --source-base"
289 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
294 func_fatal_error "missing argument for --m4-base"
299 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
304 func_fatal_error "missing argument for --tests-base"
309 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
314 func_fatal_error "missing argument for --aux-dir"
319 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
327 func_fatal_error "missing argument for --avoid"
329 avoidlist="$avoidlist $1"
332 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
343 func_fatal_error "missing argument for --macro-prefix"
348 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
350 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
356 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
359 --help | --hel | --he | --h )
362 --version | --versio | --versi | --vers | --ver | --ve | --v )
366 # Stop option processing
370 echo "gnulib-tool: unknown option $1" 1>&2
371 echo "Try 'gnulib-tool --help' for more information." 1>&2
378 if test "$mode" = update; then
379 if test $# != 0; then
380 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
381 echo "Try 'gnulib-tool --help' for more information." 1>&2
382 echo "If you really want to modify the gnulib configuration of your project," 1>&2
383 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
386 if test -n "$libname" || test -n "$sourcebase" || test -n "$m4base" \
387 || test -n "$testsbase" || test -n "$auxdir" || test -n "$inctests" \
388 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$macro_prefix"; then
389 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
390 echo "Try 'gnulib-tool --help' for more information." 1>&2
391 echo "If you really want to modify the gnulib configuration of your project," 1>&2
392 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
398 # Remove trailing slashes from the directory names. This is necessary for
399 # m4base (to avoid an error in func_import) and optional for the others.
400 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
401 case "$sourcebase" in
402 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
405 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
408 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
411 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
416 /*) self_abspathname="$0" ;;
417 */*) self_abspathname=`pwd`/"$0" ;;
418 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
419 if test -x "$d/$0" && test ! -d "$d/$0"; then
420 self_abspathname="$d/$0"
424 if test -z "$self_abspathname"; then
425 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
429 while test -h "$self_abspathname"; do
430 # Resolve symbolic link.
431 linkval=`func_readlink "$self_abspathname"`
432 test -n "$linkval" || break
434 /* ) self_abspathname="$linkval" ;;
435 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
438 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
443 # Filter out metainformation files like README, which are not modules.
444 # Filter out unit test modules; they can be retrieved through
445 # --extract-tests-module if desired.
446 (cd "$gnulib_dir/modules" && ls -1) \
447 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
448 | sed -e '/-tests$/d' \
453 # verifies a module name
454 func_verify_module ()
456 if test ! -f "$gnulib_dir/modules/$module" \
457 || test "CVS" = "$module" \
458 || test "ChangeLog" = "$module" \
459 || test "README" = "$module" \
460 || test "TEMPLATE" = "$module" \
461 || test "TEMPLATE-TESTS" = "$module"; then
462 echo "gnulib-tool: module $module doesn't exist" 1>&2
467 # func_verify_nontests_module
468 # verifies a module name, excluding tests modules
469 func_verify_nontests_module ()
473 * ) func_verify_module ;;
477 # func_verify_tests_module
478 # verifies a module name, considering only tests modules
479 func_verify_tests_module ()
482 *-tests ) func_verify_module ;;
487 sed_extract_prog=':[ ]*$/ {
490 s/^Description:[ ]*$//
492 s/^Depends-on:[ ]*$//
493 s/^configure\.ac:[ ]*$//
494 s/^Makefile\.am:[ ]*$//
497 s/^Maintainer:[ ]*$//
504 # func_get_description module
505 func_get_description ()
507 sed -n -e "/^Description$sed_extract_prog" < "$gnulib_dir/modules/$1"
510 # func_get_filelist module
513 sed -n -e "/^Files$sed_extract_prog" < "$gnulib_dir/modules/$1"
515 echo m4/onceonly_2_57.m4
518 # func_get_dependencies module
519 func_get_dependencies ()
521 # ${module}-tests always implicitly depends on ${module}.
522 echo "$1" | sed -n -e 's/-tests//p'
523 # Then the explicit dependencies listed in the module description.
524 sed -n -e "/^Depends-on$sed_extract_prog" < "$gnulib_dir/modules/$1"
527 # func_get_autoconf_snippet module
528 func_get_autoconf_snippet ()
530 sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
533 # func_get_automake_snippet module
534 func_get_automake_snippet ()
536 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$gnulib_dir/modules/$1"
539 # func_get_include_directive module
540 func_get_include_directive ()
542 sed -n -e "/^Include$sed_extract_prog" < "$gnulib_dir/modules/$1" | \
543 sed -e 's/^\(["<]\)/#include \1/'
546 # func_get_license module
549 sed -n -e "/^License$sed_extract_prog" < "$gnulib_dir/modules/$1"
552 # func_get_maintainer module
553 func_get_maintainer ()
555 sed -n -e "/^Maintainer$sed_extract_prog" < "$gnulib_dir/modules/$1"
558 # func_get_tests_module module
559 func_get_tests_module ()
561 # The naming convention for tests modules is hardwired: ${module}-tests.
562 if test -f modules/"$1"-tests; then
567 # func_acceptable module
568 # tests whether a module is acceptable.
570 # - avoidlist list of modules to avoid
573 for avoid in $avoidlist; do
574 if test "$avoid" = "$1"; then
581 # func_modules_transitive_closure
583 # - modules list of specified modules
584 # - inctests true if tests should be included, blank otherwise
585 # - avoidlist list of modules to avoid
587 # - modules list of modules, including dependencies
588 func_modules_transitive_closure ()
592 for module in $modules; do
594 if test -n "$module"; then
595 # Duplicate dependencies are harmless, but Jim wants a warning.
596 duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d`
597 if test -n "$duplicated_deps"; then
598 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
600 if func_acceptable $module; then
601 xmodules="$xmodules $module"
602 for depmodule in `func_get_dependencies $module`; do
603 if func_acceptable $depmodule; then
604 xmodules="$xmodules $depmodule"
607 if test -n "$inctests"; then
608 testsmodule=`func_get_tests_module $module`
609 if test -n "$testsmodule"; then
610 if func_acceptable $testsmodule; then
611 xmodules="$xmodules $testsmodule"
612 for depmodule in `func_get_dependencies $testsmodule`; do
613 if func_acceptable $depmodule; then
614 xmodules="$xmodules $depmodule"
623 xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
624 if test "$xmodules" = "$modules"; then
631 # func_modules_to_filelist
633 # - modules list of modules, including dependencies
635 # - files list of files
636 func_modules_to_filelist ()
639 for module in $modules; do
641 if test -n "$module"; then
642 files="$files "`func_get_filelist $module`
645 files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
648 # func_emit_lib_Makefile_am
649 # emits the contents of lib/Makefile.am to standard output.
651 # - modules list of modules, including dependencies
652 # - libname library name
653 # - libtool true if libtool will be used, blank otherwise
654 # - actioncmd (optional) command that will reproduce this invocation
655 func_emit_lib_Makefile_am ()
657 if test -n "$libtool"; then
664 echo "## Process this file with automake to produce Makefile.in."
665 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
667 echo "# This file is free software, distributed under the terms of the GNU"
668 echo "# General Public License. As a special exception to the GNU General"
669 echo "# Public License, this file may be distributed as part of a program"
670 echo "# that contains a configuration script generated by Automake, under"
671 echo "# the same distribution terms as the rest of that program."
673 echo "# Generated by gnulib-tool."
674 if test -n "$actioncmd"; then
675 echo "# Reproduce by: $actioncmd"
678 # No need to generate dependencies since the sources are in gnulib, not here.
679 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
681 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
683 echo "${libname}_${libext}_SOURCES ="
684 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
686 echo "BUILT_SOURCES ="
688 echo "MOSTLYCLEANFILES ="
690 echo "DISTCLEANFILES ="
691 echo "MAINTAINERCLEANFILES ="
693 for module in $modules; do
694 func_verify_nontests_module
695 if test -n "$module"; then
697 func_get_automake_snippet "$module" |
698 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
699 if test "$module" = 'alloca'; then
700 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
703 # Skip the contents if its entirely empty.
704 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
705 echo "## begin gnulib module $module"
708 echo "## end gnulib module $module"
715 echo "# Makefile.am ends here"
718 # func_emit_tests_Makefile_am
719 # emits the contents of tests/Makefile.am to standard output.
721 # - modules list of modules, including dependencies
722 # - libname library name
723 # - libtool true if libtool will be used, blank otherwise
724 # - sourcebase relative directory containing lib source code
725 # - m4base relative directory containing autoconf macros
726 # - testsbase relative directory containing unit test code
727 func_emit_tests_Makefile_am ()
729 if test -n "$libtool"; then
734 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
735 echo "## Process this file with automake to produce Makefile.in."
736 echo "# Copyright (C) 2004-2005 Free Software Foundation, Inc."
738 echo "# This file is free software, distributed under the terms of the GNU"
739 echo "# General Public License. As a special exception to the GNU General"
740 echo "# Public License, this file may be distributed as part of a program"
741 echo "# that contains a configuration script generated by Automake, under"
742 echo "# the same distribution terms as the rest of that program."
744 echo "# Generated by gnulib-tool."
746 # Generate dependencies here, since it eases the debugging of test failures.
747 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
749 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
751 # Nothing is being added to SUBDIRS; nevertheless the existence of this
752 # variable is needed to avoid an error from automake:
753 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
756 echo "TESTS_ENVIRONMENT ="
757 echo "noinst_PROGRAMS ="
759 echo "BUILT_SOURCES ="
761 echo "MOSTLYCLEANFILES ="
763 echo "DISTCLEANFILES ="
764 echo "MAINTAINERCLEANFILES ="
766 echo "AM_CPPFLAGS = \\"
767 echo " -I. -I\$(srcdir) \\"
768 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
769 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
771 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
773 for module in $modules; do
774 func_verify_tests_module
775 if test -n "$module"; then
776 func_get_automake_snippet "$module" > amsnippet.tmp
777 # Skip the contents if its entirely empty.
778 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
779 echo "## begin gnulib module $module"
782 echo "## end gnulib module $module"
788 echo "# Clean up after Solaris cc."
790 echo " rm -rf SunWS_cache"
792 echo "# Makefile.am ends here"
795 # func_import modules
796 # Uses also the variables
797 # - destdir target directory
798 # - libname library name
799 # - sourcebase directory relative to destdir where to place source code
800 # - m4base directory relative to destdir where to place *.m4 macros
801 # - testsbase directory relative to destdir where to place unit test code
802 # - auxdir directory relative to destdir where to place build aux files
803 # - inctests true if --with-tests was given, blank otherwise
804 # - avoidlist list of modules to avoid, from --avoid
805 # - lgpl true if library's license shall be LGPL, blank otherwise
806 # - libtool true if libtool will be used, blank otherwise
807 # - guessed_libtool true if the configure.ac file uses libtool, blank otherwise
808 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
809 # - doit : if actions shall be executed, false if only to be printed
810 # - symbolic true if files should be symlinked, copied otherwise
813 # Get the cached settings.
814 cached_specified_modules=
824 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
830 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
833 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
836 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
839 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
842 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
845 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
848 s,^.*$,cached_lgpl=true,p
851 s,^.*$,cached_libtool=true,p
854 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
856 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
857 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
862 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
863 s,^.*$,cached_files=",p
875 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
879 # Merge the cached settings with the specified ones.
880 # The m4base must be the same as expected from the pathname.
881 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
882 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
884 # Append the cached and the specified module names. So that
885 # "gnulib-tool --import foo" means to add the module foo.
886 specified_modules="$cached_specified_modules $1"
887 # Append the cached and the specified avoidlist. This is probably better
888 # than dropping the cached one when --avoid is specified at least once.
889 avoidlist=`echo $cached_avoidlist $avoidlist`
890 # The sourcebase defaults to the cached one.
891 if test -z "$sourcebase"; then
892 sourcebase="$cached_sourcebase"
893 if test -z "$sourcebase"; then
894 func_fatal_error "missing --source-base option"
897 # The testsbase defaults to the cached one.
898 if test -z "$testsbase"; then
899 testsbase="$cached_testsbase"
900 if test -z "$testsbase"; then
901 func_fatal_error "missing --tests-base option"
904 # The libname defaults to the cached one.
905 if test -z "$supplied_libname"; then
906 libname="$cached_libname"
907 if test -z "$libname"; then
908 func_fatal_error "missing --lib option"
911 # Require LGPL if specified either way.
912 if test -z "$lgpl"; then
915 # Use libtool if specified either way, or if guessed.
916 if test -z "$libtool"; then
917 if test -n "$cached_m4base"; then
918 libtool="$cached_libtool"
920 libtool="$guessed_libtool"
923 # The macro_prefix defaults to the cached one.
924 if test -z "$macro_prefix"; then
925 macro_prefix="$cached_macro_prefix"
926 if test -z "$macro_prefix"; then
927 func_fatal_error "missing --macro-prefix option"
931 # Canonicalize the list of specified modules.
932 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
934 # Determine final module list.
935 modules="$specified_modules"
936 func_modules_transitive_closure
937 echo "Module list with included dependencies:"
938 echo "$modules" | sed -e 's/^/ /'
940 # If --lgpl, check the license of modules are compatible.
941 if test -n "$lgpl"; then
942 for module in $modules; do
943 license=`func_get_license $module`
945 LGPL | 'GPLed build tool' | 'public domain' | 'unlimited') ;;
946 *) func_fatal_error "incompatible license on module $module: $license" ;;
951 # Determine final file list.
952 func_modules_to_filelist
954 echo "$files" | sed -e 's/^/ /'
957 || func_fatal_error "refusing to do nothing"
959 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
960 new_files="$files m4/gnulib-tool.m4"
961 old_files="$cached_files"
962 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
963 old_files="$old_files m4/gnulib-tool.m4"
966 # Create directories.
967 if test ! -d "$destdir/$sourcebase"; then
969 echo "Creating directory $destdir/$sourcebase"
970 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
972 echo "Create directory $destdir/$sourcebase"
975 if test ! -d "$destdir/$m4base"; then
977 echo "Creating directory $destdir/$m4base"
978 mkdir "$destdir/$m4base" || func_fatal_error "failed"
980 echo "Create directory $destdir/$m4base"
983 if test -n "$inctests"; then
984 if test ! -d "$destdir/$testsbase"; then
986 echo "Creating directory $destdir/$testsbase"
987 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
989 echo "Create directory $destdir/$testsbase"
993 if test ! -d "$destdir/$auxdir"; then
995 echo "Creating directory $destdir/$auxdir"
996 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
998 echo "Create directory $destdir/$auxdir"
1002 # Copy files or make symbolic links. Remove obsolete files.
1004 trap 'rm -rf "$tmp"' 0 1 2 3 15
1006 for f in $old_files; do
1008 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1009 lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
1010 m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
1011 tests/*) g=`echo "$f" | sed -e "s,^tests/,$cached_testsbase/,"` ;;
1014 echo "$g""$delimiter""$f"
1015 done | LC_ALL=C sort > "$tmp"/old-files
1016 for f in $new_files; do
1018 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1019 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1020 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1021 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1024 echo "$g""$delimiter""$f"
1025 done | LC_ALL=C sort > "$tmp"/new-files
1026 # First the files that are in old-files, but not in new-files:
1027 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e 's,'"$delimiter"'.*,,'`; do
1028 # Remove the file. Do nothing if the user already removed it.
1029 if test -f "$destdir/$g"; then
1031 echo "Removing file $g (backup in ${g}~)"
1032 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1034 echo "Remove file $g (backup in ${g}~)"
1038 # func_add_or_update handles a file that ought to be present afterwards.
1039 # Uses parameters f, g, already_present.
1040 func_add_or_update ()
1042 cp "$gnulib_dir/$f" "$destdir/$g.tmp" || func_fatal_error "failed"
1043 if test -n "$lgpl"; then
1047 sed -e 's/GNU General/GNU Lesser General/g' \
1048 -e 's/version 2\([ ,]\)/version 2.1\1/g' \
1049 < "$gnulib_dir/$f" > "$destdir/$g.tmp" || func_fatal_error "failed"
1053 if test -f "$destdir/$g"; then
1054 # The file already exists.
1055 if cmp "$destdir/$g" "$destdir/$g.tmp" > /dev/null; then
1056 : # The file has not changed.
1060 if test -n "$already_present"; then
1061 echo "Updating file $g (backup in ${g}~)"
1063 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1065 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1066 if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$destdir/$g.tmp" > /dev/null; then
1067 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
1069 mv -f "$destdir/$g.tmp" "$destdir/${g}" || func_fatal_error "failed"
1072 if test -n "$already_present"; then
1073 echo "Update file $g (backup in ${g}~)"
1075 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1081 # Don't protest if the file should be there but isn't: it happens
1082 # frequently that developers don't put autogenerated files into CVS.
1084 echo "Copying file $g"
1085 if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$destdir/$g.tmp" > /dev/null; then
1086 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
1088 mv -f "$destdir/$g.tmp" "$destdir/${g}" || func_fatal_error "failed"
1094 rm -f "$destdir/$g.tmp"
1096 # Then the files that are in new-files, but not in old-files:
1098 for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e 's,'^.*"$delimiter"',,'`; do
1100 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1101 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1102 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1103 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1108 # Then the files that are in new-files and in old-files:
1109 already_present=true
1110 for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e 's,'^.*"$delimiter"',,'`; do
1112 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1113 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1114 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1115 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1123 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1124 actioncmd="gnulib-tool --import"
1125 actioncmd="$actioncmd --dir=$destdir"
1126 actioncmd="$actioncmd --lib=$libname"
1127 actioncmd="$actioncmd --source-base=$sourcebase"
1128 actioncmd="$actioncmd --m4-base=$m4base"
1129 actioncmd="$actioncmd --aux-dir=$auxdir"
1130 for module in $avoidlist; do
1131 actioncmd="$actioncmd --avoid=$module"
1133 if test -n "$lgpl"; then
1134 actioncmd="$actioncmd --lgpl"
1136 if test -n "$libtool"; then
1137 actioncmd="$actioncmd --libtool"
1139 actioncmd="$actioncmd --macro-prefix=$macro_prefix"
1140 actioncmd="$actioncmd `echo $specified_modules`"
1142 # Create lib/Makefile.am.
1143 func_emit_lib_Makefile_am > "$destdir"/$sourcebase/Makefile.am.tmp
1144 if test -f "$destdir"/$sourcebase/Makefile.am; then
1145 if cmp "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am.tmp > /dev/null; then
1146 rm -f "$destdir"/$sourcebase/Makefile.am.tmp
1149 echo "Updating $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1150 mv -f "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am~
1151 mv -f "$destdir"/$sourcebase/Makefile.am.tmp "$destdir"/$sourcebase/Makefile.am
1153 echo "Update $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1154 rm -f "$destdir"/$sourcebase/Makefile.am.tmp
1159 echo "Creating $sourcebase/Makefile.am"
1160 mv -f "$destdir"/$sourcebase/Makefile.am.tmp "$destdir"/$sourcebase/Makefile.am
1162 echo "Create $sourcebase/Makefile.am"
1163 rm -f "$destdir"/$sourcebase/Makefile.am.tmp
1167 # Create m4/gnulib-cache.m4.
1169 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
1170 echo "# This file is free software, distributed under the terms of the GNU"
1171 echo "# General Public License. As a special exception to the GNU General"
1172 echo "# Public License, this file may be distributed as part of a program"
1173 echo "# that contains a configuration script generated by Autoconf, under"
1174 echo "# the same distribution terms as the rest of that program."
1176 echo "# Generated by gnulib-tool."
1178 echo "# This file represents the specification of how gnulib-tool is used."
1179 echo "# It acts as a cache: It is written and read by gnulib-tool."
1180 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1181 echo "# like the configure.ac and various Makefile.am files."
1184 echo "# Specification in the form of a command-line invocation:"
1187 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1188 echo "gl_MODULES(["`echo $specified_modules`"])"
1189 echo "gl_AVOID([$avoidlist])"
1190 echo "gl_SOURCE_BASE([$sourcebase])"
1191 echo "gl_M4_BASE([$m4base])"
1192 echo "gl_TESTS_BASE([$testsbase])"
1193 echo "gl_LIB([$libname])"
1194 test -z "$lgpl" || echo "gl_LGPL"
1195 test -z "$libtool" || echo "gl_LIBTOOL"
1196 echo "gl_MACRO_PREFIX([$macro_prefix])"
1197 ) > "$destdir"/$m4base/gnulib-cache.m4.tmp
1198 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1199 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4.tmp > /dev/null; then
1200 rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
1203 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1204 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1205 mv -f "$destdir"/$m4base/gnulib-cache.m4.tmp "$destdir"/$m4base/gnulib-cache.m4
1207 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1209 cat "$destdir"/$m4base/gnulib-cache.m4.tmp
1211 echo "# gnulib-cache.m4 ends here"
1213 rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
1218 echo "Creating $m4base/gnulib-cache.m4"
1219 mv -f "$destdir"/$m4base/gnulib-cache.m4.tmp "$destdir"/$m4base/gnulib-cache.m4
1221 echo "Create $m4base/gnulib-cache.m4"
1222 cat "$destdir"/$m4base/gnulib-cache.m4.tmp
1223 rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
1227 # Create m4/gnulib-comp.m4.
1229 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
1230 echo "# This file is free software, distributed under the terms of the GNU"
1231 echo "# General Public License. As a special exception to the GNU General"
1232 echo "# Public License, this file may be distributed as part of a program"
1233 echo "# that contains a configuration script generated by Autoconf, under"
1234 echo "# the same distribution terms as the rest of that program."
1236 echo "# Generated by gnulib-tool."
1238 echo "# This file represents the compiled summary of the specification in"
1239 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1240 echo "# to be invoked from configure.ac."
1241 echo "# In projects using CVS, this file can be treated like other built files."
1244 echo "# This macro should be invoked from $configure_ac, in the section"
1245 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1246 echo "# any checks for libraries, header files, types and library functions."
1247 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1249 echo " AC_REQUIRE([AC_PROG_RANLIB])"
1250 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
1251 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1253 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
1254 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1258 echo "# This macro should be invoked from $configure_ac, in the section"
1259 echo "# \"Check for header files, types and library functions\"."
1260 echo "AC_DEFUN([${macro_prefix}_INIT],"
1262 if test -z "$libtool"; then
1263 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1265 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1267 for module in $modules; do
1269 if test -n "$module"; then
1270 func_get_autoconf_snippet "$module" | sed -e '/^$/d;' -e 's/^/ /' -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
1271 if test "$module" = 'alloca' && test -n "$libtool"; then
1272 echo 'changequote(,)dnl'
1273 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1274 echo 'changequote([, ])dnl'
1275 echo 'AC_SUBST([LTALLOCA])'
1281 echo "# This macro records the list of files which have been installed by"
1282 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1283 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1284 echo "$files" | sed -e 's,^, ,'
1286 ) > "$destdir"/$m4base/gnulib-comp.m4.tmp
1287 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1288 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4.tmp > /dev/null; then
1289 rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
1292 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1293 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1294 mv -f "$destdir"/$m4base/gnulib-comp.m4.tmp "$destdir"/$m4base/gnulib-comp.m4
1296 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1298 cat "$destdir"/$m4base/gnulib-comp.m4.tmp
1300 echo "# gnulib-comp.m4 ends here"
1302 rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
1307 echo "Creating $m4base/gnulib-comp.m4"
1308 mv -f "$destdir"/$m4base/gnulib-comp.m4.tmp "$destdir"/$m4base/gnulib-comp.m4
1310 echo "Create $m4base/gnulib-comp.m4"
1311 cat "$destdir"/$m4base/gnulib-comp.m4.tmp
1312 rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
1316 if test -n "$inctests"; then
1317 # Create tests/Makefile.am.
1318 func_emit_tests_Makefile_am > "$destdir"/$testsbase/Makefile.am.tmp
1319 if test -f "$destdir"/$testsbase/Makefile.am; then
1320 if cmp "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am.tmp > /dev/null; then
1321 rm -f "$destdir"/$testsbase/Makefile.am.tmp
1324 echo "Updating $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1325 mv -f "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am~
1326 mv -f "$destdir"/$testsbase/Makefile.am.tmp "$destdir"/$testsbase/Makefile.am
1328 echo "Update $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1329 rm -f "$destdir"/$testsbase/Makefile.am.tmp
1334 echo "Creating $testsbase/Makefile.am"
1335 mv -f "$destdir"/$testsbase/Makefile.am.tmp "$destdir"/$testsbase/Makefile.am
1337 echo "Create $testsbase/Makefile.am"
1338 rm -f "$destdir"/$testsbase/Makefile.am.tmp
1345 echo "You may need to add #include directives for the following .h files."
1346 for module in $modules; do
1347 func_get_include_directive "$module"
1348 done | LC_ALL=C sort -u | sed -e '/^$/d;' -e 's/^/ /'
1350 echo "Don't forget to"
1351 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1352 if test -n "$inctests"; then
1353 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1355 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
1356 sourcebase_base=`basename "$sourcebase"`
1357 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
1358 if test -n "$inctests"; then
1359 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
1360 testsbase_base=`basename "$testsbase"`
1361 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
1363 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
1364 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
1365 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
1368 # func_create_testdir testdir modules
1370 # - auxdir directory relative to destdir where to place build aux files
1371 func_create_testdir ()
1375 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1377 # Determine final module list.
1378 func_modules_transitive_closure
1379 echo "Module list with included dependencies:"
1380 echo "$modules" | sed -e 's/^/ /'
1382 # Determine final file list.
1383 func_modules_to_filelist
1385 echo "$files" | sed -e 's/^/ /'
1387 # Create directories.
1388 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
1389 if test "$d" = build-aux; then
1390 mkdir -p "$testdir/$auxdir"
1392 mkdir -p "$testdir/$d"
1396 # Copy files or make symbolic links.
1399 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1402 ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
1403 if test -z "$symbolic"; then
1404 cp -p "$gnulib_dir/$f" "$testdir/$g"
1406 ln -s "$gnulib_dir/$f" "$testdir/$g"
1410 # Create lib/Makefile.am.
1411 mkdir -p "$testdir/lib"
1412 func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
1414 # Create m4/Makefile.am.
1415 mkdir -p "$testdir/m4"
1416 (echo "## Process this file with automake to produce Makefile.in."
1422 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
1425 ) > "$testdir/m4/Makefile.am"
1428 subdirs_with_configure_ac=""
1430 if test -f "$testdir"/m4/gettext.m4; then
1431 # Avoid stupid error message from automake:
1432 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
1433 mkdir -p "$testdir/po"
1434 (echo "## Process this file with automake to produce Makefile.in."
1435 ) > "$testdir/po/Makefile.am"
1436 subdirs="$subdirs po"
1439 if test -n "$inctests"; then
1440 test -d "$testdir/tests" || mkdir "$testdir/tests"
1441 # Create tests/Makefile.am.
1445 func_emit_tests_Makefile_am > "$testdir/tests/Makefile.am"
1446 # Create tests/configure.ac.
1447 (echo "# Process this file with autoconf to produce a configure script."
1448 echo "AC_INIT([dummy], [0])"
1449 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
1450 echo "AM_INIT_AUTOMAKE"
1452 echo "AM_CONFIG_HEADER([config.h])"
1455 echo "AC_PROG_INSTALL"
1456 echo "AC_PROG_MAKE_SET"
1457 echo "AC_PROG_RANLIB"
1459 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
1460 echo "AC_GNU_SOURCE"
1463 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
1464 echo "gl_USE_SYSTEM_EXTENSIONS"
1467 if test -z "$libtool"; then
1468 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1470 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1472 # We don't have explicit ordering constraints between the various
1473 # autoconf snippets. It's cleanest to put those of the library before
1474 # those of the tests.
1475 for module in $modules; do
1476 func_verify_nontests_module
1477 if test -n "$module"; then
1478 func_get_autoconf_snippet "$module"
1481 for module in $modules; do
1482 func_verify_tests_module
1483 if test -n "$module"; then
1484 func_get_autoconf_snippet "$module"
1488 # Usually tests/config.h will be a superset of config.h. Verify this by
1489 # "merging" config.h into tests/config.h; look out for gcc warnings.
1490 echo "AH_TOP([#include \"../config.h\"])"
1492 echo "AC_OUTPUT([Makefile])"
1493 ) > "$testdir/tests/configure.ac"
1494 subdirs="$subdirs tests"
1495 subdirs_with_configure_ac="$subdirs_with_configure_ac tests"
1498 # Create Makefile.am.
1499 (echo "## Process this file with automake to produce Makefile.in."
1501 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1503 echo "SUBDIRS = $subdirs"
1505 echo "ACLOCAL_AMFLAGS = -I m4"
1506 ) > "$testdir/Makefile.am"
1508 # Create configure.ac.
1509 (echo "# Process this file with autoconf to produce a configure script."
1510 echo "AC_INIT([dummy], [0])"
1511 if test "$auxdir" != "."; then
1512 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1514 echo "AM_INIT_AUTOMAKE"
1516 echo "AM_CONFIG_HEADER([config.h])"
1519 echo "AC_PROG_INSTALL"
1520 echo "AC_PROG_MAKE_SET"
1521 echo "AC_PROG_RANLIB"
1523 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
1524 echo "AC_GNU_SOURCE"
1527 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
1528 echo "gl_USE_SYSTEM_EXTENSIONS"
1531 if test -z "$libtool"; then
1532 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1534 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1536 for module in $modules; do
1537 func_verify_nontests_module
1538 if test -n "$module"; then
1539 func_get_autoconf_snippet "$module"
1543 if test -n "$subdirs_with_configure_ac"; then
1544 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
1546 makefiles="Makefile"
1547 for d in $subdirs; do
1548 # For subdirs that have a configure.ac by their own, it's the subdir's
1549 # configure.ac which creates the subdir's Makefile.am, not this one.
1550 case " $subdirs_with_configure_ac " in
1552 *) makefiles="$makefiles $d/Makefile" ;;
1555 echo "AC_OUTPUT([$makefiles])"
1556 ) > "$testdir/configure.ac"
1558 # Create autogenerated files.
1560 echo "executing ${AUTORECONF} --force --install"
1561 ${AUTORECONF} --force --install
1563 if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
1567 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
1575 # func_create_megatestdir megatestdir allmodules
1577 # - auxdir directory relative to destdir where to place build aux files
1578 func_create_megatestdir ()
1582 if test -z "$allmodules"; then
1583 allmodules=`func_all_modules`
1587 # First, all modules one by one.
1588 for onemodule in $allmodules; do
1589 func_create_testdir "$megatestdir/$onemodule" $onemodule
1590 megasubdirs="${megasubdirs}$onemodule "
1592 # Then, all modules all together.
1593 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
1594 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
1595 func_create_testdir "$megatestdir/ALL" "$allmodules"
1596 megasubdirs="${megasubdirs}ALL"
1598 # Create Makefile.am.
1599 (echo "## Process this file with automake to produce Makefile.in."
1601 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1603 echo "SUBDIRS = $megasubdirs"
1604 ) > "$megatestdir/Makefile.am"
1606 # Create configure.ac.
1607 (echo "# Process this file with autoconf to produce a configure script."
1608 echo "AC_INIT([dummy], [0])"
1609 if test "$auxdir" != "."; then
1610 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1612 echo "AM_INIT_AUTOMAKE"
1614 echo "AC_PROG_MAKE_SET"
1616 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
1617 echo "AC_OUTPUT([Makefile])"
1618 ) > "$megatestdir/configure.ac"
1620 # Create autogenerated files.
1622 echo "executing ${AUTORECONF} --install"
1623 ${AUTORECONF} --install
1629 func_fatal_error "no mode specified" ;;
1638 if test -z "$destdir"; then
1641 test -d "$destdir" \
1642 || func_fatal_error "destination directory does not exist: $destdir"
1644 # Prefer configure.ac to configure.in.
1645 if test -f "$destdir"/configure.ac; then
1646 configure_ac="$destdir/configure.ac"
1648 if test -f "$destdir"/configure.in; then
1649 configure_ac="$destdir/configure.in"
1651 func_fatal_error "cannot find $destdir/configure.ac"
1655 test -f "$destdir"/Makefile.am \
1656 || func_fatal_error "cannot find $destdir/Makefile.am"
1658 # Analyze configure.ac.
1665 /AC_CONFIG_AUX_DIR/ {
1666 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
1668 /A[CM]_PROG_LIBTOOL/ {
1669 s,^.*$,guessed_libtool=true,p
1671 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
1673 if test -z "$auxdir"; then
1674 auxdir="$guessed_auxdir"
1677 # Determine where to apply func_import.
1678 if test -n "$m4base"; then
1679 # Apply func_import to a particular gnulib directory.
1680 # Any number of additional modules can be given.
1681 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
1682 # First use of gnulib in the given m4base.
1683 test -n "$supplied_libname" || supplied_libname=true
1684 test -n "$sourcebase" || sourcebase="lib"
1685 test -n "$testsbase" || testsbase="tests"
1686 test -n "$macro_prefix" || macro_prefix="gl"
1690 # Apply func_import to all gnulib directories.
1691 # To get this list of directories, look at Makefile.am. (Not at
1692 # configure, because it may be omitted from CVS. Also, don't run
1693 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
1694 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
1698 for arg in $aclocal_amflags; do
1699 if test -n "$m4dir_is_next"; then
1700 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
1704 if test -f "$destdir/$arg"/gnulib-cache.m4; then
1705 m4dirs="$m4dirs $arg"
1706 m4dirs_count=`expr $m4dirs_count + 1`
1711 if test "X$arg" = "X-I"; then
1718 if test $m4dirs_count = 0; then
1719 # First use of gnulib in a package.
1720 # Any number of additional modules can be given.
1721 test -n "$supplied_libname" || supplied_libname=true
1722 test -n "$sourcebase" || sourcebase="lib"
1724 test -n "$testsbase" || testsbase="tests"
1725 test -n "$macro_prefix" || macro_prefix="gl"
1728 if test $m4dirs_count = 1; then
1729 # There's only one use of gnulib here. Assume the user means it.
1730 # Any number of additional modules can be given.
1731 for m4base in $m4dirs; do
1735 # Ambiguous - guess what the user meant.
1736 if test $# = 0; then
1737 # No further arguments. Guess the user wants to update all of them.
1738 for m4base in $m4dirs; do
1743 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
1751 if test -z "$destdir"; then
1752 func_fatal_error "please specify --dir option"
1755 test -d "$destdir" \
1756 || func_fatal_error "could not create destination directory"
1757 test -n "$auxdir" || auxdir="build-aux"
1758 func_create_testdir "$destdir" "$*"
1761 create-megatestdir )
1762 if test -z "$destdir"; then
1763 func_fatal_error "please specify --dir option"
1765 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1766 test -n "$auxdir" || auxdir="build-aux"
1767 func_create_megatestdir "$destdir" "$*"
1771 test -n "$destdir" || destdir=testdir$$
1772 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1773 test -n "$auxdir" || auxdir="build-aux"
1774 func_create_testdir "$destdir" "$*"
1782 remaining=`find . -type f -print`
1783 if test -n "$remaining"; then
1784 echo "Remaining files:" $remaining 1>&2
1785 echo "gnulib-tool: *** Stop." 1>&2
1794 test -n "$destdir" || destdir=testdir$$
1795 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1796 test -n "$auxdir" || auxdir="build-aux"
1797 func_create_megatestdir "$destdir" "$*"
1805 remaining=`find . -type f -print`
1806 if test -n "$remaining"; then
1807 echo "Remaining files:" $remaining 1>&2
1808 echo "gnulib-tool: *** Stop." 1>&2
1816 extract-description )
1820 if test -n "$module"; then
1821 func_get_description "$module"
1830 if test -n "$module"; then
1831 func_get_filelist "$module"
1836 extract-dependencies )
1840 if test -n "$module"; then
1841 func_get_dependencies "$module"
1846 extract-autoconf-snippet )
1850 if test -n "$module"; then
1851 func_get_autoconf_snippet "$module"
1856 extract-automake-snippet )
1860 if test -n "$module"; then
1861 func_get_automake_snippet "$module"
1866 extract-include-directive )
1870 if test -n "$module"; then
1871 func_get_include_directive "$module"
1880 if test -n "$module"; then
1881 func_get_license "$module"
1886 extract-maintainer )
1890 if test -n "$module"; then
1891 func_get_maintainer "$module"
1896 extract-tests-module )
1900 if test -n "$module"; then
1901 func_get_tests_module "$module"
1907 func_fatal_error "unknown operation mode --$mode" ;;