doc: Add guestfish 'lvcreate 1M' gotcha.
[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 include $(top_srcdir)/subdir-rules.mk
19
20 generator_built = \
21         guestfs.mli \
22         guestfs.ml \
23         guestfs_inspector.mli \
24         guestfs_inspector.ml \
25         guestfs_c_actions.c \
26         bindtests.ml
27
28 EXTRA_DIST = \
29         $(generator_built) \
30         guestfs_c.c guestfs_c.h \
31         guestfs_inspector.mli guestfs_inspector.ml \
32         .depend META.in \
33         run-bindtests \
34         t/*.ml
35
36 CLEANFILES = *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so
37 CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so
38
39 AM_CPPFLAGS = -I$(top_builddir) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml \
40   -I$(top_srcdir)/src -I$(top_builddir)/src \
41   $(WARN_CFLAGS) $(WERROR_CFLAGS)
42
43 if HAVE_OCAML
44 if HAVE_XML_LIGHT
45
46 noinst_DATA = mlguestfs.cma mlguestfs.cmxa META
47
48 OBJS = guestfs_c.o guestfs_c_actions.o guestfs.cmo guestfs_inspector.cmo
49 XOBJS = $(OBJS:.cmo=.cmx)
50
51 mlguestfs.cma: $(OBJS)
52         $(OCAMLMKLIB) -o mlguestfs $^ -L$(top_builddir)/src/.libs -lguestfs
53
54 mlguestfs.cmxa: $(XOBJS)
55         $(OCAMLMKLIB) -o mlguestfs $^ -L$(top_builddir)/src/.libs -lguestfs
56
57 guestfs_c.o: guestfs_c.c
58         $(CC) $(AM_CPPFLAGS) $(CFLAGS) -fPIC -Wall -c $<
59
60 guestfs_c_actions.o: guestfs_c_actions.c
61         $(CC) $(AM_CPPFLAGS) $(CFLAGS) -fPIC -Wall -c $<
62
63 TESTS_ENVIRONMENT = \
64         LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
65         LIBGUESTFS_PATH=$(top_builddir)/appliance \
66         $(VG)
67
68 TESTS = run-bindtests \
69         t/guestfs_005_load t/guestfs_010_launch t/guestfs_050_lvcreate \
70         t/guestfs_060_readdir t/guestfs_070_threads t/guestfs_500_inspect
71 noinst_DATA += bindtests \
72         t/guestfs_005_load t/guestfs_010_launch t/guestfs_050_lvcreate \
73         t/guestfs_060_readdir t/guestfs_070_threads t/guestfs_500_inspect
74
75 bindtests: bindtests.cmx mlguestfs.cmxa
76         mkdir -p t
77         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package xml-light,unix -linkpkg mlguestfs.cmxa $< -o $@
78
79 t/guestfs_005_load: t/guestfs_005_load.cmx mlguestfs.cmxa
80         mkdir -p t
81         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package xml-light,unix -linkpkg mlguestfs.cmxa $< -o $@
82
83 t/guestfs_010_launch: t/guestfs_010_launch.cmx mlguestfs.cmxa
84         mkdir -p t
85         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package xml-light,unix -linkpkg mlguestfs.cmxa $< -o $@
86
87 t/guestfs_050_lvcreate: t/guestfs_050_lvcreate.cmx mlguestfs.cmxa
88         mkdir -p t
89         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package xml-light,unix -linkpkg mlguestfs.cmxa $< -o $@
90
91 t/guestfs_060_readdir: t/guestfs_060_readdir.cmx mlguestfs.cmxa
92         mkdir -p t
93         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package xml-light,unix -linkpkg mlguestfs.cmxa $< -o $@
94
95 t/guestfs_070_threads: t/guestfs_070_threads.cmx mlguestfs.cmxa
96         mkdir -p t
97         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package unix,threads -thread -linkpkg mlguestfs.cmxa $< -o $@
98
99 t/guestfs_500_inspect: t/guestfs_500_inspect.cmx mlguestfs.cmxa
100         mkdir -p t
101         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package xml-light,unix -linkpkg mlguestfs.cmxa $< -o $@
102
103 # Need to rebuild the tests from source if the main library has
104 # changed at all, otherwise we get inconsistent assumptions.
105 t/guestfs_070_threads.cmx: t/guestfs_070_threads.ml mlguestfs.cmxa
106         $(OCAMLFIND) ocamlopt -package unix,threads -thread -linkpkg -c $< -o $@
107
108 t/%.cmx: t/%.ml mlguestfs.cmxa
109         $(OCAMLFIND) ocamlopt -package xml-light,unix -linkpkg -c $< -o $@
110
111 .mli.cmi:
112         $(OCAMLFIND) ocamlc -package xml-light,unix -c $< -o $@
113 .ml.cmo:
114         $(OCAMLFIND) ocamlc -package xml-light,unix -c $< -o $@
115 .ml.cmx:
116         $(OCAMLFIND) ocamlopt -package xml-light,unix -c $< -o $@
117
118 depend: .depend
119
120 .depend: $(wildcard *.mli) $(wildcard *.ml)
121         rm -f $@ $@-t
122         $(OCAMLFIND) ocamldep $^ | sed 's/  *$$//' | sort > $@-t
123         mv $@-t $@
124
125 include .depend
126
127 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
128
129 # Do the installation by hand, because we want to run ocamlfind.
130 install-data-hook:
131         mkdir -p $(DESTDIR)$(OCAMLLIB)
132         mkdir -p $(DESTDIR)$(OCAMLLIB)/stublibs
133         $(OCAMLFIND) install \
134           -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \
135           guestfs \
136           META *.so *.a *.cma *.cmx *.cmxa *.cmi *.mli
137
138 CLEANFILES += $(noinst_DATA)
139
140 endif
141 endif
142
143 # Tell version 3.79 and up of GNU make to not build goals in this
144 # directory in parallel.  (Possible solution for RHBZ#502309).
145 .NOTPARALLEL: