From bf61bf7355d3876cdf49c3c837349e74844886a8 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 10 Mar 2020 15:02:30 +0000 Subject: [PATCH] build: Allow OCaml programs using libguestfs to be compiled against build dir. You have to use: ../libguestfs/run ./configure ../libguestfs/run make Use of the second ../libguestfs/run against make is unfortunate but I believe it's unavoidable due to the way that ocamlfind works. --- .gitignore | 1 + ocaml/Makefile.am | 19 ++++++++++++++++++- run.in | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1ebc5421f..cdc90453c 100644 --- a/.gitignore +++ b/.gitignore @@ -379,6 +379,7 @@ Makefile.in /ocaml/examples/guestfs-ocaml.3 /ocaml/examples/inspect_vm /ocaml/examples/stamp-guestfs-ocaml.pod +/ocaml/guestfs /ocaml/guestfs-c-actions.c /ocaml/guestfs-c-errnos.c /ocaml/guestfs.ml diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index c85efee64..31d026493 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -197,4 +197,21 @@ install-data-hook: CLEANFILES += $(noinst_DATA) $(check_DATA) -endif +# This "tricks" ocamlfind into allowing us to compile other OCaml +# programs against a locally compiled copy of the libguestfs sources. +# ocamlfind needs to see a directory called ‘guestfs’ 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 +# ‘../libguestfs/run make’ in your other program and everything should +# just work. +CLEANFILES += guestfs + +all-local: guestfs + +guestfs: + rm -f $@ + $(LN_S) . $@ + +endif HAVE_OCAML diff --git a/run.in b/run.in index 6896d5a2c..90552fb04 100755 --- a/run.in +++ b/run.in @@ -227,6 +227,8 @@ export MALLOC_PERTURB_=$random_val # local libguestfs. 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.