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