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