tests: Fix read_file test.
[libguestfs.git] / ocaml / Makefile.am
1 # libguestfs OCaml bindings
2 # Copyright (C) 2009 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 EXTRA_DIST = \
19         guestfs.mli guestfs.ml \
20         guestfs_c.c guestfs_c.h guestfs_c_actions.c \
21         .depend META.in \
22         bindtests.ml \
23         run-bindtests \
24         t/*.ml
25
26 SUBDIRS = examples
27
28 CLEANFILES = *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so
29 CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so
30
31 if HAVE_OCAML
32
33 noinst_DATA = mlguestfs.cma mlguestfs.cmxa META
34
35 mlguestfs.cma: guestfs_c.o guestfs_c_actions.o guestfs.cmo
36         $(OCAMLMKLIB) -o mlguestfs $^ -L$(top_builddir)/src/.libs -lguestfs
37
38 mlguestfs.cmxa: guestfs_c.o guestfs_c_actions.o guestfs.cmx
39         $(OCAMLMKLIB) -o mlguestfs $^ -L$(top_builddir)/src/.libs -lguestfs
40
41 guestfs_c.o: guestfs_c.c
42         $(CC) $(CFLAGS) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml -I$(top_srcdir)/src -I$(top_builddir)/src -fPIC -Wall -c $<
43
44 guestfs_c_actions.o: guestfs_c_actions.c
45         $(CC) $(CFLAGS) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml -I$(top_srcdir)/src -I$(top_builddir)/src -fPIC -Wall -c $<
46
47 TESTS_ENVIRONMENT = \
48         LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
49         LIBGUESTFS_PATH=$(top_builddir)/appliance \
50         $(VG)
51
52 TESTS = run-bindtests \
53         t/guestfs_005_load t/guestfs_010_launch t/guestfs_050_lvcreate \
54         t/guestfs_060_readdir
55 noinst_DATA += bindtests \
56         t/guestfs_005_load t/guestfs_010_launch t/guestfs_050_lvcreate \
57         t/guestfs_060_readdir
58
59 bindtests: bindtests.cmx mlguestfs.cmxa
60         mkdir -p t
61         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . unix.cmxa mlguestfs.cmxa $< -o $@
62
63 t/guestfs_005_load: t/guestfs_005_load.cmx mlguestfs.cmxa
64         mkdir -p t
65         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . unix.cmxa mlguestfs.cmxa $< -o $@
66
67 t/guestfs_010_launch: t/guestfs_010_launch.cmx mlguestfs.cmxa
68         mkdir -p t
69         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . unix.cmxa mlguestfs.cmxa $< -o $@
70
71 t/guestfs_050_lvcreate: t/guestfs_050_lvcreate.cmx mlguestfs.cmxa
72         mkdir -p t
73         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . unix.cmxa mlguestfs.cmxa $< -o $@
74
75 t/guestfs_060_readdir: t/guestfs_060_readdir.cmx mlguestfs.cmxa
76         mkdir -p t
77         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . unix.cmxa mlguestfs.cmxa $< -o $@
78
79 # Need to rebuild the tests from source if the main library has
80 # changed at all, otherwise we get inconsistent assumptions.
81 t/%.cmx: t/%.ml mlguestfs.cmxa
82         $(OCAMLFIND) ocamlopt -c $< -o $@
83
84 .mli.cmi:
85         $(OCAMLFIND) ocamlc -c $< -o $@
86 .ml.cmo:
87         $(OCAMLFIND) ocamlc -c $< -o $@
88 .ml.cmx:
89         $(OCAMLFIND) ocamlopt -c $< -o $@
90
91 depend: .depend
92
93 .depend: $(wildcard *.mli) $(wildcard *.ml)
94         rm -f .depend
95         $(OCAMLFIND) ocamldep $^ > $@
96
97 include .depend
98
99 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
100
101 # Do the installation by hand, because we want to run ocamlfind.
102 install-data-hook:
103         mkdir -p $(DESTDIR)$(OCAMLLIB)
104         mkdir -p $(DESTDIR)$(OCAMLLIB)/stublibs
105         $(OCAMLFIND) install \
106           -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \
107           guestfs \
108           META *.so *.a *.cma *.cmx *.cmxa *.cmi *.mli
109
110 CLEANFILES += $(noinst_DATA)
111
112 endif
113
114 # Tell version 3.79 and up of GNU make to not build goals in this
115 # directory in parallel.  (Possible solution for RHBZ#502309).
116 .NOTPARALLEL: