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