[Libguestfs] [libnbd PATCH] build: allow OCaml programs using libnbd to be compiled against build dir

Richard W.M. Jones rjones at redhat.com
Mon Sep 27 08:00:19 UTC 2021


On Mon, Sep 27, 2021 at 08:24:42AM +0200, Laszlo Ersek wrote:
> Port libguestfs commit bf61bf7355d3 ("build: Allow OCaml programs using
> libguestfs to be compiled against build dir.", 2020-03-12) to libnbd.
> 
> This allows C+OCaml programs, such as virt-v2v, to find a just built, but
> not installed, libnbd tree.
> 
> Signed-off-by: Laszlo Ersek <lersek at redhat.com>

ACK

Thanks,

Rich.

>  ocaml/Makefile.am | 17 +++++++++++++++++
>  .gitignore        |  1 +
>  run.in            |  2 ++
>  3 files changed, 20 insertions(+)
> 
> diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
> index 1c7397a9da7a..b1ab80dd5fa5 100644
> --- a/ocaml/Makefile.am
> +++ b/ocaml/Makefile.am
> @@ -161,4 +161,21 @@ install-data-hook:
>  	  $(data_hook_files)
>  	rm $(DESTDIR)$(OCAMLLIB)/nbd/libnbdocaml.a
>  
> +# This "tricks" ocamlfind into allowing us to compile other OCaml
> +# programs against a locally compiled copy of the libnbd sources.
> +# ocamlfind needs to see a directory called ‘nbd’ which contains
> +# ‘META’.  The current directory is called ‘ocaml’, but if we make
> +# this symlink then we can create the required directory structure.
> +#
> +# Note if you just want to use this, make sure you use
> +# ‘../libnbd/run make’ in your other program and everything should
> +# just work.
> +CLEANFILES += nbd
> +
> +all-local: nbd
> +
> +nbd:
> +	rm -f $@
> +	$(LN_S) . $@
> +
>  endif HAVE_OCAML
> diff --git a/.gitignore b/.gitignore
> index 5fc596773ed4..55a5449a70e2 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -141,6 +141,7 @@ Makefile.in
>  /ocaml/examples/.depend
>  /ocaml/libnbd-ocaml.3
>  /ocaml/libnbdocaml.a
> +/ocaml/nbd
>  /ocaml/nbd-c.c
>  /ocaml/stamp-manpages
>  /ocaml/stamp-mlnbd
> diff --git a/run.in b/run.in
> index 99c1f7ff0ff6..dda49228f949 100755
> --- a/run.in
> +++ b/run.in
> @@ -100,6 +100,8 @@ export GODEBUG=cgocheck=2
>  # Allow dependent packages to be compiled against local libnbd.
>  prepend PKG_CONFIG_PATH "$b/lib/local"
>  export PKG_CONFIG_PATH
> +prepend OCAMLPATH "$b/ocaml"
> +export OCAMLPATH
>  
>  # Do we have libtool?  If we have it then we can use it to make
>  # running valgrind simpler.  However don't depend on it.
> -- 
> 2.19.1.3.g30247aa5d201
> 
> 
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://listman.redhat.com/mailman/listinfo/libguestfs

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html




More information about the Libguestfs mailing list