enable build for ocaml bytecode
This is a first attempt to build libguestfs with just a ocaml bytecode compiler. The three tools written in ocaml will be build only when an ocamlopt compiler is available. Olaf --- Makefile.am | 5 ++++- configure.ac | 2 ++ ocaml/Makefile.am | 20 +++++++++++++++++--- resize/Makefile.am | 2 +- sparsify/Makefile.am | 2 +- sysprep/Makefile.am | 2 +- 6 files changed, 26 insertions(+), 7 deletions(-) Index: libguestfs-1.20.1/Makefile.am =================================================================== --- libguestfs-1.20.1.orig/Makefile.am +++ libguestfs-1.20.1/Makefile.am @@ -74,7 +74,10 @@ if HAVE_PERL SUBDIRS += perl perl/examples endif if HAVE_OCAML -SUBDIRS += ocaml ocaml/examples +SUBDIRS += ocaml +endif +if HAVE_OCAMLOPT +SUBDIRS += ocaml/examples endif if HAVE_PYTHON SUBDIRS += python python/examples Index: libguestfs-1.20.1/configure.ac =================================================================== --- libguestfs-1.20.1.orig/configure.ac +++ libguestfs-1.20.1/configure.ac @@ -865,6 +865,8 @@ AS_IF([test "x$enable_ocaml" != "xno"], ]) AM_CONDITIONAL([HAVE_OCAML], [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"]) +AM_CONDITIONAL([HAVE_OCAMLOPT], + [test "x$OCAMLOPT" != "xno" && test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"]) AM_CONDITIONAL([HAVE_OCAMLDOC], [test "x$OCAMLDOC" != "xno"]) Index: libguestfs-1.20.1/ocaml/Makefile.am =================================================================== --- libguestfs-1.20.1.orig/ocaml/Makefile.am +++ libguestfs-1.20.1/ocaml/Makefile.am @@ -43,10 +43,20 @@ CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/ if HAVE_OCAML +DATA_HOOK_FILES = META *.so *.a *.cma \ + *.cmi $(srcdir)/*.mli +if HAVE_OCAMLOPT +DATA_HOOK_FILES += *.cmx *.cmxa +endif + OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX OCAMLOPTFLAGS = $(OCAMLCFLAGS) -noinst_DATA = mlguestfs.cma mlguestfs.cmxa META +noinst_DATA = mlguestfs.cma +if HAVE_OCAMLOPT +noinst_DATA += mlguestfs.cmxa +endif +noinst_DATA += META # Build the C part into a library, so that automake handles the C # compilation step for us. Note that we don't directly use this @@ -101,9 +111,13 @@ TESTS = run-bindtests \ $(patsubst %,%.opt,$(test_progs))) noinst_DATA += \ - bindtests.bc bindtests.opt \ + bindtests.bc +if HAVE_OCAMLOPT +noinst_DATA += \ + bindtests.opt \ $(test_progs:%=%.bc) \ $(test_progs:%=%.opt) +endif bindtests.bc: bindtests.cmo mlguestfs.cma mkdir -p t @@ -217,7 +231,7 @@ install-data-hook: $(OCAMLFIND) install \ -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \ guestfs \ - META *.so *.a *.cma *.cmx *.cmxa *.cmi $(srcdir)/*.mli + $(DATA_HOOK_FILES) rm $(DESTDIR)$(OCAMLLIB)/guestfs/bindtests.* rm $(DESTDIR)$(OCAMLLIB)/guestfs/libguestfsocaml.a Index: libguestfs-1.20.1/resize/Makefile.am =================================================================== --- libguestfs-1.20.1.orig/resize/Makefile.am +++ libguestfs-1.20.1/resize/Makefile.am @@ -40,7 +40,7 @@ SOURCES = \ resize_utils.ml \ resize_utils_tests.ml -if HAVE_OCAML +if HAVE_OCAMLOPT # Note this list must be in dependency order. OBJECTS = \ Index: libguestfs-1.20.1/sparsify/Makefile.am =================================================================== --- libguestfs-1.20.1.orig/sparsify/Makefile.am +++ libguestfs-1.20.1/sparsify/Makefile.am @@ -36,7 +36,7 @@ SOURCES = \ sparsify_gettext.ml \ sparsify_utils.ml -if HAVE_OCAML +if HAVE_OCAMLOPT # Note this list must be in dependency order. OBJECTS = \ Index: libguestfs-1.20.1/sysprep/Makefile.am =================================================================== --- libguestfs-1.20.1.orig/sysprep/Makefile.am +++ libguestfs-1.20.1/sysprep/Makefile.am @@ -86,7 +86,7 @@ SOURCES = \ utils.ml \ utils.mli -if HAVE_OCAML +if HAVE_OCAMLOPT # Note this list must be in dependency order. OBJECTS = \
On Mon, Jan 14, Olaf Hering wrote:
This is a first attempt to build libguestfs with just a ocaml bytecode compiler. The three tools written in ocaml will be build only when an ocamlopt compiler is available.
Here is a more complete change which covers also resize, sysprep and sparsify. ocaml/examples are still disabled. Olaf --- configure.ac | 2 ++ ocaml/Makefile.am | 20 +++++++++++++++++--- ocaml/examples/Makefile.am | 2 +- resize/Makefile.am | 32 ++++++++++++++++++++++++++++---- sparsify/Makefile.am | 28 ++++++++++++++++++++++++++-- sysprep/Makefile.am | 28 ++++++++++++++++++++++++++-- 6 files changed, 100 insertions(+), 12 deletions(-) Index: libguestfs-1.20.1/configure.ac =================================================================== --- libguestfs-1.20.1.orig/configure.ac +++ libguestfs-1.20.1/configure.ac @@ -865,6 +865,8 @@ AS_IF([test "x$enable_ocaml" != "xno"], ]) AM_CONDITIONAL([HAVE_OCAML], [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"]) +AM_CONDITIONAL([HAVE_OCAMLOPT], + [test "x$OCAMLOPT" != "xno" && test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"]) AM_CONDITIONAL([HAVE_OCAMLDOC], [test "x$OCAMLDOC" != "xno"]) Index: libguestfs-1.20.1/ocaml/Makefile.am =================================================================== --- libguestfs-1.20.1.orig/ocaml/Makefile.am +++ libguestfs-1.20.1/ocaml/Makefile.am @@ -43,10 +43,20 @@ CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/ if HAVE_OCAML +DATA_HOOK_FILES = META *.so *.a *.cma \ + *.cmi $(srcdir)/*.mli +if HAVE_OCAMLOPT +DATA_HOOK_FILES += *.cmx *.cmxa +endif + OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX OCAMLOPTFLAGS = $(OCAMLCFLAGS) -noinst_DATA = mlguestfs.cma mlguestfs.cmxa META +noinst_DATA = mlguestfs.cma +if HAVE_OCAMLOPT +noinst_DATA += mlguestfs.cmxa +endif +noinst_DATA += META # Build the C part into a library, so that automake handles the C # compilation step for us. Note that we don't directly use this @@ -101,9 +111,13 @@ TESTS = run-bindtests \ $(patsubst %,%.opt,$(test_progs))) noinst_DATA += \ - bindtests.bc bindtests.opt \ + bindtests.bc +if HAVE_OCAMLOPT +noinst_DATA += \ + bindtests.opt \ $(test_progs:%=%.bc) \ $(test_progs:%=%.opt) +endif bindtests.bc: bindtests.cmo mlguestfs.cma mkdir -p t @@ -217,7 +231,7 @@ install-data-hook: $(OCAMLFIND) install \ -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \ guestfs \ - META *.so *.a *.cma *.cmx *.cmxa *.cmi $(srcdir)/*.mli + $(DATA_HOOK_FILES) rm $(DESTDIR)$(OCAMLLIB)/guestfs/bindtests.* rm $(DESTDIR)$(OCAMLLIB)/guestfs/libguestfsocaml.a Index: libguestfs-1.20.1/ocaml/examples/Makefile.am =================================================================== --- libguestfs-1.20.1.orig/ocaml/examples/Makefile.am +++ libguestfs-1.20.1/ocaml/examples/Makefile.am @@ -41,7 +41,7 @@ stamp-guestfs-ocaml.pod: guestfs-ocaml.p $< touch $@ -if HAVE_OCAML +if HAVE_OCAMLOPT noinst_SCRIPTS = create_disk inspect_vm Index: libguestfs-1.20.1/resize/Makefile.am =================================================================== --- libguestfs-1.20.1.orig/resize/Makefile.am +++ libguestfs-1.20.1/resize/Makefile.am @@ -43,7 +43,15 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +OBJECTS_bc = \ + $(top_builddir)/fish/guestfish-progress.o \ + progress-c.o \ + resize_gettext.cmo \ + resize_utils.cmo \ + progress.cmo \ + resize.cmo + +OBJECTS_opt = \ $(top_builddir)/fish/guestfish-progress.o \ progress-c.o \ resize_gettext.cmx \ @@ -51,26 +59,42 @@ OBJECTS = \ progress.cmx \ resize.cmx +if HAVE_OCAMLOPT +FINAL_BINARY = virt-resize.opt +else +FINAL_BINARY = virt-resize.bc +endif bin_SCRIPTS = virt-resize # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L # option to be passed to gcc, so we don't try linking against an # installed copy of libguestfs. -OCAMLPACKAGES = -package str,unix -I $(top_builddir)/src/.libs -I ../ocaml +OCAMLPACKAGES = -package str,unix -I ../ocaml -I . if HAVE_OCAML_PKG_GETTEXT OCAMLPACKAGES += -package gettext-stub endif OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES) -OCAMLOPTFLAGS = $(OCAMLCFLAGS) +OCAMLOPTFLAGS = -I $(top_builddir)/src/.libs $(OCAMLCFLAGS) -virt-resize: $(OBJECTS) +virt-resize.bc: $(OBJECTS_bc) + $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + -custom \ + mlguestfs.cma -linkpkg $^ \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ + +virt-resize.opt: $(OBJECTS_opt) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib -lncurses \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +virt-resize: $(FINAL_BINARY) + cp -vf $< $@ + .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ .ml.cmo: Index: libguestfs-1.20.1/sparsify/Makefile.am =================================================================== --- libguestfs-1.20.1.orig/sparsify/Makefile.am +++ libguestfs-1.20.1/sparsify/Makefile.am @@ -39,7 +39,15 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +OBJECTS_bc = \ + $(top_builddir)/fish/guestfish-progress.o \ + $(top_builddir)/resize/progress-c.o \ + sparsify_gettext.cmo \ + sparsify_utils.cmo \ + $(top_builddir)/resize/progress.cmo \ + sparsify.cmo + +OBJECTS_opt = \ $(top_builddir)/fish/guestfish-progress.o \ $(top_builddir)/resize/progress-c.o \ sparsify_gettext.cmx \ @@ -47,6 +55,11 @@ OBJECTS = \ $(top_builddir)/resize/progress.cmx \ sparsify.cmx +if HAVE_OCAMLOPT +FINAL_BINARY = virt-sparsify.opt +else +FINAL_BINARY = virt-sparsify.bc +endif bin_SCRIPTS = virt-sparsify # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -60,13 +73,24 @@ endif OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES) OCAMLOPTFLAGS = $(OCAMLCFLAGS) -virt-sparsify: $(OBJECTS) +virt-sparsify.bc: $(OBJECTS_bc) + $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + -custom \ + mlguestfs.cma -linkpkg $^ \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ + +virt-sparsify.opt: $(OBJECTS_opt) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib -lncurses \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +virt-sparsify: $(FINAL_BINARY) + cp -vf $< $@ + .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ .ml.cmo: Index: libguestfs-1.20.1/sysprep/Makefile.am =================================================================== --- libguestfs-1.20.1.orig/sysprep/Makefile.am +++ libguestfs-1.20.1/sysprep/Makefile.am @@ -89,7 +89,15 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +OBJECTS_bc = \ + sysprep_gettext.cmo \ + utils.cmo \ + firstboot.cmo \ + sysprep_operation.cmo \ + $(patsubst %,sysprep_operation_%.cmo,$(operations)) \ + main.cmo + +OBJECTS_opt = \ sysprep_gettext.cmx \ utils.cmx \ firstboot.cmx \ @@ -97,6 +105,11 @@ OBJECTS = \ $(patsubst %,sysprep_operation_%.cmx,$(operations)) \ main.cmx +if HAVE_OCAMLOPT +FINAL_BINARY = virt-sysprep.opt +else +FINAL_BINARY = virt-sysprep.bc +endif bin_SCRIPTS = virt-sysprep # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -110,13 +123,24 @@ endif OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES) OCAMLOPTFLAGS = $(OCAMLCFLAGS) -virt-sysprep: $(OBJECTS) +virt-sysprep.bc: $(OBJECTS_bc) + $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + -custom \ + mlguestfs.cma -linkpkg $^ \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ + +virt-sysprep.opt: $(OBJECTS_opt) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib -lncurses \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +virt-sysprep: $(FINAL_BINARY) + cp -vf $< $@ + .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ .ml.cmo:
On Wed, Jan 16, 2013 at 05:51:53PM +0100, Olaf Hering wrote:
On Mon, Jan 14, Olaf Hering wrote:
This is a first attempt to build libguestfs with just a ocaml bytecode compiler. The three tools written in ocaml will be build only when an ocamlopt compiler is available.
Here is a more complete change which covers also resize, sysprep and sparsify. ocaml/examples are still disabled.
Generally looks good. Did you want to submit this second version or should we wait for more? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
On Thu, Jan 17, Richard W.M. Jones wrote:
On Wed, Jan 16, 2013 at 05:51:53PM +0100, Olaf Hering wrote:
On Mon, Jan 14, Olaf Hering wrote:
This is a first attempt to build libguestfs with just a ocaml bytecode compiler. The three tools written in ocaml will be build only when an ocamlopt compiler is available.
Here is a more complete change which covers also resize, sysprep and sparsify. ocaml/examples are still disabled.
Generally looks good. Did you want to submit this second version or should we wait for more?
If the approach is ok I will convert also ocaml/examples and submit a final patch. Olaf
On Thu, Jan 17, Richard W.M. Jones wrote:
On Wed, Jan 16, 2013 at 05:51:53PM +0100, Olaf Hering wrote:
On Mon, Jan 14, Olaf Hering wrote:
This is a first attempt to build libguestfs with just a ocaml bytecode compiler. The three tools written in ocaml will be build only when an ocamlopt compiler is available. Here is a more complete change which covers also resize, sysprep and sparsify. ocaml/examples are still disabled. Generally looks good. Did you want to submit this second version or should we wait for more?
So here is a 1.24.X version which appears to work, at least for the bytecode case. Olaf --- builder/Makefile.am | 50 ++++++++++++++++++++++++++++++++++++++---- configure.ac | 2 ++ mllib/Makefile.am | 54 ++++++++++++++++++++++++++++++++++++++++++---- ocaml/Makefile.am | 32 ++++++++++++++++++++++----- ocaml/examples/Makefile.am | 25 +++++++++++++++++++-- resize/Makefile.am | 43 ++++++++++++++++++++++++++++++++---- sparsify/Makefile.am | 39 +++++++++++++++++++++++++++++---- sysprep/Makefile.am | 40 ++++++++++++++++++++++++++++++++-- 8 files changed, 260 insertions(+), 25 deletions(-) diff --git a/builder/Makefile.am b/builder/Makefile.am index b8bf6ac..83ef46b 100644 --- a/builder/Makefile.am +++ b/builder/Makefile.am @@ -43,7 +43,30 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +OBJECTS_bc = \ + $(top_builddir)/mllib/libdir.cmo \ + $(top_builddir)/mllib/common_gettext.cmo \ + $(top_builddir)/mllib/common_utils.cmo \ + $(top_builddir)/mllib/urandom.cmo \ + $(top_builddir)/mllib/random_seed.cmo \ + $(top_builddir)/mllib/hostname.cmo \ + $(top_builddir)/mllib/firstboot.cmo \ + $(top_builddir)/mllib/perl_edit.cmo \ + $(top_builddir)/mllib/crypt-c.o \ + $(top_builddir)/mllib/crypt.cmo \ + $(top_builddir)/mllib/fsync-c.o \ + $(top_builddir)/mllib/fsync.cmo \ + $(top_builddir)/mllib/password.cmo \ + $(top_builddir)/mllib/config.cmo \ + get_kernel.cmo \ + downloader.cmo \ + sigchecker.cmo \ + index_parser.cmo \ + list_entries.cmo \ + cmdline.cmo \ + builder.cmo + +OBJECTS_opt = \ $(top_builddir)/mllib/libdir.cmx \ $(top_builddir)/mllib/common_gettext.cmx \ $(top_builddir)/mllib/common_utils.cmx \ @@ -66,6 +89,12 @@ OBJECTS = \ cmdline.cmx \ builder.cmx +if HAVE_OCAMLOPT +FINAL_BINARY = virt-builder.opt +else +FINAL_BINARY = virt-builder.bc +endif + bin_SCRIPTS = virt-builder # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -73,7 +102,6 @@ bin_SCRIPTS = virt-builder # installed copy of libguestfs. OCAMLPACKAGES = \ -package str,unix \ - -I $(top_builddir)/src/.libs \ -I $(top_builddir)/ocaml \ -I $(top_builddir)/mllib if HAVE_OCAML_PKG_GETTEXT @@ -81,15 +109,29 @@ OCAMLPACKAGES += -package gettext-stub endif OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES) -OCAMLOPTFLAGS = $(OCAMLCFLAGS) +OCAMLOPTFLAGS = \ + -I $(top_builddir)/src/.libs \ + $(OCAMLCFLAGS) -virt-builder: $(OBJECTS) +virt-builder.bc: $(OBJECTS_bc) + $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + -custom \ + mlguestfs.cma -linkpkg $^ \ + -cclib '-lncurses -lcrypt' \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ + +virt-builder.opt: $(OBJECTS_opt) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib '-lncurses -lcrypt' \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +virt-builder: $(FINAL_BINARY) + cp -vf $< $@ + .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ .ml.cmo: diff --git a/configure.ac b/configure.ac index d7430db..d0063e8 100644 --- a/configure.ac +++ b/configure.ac @@ -1024,6 +1024,8 @@ AS_IF([test "x$enable_ocaml" != "xno"],[ ]) AM_CONDITIONAL([HAVE_OCAML], [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"]) +AM_CONDITIONAL([HAVE_OCAMLOPT], + [test "x$OCAMLOPT" != "xno" && test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"]) AM_CONDITIONAL([HAVE_OCAMLDOC], [test "x$OCAMLDOC" != "xno"]) diff --git a/mllib/Makefile.am b/mllib/Makefile.am index 8c8d508..4312283 100644 --- a/mllib/Makefile.am +++ b/mllib/Makefile.am @@ -62,7 +62,31 @@ if HAVE_OCAML # - We're not actually building a functioning program here, we're just # linking everything together to check all the modules build OK. # - This list must be in dependency order. -OBJECTS = \ +OBJECTS_bc = \ + $(top_builddir)/fish/guestfish-progress.o \ + $(top_builddir)/fish/guestfish-uri.o \ + tty-c.o \ + fsync-c.o \ + progress-c.o \ + uri-c.o \ + crypt-c.o \ + config.cmo \ + libdir.cmo \ + common_gettext.cmo \ + common_utils.cmo \ + urandom.cmo \ + random_seed.cmo \ + hostname.cmo \ + firstboot.cmo \ + perl_edit.cmo \ + tTY.cmo \ + fsync.cmo \ + progress.cmo \ + uRI.cmo \ + crypt.cmo \ + password.cmo + +OBJECTS_opt = \ $(top_builddir)/fish/guestfish-progress.o \ $(top_builddir)/fish/guestfish-uri.o \ tty-c.o \ @@ -86,31 +110,53 @@ OBJECTS = \ crypt.cmx \ password.cmx +if HAVE_OCAMLOPT +FINAL_BINARY = dummy.opt +else +FINAL_BINARY = dummy.bc +endif noinst_SCRIPTS = dummy # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L # option to be passed to gcc, so we don't try linking against an # installed copy of libguestfs. -OCAMLPACKAGES = -package str,unix -I $(top_builddir)/src/.libs -I ../ocaml +OCAMLPACKAGES = \ + -package str,unix \ + -I $(top_builddir)/ocaml + if HAVE_OCAML_PKG_GETTEXT OCAMLPACKAGES += -package gettext-stub endif OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES) -OCAMLOPTFLAGS = $(OCAMLCFLAGS) +OCAMLOPTFLAGS = \ + -I $(top_builddir)/src/.libs \ + $(OCAMLCFLAGS) OCAMLCLIBS = \ $(LIBXML2_LIBS) -lncurses -lcrypt \ -L../src/.libs -lutils \ -L../gnulib/lib/.libs -lgnu -dummy: $(OBJECTS) +dummy.bc: $(OBJECTS_bc) + $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + -custom \ + mlguestfs.cma -linkpkg $^ \ + -cclib '$(OCAMLCLIBS)' \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ + +dummy.opt: $(OBJECTS_opt) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib '$(OCAMLCLIBS)' \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +dummy: $(FINAL_BINARY) + cp -vf $< $@ + .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ .ml.cmo: diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 5dd2c9b..43e0c59 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -37,10 +37,25 @@ CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so if HAVE_OCAML +DATA_HOOK_FILES = META *.so *.a *.cma \ + *.cmi $(srcdir)/*.mli +if HAVE_OCAMLOPT +DATA_HOOK_FILES += *.cmx *.cmxa +endif + OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX OCAMLOPTFLAGS = $(OCAMLCFLAGS) -noinst_DATA = mlguestfs.cma mlguestfs.cmxa META +noinst_DATA = META +if HAVE_OCAMLOPT +noinst_DATA += mlguestfs.cma +noinst_DATA += mlguestfs.cmxa +endif + +guestfs_deps = guestfs.cmo +if HAVE_OCAMLOPT +guestfs_deps += guestfs.cmx +endif # Build the C part into a library, so that automake handles the C # compilation step for us. Note that we don't directly use this @@ -55,13 +70,15 @@ CLEANFILES += stamp-mlguestfs mlguestfs.cma mlguestfs.cmxa: stamp-mlguestfs -stamp-mlguestfs: libguestfsocaml.a guestfs.cmo guestfs.cmx +stamp-mlguestfs: libguestfsocaml.a $(guestfs_deps) $(OCAMLMKLIB) -o mlguestfs \ $(libguestfsocaml_a_OBJECTS) guestfs.cmo \ -L$(top_builddir)/src/.libs -lguestfs +if HAVE_OCAMLOPT $(OCAMLMKLIB) -o mlguestfs \ $(libguestfsocaml_a_OBJECTS) guestfs.cmx \ -L$(top_builddir)/src/.libs -lguestfs +endif touch $@ libguestfsocaml_a_CPPFLAGS = \ @@ -121,11 +138,16 @@ test_progs_opt += \ t/guestfs_430_progress_messages.opt endif -test_progs_all = $(test_progs_bc) $(test_progs_opt) +test_progs_all = $(test_progs_bc) +bindtests_all = bindtests.bc +if HAVE_OCAMLOPT +test_progs_all += $(test_progs_opt) +bindtests_all += bindtests.opt +endif TESTS = run-bindtests $(test_progs_all) -noinst_DATA += bindtests.bc bindtests.opt $(test_progs_all) +noinst_DATA += $(bindtests_all) $(test_progs_all) %.bc: %.cmo mlguestfs.cma $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ @@ -171,7 +193,7 @@ install-data-hook: $(OCAMLFIND) install \ -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \ guestfs \ - META *.so *.a *.cma *.cmx *.cmxa *.cmi $(srcdir)/*.mli + $(DATA_HOOK_FILES) rm $(DESTDIR)$(OCAMLLIB)/guestfs/bindtests.* rm $(DESTDIR)$(OCAMLLIB)/guestfs/libguestfsocaml.a diff --git a/ocaml/examples/Makefile.am b/ocaml/examples/Makefile.am index 200a0aa..3dadf03 100644 --- a/ocaml/examples/Makefile.am +++ b/ocaml/examples/Makefile.am @@ -47,14 +47,35 @@ if HAVE_OCAML noinst_SCRIPTS = create_disk inspect_vm +if HAVE_OCAMLOPT +FINAL_BINARY_create_disk = create_disk.opt +FINAL_BINARY_inspect_vm = inspect_vm.opt +else +FINAL_BINARY_create_disk = create_disk.bc +FINAL_BINARY_inspect_vm = inspect_vm.bc +endif OCAMLFINDFLAGS = -cclib -L$(top_builddir)/src/.libs -create_disk: create_disk.ml +create_disk.bc: create_disk.ml + $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ + $(OCAMLFIND) ocamlc $(OCAMLFINDFLAGS) -package unix -linkpkg \ + -custom \ + -warn-error A -I .. mlguestfs.cma $< -o $@ +create_disk.opt: create_disk.ml $(OCAMLFIND) ocamlopt $(OCAMLFINDFLAGS) -package unix -linkpkg \ -warn-error A -I .. mlguestfs.cmxa $< -o $@ -inspect_vm: inspect_vm.ml +inspect_vm.bc: inspect_vm.ml + $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ + $(OCAMLFIND) ocamlc $(OCAMLFINDFLAGS) -package unix -linkpkg \ + -custom \ + -warn-error A -I .. mlguestfs.cma $< -o $@ +inspect_vm.opt: inspect_vm.ml $(OCAMLFIND) ocamlopt $(OCAMLFINDFLAGS) -package unix -linkpkg \ -warn-error A -I .. mlguestfs.cmxa $< -o $@ +create_disk: $(FINAL_BINARY_create_disk) + cp -vf $< $@ +inspect_vm: $(FINAL_BINARY_inspect_vm) + cp -vf $< $@ endif diff --git a/resize/Makefile.am b/resize/Makefile.am index 76c26ee..b8a1209 100644 --- a/resize/Makefile.am +++ b/resize/Makefile.am @@ -31,7 +31,23 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +OBJECTS_bc = \ + $(top_builddir)/mllib/tty-c.o \ + $(top_builddir)/mllib/tTY.cmo \ + $(top_builddir)/mllib/fsync-c.o \ + $(top_builddir)/mllib/fsync.cmo \ + $(top_builddir)/fish/guestfish-progress.o \ + $(top_builddir)/mllib/progress-c.o \ + $(top_builddir)/mllib/progress.cmo \ + $(top_builddir)/fish/guestfish-uri.o \ + $(top_builddir)/mllib/uri-c.o \ + $(top_builddir)/mllib/uRI.cmo \ + $(top_builddir)/mllib/common_gettext.cmo \ + $(top_builddir)/mllib/common_utils.cmo \ + $(top_builddir)/mllib/config.cmo \ + resize.cmo + +OBJECTS_opt = \ $(top_builddir)/mllib/tty-c.o \ $(top_builddir)/mllib/tTY.cmx \ $(top_builddir)/mllib/fsync-c.o \ @@ -47,6 +63,12 @@ OBJECTS = \ $(top_builddir)/mllib/config.cmx \ resize.cmx +if HAVE_OCAMLOPT +FINAL_BINARY = virt-resize.opt +else +FINAL_BINARY = virt-resize.bc +endif + bin_SCRIPTS = virt-resize # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -54,7 +76,6 @@ bin_SCRIPTS = virt-resize # installed copy of libguestfs. OCAMLPACKAGES = \ -package str,unix \ - -I $(top_builddir)/src/.libs \ -I $(top_builddir)/ocaml \ -I $(top_builddir)/mllib if HAVE_OCAML_PKG_GETTEXT @@ -62,20 +83,34 @@ OCAMLPACKAGES += -package gettext-stub endif OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES) -OCAMLOPTFLAGS = $(OCAMLCFLAGS) +OCAMLOPTFLAGS = \ + -I $(top_builddir)/src/.libs \ + $(OCAMLCFLAGS) OCAMLCLIBS = \ $(LIBXML2_LIBS) -lncurses \ -L../src/.libs -lutils \ -L../gnulib/lib/.libs -lgnu -virt-resize: $(OBJECTS) +virt-resize.bc: $(OBJECTS_bc) + $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + -custom \ + mlguestfs.cma -linkpkg $^ \ + -cclib '$(OCAMLCLIBS)' \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ + +virt-resize.opt: $(OBJECTS_opt) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib '$(OCAMLCLIBS)' \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +virt-resize: $(FINAL_BINARY) + cp -vf $< $@ + .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ .ml.cmo: diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am index 98d9c70..645eb11 100644 --- a/sparsify/Makefile.am +++ b/sparsify/Makefile.am @@ -32,7 +32,19 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +OBJECTS_bc = \ + $(top_builddir)/fish/guestfish-progress.o \ + $(top_builddir)/mllib/tty-c.o \ + $(top_builddir)/mllib/progress-c.o \ + $(top_builddir)/mllib/common_gettext.cmo \ + $(top_builddir)/mllib/common_utils.cmo \ + $(top_builddir)/mllib/tTY.cmo \ + $(top_builddir)/mllib/progress.cmo \ + $(top_builddir)/mllib/config.cmo \ + statvfs-c.o \ + sparsify.cmo + +OBJECTS_opt = \ $(top_builddir)/fish/guestfish-progress.o \ $(top_builddir)/mllib/tty-c.o \ $(top_builddir)/mllib/progress-c.o \ @@ -44,6 +56,12 @@ OBJECTS = \ statvfs-c.o \ sparsify.cmx +if HAVE_OCAMLOPT +FINAL_BINARY = virt-sparsify.opt +else +FINAL_BINARY = virt-sparsify.bc +endif + bin_SCRIPTS = virt-sparsify # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -51,7 +69,6 @@ bin_SCRIPTS = virt-sparsify # installed copy of libguestfs. OCAMLPACKAGES = \ -package str,unix \ - -I $(top_builddir)/src/.libs \ -I $(top_builddir)/ocaml \ -I $(top_builddir)/mllib if HAVE_OCAML_PKG_GETTEXT @@ -59,15 +76,29 @@ OCAMLPACKAGES += -package gettext-stub endif OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES) -OCAMLOPTFLAGS = $(OCAMLCFLAGS) +OCAMLOPTFLAGS = \ + -I $(top_builddir)/src/.libs \ + $(OCAMLCFLAGS) -virt-sparsify: $(OBJECTS) +virt-sparsify.bc: $(OBJECTS_bc) + $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + -custom \ + mlguestfs.cma -linkpkg $^ \ + -cclib -lncurses \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ + +virt-sparsify.opt: $(OBJECTS_opt) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib -lncurses \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +virt-sparsify: $(FINAL_BINARY) + cp -vf $< $@ + .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ .ml.cmo: diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index 24654cb..cc9e958 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -81,7 +81,25 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +OBJECTS_bc = \ + $(top_builddir)/mllib/common_gettext.cmo \ + $(top_builddir)/mllib/common_utils.cmo \ + $(top_builddir)/fish/guestfish-uri.o \ + $(top_builddir)/mllib/uri-c.o \ + $(top_builddir)/mllib/uRI.cmo \ + $(top_builddir)/mllib/crypt-c.o \ + $(top_builddir)/mllib/crypt.cmo \ + $(top_builddir)/mllib/urandom.cmo \ + $(top_builddir)/mllib/password.cmo \ + $(top_builddir)/mllib/random_seed.cmo \ + $(top_builddir)/mllib/hostname.cmo \ + $(top_builddir)/mllib/firstboot.cmo \ + $(top_builddir)/mllib/config.cmo \ + sysprep_operation.cmo \ + $(patsubst %,sysprep_operation_%.cmo,$(operations)) \ + main.cmo + +OBJECTS_opt = \ $(top_builddir)/mllib/common_gettext.cmx \ $(top_builddir)/mllib/common_utils.cmx \ $(top_builddir)/fish/guestfish-uri.o \ @@ -99,6 +117,12 @@ OBJECTS = \ $(patsubst %,sysprep_operation_%.cmx,$(operations)) \ main.cmx +if HAVE_OCAMLOPT +FINAL_BINARY = virt-sysprep.opt +else +FINAL_BINARY = virt-sysprep.bc +endif + bin_SCRIPTS = virt-sysprep # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -121,13 +145,25 @@ OCAMLCLIBS = \ -L../src/.libs -lutils \ -L../gnulib/lib/.libs -lgnu -virt-sysprep: $(OBJECTS) +virt-sysprep.bc: $(OBJECTS_bc) + $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ + $(OCAMLFIND) ocamlc $(OCAMLOPTFLAGS) \ + -custom \ + mlguestfs.cma -linkpkg $^ \ + -cclib '$(OCAMLCLIBS)' \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ + +virt-sysprep.opt: $(OBJECTS_opt) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib '$(OCAMLCLIBS)' \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +virt-sysprep: $(FINAL_BINARY) + cp -vf $< $@ + .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ .ml.cmo:
On Wed, Feb 26, 2014 at 07:03:44PM +0100, Olaf Hering wrote:
On Thu, Jan 17, Richard W.M. Jones wrote:
On Wed, Jan 16, 2013 at 05:51:53PM +0100, Olaf Hering wrote:
On Mon, Jan 14, Olaf Hering wrote:
This is a first attempt to build libguestfs with just a ocaml bytecode compiler. The three tools written in ocaml will be build only when an ocamlopt compiler is available. Here is a more complete change which covers also resize, sysprep and sparsify. ocaml/examples are still disabled. Generally looks good. Did you want to submit this second version or should we wait for more?
So here is a 1.24.X version which appears to work, at least for the bytecode case.
OK, I'll need to rebase this because the upstream code has changed a bit. Two random thoughts: (1) This morning I discovered it's possible to make automake compile OCaml programs, provided they contain at least one C object (which all of ours do): https://github.com/libguestfs/supermin/blob/master/src/Makefile.am#L94 It needs a relatively small hack to add -l options in the right place: https://github.com/libguestfs/supermin/blob/master/src/supermin-link.sh.in (2) Related to the above, I rewrote supermin. This entailed dropping the zypper/SUSE support *temporarily*. I intend to add it back. It should in fact be simpler, as the Fedora support just uses 'rpm': https://github.com/libguestfs/supermin/blob/master/src/rpm.ml and it seems likely that any RPM based distro could use the same code (ie. SUSE support won't need to depend on zypper at all). Except for one small point: we need a tool to download RPMs from the repository, for which I'm using yumdownloader in that file. So that will need fixing for SUSE. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
I believe this patch has now been superseded by Hilko's commit here: https://github.com/libguestfs/libguestfs/commit/f75142c577255b30f2a8e1d27baa... Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
On Fri, Feb 28, Olaf Hering wrote:
On Fri, Feb 28, Richard W.M. Jones wrote:
I believe this patch has now been superseded by Hilko's commit here:
I'm backporting it right now, will send my version once it actually builds.
This is the 1.24 version of f75142c577255b30f2a8e1d27baa5fd185594197, passes my build test. Olaf --- builder/Makefile.am | 18 +++++++++++++++- configure.ac | 2 ++ mllib/Makefile.am | 54 ++++++++++++++++++++++++++++++++-------------- ocaml/Makefile.am | 35 +++++++++++++++++++++--------- ocaml/examples/Makefile.am | 13 +++++++++++ resize/Makefile.am | 18 +++++++++++++++- sparsify/Makefile.am | 18 +++++++++++++++- sysprep/Makefile.am | 18 +++++++++++++++- 8 files changed, 146 insertions(+), 30 deletions(-) diff --git a/builder/Makefile.am b/builder/Makefile.am index b8bf6ac..80646c1 100644 --- a/builder/Makefile.am +++ b/builder/Makefile.am @@ -43,7 +43,7 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +deps = \ $(top_builddir)/mllib/libdir.cmx \ $(top_builddir)/mllib/common_gettext.cmx \ $(top_builddir)/mllib/common_utils.cmx \ @@ -66,6 +66,12 @@ OBJECTS = \ cmdline.cmx \ builder.cmx +if HAVE_OCAMLOPT +OBJECTS = $(deps) +else +OBJECTS = $(patsubst %.cmx,%.cmo,$(deps)) +endif + bin_SCRIPTS = virt-builder # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -83,12 +89,22 @@ endif OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES) OCAMLOPTFLAGS = $(OCAMLCFLAGS) +if HAVE_OCAMLOPT virt-builder: $(OBJECTS) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib '-lncurses -lcrypt' \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +else +virt-builder: $(OBJECTS) + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + mlguestfs.cma -linkpkg $^ \ + -cclib '-lncurses -lcrypt' \ + -custom \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ +endif .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ diff --git a/configure.ac b/configure.ac index d7430db..e57bbf7 100644 --- a/configure.ac +++ b/configure.ac @@ -1024,6 +1024,8 @@ AS_IF([test "x$enable_ocaml" != "xno"],[ ]) AM_CONDITIONAL([HAVE_OCAML], [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"]) +AM_CONDITIONAL([HAVE_OCAMLOPT], + [test "x$OCAMLOPT" != "xno" && test "x$OCAMLFIND" != "xno"]) AM_CONDITIONAL([HAVE_OCAMLDOC], [test "x$OCAMLDOC" != "xno"]) diff --git a/mllib/Makefile.am b/mllib/Makefile.am index 8c8d508..a685310 100644 --- a/mllib/Makefile.am +++ b/mllib/Makefile.am @@ -62,6 +62,22 @@ if HAVE_OCAML # - We're not actually building a functioning program here, we're just # linking everything together to check all the modules build OK. # - This list must be in dependency order. +ocaml_modules = config \ + libdir \ + common_gettext \ + common_utils \ + urandom \ + random_seed \ + hostname \ + firstboot \ + perl_edit \ + tTY \ + fsync \ + progress \ + uRI \ + crypt \ + password + OBJECTS = \ $(top_builddir)/fish/guestfish-progress.o \ $(top_builddir)/fish/guestfish-uri.o \ @@ -69,22 +85,13 @@ OBJECTS = \ fsync-c.o \ progress-c.o \ uri-c.o \ - crypt-c.o \ - config.cmx \ - libdir.cmx \ - common_gettext.cmx \ - common_utils.cmx \ - urandom.cmx \ - random_seed.cmx \ - hostname.cmx \ - firstboot.cmx \ - perl_edit.cmx \ - tTY.cmx \ - fsync.cmx \ - progress.cmx \ - uRI.cmx \ - crypt.cmx \ - password.cmx + crypt-c.o + +if HAVE_OCAMLOPT +OBJECTS += $(patsubst %,%.cmx,$(ocaml_modules)) +else +OBJECTS += $(patsubst %,%.cmo,$(ocaml_modules)) +endif noinst_SCRIPTS = dummy @@ -105,11 +112,20 @@ OCAMLCLIBS = \ -L../gnulib/lib/.libs -lgnu dummy: $(OBJECTS) +if HAVE_OCAMLOPT $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib '$(OCAMLCLIBS)' \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +else + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + mlguestfs.cma -linkpkg $^ \ + -cclib '$(OCAMLCLIBS)' \ + -custom \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ +endif .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ @@ -142,9 +158,15 @@ DEFAULT_INCLUDES = \ check_SCRIPTS = common_utils_tests +if HAVE_OCAMLOPT common_utils_tests: common_gettext.cmx common_utils.cmx common_utils_tests.cmx $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ -cclib -lncurses -o $@ +else +common_utils_tests: common_gettext.cmo common_utils.cmo common_utils_tests.cmo + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + mlguestfs.cma -linkpkg $^ -cclib -lncurses -o $@ +endif TESTS_ENVIRONMENT = $(top_builddir)/run --test diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 5dd2c9b..698e13a 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -37,10 +37,18 @@ CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so if HAVE_OCAML +DATA_HOOK_FILES = META *.so *.a *.cma *.cmi $(srcdir)/*.mli +if HAVE_OCAMLOPT +DATA_HOOK_FILES += *.cmx *.cmxa +endif + OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX OCAMLOPTFLAGS = $(OCAMLCFLAGS) -noinst_DATA = mlguestfs.cma mlguestfs.cmxa META +noinst_DATA = mlguestfs.cma META +if HAVE_OCAMLOPT +noinst_DATA += mlguestfs.cmxa +endif # Build the C part into a library, so that automake handles the C # compilation step for us. Note that we don't directly use this @@ -51,18 +59,15 @@ noinst_LIBRARIES = libguestfsocaml.a # 'libmlguestfs.a' and if run at the same time, they will stomp on or # corrupt each others copy. Hence we have to serialize the calls. -CLEANFILES += stamp-mlguestfs - -mlguestfs.cma mlguestfs.cmxa: stamp-mlguestfs - -stamp-mlguestfs: libguestfsocaml.a guestfs.cmo guestfs.cmx +mlguestfs.cma: libguestfsocaml.a guestfs.cmo $(OCAMLMKLIB) -o mlguestfs \ $(libguestfsocaml_a_OBJECTS) guestfs.cmo \ -L$(top_builddir)/src/.libs -lguestfs + +mlguestfs.cmxa: libguestfsocaml.a guestfs.cmx $(OCAMLMKLIB) -o mlguestfs \ $(libguestfsocaml_a_OBJECTS) guestfs.cmx \ -L$(top_builddir)/src/.libs -lguestfs - touch $@ libguestfsocaml_a_CPPFLAGS = \ -DGUESTFS_PRIVATE=1 \ @@ -121,11 +126,17 @@ test_progs_opt += \ t/guestfs_430_progress_messages.opt endif -test_progs_all = $(test_progs_bc) $(test_progs_opt) +test_progs_all = $(test_progs_bc) +if HAVE_OCAMLOPT +test_progs_all += $(test_progs_opt) +endif TESTS = run-bindtests $(test_progs_all) -noinst_DATA += bindtests.bc bindtests.opt $(test_progs_all) +noinst_DATA += bindtests.bc $(test_progs_all) +if HAVE_OCAMLOPT +noinst_DATA += bindtests.opt +endif %.bc: %.cmo mlguestfs.cma $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ @@ -171,10 +182,14 @@ install-data-hook: $(OCAMLFIND) install \ -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \ guestfs \ - META *.so *.a *.cma *.cmx *.cmxa *.cmi $(srcdir)/*.mli + $(DATA_HOOK_FILES) rm $(DESTDIR)$(OCAMLLIB)/guestfs/bindtests.* rm $(DESTDIR)$(OCAMLLIB)/guestfs/libguestfsocaml.a CLEANFILES += $(noinst_DATA) endif + +# Tell version 3.79 and up of GNU make to not build goals in this +# directory in parallel. +.NOTPARALLEL: diff --git a/ocaml/examples/Makefile.am b/ocaml/examples/Makefile.am index 200a0aa..472e180 100644 --- a/ocaml/examples/Makefile.am +++ b/ocaml/examples/Makefile.am @@ -49,6 +49,7 @@ noinst_SCRIPTS = create_disk inspect_vm OCAMLFINDFLAGS = -cclib -L$(top_builddir)/src/.libs +if HAVE_OCAMLOPT create_disk: create_disk.ml $(OCAMLFIND) ocamlopt $(OCAMLFINDFLAGS) -package unix -linkpkg \ -warn-error A -I .. mlguestfs.cmxa $< -o $@ @@ -56,5 +57,17 @@ create_disk: create_disk.ml inspect_vm: inspect_vm.ml $(OCAMLFIND) ocamlopt $(OCAMLFINDFLAGS) -package unix -linkpkg \ -warn-error A -I .. mlguestfs.cmxa $< -o $@ +else + +# This avoids: +# Error: Error on dynamically loaded library: ../dllmlguestfs.so: libguestfs.so.0: cannot open shared object file: No such file or directory +create_disk: create_disk.ml + $(top_builddir)/run $(OCAMLFIND) ocamlc $(OCAMLFINDFLAGS) -package unix -linkpkg \ + -warn-error A -I .. mlguestfs.cma $< -o $@ + +inspect_vm: inspect_vm.ml + $(top_builddir)/run $(OCAMLFIND) ocamlc $(OCAMLFINDFLAGS) -package unix -linkpkg \ + -warn-error A -I .. mlguestfs.cma $< -o $@ +endif endif diff --git a/resize/Makefile.am b/resize/Makefile.am index 76c26ee..ef35bf9 100644 --- a/resize/Makefile.am +++ b/resize/Makefile.am @@ -31,7 +31,7 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +deps = \ $(top_builddir)/mllib/tty-c.o \ $(top_builddir)/mllib/tTY.cmx \ $(top_builddir)/mllib/fsync-c.o \ @@ -47,6 +47,12 @@ OBJECTS = \ $(top_builddir)/mllib/config.cmx \ resize.cmx +if HAVE_OCAMLOPT +OBJECTS = $(deps) +else +OBJECTS = $(patsubst %.cmx,%.cmo,$(deps)) +endif + bin_SCRIPTS = virt-resize # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -69,12 +75,22 @@ OCAMLCLIBS = \ -L../src/.libs -lutils \ -L../gnulib/lib/.libs -lgnu +if HAVE_OCAMLOPT virt-resize: $(OBJECTS) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib '$(OCAMLCLIBS)' \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +else +virt-resize: $(OBJECTS) + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + mlguestfs.cma -linkpkg $^ \ + -cclib '$(OCAMLCLIBS)' \ + -custom \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ +endif .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am index 98d9c70..bf6caf0 100644 --- a/sparsify/Makefile.am +++ b/sparsify/Makefile.am @@ -32,7 +32,7 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +deps = \ $(top_builddir)/fish/guestfish-progress.o \ $(top_builddir)/mllib/tty-c.o \ $(top_builddir)/mllib/progress-c.o \ @@ -44,6 +44,12 @@ OBJECTS = \ statvfs-c.o \ sparsify.cmx +if HAVE_OCAMLOPT +OBJECTS = $(deps) +else +OBJECTS = $(patsubst %.cmx,%.cmo,$(deps)) +endif + bin_SCRIPTS = virt-sparsify # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -61,12 +67,22 @@ endif OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES) OCAMLOPTFLAGS = $(OCAMLCFLAGS) +if HAVE_OCAMLOPT virt-sparsify: $(OBJECTS) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib -lncurses \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +else +virt-sparsify: $(OBJECTS) + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + mlguestfs.cma -linkpkg $^ \ + -cclib -lncurses \ + -custom \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ +endif .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index 24654cb..352735b 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -81,7 +81,7 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +deps = \ $(top_builddir)/mllib/common_gettext.cmx \ $(top_builddir)/mllib/common_utils.cmx \ $(top_builddir)/fish/guestfish-uri.o \ @@ -99,6 +99,12 @@ OBJECTS = \ $(patsubst %,sysprep_operation_%.cmx,$(operations)) \ main.cmx +if HAVE_OCAMLOPT +OBJECTS = $(deps) +else +OBJECTS = $(patsubst %.cmx,%.cmo,$(deps)) +endif + bin_SCRIPTS = virt-sysprep # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -121,12 +127,22 @@ OCAMLCLIBS = \ -L../src/.libs -lutils \ -L../gnulib/lib/.libs -lgnu +if HAVE_OCAMLOPT virt-sysprep: $(OBJECTS) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib '$(OCAMLCLIBS)' \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +else +virt-sysprep: $(OBJECTS) + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + mlguestfs.cma -linkpkg $^ \ + -cclib '$(OCAMLCLIBS)' \ + -custom \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ +endif .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
participants (2)
-
Olaf Hering -
Richard W.M. Jones