3 # Copyright (C) 2002, 2003, 2004, 2005 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: 2005-10-21 15:05:31 $'
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]
47 gnulib-tool --create-testdir --dir=directory module1 ... moduleN
48 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
49 gnulib-tool --test --dir=directory module1 ... moduleN
50 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
51 gnulib-tool --extract-description module
52 gnulib-tool --extract-filelist module
53 gnulib-tool --extract-dependencies module
54 gnulib-tool --extract-autoconf-snippet module
55 gnulib-tool --extract-automake-snippet module
56 gnulib-tool --extract-include-directive module
57 gnulib-tool --extract-license module
58 gnulib-tool --extract-maintainer module
59 gnulib-tool --extract-tests-module module
62 --list print the available module names
63 --import import the given modules into the current package
64 --create-testdir create a scratch package with the given modules
65 --create-megatestdir create a mega scratch package with the given modules
66 one by one and all together
67 --test test the combination of the given modules
68 (recommended to use CC=\"gcc -Wall\" here)
69 --megatest test the given modules one by one and all together
70 (recommended to use CC=\"gcc -Wall\" here)
71 --extract-description extract the description
72 --extract-filelist extract the list of files
73 --extract-dependencies extract the dependencies
74 --extract-autoconf-snippet extract the snippet for configure.ac
75 --extract-automake-snippet extract the snippet for lib/Makefile.am
76 --extract-include-directive extract the #include directive
77 --extract-license report the license terms of the source files
79 --extract-maintainer report the maintainer(s) inside gnulib
80 --extract-tests-module report the unit test module, if it exists
83 --dir=DIRECTORY specify the target directory
84 For --import, this specifies where your
85 configure.ac can be found. Defaults to current
87 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
88 --source-base=DIRECTORY
89 Directory relative --dir where source code is
90 placed (default \"lib\"), for --import.
91 --m4-base=DIRECTORY Directory relative --dir where *.m4 macros are
92 placed (default \"m4\"), for --import.
93 --tests-base=DIRECTORY
94 Directory relative --dir where unit tests are
95 placed (default \"tests\"), for --import.
96 --aux-dir=DIRECTORY Directory relative --dir where auxiliary build
97 tools are placed (default \"build-aux\").
98 --with-tests Include unit tests for the included modules.
99 --avoid=MODULE Avoid including the given MODULE. Useful if you
100 have code that provides equivalent functionality.
101 This option can be repeated.
102 --lgpl Abort if modules aren't available under the LGPL.
103 Also modify license template from GPL to LGPL.
104 --libtool Use libtool rules, for --import.
105 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
106 'gl_INIT'. Default is 'gl'.
107 --no-changelog don't update or create ChangeLog files
108 --dry-run For --import, only print what would have been done.
109 -s, --symbolic, --symlink Make symbolic links instead of copying files.
111 Report bugs to <bug-gnulib@gnu.org>."
115 # outputs to stdout the --version message.
118 echo "$progname (GNU $package) $version"
119 echo "Copyright (C) 2002-2005 Free Software Foundation, Inc.
120 This is free software; see the source for copying conditions. There is NO
121 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
122 echo "Written by" "Bruno Haible" "and" "Simon Josefsson"
126 # creates a temporary directory.
128 # - tmp pathname of freshly created temporary directory
131 # Use the environment variable TMPDIR, falling back to /tmp. This allows
132 # users to specify a different temporary directory, for example, if their
133 # /tmp is filled up or too small.
136 # Use the mktemp program if available. If not available, hide the error
138 tmp=`(umask 077 && mktemp -d -q "$TMPDIR/glXXXXXX") 2>/dev/null` &&
139 test -n "$tmp" && test -d "$tmp"
142 # Use a simple mkdir command. It is guaranteed to fail if the directory
143 # already exists. $RANDOM is bash specific and expands to empty in shells
144 # other than bash, ksh and zsh. Its use does not increase security;
145 # rather, it minimizes the probability of failure in a very cluttered /tmp
147 tmp=$TMPDIR/gl$$-$RANDOM
148 (umask 077 && mkdir "$tmp")
151 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
152 { (exit 1); exit 1; }
156 # func_fatal_error message
157 # outputs to stderr a fatal error message, and terminates the program.
160 echo "gnulib-tool: *** $1" 1>&2
161 echo "gnulib-tool: *** Stop." 1>&2
165 # func_readlink SYMLINK
166 # outputs the target of the given symlink.
167 if (type -p readlink) > /dev/null 2>&1; then
170 # Use the readlink program from GNU coreutils.
176 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
177 # would do the wrong thing if the link target contains " -> ".
178 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
182 # func_ln_if_changed SRC DEST
183 # Like ln -s, but avoids munging timestamps if the link is correct.
184 func_ln_if_changed ()
186 if test $# -ne 2; then
187 echo "usage: func_ln_if_changed SRC DEST" >&2
189 if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then
197 # Command-line option processing.
198 # Removes the OPTIONS from the arguments. Sets the variables:
199 # - mode list or import or create-testdir or create-megatestdir
200 # - destdir from --dir
201 # - libname, supplied_libname from --lib
202 # - sourcebase from --source-base
203 # - m4base from --m4-base
204 # - testsbase from --tests-base
205 # - auxdir from --aux-dir
206 # - inctests true if --with-tests was given, blank otherwise
207 # - avoidlist list of modules to avoid, from --avoid
208 # - lgpl true if --lgpl was given, blank otherwise
209 # - libtool true if --libtool was given, blank otherwise
210 # - do_changelog false if --no-changelog was given, : otherwise
211 # - doit : if actions shall be executed, false if only to be printed
232 while test $# -gt 0; do
237 --import | --impor | --impo | --imp | --im | --i )
240 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
243 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
244 mode=create-megatestdir
246 --test | --tes | --te | --t )
249 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
253 mode=`echo "X$1" | sed -e 's/^X--//'`
258 func_fatal_error "missing argument for --dir"
263 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
268 func_fatal_error "missing argument for --lib"
271 supplied_libname=true
274 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
275 supplied_libname=true
280 func_fatal_error "missing argument for --source-base"
285 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
290 func_fatal_error "missing argument for --m4-base"
295 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
300 func_fatal_error "missing argument for --tests-base"
305 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
310 func_fatal_error "missing argument for --aux-dir"
315 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
323 func_fatal_error "missing argument for --avoid"
325 avoidlist="$avoidlist $1"
328 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
339 func_fatal_error "missing argument for --macro-prefix"
344 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
346 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
352 -s | --symbolic | --symlink )
355 --help | --hel | --he | --h )
358 --version | --versio | --versi | --vers | --ver | --ve | --v )
362 # Stop option processing
366 echo "gnulib-tool: unknown option $1" 1>&2
367 echo "Try 'gnulib-tool --help' for more information." 1>&2
374 # Remove trailing slashes from the directory names. This is necessary for
375 # m4base (to avoid an error in func_import) and optional for the others.
376 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
377 case "$sourcebase" in
378 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
381 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
384 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
387 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
392 /*) self_abspathname="$0" ;;
393 */*) self_abspathname=`pwd`/"$0" ;;
394 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
395 if test -x "$d/$0" && test ! -d "$d/$0"; then
396 self_abspathname="$d/$0"
400 if test -z "$self_abspathname"; then
401 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
405 while test -h "$self_abspathname"; do
406 # Resolve symbolic link.
407 linkval=`func_readlink "$self_abspathname"`
408 test -n "$linkval" || break
410 /* ) self_abspathname="$linkval" ;;
411 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
414 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
419 # Filter out metainformation files like README, which are not modules.
420 # Filter out unit test modules; they can be retrieved through
421 # --extract-tests-module if desired.
422 (cd "$gnulib_dir/modules" && ls -1) \
423 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
424 | sed -e '/-tests$/d' \
429 # verifies a module name
430 func_verify_module ()
432 if test ! -f "$gnulib_dir/modules/$module" \
433 || test "CVS" = "$module" \
434 || test "ChangeLog" = "$module" \
435 || test "README" = "$module" \
436 || test "TEMPLATE" = "$module" \
437 || test "TEMPLATE-TESTS" = "$module"; then
438 echo "gnulib-tool: module $module doesn't exist" 1>&2
443 # func_verify_nontests_module
444 # verifies a module name, excluding tests modules
445 func_verify_nontests_module ()
449 * ) func_verify_module ;;
453 # func_verify_tests_module
454 # verifies a module name, considering only tests modules
455 func_verify_tests_module ()
458 *-tests ) func_verify_module ;;
463 sed_extract_prog=':[ ]*$/ {
466 s/^Description:[ ]*$//
468 s/^Depends-on:[ ]*$//
469 s/^configure\.ac:[ ]*$//
470 s/^Makefile\.am:[ ]*$//
473 s/^Maintainer:[ ]*$//
480 # func_get_description module
481 func_get_description ()
483 sed -n -e "/^Description$sed_extract_prog" < "$gnulib_dir/modules/$1"
486 # func_get_filelist module
489 sed -n -e "/^Files$sed_extract_prog" < "$gnulib_dir/modules/$1"
491 echo m4/onceonly_2_57.m4
494 # func_get_dependencies module
495 func_get_dependencies ()
497 # ${module}-tests always implicitly depends on ${module}.
498 echo "$1" | sed -n -e 's/-tests//p'
499 # Then the explicit dependencies listed in the module description.
500 sed -n -e "/^Depends-on$sed_extract_prog" < "$gnulib_dir/modules/$1"
503 # func_get_autoconf_snippet module
504 func_get_autoconf_snippet ()
506 sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
509 # func_get_automake_snippet module
510 func_get_automake_snippet ()
512 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$gnulib_dir/modules/$1"
515 # func_get_include_directive module
516 func_get_include_directive ()
518 sed -n -e "/^Include$sed_extract_prog" < "$gnulib_dir/modules/$1" | \
519 sed -e 's/^\(["<]\)/#include \1/'
522 # func_get_license module
525 sed -n -e "/^License$sed_extract_prog" < "$gnulib_dir/modules/$1"
528 # func_get_maintainer module
529 func_get_maintainer ()
531 sed -n -e "/^Maintainer$sed_extract_prog" < "$gnulib_dir/modules/$1"
534 # func_get_tests_module module
535 func_get_tests_module ()
537 # The naming convention for tests modules is hardwired: ${module}-tests.
538 if test -f modules/"$1"-tests; then
543 # func_acceptable module
544 # tests whether a module is acceptable.
546 # - avoidlist list of modules to avoid
549 for avoid in $avoidlist; do
550 if test "$avoid" = "$1"; then
557 # func_modules_transitive_closure
559 # - modules list of specified modules
560 # - inctests true if tests should be included, blank otherwise
561 # - avoidlist list of modules to avoid
563 # - modules list of modules, including dependencies
564 func_modules_transitive_closure ()
568 for module in $modules; do
570 if test -n "$module"; then
571 # Duplicate dependencies are harmless, but Jim wants a warning.
572 duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d`
573 if test -n "$duplicated_deps"; then
574 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
576 if func_acceptable $module; then
577 xmodules="$xmodules $module"
578 for depmodule in `func_get_dependencies $module`; do
579 if func_acceptable $depmodule; then
580 xmodules="$xmodules $depmodule"
583 if test -n "$inctests"; then
584 testsmodule=`func_get_tests_module $module`
585 if test -n "$testsmodule"; then
586 if func_acceptable $testsmodule; then
587 xmodules="$xmodules $testsmodule"
588 for depmodule in `func_get_dependencies $testsmodule`; do
589 if func_acceptable $depmodule; then
590 xmodules="$xmodules $depmodule"
599 xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
600 if test "$xmodules" = "$modules"; then
607 # func_modules_to_filelist
609 # - modules list of modules, including dependencies
611 # - files list of files
612 func_modules_to_filelist ()
615 for module in $modules; do
617 if test -n "$module"; then
618 files="$files "`func_get_filelist $module`
621 files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
624 # func_emit_lib_Makefile_am
625 # emits the contents of lib/Makefile.am to standard output.
627 # - modules list of modules, including dependencies
628 # - libname library name
629 # - libtool true if libtool will be used, blank otherwise
630 # - actioncmd (optional) command that will reproduce this invocation
631 func_emit_lib_Makefile_am ()
633 if test -n "$libtool"; then
640 echo "## Process this file with automake to produce Makefile.in."
641 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
643 echo "# This file is free software, distributed under the terms of the GNU"
644 echo "# General Public License. As a special exception to the GNU General"
645 echo "# Public License, this file may be distributed as part of a program"
646 echo "# that contains a configuration script generated by Automake, under"
647 echo "# the same distribution terms as the rest of that program."
649 echo "# Generated by gnulib-tool."
650 if test -n "$actioncmd"; then
651 echo "# Reproduce by: $actioncmd"
654 # No need to generate dependencies since the sources are in gnulib, not here.
655 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
657 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
659 echo "${libname}_${libext}_SOURCES ="
660 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
662 echo "BUILT_SOURCES ="
664 echo "MOSTLYCLEANFILES ="
666 echo "DISTCLEANFILES ="
667 echo "MAINTAINERCLEANFILES ="
669 for module in $modules; do
670 func_verify_nontests_module
671 if test -n "$module"; then
673 func_get_automake_snippet "$module" |
674 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
675 if test "$module" = 'alloca'; then
676 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
679 # Skip the contents if its entirely empty.
680 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
681 echo "## begin gnulib module $module"
684 echo "## end gnulib module $module"
691 echo "# Makefile.am ends here"
694 # func_emit_tests_Makefile_am
695 # emits the contents of tests/Makefile.am to standard output.
697 # - modules list of modules, including dependencies
698 # - libname library name
699 # - libtool true if libtool will be used, blank otherwise
700 # - sourcebase relative directory containing lib source code
701 # - m4base relative directory containing autoconf macros
702 # - testsbase relative directory containing unit test code
703 func_emit_tests_Makefile_am ()
705 if test -n "$libtool"; then
710 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
711 echo "## Process this file with automake to produce Makefile.in."
712 echo "# Copyright (C) 2004-2005 Free Software Foundation, Inc."
714 echo "# This file is free software, distributed under the terms of the GNU"
715 echo "# General Public License. As a special exception to the GNU General"
716 echo "# Public License, this file may be distributed as part of a program"
717 echo "# that contains a configuration script generated by Automake, under"
718 echo "# the same distribution terms as the rest of that program."
720 echo "# Generated by gnulib-tool."
722 # Generate dependencies here, since it eases the debugging of test failures.
723 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
725 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
728 echo "TESTS_ENVIRONMENT ="
729 echo "noinst_PROGRAMS ="
731 echo "BUILT_SOURCES ="
733 echo "MOSTLYCLEANFILES ="
735 echo "DISTCLEANFILES ="
736 echo "MAINTAINERCLEANFILES ="
738 echo "AM_CPPFLAGS = \\"
739 echo " -I. -I\$(srcdir) \\"
740 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
741 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
743 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
745 for module in $modules; do
746 func_verify_tests_module
747 if test -n "$module"; then
748 func_get_automake_snippet "$module" > amsnippet.tmp
749 # Skip the contents if its entirely empty.
750 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
751 echo "## begin gnulib module $module"
754 echo "## end gnulib module $module"
760 echo "# Clean up after Solaris cc."
762 echo " rm -rf SunWS_cache"
764 echo "# Makefile.am ends here"
767 # func_import modules
768 # Uses also the variables
769 # - destdir target directory
770 # - libname library name
771 # - sourcebase directory relative to destdir where to place source code
772 # - m4base directory relative to destdir where to place *.m4 macros
773 # - testsbase directory relative to destdir where to place unit test code
774 # - auxdir directory relative to destdir where to place build aux files
775 # - inctests true if --with-tests was given, blank otherwise
776 # - avoidlist list of modules to avoid, from --avoid
777 # - lgpl true if library's license shall be LGPL, blank otherwise
778 # - libtool true if libtool will be used, blank otherwise
779 # - guessed_libtool true if the configure.ac file uses libtool, blank otherwise
780 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
781 # - doit : if actions shall be executed, false if only to be printed
782 # - symbolic true if files should be symlinked, copied otherwise
785 # Get the cached settings.
786 cached_specified_modules=
796 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
802 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
805 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
808 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
811 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
814 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
817 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
820 s,^.*$,cached_lgpl=true,p
823 s,^.*$,cached_libtool=true,p
826 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
828 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
829 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
834 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
835 s,^.*$,cached_files=",p
847 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
851 # Merge the cached settings with the specified ones.
852 # The m4base must be the same as expected from the pathname.
853 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
854 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
856 # Append the cached and the specified module names. So that
857 # "gnulib-tool --import foo" means to add the module foo.
858 specified_modules="$cached_specified_modules $1"
859 # Append the cached and the specified avoidlist. This is probably better
860 # than dropping the cached one when --avoid is specified at least once.
861 avoidlist=`echo $cached_avoidlist $avoidlist`
862 # The sourcebase defaults to the cached one.
863 if test -z "$sourcebase"; then
864 sourcebase="$cached_sourcebase"
865 if test -z "$sourcebase"; then
866 func_fatal_error "missing --source-base option"
869 # The testsbase defaults to the cached one.
870 if test -z "$testsbase"; then
871 testsbase="$cached_testsbase"
872 if test -z "$testsbase"; then
873 func_fatal_error "missing --tests-base option"
876 # The libname defaults to the cached one.
877 if test -z "$supplied_libname"; then
878 libname="$cached_libname"
879 if test -z "$libname"; then
880 func_fatal_error "missing --lib option"
883 # Require LGPL if specified either way.
884 if test -z "$lgpl"; then
887 # Use libtool if specified either way, or if guessed.
888 if test -z "$libtool"; then
889 if test -n "$cached_m4base"; then
890 libtool="$cached_libtool"
892 libtool="$guessed_libtool"
895 # The macro_prefix defaults to the cached one.
896 if test -z "$macro_prefix"; then
897 macro_prefix="$cached_macro_prefix"
898 if test -z "$macro_prefix"; then
899 func_fatal_error "missing --macro-prefix option"
903 # Canonicalize the list of specified modules.
904 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
906 # Determine final module list.
907 modules="$specified_modules"
908 func_modules_transitive_closure
909 echo "Module list with included dependencies:"
910 echo "$modules" | sed -e 's/^/ /'
912 # If --lgpl, check the license of modules are compatible.
913 if test -n "$lgpl"; then
914 for module in $modules; do
915 license=`func_get_license $module`
917 LGPL | 'public domain' | 'unlimited') ;;
918 *) func_fatal_error "incompatible license on module $module: $license" ;;
923 # Determine final file list.
924 func_modules_to_filelist
926 echo "$files" | sed -e 's/^/ /'
929 || func_fatal_error "refusing to do nothing"
931 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
932 new_files="$files m4/gnulib-tool.m4"
933 old_files="$cached_files"
934 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
935 old_files="$old_files m4/gnulib-tool.m4"
938 # Create directories.
939 if test ! -d "$destdir/$sourcebase"; then
941 echo "Creating directory $destdir/$sourcebase"
942 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
944 echo "Create directory $destdir/$sourcebase"
947 if test ! -d "$destdir/$m4base"; then
949 echo "Creating directory $destdir/$m4base"
950 mkdir "$destdir/$m4base" || func_fatal_error "failed"
952 echo "Create directory $destdir/$m4base"
955 if test -n "$inctests"; then
956 if test ! -d "$destdir/$testsbase"; then
958 echo "Creating directory $destdir/$testsbase"
959 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
961 echo "Create directory $destdir/$testsbase"
965 if test ! -d "$destdir/$auxdir"; then
967 echo "Creating directory $destdir/$auxdir"
968 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
970 echo "Create directory $destdir/$auxdir"
974 # Copy files or make symbolic links. Remove obsolete files.
976 trap 'rm -rf "$tmp"' 0 1 2 3 15
978 for f in $old_files; do
980 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
981 lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
982 m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
985 echo "$g""$delimiter""$f"
986 done | LC_ALL=C sort > "$tmp"/old-files
987 for f in $new_files; do
989 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
990 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
991 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
994 echo "$g""$delimiter""$f"
995 done | LC_ALL=C sort > "$tmp"/new-files
996 # First the files that are in old-files, but not in new-files:
997 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e 's,'"$delimiter"'.*,,'`; do
998 # Remove the file. Do nothing if the user already removed it.
999 if test -f "$destdir/$g"; then
1001 echo "Removing file $g (backup in ${g}~)"
1002 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1004 echo "Remove file $g (backup in ${g}~)"
1008 # func_add_or_update handles a file that ought to be present afterwards.
1009 # Uses parameters f, g, already_present.
1010 func_add_or_update ()
1012 cp "$gnulib_dir/$f" "$destdir/$g.tmp" || func_fatal_error "failed"
1013 if test -n "$lgpl"; then
1017 sed -e 's/GNU General/GNU Lesser General/g' \
1018 -e 's/version 2\([ ,]\)/version 2.1\1/g' \
1019 < "$gnulib_dir/$f" > "$destdir/$g.tmp" || func_fatal_error "failed"
1023 if test -f "$destdir/$g"; then
1024 # The file already exists.
1025 if cmp "$destdir/$g" "$destdir/$g.tmp" > /dev/null; then
1026 : # The file has not changed.
1030 if test -n "$already_present"; then
1031 echo "Updating file $g (backup in ${g}~)"
1033 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1035 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1036 if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$destdir/$g.tmp" > /dev/null; then
1037 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
1039 mv -f "$destdir/$g.tmp" "$destdir/${g}" || func_fatal_error "failed"
1042 if test -n "$already_present"; then
1043 echo "Update file $g (backup in ${g}~)"
1045 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1051 # Don't protest if the file should be there but isn't: it happens
1052 # frequently that developers don't put autogenerated files into CVS.
1054 echo "Copying file $g"
1055 if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$destdir/$g.tmp" > /dev/null; then
1056 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
1058 mv -f "$destdir/$g.tmp" "$destdir/${g}" || func_fatal_error "failed"
1064 rm -f "$destdir/$g.tmp"
1066 # Then the files that are in new-files, but not in old-files:
1068 for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e 's,'^.*"$delimiter"',,'`; do
1070 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1071 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1072 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1077 # Then the files that are in new-files and in old-files:
1078 already_present=true
1079 for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e 's,'^.*"$delimiter"',,'`; do
1081 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1082 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1083 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1091 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1092 actioncmd="gnulib-tool --import"
1093 actioncmd="$actioncmd --dir=$destdir"
1094 actioncmd="$actioncmd --lib=$libname"
1095 actioncmd="$actioncmd --source-base=$sourcebase"
1096 actioncmd="$actioncmd --m4-base=$m4base"
1097 actioncmd="$actioncmd --aux-dir=$auxdir"
1098 for module in $avoidlist; do
1099 actioncmd="$actioncmd --avoid=$module"
1101 if test -n "$lgpl"; then
1102 actioncmd="$actioncmd --lgpl"
1104 if test -n "$libtool"; then
1105 actioncmd="$actioncmd --libtool"
1107 actioncmd="$actioncmd --macro-prefix=$macro_prefix"
1108 actioncmd="$actioncmd `echo $specified_modules`"
1110 # Create lib/Makefile.am.
1111 func_emit_lib_Makefile_am > "$destdir"/$sourcebase/Makefile.am.tmp
1112 if test -f "$destdir"/$sourcebase/Makefile.am; then
1113 if cmp "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am.tmp > /dev/null; then
1114 rm -f "$destdir"/$sourcebase/Makefile.am.tmp
1117 echo "Updating $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1118 mv -f "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am~
1119 mv -f "$destdir"/$sourcebase/Makefile.am.tmp "$destdir"/$sourcebase/Makefile.am
1121 echo "Update $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1122 rm -f "$destdir"/$sourcebase/Makefile.am.tmp
1127 echo "Creating $sourcebase/Makefile.am"
1128 mv -f "$destdir"/$sourcebase/Makefile.am.tmp "$destdir"/$sourcebase/Makefile.am
1130 echo "Create $sourcebase/Makefile.am"
1131 rm -f "$destdir"/$sourcebase/Makefile.am.tmp
1135 # Create m4/gnulib-cache.m4.
1137 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
1138 echo "# This file is free software, distributed under the terms of the GNU"
1139 echo "# General Public License. As a special exception to the GNU General"
1140 echo "# Public License, this file may be distributed as part of a program"
1141 echo "# that contains a configuration script generated by Autoconf, under"
1142 echo "# the same distribution terms as the rest of that program."
1144 echo "# Generated by gnulib-tool."
1146 echo "# This file represents the specification of how gnulib-tool is used."
1147 echo "# It acts as a cache: It is written and read by gnulib-tool."
1148 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1149 echo "# like the configure.ac and various Makefile.am files."
1152 echo "# Specification in the form of a command-line invocation:"
1155 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1156 echo "gl_MODULES(["`echo $specified_modules`"])"
1157 echo "gl_AVOID([$avoidlist])"
1158 echo "gl_SOURCE_BASE([$sourcebase])"
1159 echo "gl_M4_BASE([$m4base])"
1160 echo "gl_TESTS_BASE([$testsbase])"
1161 echo "gl_LIB([$libname])"
1162 test -z "$lgpl" || echo "gl_LGPL"
1163 test -z "$libtool" || echo "gl_LIBTOOL"
1164 echo "gl_MACRO_PREFIX([$macro_prefix])"
1165 ) > "$destdir"/$m4base/gnulib-cache.m4.tmp
1166 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1167 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4.tmp > /dev/null; then
1168 rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
1171 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1172 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1173 mv -f "$destdir"/$m4base/gnulib-cache.m4.tmp "$destdir"/$m4base/gnulib-cache.m4
1175 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1177 cat "$destdir"/$m4base/gnulib-cache.m4.tmp
1179 echo "# gnulib-cache.m4 ends here"
1181 rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
1186 echo "Creating $m4base/gnulib-cache.m4"
1187 mv -f "$destdir"/$m4base/gnulib-cache.m4.tmp "$destdir"/$m4base/gnulib-cache.m4
1189 echo "Create $m4base/gnulib-cache.m4"
1190 cat "$destdir"/$m4base/gnulib-cache.m4.tmp
1191 rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
1195 # Create m4/gnulib-comp.m4.
1197 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
1198 echo "# This file is free software, distributed under the terms of the GNU"
1199 echo "# General Public License. As a special exception to the GNU General"
1200 echo "# Public License, this file may be distributed as part of a program"
1201 echo "# that contains a configuration script generated by Autoconf, under"
1202 echo "# the same distribution terms as the rest of that program."
1204 echo "# Generated by gnulib-tool."
1206 echo "# This file represents the compiled summary of the specification in"
1207 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1208 echo "# to be invoked from configure.ac."
1209 echo "# In projects using CVS, this file can be treated like other built files."
1212 echo "# This macro should be invoked from $configure_ac, in the section"
1213 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1214 echo "# any checks for libraries, header files, types and library functions."
1215 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1217 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
1218 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1220 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
1221 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1225 echo "# This macro should be invoked from $configure_ac, in the section"
1226 echo "# \"Check for header files, types and library functions\"."
1227 echo "AC_DEFUN([${macro_prefix}_INIT],"
1229 if test -z "$libtool"; then
1230 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1232 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1234 for module in $modules; do
1236 if test -n "$module"; then
1237 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./'
1238 if test "$module" = 'alloca' && test -n "$libtool"; then
1239 echo 'changequote(,)dnl'
1240 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1241 echo 'changequote([, ])dnl'
1242 echo 'AC_SUBST([LTALLOCA])'
1248 echo "# This macro records the list of files which have been installed by"
1249 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1250 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1251 echo "$files" | sed -e 's,^, ,'
1253 ) > "$destdir"/$m4base/gnulib-comp.m4.tmp
1254 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1255 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4.tmp > /dev/null; then
1256 rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
1259 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1260 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1261 mv -f "$destdir"/$m4base/gnulib-comp.m4.tmp "$destdir"/$m4base/gnulib-comp.m4
1263 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1265 cat "$destdir"/$m4base/gnulib-comp.m4.tmp
1267 echo "# gnulib-comp.m4 ends here"
1269 rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
1274 echo "Creating $m4base/gnulib-comp.m4"
1275 mv -f "$destdir"/$m4base/gnulib-comp.m4.tmp "$destdir"/$m4base/gnulib-comp.m4
1277 echo "Create $m4base/gnulib-comp.m4"
1278 cat "$destdir"/$m4base/gnulib-comp.m4.tmp
1279 rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
1283 if test -n "$inctests"; then
1284 # Create tests/Makefile.am.
1285 func_emit_tests_Makefile_am > "$destdir"/$testsbase/Makefile.am.tmp
1286 if test -f "$destdir"/$testsbase/Makefile.am; then
1287 if cmp "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am.tmp > /dev/null; then
1288 rm -f "$destdir"/$testsbase/Makefile.am.tmp
1291 echo "Updating $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1292 mv -f "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am~
1293 mv -f "$destdir"/$testsbase/Makefile.am.tmp "$destdir"/$testsbase/Makefile.am
1295 echo "Update $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1296 rm -f "$destdir"/$testsbase/Makefile.am.tmp
1301 echo "Creating $testsbase/Makefile.am"
1302 mv -f "$destdir"/$testsbase/Makefile.am.tmp "$destdir"/$testsbase/Makefile.am
1304 echo "Create $testsbase/Makefile.am"
1305 rm -f "$destdir"/$testsbase/Makefile.am.tmp
1312 echo "You may need to add #include directives for the following .h files."
1313 for module in $modules; do
1314 func_get_include_directive "$module"
1315 done | LC_ALL=C sort -u | sed -e '/^$/d;' -e 's/^/ /'
1317 echo "Don't forget to"
1318 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1319 if test -n "$inctests"; then
1320 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1322 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
1323 sourcebase_base=`basename "$sourcebase"`
1324 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
1325 if test -n "$inctests"; then
1326 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
1327 testsbase_base=`basename "$testsbase"`
1328 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
1330 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
1331 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
1332 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
1335 # func_create_testdir testdir modules
1337 # - auxdir directory relative to destdir where to place build aux files
1338 func_create_testdir ()
1342 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1344 # Determine final module list.
1345 func_modules_transitive_closure
1346 echo "Module list with included dependencies:"
1347 echo "$modules" | sed -e 's/^/ /'
1349 # Determine final file list.
1350 func_modules_to_filelist
1352 echo "$files" | sed -e 's/^/ /'
1354 # Create directories.
1355 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
1356 if test "$d" = build-aux; then
1357 mkdir -p "$testdir/$auxdir"
1359 mkdir -p "$testdir/$d"
1363 # Copy files or make symbolic links.
1366 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1369 ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
1370 if test -z "$symbolic"; then
1371 cp -p "$gnulib_dir/$f" "$testdir/$g"
1373 ln -s "$gnulib_dir/$f" "$testdir/$g"
1377 # Create lib/Makefile.am.
1378 mkdir -p "$testdir/lib"
1379 func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
1381 # Create m4/Makefile.am.
1382 mkdir -p "$testdir/m4"
1383 (echo "## Process this file with automake to produce Makefile.in."
1389 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
1392 ) > "$testdir/m4/Makefile.am"
1395 subdirs_with_configure_ac=""
1397 if test -f "$testdir"/m4/gettext.m4; then
1398 # Avoid stupid error message from automake:
1399 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
1400 mkdir -p "$testdir/po"
1401 (echo "## Process this file with automake to produce Makefile.in."
1402 ) > "$testdir/po/Makefile.am"
1403 subdirs="$subdirs po"
1406 if test -n "$inctests"; then
1407 test -d "$testdir/tests" || mkdir "$testdir/tests"
1408 # Create tests/Makefile.am.
1412 func_emit_tests_Makefile_am > "$testdir/tests/Makefile.am"
1413 # Create tests/configure.ac.
1414 (echo "# Process this file with autoconf to produce a configure script."
1415 echo "AC_INIT([dummy], [0])"
1416 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
1417 echo "AM_INIT_AUTOMAKE"
1419 echo "AM_CONFIG_HEADER([config.h])"
1422 echo "AC_PROG_INSTALL"
1423 echo "AC_PROG_MAKE_SET"
1424 echo "AC_PROG_RANLIB"
1426 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
1427 echo "AC_GNU_SOURCE"
1430 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
1431 echo "gl_USE_SYSTEM_EXTENSIONS"
1434 if test -z "$libtool"; then
1435 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1437 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1439 # We don't have explicit ordering constraints between the various
1440 # autoconf snippets. It's cleanest to put those of the library before
1441 # those of the tests.
1442 for module in $modules; do
1443 func_verify_nontests_module
1444 if test -n "$module"; then
1445 func_get_autoconf_snippet "$module"
1448 for module in $modules; do
1449 func_verify_tests_module
1450 if test -n "$module"; then
1451 func_get_autoconf_snippet "$module"
1455 # Usually tests/config.h will be a superset of config.h. Verify this by
1456 # "merging" config.h into tests/config.h; look out for gcc warnings.
1457 echo "AH_TOP([#include \"../config.h\"])"
1459 echo "AC_OUTPUT([Makefile])"
1460 ) > "$testdir/tests/configure.ac"
1461 subdirs="$subdirs tests"
1462 subdirs_with_configure_ac="$subdirs_with_configure_ac tests"
1465 # Create Makefile.am.
1466 (echo "## Process this file with automake to produce Makefile.in."
1468 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1470 echo "SUBDIRS = $subdirs"
1472 echo "ACLOCAL_AMFLAGS = -I m4"
1473 ) > "$testdir/Makefile.am"
1475 # Create configure.ac.
1476 (echo "# Process this file with autoconf to produce a configure script."
1477 echo "AC_INIT([dummy], [0])"
1478 if test "$auxdir" != "."; then
1479 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1481 echo "AM_INIT_AUTOMAKE"
1483 echo "AM_CONFIG_HEADER([config.h])"
1486 echo "AC_PROG_INSTALL"
1487 echo "AC_PROG_MAKE_SET"
1488 echo "AC_PROG_RANLIB"
1490 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
1491 echo "AC_GNU_SOURCE"
1494 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
1495 echo "gl_USE_SYSTEM_EXTENSIONS"
1498 if test -z "$libtool"; then
1499 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1501 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1503 for module in $modules; do
1504 func_verify_nontests_module
1505 if test -n "$module"; then
1506 func_get_autoconf_snippet "$module"
1510 if test -n "$subdirs_with_configure_ac"; then
1511 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
1513 makefiles="Makefile"
1514 for d in $subdirs; do
1515 # For subdirs that have a configure.ac by their own, it's the subdir's
1516 # configure.ac which creates the subdir's Makefile.am, not this one.
1517 case " $subdirs_with_configure_ac " in
1519 *) makefiles="$makefiles $d/Makefile" ;;
1522 echo "AC_OUTPUT([$makefiles])"
1523 ) > "$testdir/configure.ac"
1525 # Create autogenerated files.
1527 echo "executing ${AUTORECONF} --force --install"
1528 ${AUTORECONF} --force --install
1530 if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
1534 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
1542 # func_create_megatestdir megatestdir allmodules
1544 # - auxdir directory relative to destdir where to place build aux files
1545 func_create_megatestdir ()
1549 if test -z "$allmodules"; then
1550 allmodules=`func_all_modules`
1554 # First, all modules one by one.
1555 for onemodule in $allmodules; do
1556 func_create_testdir "$megatestdir/$onemodule" $onemodule
1557 megasubdirs="${megasubdirs}$onemodule "
1559 # Then, all modules all together.
1560 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
1561 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
1562 func_create_testdir "$megatestdir/ALL" "$allmodules"
1563 megasubdirs="${megasubdirs}ALL"
1565 # Create Makefile.am.
1566 (echo "## Process this file with automake to produce Makefile.in."
1568 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1570 echo "SUBDIRS = $megasubdirs"
1571 ) > "$megatestdir/Makefile.am"
1573 # Create configure.ac.
1574 (echo "# Process this file with autoconf to produce a configure script."
1575 echo "AC_INIT([dummy], [0])"
1576 if test "$auxdir" != "."; then
1577 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1579 echo "AM_INIT_AUTOMAKE"
1581 echo "AC_PROG_MAKE_SET"
1583 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
1584 echo "AC_OUTPUT([Makefile])"
1585 ) > "$megatestdir/configure.ac"
1587 # Create autogenerated files.
1589 echo "executing ${AUTORECONF} --install"
1590 ${AUTORECONF} --install
1596 func_fatal_error "no mode specified" ;;
1604 if test -z "$destdir"; then
1607 test -d "$destdir" \
1608 || func_fatal_error "destination directory does not exist: $destdir"
1610 # Prefer configure.ac to configure.in.
1611 if test -f "$destdir"/configure.ac; then
1612 configure_ac="$destdir/configure.ac"
1614 if test -f "$destdir"/configure.in; then
1615 configure_ac="$destdir/configure.in"
1617 func_fatal_error "cannot find $destdir/configure.ac"
1621 test -f "$destdir"/Makefile.am \
1622 || func_fatal_error "cannot find $destdir/Makefile.am"
1624 # Analyze configure.ac.
1631 /AC_CONFIG_AUX_DIR/ {
1632 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
1634 /A[CM]_PROG_LIBTOOL/ {
1635 s,^.*$,guessed_libtool=true,p
1637 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
1639 if test -z "$auxdir"; then
1640 auxdir="$guessed_auxdir"
1643 # Determine where to apply func_import.
1644 if test -n "$m4base"; then
1645 # Apply func_import to a particular gnulib directory.
1646 # Any number of additional modules can be given.
1647 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
1648 # First use of gnulib in the given m4base.
1649 test -n "$supplied_libname" || supplied_libname=true
1650 test -n "$sourcebase" || sourcebase="lib"
1651 test -n "$testsbase" || testsbase="tests"
1652 test -n "$macro_prefix" || macro_prefix="gl"
1656 # Apply func_import to all gnulib directories.
1657 # To get this list of directories, look at Makefile.am. (Not at
1658 # configure, because it may be omitted from CVS. Also, don't run
1659 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
1660 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
1664 for arg in $aclocal_amflags; do
1665 if test -n "$m4dir_is_next"; then
1666 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
1670 if test -f "$destdir/$arg"/gnulib-cache.m4; then
1671 m4dirs="$m4dirs $arg"
1672 m4dirs_count=`expr $m4dirs_count + 1`
1677 if test "X$arg" = "X-I"; then
1684 if test $m4dirs_count = 0; then
1685 # First use of gnulib in a package.
1686 # Any number of additional modules can be given.
1687 test -n "$supplied_libname" || supplied_libname=true
1688 test -n "$sourcebase" || sourcebase="lib"
1690 test -n "$testsbase" || testsbase="tests"
1691 test -n "$macro_prefix" || macro_prefix="gl"
1694 if test $m4dirs_count = 1; then
1695 # There's only one use of gnulib here. Assume the user means it.
1696 # Any number of additional modules can be given.
1697 for m4base in $m4dirs; do
1701 # Ambiguous - guess what the user meant.
1702 if test $# = 0; then
1703 # No further arguments. Guess the user wants to update all of them.
1704 for m4base in $m4dirs; do
1709 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
1717 if test -z "$destdir"; then
1718 func_fatal_error "please specify --dir option"
1721 test -d "$destdir" \
1722 || func_fatal_error "could not create destination directory"
1723 test -n "$auxdir" || auxdir="build-aux"
1724 func_create_testdir "$destdir" "$*"
1727 create-megatestdir )
1728 if test -z "$destdir"; then
1729 func_fatal_error "please specify --dir option"
1731 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1732 test -n "$auxdir" || auxdir="build-aux"
1733 func_create_megatestdir "$destdir" "$*"
1737 test -n "$destdir" || destdir=testdir$$
1738 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1739 test -n "$auxdir" || auxdir="build-aux"
1740 func_create_testdir "$destdir" "$*"
1748 remaining=`find . -type f -print`
1749 if test -n "$remaining"; then
1750 echo "Remaining files:" $remaining 1>&2
1751 echo "gnulib-tool: *** Stop." 1>&2
1760 test -n "$destdir" || destdir=testdir$$
1761 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1762 test -n "$auxdir" || auxdir="build-aux"
1763 func_create_megatestdir "$destdir" "$*"
1771 remaining=`find . -type f -print`
1772 if test -n "$remaining"; then
1773 echo "Remaining files:" $remaining 1>&2
1774 echo "gnulib-tool: *** Stop." 1>&2
1782 extract-description )
1786 if test -n "$module"; then
1787 func_get_description "$module"
1796 if test -n "$module"; then
1797 func_get_filelist "$module"
1802 extract-dependencies )
1806 if test -n "$module"; then
1807 func_get_dependencies "$module"
1812 extract-autoconf-snippet )
1816 if test -n "$module"; then
1817 func_get_autoconf_snippet "$module"
1822 extract-automake-snippet )
1826 if test -n "$module"; then
1827 func_get_automake_snippet "$module"
1832 extract-include-directive )
1836 if test -n "$module"; then
1837 func_get_include_directive "$module"
1846 if test -n "$module"; then
1847 func_get_license "$module"
1852 extract-maintainer )
1856 if test -n "$module"; then
1857 func_get_maintainer "$module"
1862 extract-tests-module )
1866 if test -n "$module"; then
1867 func_get_tests_module "$module"
1873 func_fatal_error "unknown operation mode --$mode" ;;