build: Make OCaml compiler required for all builds.

Previously the OCaml compiler was only required if building from git
but was at least theoretically optional if building from tarballs
(although this was never tested).  Since we want to write parts of the
daemon in OCaml, this makes OCaml required for all builds.

Note that the ‘--disable-ocaml’ option remains, but it now only
disables OCaml bindings and OCaml virt tools.  Using this option does
not disable the OCaml compiler requirement.

Also note that ‘HAVE_OCAML’ changes meaning slightly, so it now means
"build OCaml bindings and tools" (analogous to ‘HAVE_PERL’ and
others).  The generator, daemon [in a future commit], and some utility
libraries needed by the generator or daemon do not test for this macro
because we can assume OCaml compiler availability.
This commit is contained in:
Richard W.M. Jones
2017-07-14 13:22:49 +01:00
parent 8ecfa6c638
commit 318ca68408
4 changed files with 47 additions and 66 deletions

View File

@@ -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

View File

@@ -120,8 +120,7 @@ I<Required>. Part of Perl core.
=item OCaml findlib
I<Required> if compiling from git.
Optional (but recommended) if compiling from tarball.
I<Required>.
=item autoconf
@@ -600,8 +599,12 @@ See L</USING A PREBUILT BINARY APPLIANCE> 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>

View File

@@ -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.

View File

@@ -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 <caml/unixsupport.h> header.
old_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I`$OCAMLC -where`"
AC_CHECK_HEADERS([caml/unixsupport.h],[],[],[#include <caml/mlvalues.h>])
CPPFLAGS="$old_CPPFLAGS"
])
dnl Check for <caml/unixsupport.h> header.
old_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I`$OCAMLC -where`"
AC_CHECK_HEADERS([caml/unixsupport.h],[],[],[#include <caml/mlvalues.h>])
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