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-11 12:56:40 $'
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 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
41 AUTOCONF="${AUTOCONFPATH}autoconf"
42 ACLOCAL="${AUTOMAKEPATH}aclocal"
43 AUTOMAKE="${AUTOMAKEPATH}automake"
44 AUTORECONF="${AUTOCONFPATH}autoreconf"
47 # outputs to stdout the --help usage message.
51 Usage: gnulib-tool --list
52 gnulib-tool --import [module1 ... moduleN]
54 gnulib-tool --create-testdir --dir=directory module1 ... moduleN
55 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
56 gnulib-tool --test --dir=directory module1 ... moduleN
57 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
58 gnulib-tool --extract-description module
59 gnulib-tool --extract-filelist module
60 gnulib-tool --extract-dependencies module
61 gnulib-tool --extract-autoconf-snippet module
62 gnulib-tool --extract-automake-snippet module
63 gnulib-tool --extract-include-directive module
64 gnulib-tool --extract-license module
65 gnulib-tool --extract-maintainer module
66 gnulib-tool --extract-tests-module module
69 --list print the available module names
70 --import import the given modules into the current package
71 --create-testdir create a scratch package with the given modules
72 --create-megatestdir create a mega scratch package with the given modules
73 one by one and all together
74 --test test the combination of the given modules
75 (recommended to use CC=\"gcc -Wall\" here)
76 --megatest test the given modules one by one and all together
77 (recommended to use CC=\"gcc -Wall\" here)
78 --extract-description extract the description
79 --extract-filelist extract the list of files
80 --extract-dependencies extract the dependencies
81 --extract-autoconf-snippet extract the snippet for configure.ac
82 --extract-automake-snippet extract the snippet for lib/Makefile.am
83 --extract-include-directive extract the #include directive
84 --extract-license report the license terms of the source files
86 --extract-maintainer report the maintainer(s) inside gnulib
87 --extract-tests-module report the unit test module, if it exists
90 --dir=DIRECTORY specify the target directory
91 For --import, this specifies where your
92 configure.ac can be found. Defaults to current
94 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
95 --source-base=DIRECTORY
96 Directory relative --dir where source code is
97 placed (default \"lib\"), for --import.
98 --m4-base=DIRECTORY Directory relative --dir where *.m4 macros are
99 placed (default \"m4\"), for --import.
100 --tests-base=DIRECTORY
101 Directory relative --dir where unit tests are
102 placed (default \"tests\"), for --import.
103 --aux-dir=DIRECTORY Directory relative --dir where auxiliary build
104 tools are placed (default \"build-aux\").
105 --with-tests Include unit tests for the included modules.
106 --avoid=MODULE Avoid including the given MODULE. Useful if you
107 have code that provides equivalent functionality.
108 This option can be repeated.
109 --lgpl Abort if modules aren't available under the LGPL.
110 Also modify license template from GPL to LGPL.
111 --libtool Use libtool rules, for --import.
112 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
113 'gl_INIT'. Default is 'gl'.
114 --no-changelog don't update or create ChangeLog files
115 --dry-run For --import, only print what would have been done.
116 -s, --symbolic, --symlink Make symbolic links instead of copying files.
118 Report bugs to <bug-gnulib@gnu.org>."
122 # outputs to stdout the --version message.
125 echo "$progname (GNU $package) $version"
126 echo "Copyright (C) 2002-2005 Free Software Foundation, Inc.
127 This is free software; see the source for copying conditions. There is NO
128 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
129 echo "Written by" "Bruno Haible" "and" "Simon Josefsson"
133 # creates a temporary directory.
135 # - tmp pathname of freshly created temporary directory
138 # Use the environment variable TMPDIR, falling back to /tmp. This allows
139 # users to specify a different temporary directory, for example, if their
140 # /tmp is filled up or too small.
143 # Use the mktemp program if available. If not available, hide the error
145 tmp=`(umask 077 && mktemp -d -q "$TMPDIR/glXXXXXX") 2>/dev/null` &&
146 test -n "$tmp" && test -d "$tmp"
149 # Use a simple mkdir command. It is guaranteed to fail if the directory
150 # already exists. $RANDOM is bash specific and expands to empty in shells
151 # other than bash, ksh and zsh. Its use does not increase security;
152 # rather, it minimizes the probability of failure in a very cluttered /tmp
154 tmp=$TMPDIR/gl$$-$RANDOM
155 (umask 077 && mkdir "$tmp")
158 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
159 { (exit 1); exit 1; }
163 # func_fatal_error message
164 # outputs to stderr a fatal error message, and terminates the program.
167 echo "gnulib-tool: *** $1" 1>&2
168 echo "gnulib-tool: *** Stop." 1>&2
172 # func_readlink SYMLINK
173 # outputs the target of the given symlink.
174 if (type -p readlink) > /dev/null 2>&1; then
177 # Use the readlink program from GNU coreutils.
183 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
184 # would do the wrong thing if the link target contains " -> ".
185 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
189 # func_ln_if_changed SRC DEST
190 # Like ln -s, but avoids munging timestamps if the link is correct.
191 func_ln_if_changed ()
193 if test $# -ne 2; then
194 echo "usage: func_ln_if_changed SRC DEST" >&2
196 if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then
204 # Command-line option processing.
205 # Removes the OPTIONS from the arguments. Sets the variables:
206 # - mode list or import or create-testdir or create-megatestdir
207 # - destdir from --dir
208 # - libname, supplied_libname from --lib
209 # - sourcebase from --source-base
210 # - m4base from --m4-base
211 # - testsbase from --tests-base
212 # - auxdir from --aux-dir
213 # - inctests true if --with-tests was given, blank otherwise
214 # - avoidlist list of modules to avoid, from --avoid
215 # - lgpl true if --lgpl was given, blank otherwise
216 # - libtool true if --libtool was given, blank otherwise
217 # - do_changelog false if --no-changelog was given, : otherwise
218 # - doit : if actions shall be executed, false if only to be printed
239 while test $# -gt 0; do
244 --import | --impor | --impo | --imp | --im | --i )
247 --update | --updat | --upda | --upd | --up | --u )
250 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
253 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
254 mode=create-megatestdir
256 --test | --tes | --te | --t )
259 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
263 mode=`echo "X$1" | sed -e 's/^X--//'`
268 func_fatal_error "missing argument for --dir"
273 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
278 func_fatal_error "missing argument for --lib"
281 supplied_libname=true
284 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
285 supplied_libname=true
290 func_fatal_error "missing argument for --source-base"
295 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
300 func_fatal_error "missing argument for --m4-base"
305 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
310 func_fatal_error "missing argument for --tests-base"
315 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
320 func_fatal_error "missing argument for --aux-dir"
325 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
333 func_fatal_error "missing argument for --avoid"
335 avoidlist="$avoidlist $1"
338 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
349 func_fatal_error "missing argument for --macro-prefix"
354 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
356 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
362 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
365 --help | --hel | --he | --h )
368 --version | --versio | --versi | --vers | --ver | --ve | --v )
372 # Stop option processing
376 echo "gnulib-tool: unknown option $1" 1>&2
377 echo "Try 'gnulib-tool --help' for more information." 1>&2
384 if test "$mode" = update; then
385 if test $# != 0; then
386 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
387 echo "Try 'gnulib-tool --help' for more information." 1>&2
388 echo "If you really want to modify the gnulib configuration of your project," 1>&2
389 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
392 if test -n "$libname" || test -n "$sourcebase" || test -n "$m4base" \
393 || test -n "$testsbase" || test -n "$auxdir" || test -n "$inctests" \
394 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$macro_prefix"; then
395 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
396 echo "Try 'gnulib-tool --help' for more information." 1>&2
397 echo "If you really want to modify the gnulib configuration of your project," 1>&2
398 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
404 # Remove trailing slashes from the directory names. This is necessary for
405 # m4base (to avoid an error in func_import) and optional for the others.
406 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
407 case "$sourcebase" in
408 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
411 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
414 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
417 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
422 /*) self_abspathname="$0" ;;
423 */*) self_abspathname=`pwd`/"$0" ;;
424 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
425 if test -x "$d/$0" && test ! -d "$d/$0"; then
426 self_abspathname="$d/$0"
430 if test -z "$self_abspathname"; then
431 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
435 while test -h "$self_abspathname"; do
436 # Resolve symbolic link.
437 linkval=`func_readlink "$self_abspathname"`
438 test -n "$linkval" || break
440 /* ) self_abspathname="$linkval" ;;
441 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
444 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
449 # Filter out metainformation files like README, which are not modules.
450 # Filter out unit test modules; they can be retrieved through
451 # --extract-tests-module if desired.
452 (cd "$gnulib_dir/modules" && ls -1) \
453 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
454 | sed -e '/-tests$/d' \
459 # verifies a module name
460 func_verify_module ()
462 if test ! -f "$gnulib_dir/modules/$module" \
463 || test "CVS" = "$module" \
464 || test "ChangeLog" = "$module" \
465 || test "README" = "$module" \
466 || test "TEMPLATE" = "$module" \
467 || test "TEMPLATE-TESTS" = "$module"; then
468 echo "gnulib-tool: module $module doesn't exist" 1>&2
473 # func_verify_nontests_module
474 # verifies a module name, excluding tests modules
475 func_verify_nontests_module ()
479 * ) func_verify_module ;;
483 # func_verify_tests_module
484 # verifies a module name, considering only tests modules
485 func_verify_tests_module ()
488 *-tests ) func_verify_module ;;
493 sed_extract_prog=':[ ]*$/ {
496 s/^Description:[ ]*$//
498 s/^Depends-on:[ ]*$//
499 s/^configure\.ac:[ ]*$//
500 s/^Makefile\.am:[ ]*$//
503 s/^Maintainer:[ ]*$//
510 # func_get_description module
511 func_get_description ()
513 sed -n -e "/^Description$sed_extract_prog" < "$gnulib_dir/modules/$1"
516 # func_get_filelist module
519 sed -n -e "/^Files$sed_extract_prog" < "$gnulib_dir/modules/$1"
521 echo m4/onceonly_2_57.m4
524 # func_get_dependencies module
525 func_get_dependencies ()
527 # ${module}-tests always implicitly depends on ${module}.
528 echo "$1" | sed -n -e 's/-tests//p'
529 # Then the explicit dependencies listed in the module description.
530 sed -n -e "/^Depends-on$sed_extract_prog" < "$gnulib_dir/modules/$1"
533 # func_get_autoconf_snippet module
534 func_get_autoconf_snippet ()
536 sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
539 # func_get_automake_snippet module
540 func_get_automake_snippet ()
542 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$gnulib_dir/modules/$1"
545 # func_get_include_directive module
546 func_get_include_directive ()
548 sed -n -e "/^Include$sed_extract_prog" < "$gnulib_dir/modules/$1" | \
549 sed -e 's/^\(["<]\)/#include \1/'
552 # func_get_license module
555 sed -n -e "/^License$sed_extract_prog" < "$gnulib_dir/modules/$1"
558 # func_get_maintainer module
559 func_get_maintainer ()
561 sed -n -e "/^Maintainer$sed_extract_prog" < "$gnulib_dir/modules/$1"
564 # func_get_tests_module module
565 func_get_tests_module ()
567 # The naming convention for tests modules is hardwired: ${module}-tests.
568 if test -f modules/"$1"-tests; then
573 # func_acceptable module
574 # tests whether a module is acceptable.
576 # - avoidlist list of modules to avoid
579 for avoid in $avoidlist; do
580 if test "$avoid" = "$1"; then
587 # func_modules_transitive_closure
589 # - modules list of specified modules
590 # - inctests true if tests should be included, blank otherwise
591 # - avoidlist list of modules to avoid
593 # - modules list of modules, including dependencies
594 func_modules_transitive_closure ()
598 for module in $modules; do
600 if test -n "$module"; then
601 # Duplicate dependencies are harmless, but Jim wants a warning.
602 duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d`
603 if test -n "$duplicated_deps"; then
604 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
606 if func_acceptable $module; then
607 xmodules="$xmodules $module"
608 for depmodule in `func_get_dependencies $module`; do
609 if func_acceptable $depmodule; then
610 xmodules="$xmodules $depmodule"
613 if test -n "$inctests"; then
614 testsmodule=`func_get_tests_module $module`
615 if test -n "$testsmodule"; then
616 if func_acceptable $testsmodule; then
617 xmodules="$xmodules $testsmodule"
618 for depmodule in `func_get_dependencies $testsmodule`; do
619 if func_acceptable $depmodule; then
620 xmodules="$xmodules $depmodule"
629 xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
630 if test "$xmodules" = "$modules"; then
637 # func_modules_to_filelist
639 # - modules list of modules, including dependencies
641 # - files list of files
642 func_modules_to_filelist ()
645 for module in $modules; do
647 if test -n "$module"; then
648 files="$files "`func_get_filelist $module`
651 files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
654 # func_emit_lib_Makefile_am
655 # emits the contents of lib/Makefile.am to standard output.
657 # - modules list of modules, including dependencies
658 # - libname library name
659 # - libtool true if libtool will be used, blank otherwise
660 # - actioncmd (optional) command that will reproduce this invocation
661 func_emit_lib_Makefile_am ()
663 if test -n "$libtool"; then
670 echo "## Process this file with automake to produce Makefile.in."
671 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
673 echo "# This file is free software, distributed under the terms of the GNU"
674 echo "# General Public License. As a special exception to the GNU General"
675 echo "# Public License, this file may be distributed as part of a program"
676 echo "# that contains a configuration script generated by Automake, under"
677 echo "# the same distribution terms as the rest of that program."
679 echo "# Generated by gnulib-tool."
680 if test -n "$actioncmd"; then
681 echo "# Reproduce by: $actioncmd"
684 # No need to generate dependencies since the sources are in gnulib, not here.
685 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
687 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
689 echo "${libname}_${libext}_SOURCES ="
690 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
692 echo "BUILT_SOURCES ="
694 echo "MOSTLYCLEANFILES ="
696 echo "DISTCLEANFILES ="
697 echo "MAINTAINERCLEANFILES ="
699 for module in $modules; do
700 func_verify_nontests_module
701 if test -n "$module"; then
703 func_get_automake_snippet "$module" |
704 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
705 if test "$module" = 'alloca'; then
706 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
709 # Skip the contents if its entirely empty.
710 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
711 echo "## begin gnulib module $module"
714 echo "## end gnulib module $module"
721 echo "# Makefile.am ends here"
724 # func_emit_tests_Makefile_am
725 # emits the contents of tests/Makefile.am to standard output.
727 # - modules list of modules, including dependencies
728 # - libname library name
729 # - libtool true if libtool will be used, blank otherwise
730 # - sourcebase relative directory containing lib source code
731 # - m4base relative directory containing autoconf macros
732 # - testsbase relative directory containing unit test code
733 func_emit_tests_Makefile_am ()
735 if test -n "$libtool"; then
740 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
741 echo "## Process this file with automake to produce Makefile.in."
742 echo "# Copyright (C) 2004-2005 Free Software Foundation, Inc."
744 echo "# This file is free software, distributed under the terms of the GNU"
745 echo "# General Public License. As a special exception to the GNU General"
746 echo "# Public License, this file may be distributed as part of a program"
747 echo "# that contains a configuration script generated by Automake, under"
748 echo "# the same distribution terms as the rest of that program."
750 echo "# Generated by gnulib-tool."
752 # Generate dependencies here, since it eases the debugging of test failures.
753 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
755 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
757 # Nothing is being added to SUBDIRS; nevertheless the existence of this
758 # variable is needed to avoid an error from automake:
759 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
762 echo "TESTS_ENVIRONMENT ="
763 echo "noinst_PROGRAMS ="
765 echo "BUILT_SOURCES ="
767 echo "MOSTLYCLEANFILES ="
769 echo "DISTCLEANFILES ="
770 echo "MAINTAINERCLEANFILES ="
772 echo "AM_CPPFLAGS = \\"
773 echo " -I. -I\$(srcdir) \\"
774 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
775 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
777 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
779 for module in $modules; do
780 func_verify_tests_module
781 if test -n "$module"; then
782 func_get_automake_snippet "$module" > amsnippet.tmp
783 # Skip the contents if its entirely empty.
784 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
785 echo "## begin gnulib module $module"
788 echo "## end gnulib module $module"
794 echo "# Clean up after Solaris cc."
796 echo " rm -rf SunWS_cache"
798 echo "# Makefile.am ends here"
801 # func_import modules
802 # Uses also the variables
803 # - destdir target directory
804 # - libname library name
805 # - sourcebase directory relative to destdir where to place source code
806 # - m4base directory relative to destdir where to place *.m4 macros
807 # - testsbase directory relative to destdir where to place unit test code
808 # - auxdir directory relative to destdir where to place build aux files
809 # - inctests true if --with-tests was given, blank otherwise
810 # - avoidlist list of modules to avoid, from --avoid
811 # - lgpl true if library's license shall be LGPL, blank otherwise
812 # - libtool true if libtool will be used, blank otherwise
813 # - guessed_libtool true if the configure.ac file uses libtool, blank otherwise
814 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
815 # - doit : if actions shall be executed, false if only to be printed
816 # - symbolic true if files should be symlinked, copied otherwise
819 # Get the cached settings.
820 cached_specified_modules=
830 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
836 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
839 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
842 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
845 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
848 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
851 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
854 s,^.*$,cached_lgpl=true,p
857 s,^.*$,cached_libtool=true,p
860 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
862 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
863 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
868 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
869 s,^.*$,cached_files=",p
881 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
885 # Merge the cached settings with the specified ones.
886 # The m4base must be the same as expected from the pathname.
887 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
888 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
890 # Append the cached and the specified module names. So that
891 # "gnulib-tool --import foo" means to add the module foo.
892 specified_modules="$cached_specified_modules $1"
893 # Append the cached and the specified avoidlist. This is probably better
894 # than dropping the cached one when --avoid is specified at least once.
895 avoidlist=`echo $cached_avoidlist $avoidlist`
896 # The sourcebase defaults to the cached one.
897 if test -z "$sourcebase"; then
898 sourcebase="$cached_sourcebase"
899 if test -z "$sourcebase"; then
900 func_fatal_error "missing --source-base option"
903 # The testsbase defaults to the cached one.
904 if test -z "$testsbase"; then
905 testsbase="$cached_testsbase"
906 if test -z "$testsbase"; then
907 func_fatal_error "missing --tests-base option"
910 # The libname defaults to the cached one.
911 if test -z "$supplied_libname"; then
912 libname="$cached_libname"
913 if test -z "$libname"; then
914 func_fatal_error "missing --lib option"
917 # Require LGPL if specified either way.
918 if test -z "$lgpl"; then
921 # Use libtool if specified either way, or if guessed.
922 if test -z "$libtool"; then
923 if test -n "$cached_m4base"; then
924 libtool="$cached_libtool"
926 libtool="$guessed_libtool"
929 # The macro_prefix defaults to the cached one.
930 if test -z "$macro_prefix"; then
931 macro_prefix="$cached_macro_prefix"
932 if test -z "$macro_prefix"; then
933 func_fatal_error "missing --macro-prefix option"
937 # Canonicalize the list of specified modules.
938 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
940 # Determine final module list.
941 modules="$specified_modules"
942 func_modules_transitive_closure
943 echo "Module list with included dependencies:"
944 echo "$modules" | sed -e 's/^/ /'
946 # If --lgpl, check the license of modules are compatible.
947 if test -n "$lgpl"; then
948 for module in $modules; do
949 license=`func_get_license $module`
951 LGPL | 'GPLed build tool' | 'public domain' | 'unlimited') ;;
952 *) func_fatal_error "incompatible license on module $module: $license" ;;
957 # Determine final file list.
958 func_modules_to_filelist
960 echo "$files" | sed -e 's/^/ /'
963 || func_fatal_error "refusing to do nothing"
965 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
966 new_files="$files m4/gnulib-tool.m4"
967 old_files="$cached_files"
968 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
969 old_files="$old_files m4/gnulib-tool.m4"
972 # Create directories.
973 if test ! -d "$destdir/$sourcebase"; then
975 echo "Creating directory $destdir/$sourcebase"
976 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
978 echo "Create directory $destdir/$sourcebase"
981 if test ! -d "$destdir/$m4base"; then
983 echo "Creating directory $destdir/$m4base"
984 mkdir "$destdir/$m4base" || func_fatal_error "failed"
986 echo "Create directory $destdir/$m4base"
989 if test -n "$inctests"; then
990 if test ! -d "$destdir/$testsbase"; then
992 echo "Creating directory $destdir/$testsbase"
993 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
995 echo "Create directory $destdir/$testsbase"
999 if test ! -d "$destdir/$auxdir"; then
1001 echo "Creating directory $destdir/$auxdir"
1002 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
1004 echo "Create directory $destdir/$auxdir"
1008 # Copy files or make symbolic links. Remove obsolete files.
1010 trap 'rm -rf "$tmp"' 0 1 2 3 15
1012 for f in $old_files; do
1014 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1015 lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
1016 m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
1017 tests/*) g=`echo "$f" | sed -e "s,^tests/,$cached_testsbase/,"` ;;
1020 echo "$g""$delimiter""$f"
1021 done | LC_ALL=C sort > "$tmp"/old-files
1022 for f in $new_files; do
1024 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1025 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1026 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1027 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1030 echo "$g""$delimiter""$f"
1031 done | LC_ALL=C sort > "$tmp"/new-files
1032 # First the files that are in old-files, but not in new-files:
1033 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e 's,'"$delimiter"'.*,,'`; do
1034 # Remove the file. Do nothing if the user already removed it.
1035 if test -f "$destdir/$g"; then
1037 echo "Removing file $g (backup in ${g}~)"
1038 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1040 echo "Remove file $g (backup in ${g}~)"
1044 # func_add_or_update handles a file that ought to be present afterwards.
1045 # Uses parameters f, g, already_present.
1046 func_add_or_update ()
1048 cp "$gnulib_dir/$f" "$destdir/$g.tmp" || func_fatal_error "failed"
1049 if test -n "$lgpl"; then
1053 sed -e 's/GNU General/GNU Lesser General/g' \
1054 -e 's/version 2\([ ,]\)/version 2.1\1/g' \
1055 < "$gnulib_dir/$f" > "$destdir/$g.tmp" || func_fatal_error "failed"
1059 if test -f "$destdir/$g"; then
1060 # The file already exists.
1061 if cmp "$destdir/$g" "$destdir/$g.tmp" > /dev/null; then
1062 : # The file has not changed.
1066 if test -n "$already_present"; then
1067 echo "Updating file $g (backup in ${g}~)"
1069 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1071 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1072 if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$destdir/$g.tmp" > /dev/null; then
1073 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
1075 mv -f "$destdir/$g.tmp" "$destdir/${g}" || func_fatal_error "failed"
1078 if test -n "$already_present"; then
1079 echo "Update file $g (backup in ${g}~)"
1081 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1087 # Don't protest if the file should be there but isn't: it happens
1088 # frequently that developers don't put autogenerated files into CVS.
1090 echo "Copying file $g"
1091 if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$destdir/$g.tmp" > /dev/null; then
1092 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
1094 mv -f "$destdir/$g.tmp" "$destdir/${g}" || func_fatal_error "failed"
1100 rm -f "$destdir/$g.tmp"
1102 # Then the files that are in new-files, but not in old-files:
1104 for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e 's,'^.*"$delimiter"',,'`; do
1106 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1107 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1108 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1109 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1114 # Then the files that are in new-files and in old-files:
1115 already_present=true
1116 for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e 's,'^.*"$delimiter"',,'`; do
1118 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1119 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1120 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1121 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1129 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1130 actioncmd="gnulib-tool --import"
1131 actioncmd="$actioncmd --dir=$destdir"
1132 actioncmd="$actioncmd --lib=$libname"
1133 actioncmd="$actioncmd --source-base=$sourcebase"
1134 actioncmd="$actioncmd --m4-base=$m4base"
1135 actioncmd="$actioncmd --aux-dir=$auxdir"
1136 for module in $avoidlist; do
1137 actioncmd="$actioncmd --avoid=$module"
1139 if test -n "$lgpl"; then
1140 actioncmd="$actioncmd --lgpl"
1142 if test -n "$libtool"; then
1143 actioncmd="$actioncmd --libtool"
1145 actioncmd="$actioncmd --macro-prefix=$macro_prefix"
1146 actioncmd="$actioncmd `echo $specified_modules`"
1148 # Create lib/Makefile.am.
1149 func_emit_lib_Makefile_am > "$destdir"/$sourcebase/Makefile.am.tmp
1150 if test -f "$destdir"/$sourcebase/Makefile.am; then
1151 if cmp "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am.tmp > /dev/null; then
1152 rm -f "$destdir"/$sourcebase/Makefile.am.tmp
1155 echo "Updating $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1156 mv -f "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am~
1157 mv -f "$destdir"/$sourcebase/Makefile.am.tmp "$destdir"/$sourcebase/Makefile.am
1159 echo "Update $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1160 rm -f "$destdir"/$sourcebase/Makefile.am.tmp
1165 echo "Creating $sourcebase/Makefile.am"
1166 mv -f "$destdir"/$sourcebase/Makefile.am.tmp "$destdir"/$sourcebase/Makefile.am
1168 echo "Create $sourcebase/Makefile.am"
1169 rm -f "$destdir"/$sourcebase/Makefile.am.tmp
1173 # Create m4/gnulib-cache.m4.
1175 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
1176 echo "# This file is free software, distributed under the terms of the GNU"
1177 echo "# General Public License. As a special exception to the GNU General"
1178 echo "# Public License, this file may be distributed as part of a program"
1179 echo "# that contains a configuration script generated by Autoconf, under"
1180 echo "# the same distribution terms as the rest of that program."
1182 echo "# Generated by gnulib-tool."
1184 echo "# This file represents the specification of how gnulib-tool is used."
1185 echo "# It acts as a cache: It is written and read by gnulib-tool."
1186 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1187 echo "# like the configure.ac and various Makefile.am files."
1190 echo "# Specification in the form of a command-line invocation:"
1193 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1194 echo "gl_MODULES(["`echo $specified_modules`"])"
1195 echo "gl_AVOID([$avoidlist])"
1196 echo "gl_SOURCE_BASE([$sourcebase])"
1197 echo "gl_M4_BASE([$m4base])"
1198 echo "gl_TESTS_BASE([$testsbase])"
1199 echo "gl_LIB([$libname])"
1200 test -z "$lgpl" || echo "gl_LGPL"
1201 test -z "$libtool" || echo "gl_LIBTOOL"
1202 echo "gl_MACRO_PREFIX([$macro_prefix])"
1203 ) > "$destdir"/$m4base/gnulib-cache.m4.tmp
1204 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1205 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4.tmp > /dev/null; then
1206 rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
1209 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1210 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1211 mv -f "$destdir"/$m4base/gnulib-cache.m4.tmp "$destdir"/$m4base/gnulib-cache.m4
1213 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1215 cat "$destdir"/$m4base/gnulib-cache.m4.tmp
1217 echo "# gnulib-cache.m4 ends here"
1219 rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
1224 echo "Creating $m4base/gnulib-cache.m4"
1225 mv -f "$destdir"/$m4base/gnulib-cache.m4.tmp "$destdir"/$m4base/gnulib-cache.m4
1227 echo "Create $m4base/gnulib-cache.m4"
1228 cat "$destdir"/$m4base/gnulib-cache.m4.tmp
1229 rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
1233 # Create m4/gnulib-comp.m4.
1235 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
1236 echo "# This file is free software, distributed under the terms of the GNU"
1237 echo "# General Public License. As a special exception to the GNU General"
1238 echo "# Public License, this file may be distributed as part of a program"
1239 echo "# that contains a configuration script generated by Autoconf, under"
1240 echo "# the same distribution terms as the rest of that program."
1242 echo "# Generated by gnulib-tool."
1244 echo "# This file represents the compiled summary of the specification in"
1245 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1246 echo "# to be invoked from configure.ac."
1247 echo "# In projects using CVS, this file can be treated like other built files."
1250 echo "# This macro should be invoked from $configure_ac, in the section"
1251 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1252 echo "# any checks for libraries, header files, types and library functions."
1253 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1255 echo " AC_REQUIRE([AC_PROG_RANLIB])"
1256 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
1257 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1259 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
1260 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1264 echo "# This macro should be invoked from $configure_ac, in the section"
1265 echo "# \"Check for header files, types and library functions\"."
1266 echo "AC_DEFUN([${macro_prefix}_INIT],"
1268 if test -z "$libtool"; then
1269 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1271 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1273 sed_replace_build_aux='
1275 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1276 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1279 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1280 for module in $modules; do
1282 if test -n "$module"; then
1283 func_get_autoconf_snippet "$module" \
1284 | sed -e '/^$/d;' -e 's/^/ /' \
1285 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
1286 -e "$sed_replace_build_aux"
1287 if test "$module" = 'alloca' && test -n "$libtool"; then
1288 echo 'changequote(,)dnl'
1289 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1290 echo 'changequote([, ])dnl'
1291 echo 'AC_SUBST([LTALLOCA])'
1297 echo "# This macro records the list of files which have been installed by"
1298 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1299 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1300 echo "$files" | sed -e 's,^, ,'
1302 ) > "$destdir"/$m4base/gnulib-comp.m4.tmp
1303 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1304 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4.tmp > /dev/null; then
1305 rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
1308 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1309 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1310 mv -f "$destdir"/$m4base/gnulib-comp.m4.tmp "$destdir"/$m4base/gnulib-comp.m4
1312 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1314 cat "$destdir"/$m4base/gnulib-comp.m4.tmp
1316 echo "# gnulib-comp.m4 ends here"
1318 rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
1323 echo "Creating $m4base/gnulib-comp.m4"
1324 mv -f "$destdir"/$m4base/gnulib-comp.m4.tmp "$destdir"/$m4base/gnulib-comp.m4
1326 echo "Create $m4base/gnulib-comp.m4"
1327 cat "$destdir"/$m4base/gnulib-comp.m4.tmp
1328 rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
1332 if test -n "$inctests"; then
1333 # Create tests/Makefile.am.
1334 func_emit_tests_Makefile_am > "$destdir"/$testsbase/Makefile.am.tmp
1335 if test -f "$destdir"/$testsbase/Makefile.am; then
1336 if cmp "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am.tmp > /dev/null; then
1337 rm -f "$destdir"/$testsbase/Makefile.am.tmp
1340 echo "Updating $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1341 mv -f "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am~
1342 mv -f "$destdir"/$testsbase/Makefile.am.tmp "$destdir"/$testsbase/Makefile.am
1344 echo "Update $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1345 rm -f "$destdir"/$testsbase/Makefile.am.tmp
1350 echo "Creating $testsbase/Makefile.am"
1351 mv -f "$destdir"/$testsbase/Makefile.am.tmp "$destdir"/$testsbase/Makefile.am
1353 echo "Create $testsbase/Makefile.am"
1354 rm -f "$destdir"/$testsbase/Makefile.am.tmp
1361 echo "You may need to add #include directives for the following .h files."
1362 for module in $modules; do
1363 func_get_include_directive "$module"
1364 done | LC_ALL=C sort -u | sed -e '/^$/d;' -e 's/^/ /'
1366 echo "Don't forget to"
1367 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1368 if test -n "$inctests"; then
1369 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1371 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
1372 sourcebase_base=`basename "$sourcebase"`
1373 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
1374 if test -n "$inctests"; then
1375 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
1376 testsbase_base=`basename "$testsbase"`
1377 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
1379 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
1380 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
1381 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
1384 # func_create_testdir testdir modules
1386 # - auxdir directory relative to destdir where to place build aux files
1387 func_create_testdir ()
1391 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1393 # Determine final module list.
1394 func_modules_transitive_closure
1395 echo "Module list with included dependencies:"
1396 echo "$modules" | sed -e 's/^/ /'
1398 # Determine final file list.
1399 func_modules_to_filelist
1401 echo "$files" | sed -e 's/^/ /'
1403 # Create directories.
1404 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
1405 if test "$d" = build-aux; then
1406 mkdir -p "$testdir/$auxdir"
1408 mkdir -p "$testdir/$d"
1412 # Copy files or make symbolic links.
1415 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1418 ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
1419 if test -z "$symbolic"; then
1420 cp -p "$gnulib_dir/$f" "$testdir/$g"
1422 ln -s "$gnulib_dir/$f" "$testdir/$g"
1426 # Create lib/Makefile.am.
1427 mkdir -p "$testdir/lib"
1428 func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
1430 # Create m4/Makefile.am.
1431 mkdir -p "$testdir/m4"
1432 (echo "## Process this file with automake to produce Makefile.in."
1438 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
1441 ) > "$testdir/m4/Makefile.am"
1444 subdirs_with_configure_ac=""
1446 if test -f "$testdir"/m4/gettext.m4; then
1447 # Avoid stupid error message from automake:
1448 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
1449 mkdir -p "$testdir/po"
1450 (echo "## Process this file with automake to produce Makefile.in."
1451 ) > "$testdir/po/Makefile.am"
1452 subdirs="$subdirs po"
1455 if test -n "$inctests"; then
1456 test -d "$testdir/tests" || mkdir "$testdir/tests"
1457 # Create tests/Makefile.am.
1461 func_emit_tests_Makefile_am > "$testdir/tests/Makefile.am"
1462 # Create tests/configure.ac.
1463 (echo "# Process this file with autoconf to produce a configure script."
1464 echo "AC_INIT([dummy], [0])"
1465 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
1466 echo "AM_INIT_AUTOMAKE"
1468 echo "AM_CONFIG_HEADER([config.h])"
1471 echo "AC_PROG_INSTALL"
1472 echo "AC_PROG_MAKE_SET"
1473 echo "AC_PROG_RANLIB"
1475 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
1476 echo "AC_GNU_SOURCE"
1479 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
1480 echo "gl_USE_SYSTEM_EXTENSIONS"
1483 if test -z "$libtool"; then
1484 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1486 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1488 sed_replace_build_aux='
1490 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1491 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
1494 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1495 # We don't have explicit ordering constraints between the various
1496 # autoconf snippets. It's cleanest to put those of the library before
1497 # those of the tests.
1498 for module in $modules; do
1499 func_verify_nontests_module
1500 if test -n "$module"; then
1501 func_get_autoconf_snippet "$module" \
1502 | sed -e "$sed_replace_build_aux"
1505 for module in $modules; do
1506 func_verify_tests_module
1507 if test -n "$module"; then
1508 func_get_autoconf_snippet "$module" \
1509 | sed -e "$sed_replace_build_aux"
1513 # Usually tests/config.h will be a superset of config.h. Verify this by
1514 # "merging" config.h into tests/config.h; look out for gcc warnings.
1515 echo "AH_TOP([#include \"../config.h\"])"
1517 echo "AC_OUTPUT([Makefile])"
1518 ) > "$testdir/tests/configure.ac"
1519 subdirs="$subdirs tests"
1520 subdirs_with_configure_ac="$subdirs_with_configure_ac tests"
1523 # Create Makefile.am.
1524 (echo "## Process this file with automake to produce Makefile.in."
1526 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1528 echo "SUBDIRS = $subdirs"
1530 echo "ACLOCAL_AMFLAGS = -I m4"
1531 ) > "$testdir/Makefile.am"
1533 # Create configure.ac.
1534 (echo "# Process this file with autoconf to produce a configure script."
1535 echo "AC_INIT([dummy], [0])"
1536 if test "$auxdir" != "."; then
1537 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1539 echo "AM_INIT_AUTOMAKE"
1541 echo "AM_CONFIG_HEADER([config.h])"
1544 echo "AC_PROG_INSTALL"
1545 echo "AC_PROG_MAKE_SET"
1546 echo "AC_PROG_RANLIB"
1548 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
1549 echo "AC_GNU_SOURCE"
1552 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
1553 echo "gl_USE_SYSTEM_EXTENSIONS"
1556 if test -z "$libtool"; then
1557 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1559 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1561 sed_replace_build_aux='
1563 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1564 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1567 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1568 for module in $modules; do
1569 func_verify_nontests_module
1570 if test -n "$module"; then
1571 func_get_autoconf_snippet "$module" \
1572 | sed -e "$sed_replace_build_aux"
1576 if test -n "$subdirs_with_configure_ac"; then
1577 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
1579 makefiles="Makefile"
1580 for d in $subdirs; do
1581 # For subdirs that have a configure.ac by their own, it's the subdir's
1582 # configure.ac which creates the subdir's Makefile.am, not this one.
1583 case " $subdirs_with_configure_ac " in
1585 *) makefiles="$makefiles $d/Makefile" ;;
1588 echo "AC_OUTPUT([$makefiles])"
1589 ) > "$testdir/configure.ac"
1591 # Create autogenerated files.
1593 echo "executing ${AUTORECONF} --force --install"
1594 ${AUTORECONF} --force --install
1596 if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
1600 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
1608 # func_create_megatestdir megatestdir allmodules
1610 # - auxdir directory relative to destdir where to place build aux files
1611 func_create_megatestdir ()
1615 if test -z "$allmodules"; then
1616 allmodules=`func_all_modules`
1620 # First, all modules one by one.
1621 for onemodule in $allmodules; do
1622 func_create_testdir "$megatestdir/$onemodule" $onemodule
1623 megasubdirs="${megasubdirs}$onemodule "
1625 # Then, all modules all together.
1626 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
1627 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
1628 func_create_testdir "$megatestdir/ALL" "$allmodules"
1629 megasubdirs="${megasubdirs}ALL"
1631 # Create Makefile.am.
1632 (echo "## Process this file with automake to produce Makefile.in."
1634 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1636 echo "SUBDIRS = $megasubdirs"
1637 ) > "$megatestdir/Makefile.am"
1639 # Create configure.ac.
1640 (echo "# Process this file with autoconf to produce a configure script."
1641 echo "AC_INIT([dummy], [0])"
1642 if test "$auxdir" != "."; then
1643 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1645 echo "AM_INIT_AUTOMAKE"
1647 echo "AC_PROG_MAKE_SET"
1649 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
1650 echo "AC_OUTPUT([Makefile])"
1651 ) > "$megatestdir/configure.ac"
1653 # Create autogenerated files.
1655 # Do not use "${AUTORECONF} --install", because autoreconf operates
1656 # recursively, but the subdirectories are already finished, therefore
1657 # calling autoreconf here would only waste lots of CPU time.
1658 echo "executing ${ACLOCAL}"
1660 echo "executing mkdir build-aux"
1662 echo "executing ${AUTOCONF}"
1664 echo "executing ${AUTOMAKE} --add-missing --copy"
1665 ${AUTOMAKE} --add-missing --copy
1671 func_fatal_error "no mode specified" ;;
1680 if test -z "$destdir"; then
1683 test -d "$destdir" \
1684 || func_fatal_error "destination directory does not exist: $destdir"
1686 # Prefer configure.ac to configure.in.
1687 if test -f "$destdir"/configure.ac; then
1688 configure_ac="$destdir/configure.ac"
1690 if test -f "$destdir"/configure.in; then
1691 configure_ac="$destdir/configure.in"
1693 func_fatal_error "cannot find $destdir/configure.ac"
1697 test -f "$destdir"/Makefile.am \
1698 || func_fatal_error "cannot find $destdir/Makefile.am"
1700 # Analyze configure.ac.
1707 /AC_CONFIG_AUX_DIR/ {
1708 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
1710 /A[CM]_PROG_LIBTOOL/ {
1711 s,^.*$,guessed_libtool=true,p
1713 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
1715 if test -z "$auxdir"; then
1716 auxdir="$guessed_auxdir"
1719 # Determine where to apply func_import.
1720 if test -n "$m4base"; then
1721 # Apply func_import to a particular gnulib directory.
1722 # Any number of additional modules can be given.
1723 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
1724 # First use of gnulib in the given m4base.
1725 test -n "$supplied_libname" || supplied_libname=true
1726 test -n "$sourcebase" || sourcebase="lib"
1727 test -n "$testsbase" || testsbase="tests"
1728 test -n "$macro_prefix" || macro_prefix="gl"
1732 # Apply func_import to all gnulib directories.
1733 # To get this list of directories, look at Makefile.am. (Not at
1734 # configure, because it may be omitted from CVS. Also, don't run
1735 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
1736 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
1740 for arg in $aclocal_amflags; do
1741 if test -n "$m4dir_is_next"; then
1742 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
1746 if test -f "$destdir/$arg"/gnulib-cache.m4; then
1747 m4dirs="$m4dirs $arg"
1748 m4dirs_count=`expr $m4dirs_count + 1`
1753 if test "X$arg" = "X-I"; then
1760 if test $m4dirs_count = 0; then
1761 # First use of gnulib in a package.
1762 # Any number of additional modules can be given.
1763 test -n "$supplied_libname" || supplied_libname=true
1764 test -n "$sourcebase" || sourcebase="lib"
1766 test -n "$testsbase" || testsbase="tests"
1767 test -n "$macro_prefix" || macro_prefix="gl"
1770 if test $m4dirs_count = 1; then
1771 # There's only one use of gnulib here. Assume the user means it.
1772 # Any number of additional modules can be given.
1773 for m4base in $m4dirs; do
1777 # Ambiguous - guess what the user meant.
1778 if test $# = 0; then
1779 # No further arguments. Guess the user wants to update all of them.
1780 for m4base in $m4dirs; do
1785 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
1793 if test -z "$destdir"; then
1794 func_fatal_error "please specify --dir option"
1797 test -d "$destdir" \
1798 || func_fatal_error "could not create destination directory"
1799 test -n "$auxdir" || auxdir="build-aux"
1800 func_create_testdir "$destdir" "$*"
1803 create-megatestdir )
1804 if test -z "$destdir"; then
1805 func_fatal_error "please specify --dir option"
1807 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1808 test -n "$auxdir" || auxdir="build-aux"
1809 func_create_megatestdir "$destdir" "$*"
1813 test -n "$destdir" || destdir=testdir$$
1814 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1815 test -n "$auxdir" || auxdir="build-aux"
1816 func_create_testdir "$destdir" "$*"
1824 remaining=`find . -type f -print`
1825 if test -n "$remaining"; then
1826 echo "Remaining files:" $remaining 1>&2
1827 echo "gnulib-tool: *** Stop." 1>&2
1836 test -n "$destdir" || destdir=testdir$$
1837 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1838 test -n "$auxdir" || auxdir="build-aux"
1839 func_create_megatestdir "$destdir" "$*"
1847 remaining=`find . -type f -print`
1848 if test -n "$remaining"; then
1849 echo "Remaining files:" $remaining 1>&2
1850 echo "gnulib-tool: *** Stop." 1>&2
1858 extract-description )
1862 if test -n "$module"; then
1863 func_get_description "$module"
1872 if test -n "$module"; then
1873 func_get_filelist "$module"
1878 extract-dependencies )
1882 if test -n "$module"; then
1883 func_get_dependencies "$module"
1888 extract-autoconf-snippet )
1892 if test -n "$module"; then
1893 func_get_autoconf_snippet "$module"
1898 extract-automake-snippet )
1902 if test -n "$module"; then
1903 func_get_automake_snippet "$module"
1908 extract-include-directive )
1912 if test -n "$module"; then
1913 func_get_include_directive "$module"
1922 if test -n "$module"; then
1923 func_get_license "$module"
1928 extract-maintainer )
1932 if test -n "$module"; then
1933 func_get_maintainer "$module"
1938 extract-tests-module )
1942 if test -n "$module"; then
1943 func_get_tests_module "$module"
1949 func_fatal_error "unknown operation mode --$mode" ;;