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: _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs