[Libguestfs] [libnbd PATCH] build: Fix OCaml build on Fedora 29

Richard W.M. Jones rjones at redhat.com
Mon Jun 17 13:01:28 UTC 2019


On Sat, Jun 15, 2019 at 04:56:37PM -0500, Eric Blake wrote:
> Once ocamlfind is installed, 'make' failed for me with:
> 
> ocamlfind ocamlc -g -annot -safe-string -warn-error CDEFLMPSUVYZX+52-3 -ccopt '-gdwarf' -package unix -c NBD.ml -o NBD.cmo
> File "NBD.ml", line 1:
> Error: Could not find the .cmi file for interface NBD.mli.
> make[2]: *** [Makefile:823: NBD.cmo] Error 2
>
> I'm not positive that this is the perfect fix, but it at least got the
> build working for me, and copies from idioms in
> nbdkit/plugins/ocaml/Makefile.am.
> ---
>  ocaml/Makefile.am | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
> index 0d876bb..557151c 100644
> --- a/ocaml/Makefile.am
> +++ b/ocaml/Makefile.am
> @@ -32,6 +32,11 @@ if HAVE_OCAML
>  OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
>  OCAMLPACKAGES = -package unix
> 
> +NBD.cmi: NBD.mli
> +	$(OCAMLC) -c $< -o $@

I thnk this line should be:

        $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@

otherwise you are dropping warning flags.

However I don't know why this should be necessary because in
subdir-rules.mk we have:

%.cmi: $(srcdir)/%.mli
        $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@

Maybe $(srcdir)/ confuses make because ./NBD.mli is not textually the
same as NBD.mli?  (The use of $(srcdir) was an attempt to make it work
in split source/binary builds.)

> +NBD.cmo: NBD.cmi

While correct, this line really shouldn't be necessary since
ocaml/.depend already has the same line.

In libguestfs we do some complex rewriting of .depend files (see
libguestfs.git/ocaml-dep.sh.in) because the raw output of ocamldep
doesn't really work well with autotools.  I tried to avoid doing the
same thing in libnbd, but perhaps it's really necessary after all ...

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v




More information about the Libguestfs mailing list