From 7dc8ab0a896859c51973982c607f92a215a435cc Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 27 Jul 2011 18:33:47 +0100 Subject: [PATCH] Allow bytecode compilation. 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 | 40 +++++++++++++++++++++++++--------------- configure.ac | 14 ++++++++++++-- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Makefile.am b/Makefile.am index d76c28a..36bbe1c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index 7426b9f..a5023d1 100644 --- a/configure.ac +++ b/configure.ac @@ -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 -- 1.8.3.1