-t/hivex_005_load: t/hivex_005_load.cmx mlhivex.cmxa
- mkdir -p t
- $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@
-
-t/hivex_010_open: t/hivex_010_open.cmx mlhivex.cmxa
- mkdir -p t
- $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@
-
-t/hivex_020_root: t/hivex_020_root.cmx mlhivex.cmxa
- mkdir -p t
- $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@
-
-t/hivex_100_errors: t/hivex_100_errors.cmx mlhivex.cmxa
- mkdir -p t
- $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@
-
-t/hivex_110_gc_handle: t/hivex_110_gc_handle.cmx mlhivex.cmxa
- mkdir -p t
- $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@
-
-t/hivex_200_write: t/hivex_200_write.cmx mlhivex.cmxa
- mkdir -p t
- $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@
-
-t/hivex_300_fold: t/hivex_300_fold.cmx mlhivex.cmxa
- mkdir -p t
- $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@
-
-# Need to rebuild the tests from source if the main library has
-# changed at all, otherwise we get inconsistent assumptions.
-t/%.cmx: t/%.ml mlhivex.cmxa
- $(OCAMLFIND) ocamlopt -package unix -linkpkg -c $< -o $@
+# https://www.redhat.com/archives/libguestfs/2011-May/thread.html#00015
+t/%: t/%.cmo mlhivex.cma
+ $(LIBTOOL) --mode=execute -dlopen $(top_builddir)/lib/libhivex.la \
+ $(OCAMLFIND) ocamlc -dllpath $(abs_builddir) -package unix \
+ -linkpkg mlhivex.cma $< -o $@