Allow bytecode compilation.
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 27 Jul 2011 17:33:47 +0000 (18:33 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 27 Jul 2011 17:33:47 +0000 (18:33 +0100)
Bytecode compilation (ocamlc) is selected automatically if the native
code compiler (ocamlopt) is not available on this platform.

Also the packager or developer may force bytecode compilation for
easier debugging by doing:

  ./configure --without-native

Makefile.am
configure.ac

index d76c28a..36bbe1c 100644 (file)
@@ -66,20 +66,22 @@ SOURCES = \
 
 # Note this list must be in dependency order.
 OBJECTS = \
-       config.cmx \
-       throbber.cmx \
-       utils.cmx \
-       cmdline.cmx \
-       deviceSet.cmx \
-       slave_types.cmx \
-       slave_utils.cmx \
-       slave.cmx \
-       filetree_type.cmx \
-       filetree_markup.cmx \
-       filetree_ops.cmx \
-       filetree.cmx \
-       window.cmx \
-       main.cmx
+       config.cmo \
+       throbber.cmo \
+       utils.cmo \
+       cmdline.cmo \
+       deviceSet.cmo \
+       slave_types.cmo \
+       slave_utils.cmo \
+       slave.cmo \
+       filetree_type.cmo \
+       filetree_markup.cmo \
+       filetree_ops.cmo \
+       filetree.cmo \
+       window.cmo \
+       main.cmo
+
+XOBJECTS = $(OBJECTS:.cmo=.cmx)
 
 bin_SCRIPTS = guestfs-browser
 
@@ -98,11 +100,19 @@ OCAMLDOCFLAGS = \
        -I +threads \
        -sort -html
 
-guestfs-browser: $(OBJECTS)
+if HAVE_OCAMLOPT
+guestfs-browser: $(XOBJECTS)
        $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \
          -predicates init,threads \
          -linkpkg gtkThread.cmx \
          $^ -o $@
+else
+guestfs-browser: $(OBJECTS)
+       $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \
+         -predicates init,threads \
+         -linkpkg gtkThread.cmo \
+         $^ -o $@
+endif
 
 # This file is built.  However gdk_pixbuf_mlsource requires X11 to
 # run, which prevents this from being built in places where an X
index 7426b9f..a5023d1 100644 (file)
@@ -32,10 +32,20 @@ AC_PROG_SED
 
 dnl Check for OCaml compiler.
 AC_PROG_OCAML
-if test "$OCAMLOPT" = "no"; then
-    AC_MSG_ERROR([You must install the OCaml native compiler (ocamlopt)])
+if test "$OCAMLC" = "no"; then
+    AC_MSG_ERROR([You must install the OCaml compiler (ocamlc or ocamlopt)])
 fi
 
+dnl Choose native code if available, but allow the user to specify
+dnl bytecode only (useful for debugging).
+AC_ARG_WITH([native],
+        [AS_HELP_STRING([--without-native],
+                [disable native compilation (slow, but useful for debugging)])],
+        [],
+        [with_native=yes])
+AM_CONDITIONAL([HAVE_OCAMLOPT],
+        [test "x$with_native" != "xno" && test "x$OCAMLBEST" = "xopt"])
+
 dnl Check for OCaml findlib.
 AC_PROG_FINDLIB
 if test "$OCAMLFIND" = "no"; then