c7d43a01b96be84e304e1f5f6135e8218472616a
[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         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . unix.cmxa mlguestfs.cmxa $< -o $@
61
62 t/guestfs_005_load: t/guestfs_005_load.cmx mlguestfs.cmxa
63         mkdir -p t
64         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . unix.cmxa mlguestfs.cmxa $< -o $@
65
66 t/guestfs_010_launch: t/guestfs_010_launch.cmx mlguestfs.cmxa
67         mkdir -p t
68         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . unix.cmxa mlguestfs.cmxa $< -o $@
69
70 t/guestfs_050_lvcreate: t/guestfs_050_lvcreate.cmx mlguestfs.cmxa
71         mkdir -p t
72         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . unix.cmxa mlguestfs.cmxa $< -o $@
73
74 t/guestfs_060_readdir: t/guestfs_060_readdir.cmx mlguestfs.cmxa
75         mkdir -p t
76         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . unix.cmxa mlguestfs.cmxa $< -o $@
77
78 .mli.cmi:
79         $(OCAMLFIND) ocamlc -c $< -o $@
80 .ml.cmo:
81         $(OCAMLFIND) ocamlc -c $< -o $@
82 .ml.cmx:
83         $(OCAMLFIND) ocamlopt -c $< -o $@
84
85 depend: .depend
86
87 .depend: $(wildcard *.mli) $(wildcard *.ml)
88         rm -f .depend
89         $(OCAMLFIND) ocamldep $^ > $@
90
91 include .depend
92
93 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
94
95 # Do the installation by hand, because we want to run ocamlfind.
96 install-data-hook:
97         mkdir -p $(DESTDIR)$(OCAMLLIB)
98         mkdir -p $(DESTDIR)$(OCAMLLIB)/stublibs
99         $(OCAMLFIND) install \
100           -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \
101           guestfs \
102           META *.so *.a *.cma *.cmx *.cmxa *.cmi *.mli
103
104 CLEANFILES += $(noinst_DATA)
105
106 endif
107
108 # Tell version 3.79 and up of GNU make to not build goals in this
109 # directory in parallel.  (Possible solution for RHBZ#502309).
110 .NOTPARALLEL: