+dnl zlib is required because it contains a crc32 function.
+AC_CHECK_LIB([z], [crc32], [], [AC_MSG_ERROR([zlib is required])])
+AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib is required])])
+
+dnl Check for basic OCaml environment & findlib.
+AC_PROG_OCAML
+
+if test "x$OCAMLC" = "xno"; then
+ AC_MSG_ERROR([OCaml compiler is required])
+fi
+
+AM_CONDITIONAL([HAVE_OCAMLOPT], [test "x$OCAMLOPT" != "xno"])
+
+AC_PROG_FINDLIB
+
+if test "x$OCAMLFIND" = "xno"; then
+ AC_MSG_ERROR([OCaml findlib is required])
+fi
+
+dnl Check for required OCaml packages.
+AC_CHECK_OCAML_PKG(unix)
+if test "x$OCAML_PKG_unix" = "xno"; then
+ AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
+fi
+
+AC_CHECK_OCAML_PKG(libvirt)
+if test "x$OCAML_PKG_libvirt" = "xno"; then
+ AC_MSG_ERROR([Cannot find required OCaml package 'libvirt'])
+fi
+
+dnl Enable profiling.
+AC_MSG_CHECKING([if we should enable profiling])
+AC_ARG_ENABLE([profiling],
+ AS_HELP_STRING([--enable-profiling],
+ [turn on gprof profiling in binaries (for developers)]),
+ [profiling=$enable_profiling],
+ [profiling=no])
+AC_MSG_RESULT([$profiling])
+AM_CONDITIONAL([PROFILING], [test "x$profiling" != "xno"])