diff --git a/common/mlstdutils/Makefile.am b/common/mlstdutils/Makefile.am index 9e0b34d42..303c87c93 100644 --- a/common/mlstdutils/Makefile.am +++ b/common/mlstdutils/Makefile.am @@ -33,8 +33,6 @@ SOURCES_ML = \ stringMap.ml \ std_utils.ml -if HAVE_OCAML - # We pretend that we're building a C library. automake handles the # compilation of the C sources for us. At the end we take the C # objects and OCaml objects and link them into the OCaml library. @@ -146,6 +144,4 @@ depend: .depend -include .depend -endif - .PHONY: depend docs diff --git a/docs/guestfs-building.pod b/docs/guestfs-building.pod index 68197e578..493a92b9e 100644 --- a/docs/guestfs-building.pod +++ b/docs/guestfs-building.pod @@ -120,8 +120,7 @@ I. Part of Perl core. =item OCaml findlib -I if compiling from git. -Optional (but recommended) if compiling from tarball. +I. =item autoconf @@ -600,8 +599,12 @@ See L below. Disable specific language bindings, even if C<./configure> finds all the necessary libraries are installed so that they could be compiled. -Note that disabling OCaml or Perl will have the knock-on effect of -disabling large numbers of virt tools and parts of the test suite. +Note that disabling OCaml (bindings) or Perl will have the knock-on +effect of disabling parts of the test suite and some tools. + +OCaml is required to build libguestfs and this requirement cannot be +removed. Using I<--disable-ocaml> only disables the bindings and +OCaml tools. =item B<--disable-fuse> diff --git a/generator/Makefile.am b/generator/Makefile.am index 3f54ad51d..344ba9bcb 100644 --- a/generator/Makefile.am +++ b/generator/Makefile.am @@ -177,8 +177,6 @@ OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) noinst_PROGRAM = generator -if HAVE_OCAML - generator: $(objects) $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -linkpkg $^ -o $@ @@ -196,19 +194,6 @@ depend: .depend -include .depend -else - -# No OCaml compiler. Just replace the generator with a script that -# prints a warning. - -generator: - rm -f $@ $@-t - echo 'echo Warning: Install OCaml compiler in order to rebuild the generated files.' > $@-t - chmod +x $@-t - mv $@-t $@ - -endif - noinst_DATA = stamp-generator # Run the generator. diff --git a/m4/guestfs_ocaml.m4 b/m4/guestfs_ocaml.m4 index c18a3de40..a5118c9fa 100644 --- a/m4/guestfs_ocaml.m4 +++ b/m4/guestfs_ocaml.m4 @@ -15,55 +15,52 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -dnl Check for OCaml (optional, for OCaml bindings and OCaml tools). -OCAMLC=no -OCAMLFIND=no +dnl Check for OCaml (required, for OCaml bindings and OCaml tools). + +dnl OCAMLC and OCAMLFIND have to be unset first, otherwise +dnl AC_CHECK_TOOL (inside AC_PROG_OCAML) will not look. +OCAMLC= +OCAMLFIND= +AC_PROG_OCAML +AC_PROG_FINDLIB + +AS_IF([test "x$OCAMLC" = "xno"],[ + AC_MSG_ERROR([OCaml compiler is required]) +]) + +AS_IF([test "x$OCAMLFIND" = "xno"],[ + AC_MSG_ERROR([OCaml findlib is required]) +]) + +dnl --disable-ocaml only disables OCaml bindings and OCaml virt tools. AC_ARG_ENABLE([ocaml], - AS_HELP_STRING([--disable-ocaml], [disable OCaml language bindings]), + AS_HELP_STRING([--disable-ocaml], [disable OCaml language bindings and tools]), [], [enable_ocaml=yes]) -AS_IF([test "x$enable_ocaml" != "xno"],[ - dnl OCAMLC and OCAMLFIND have to be unset first, otherwise - dnl AC_CHECK_TOOL (inside AC_PROG_OCAML) will not look. - OCAMLC= - OCAMLFIND= - AC_PROG_OCAML - AC_PROG_FINDLIB - dnl OCaml >= 3.11 is required. - AC_MSG_CHECKING([if OCaml version >= 3.11]) - ocaml_major="`echo $OCAMLVERSION | $AWK -F. '{print $1}'`" - ocaml_minor="`echo $OCAMLVERSION | $AWK -F. '{print $2}'`" - AS_IF([test "$ocaml_major" -ge 4 || ( test "$ocaml_major" -eq 3 && test "$ocaml_minor" -ge 11 )],[ - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - AC_MSG_FAILURE([OCaml compiler is not new enough. At least OCaml 3.11 is required]) - ]) +dnl OCaml >= 3.11 is required. +AC_MSG_CHECKING([if OCaml version >= 3.11]) +ocaml_major="`echo $OCAMLVERSION | $AWK -F. '{print $1}'`" +ocaml_minor="`echo $OCAMLVERSION | $AWK -F. '{print $2}'`" +AS_IF([test "$ocaml_major" -ge 4 || ( test "$ocaml_major" -eq 3 && test "$ocaml_minor" -ge 11 )],[ + AC_MSG_RESULT([yes]) +],[ + AC_MSG_RESULT([no]) + AC_MSG_FAILURE([OCaml compiler is not new enough. At least OCaml 3.11 is required]) ]) + AM_CONDITIONAL([HAVE_OCAML], - [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"]) + [test "x$enable_ocaml" != "xno"]) AM_CONDITIONAL([HAVE_OCAMLOPT], - [test "x$OCAMLOPT" != "xno" && test "x$OCAMLFIND" != "xno"]) + [test "x$OCAMLOPT" != "xno"]) AM_CONDITIONAL([HAVE_OCAMLDOC], [test "x$OCAMLDOC" != "xno"]) -dnl OCaml is required if we need to run the generator. -AS_IF([test "x$OCAMLC" = "xno" || test "x$OCAMLFIND" = "xno"],[ - AS_IF([! test -f $srcdir/common/protocol/guestfs_protocol.x],[ - AC_MSG_FAILURE([OCaml compiler and findlib is required to build from git. -If you don't have OCaml available, you should build from a tarball from -http://libguestfs.org/download]) - ]) -]) - -AS_IF([test "x$OCAMLC" != "xno"],[ - dnl Check for header. - old_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -I`$OCAMLC -where`" - AC_CHECK_HEADERS([caml/unixsupport.h],[],[],[#include ]) - CPPFLAGS="$old_CPPFLAGS" -]) +dnl Check for header. +old_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -I`$OCAMLC -where`" +AC_CHECK_HEADERS([caml/unixsupport.h],[],[],[#include ]) +CPPFLAGS="$old_CPPFLAGS" OCAML_PKG_gettext=no OCAML_PKG_libvirt=no @@ -102,15 +99,15 @@ AS_IF([test "x$OCAMLC" != "xno"],[ fi ]) AM_CONDITIONAL([HAVE_OCAML_PKG_GETTEXT], - [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && test "x$OCAML_PKG_gettext" != "xno"]) + [test "x$OCAML_PKG_gettext" != "xno"]) AM_CONDITIONAL([HAVE_OCAML_PKG_LIBVIRT], - [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && test "x$OCAML_PKG_libvirt" != "xno"]) + [test "x$OCAML_PKG_libvirt" != "xno"]) AM_CONDITIONAL([HAVE_OCAML_PKG_OUNIT], - [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && test "x$OCAML_PKG_oUnit" != "xno" && test "x$ounit_is_v2" != "xno"]) + [test "x$OCAML_PKG_oUnit" != "xno" && test "x$ounit_is_v2" != "xno"]) AC_CHECK_PROG([OCAML_GETTEXT],[ocaml-gettext],[ocaml-gettext],[no]) AM_CONDITIONAL([HAVE_OCAML_GETTEXT], - [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && test "x$OCAML_PKG_gettext" != "xno" && test "x$OCAML_GETTEXT" != "xno"]) + [test "x$OCAML_PKG_gettext" != "xno" && test "x$OCAML_GETTEXT" != "xno"]) dnl Create the backwards compatibility Bytes module for OCaml < 4.02. mkdir -p common/mlstdutils