7de8061
From 998387cf570a4569b9cdcb22f59aa7c979876fa6 Mon Sep 17 00:00:00 2001
7de8061
From: Hilko Bengen <bengen@hilluzination.de>
7de8061
Date: Thu, 12 May 2011 12:25:21 +0100
7de8061
Subject: [PATCH] ocaml: Use libtool to get correct library to build OCaml
7de8061
 tests.
7de8061
7de8061
See this thread:
7de8061
https://www.redhat.com/archives/libguestfs/2011-May/thread.html#00015
7de8061
---
7de8061
 ocaml/Makefile.am |   37 +++++--------------------------------
7de8061
 1 files changed, 5 insertions(+), 32 deletions(-)
7de8061
7de8061
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
7de8061
index fee3b88..e61b5db 100644
7de8061
--- a/ocaml/Makefile.am
7de8061
+++ b/ocaml/Makefile.am
7de8061
@@ -63,38 +63,11 @@ TESTS = \
7de8061
 	t/hivex_300_fold
7de8061
 noinst_DATA += $(TESTS)
7de8061
 
7de8061
-t/hivex_005_load: t/hivex_005_load.cmo mlhivex.cma
7de8061
-	mkdir -p t
7de8061
-	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-t/hivex_010_open: t/hivex_010_open.cmo mlhivex.cma
7de8061
-	mkdir -p t
7de8061
-	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-t/hivex_020_root: t/hivex_020_root.cmo mlhivex.cma
7de8061
-	mkdir -p t
7de8061
-	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-t/hivex_100_errors: t/hivex_100_errors.cmo mlhivex.cma
7de8061
-	mkdir -p t
7de8061
-	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-t/hivex_110_gc_handle: t/hivex_110_gc_handle.cmo mlhivex.cma
7de8061
-	mkdir -p t
7de8061
-	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-t/hivex_200_write: t/hivex_200_write.cmo mlhivex.cma
7de8061
-	mkdir -p t
7de8061
-	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-t/hivex_300_fold: t/hivex_300_fold.cmo mlhivex.cma
7de8061
-	mkdir -p t
7de8061
-	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-# Need to rebuild the tests from source if the main library has
7de8061
-# changed at all, otherwise we get inconsistent assumptions.
7de8061
-t/%.cmx: t/%.ml mlhivex.cmxa
7de8061
-	$(OCAMLFIND) ocamlopt -package unix -linkpkg -c $< -o $@
7de8061
+# https://www.redhat.com/archives/libguestfs/2011-May/thread.html#00015
7de8061
+t/%: t/%.cmo mlhivex.cma
7de8061
+	$(LIBTOOL) --mode=execute -dlopen $(top_builddir)/lib/libhivex.la \
7de8061
+	  $(OCAMLFIND) ocamlc -dllpath $(abs_builddir) -package unix \
7de8061
+	  -linkpkg mlhivex.cma $< -o $@
7de8061
 
7de8061
 .mli.cmi:
7de8061
 	$(OCAMLFIND) ocamlc -package unix -c $< -o $@
7de8061
-- 
7de8061
1.7.5
7de8061
7de8061
--- hivex/ocaml/Makefile.in.orig	2011-05-12 12:26:46.451011976 +0100
7de8061
+++ hivex/ocaml/Makefile.in	2011-05-12 12:26:56.623195014 +0100
7de8061
@@ -1188,38 +1188,11 @@
7de8061
 @HAVE_OCAML_TRUE@hivex_c.o: hivex_c.c
7de8061
 @HAVE_OCAML_TRUE@	$(CC) $(AM_CPPFLAGS) $(CFLAGS) -fPIC -Wall -c $<
7de8061
 
7de8061
-@HAVE_OCAML_TRUE@t/hivex_005_load: t/hivex_005_load.cmo mlhivex.cma
7de8061
-@HAVE_OCAML_TRUE@	mkdir -p t
7de8061
-@HAVE_OCAML_TRUE@	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-@HAVE_OCAML_TRUE@t/hivex_010_open: t/hivex_010_open.cmo mlhivex.cma
7de8061
-@HAVE_OCAML_TRUE@	mkdir -p t
7de8061
-@HAVE_OCAML_TRUE@	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-@HAVE_OCAML_TRUE@t/hivex_020_root: t/hivex_020_root.cmo mlhivex.cma
7de8061
-@HAVE_OCAML_TRUE@	mkdir -p t
7de8061
-@HAVE_OCAML_TRUE@	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-@HAVE_OCAML_TRUE@t/hivex_100_errors: t/hivex_100_errors.cmo mlhivex.cma
7de8061
-@HAVE_OCAML_TRUE@	mkdir -p t
7de8061
-@HAVE_OCAML_TRUE@	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-@HAVE_OCAML_TRUE@t/hivex_110_gc_handle: t/hivex_110_gc_handle.cmo mlhivex.cma
7de8061
-@HAVE_OCAML_TRUE@	mkdir -p t
7de8061
-@HAVE_OCAML_TRUE@	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-@HAVE_OCAML_TRUE@t/hivex_200_write: t/hivex_200_write.cmo mlhivex.cma
7de8061
-@HAVE_OCAML_TRUE@	mkdir -p t
7de8061
-@HAVE_OCAML_TRUE@	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-@HAVE_OCAML_TRUE@t/hivex_300_fold: t/hivex_300_fold.cmo mlhivex.cma
7de8061
-@HAVE_OCAML_TRUE@	mkdir -p t
7de8061
-@HAVE_OCAML_TRUE@	$(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
7de8061
-
7de8061
-# Need to rebuild the tests from source if the main library has
7de8061
-# changed at all, otherwise we get inconsistent assumptions.
7de8061
-@HAVE_OCAML_TRUE@t/%.cmx: t/%.ml mlhivex.cmxa
7de8061
-@HAVE_OCAML_TRUE@	$(OCAMLFIND) ocamlopt -package unix -linkpkg -c $< -o $@
7de8061
+# https://www.redhat.com/archives/libguestfs/2011-May/thread.html#00015
7de8061
+@HAVE_OCAML_TRUE@t/%: t/%.cmo mlhivex.cma
7de8061
+@HAVE_OCAML_TRUE@	$(LIBTOOL) --mode=execute -dlopen $(top_builddir)/lib/libhivex.la \
7de8061
+@HAVE_OCAML_TRUE@	  $(OCAMLFIND) ocamlc -dllpath $(abs_builddir) -package unix \
7de8061
+@HAVE_OCAML_TRUE@	  -linkpkg mlhivex.cma $< -o $@
7de8061
 
7de8061
 @HAVE_OCAML_TRUE@.mli.cmi:
7de8061
 @HAVE_OCAML_TRUE@	$(OCAMLFIND) ocamlc -package unix -c $< -o $@