1 # libguestfs OCaml bindings
2 # Copyright (C) 2009 Red Hat Inc.
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.
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.
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.
18 include $(top_srcdir)/subdir-rules.mk
28 guestfs_c.c guestfs_c.h \
33 CLEANFILES = *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so
34 CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so
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)
42 noinst_DATA = mlguestfs.cma mlguestfs.cmxa META
44 OBJS = guestfs_c.o guestfs_c_actions.o guestfs.cmo
45 XOBJS = $(OBJS:.cmo=.cmx)
47 mlguestfs.cma: $(OBJS)
48 $(OCAMLMKLIB) -o mlguestfs $^ -L$(top_builddir)/src/.libs -lguestfs
50 mlguestfs.cmxa: $(XOBJS)
51 $(OCAMLMKLIB) -o mlguestfs $^ -L$(top_builddir)/src/.libs -lguestfs
53 guestfs_c.o: guestfs_c.c
54 $(CC) $(AM_CPPFLAGS) $(CFLAGS) -fPIC -Wall -c $<
56 guestfs_c_actions.o: guestfs_c_actions.c
57 $(CC) $(AM_CPPFLAGS) $(CFLAGS) -fPIC -Wall -c $<
60 LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
61 LIBGUESTFS_PATH=$(top_builddir)/appliance \
64 TESTS = run-bindtests \
67 t/guestfs_070_threads \
68 t/guestfs_080_optargs \
69 t/guestfs_400_events \
70 t/guestfs_400_progress
71 noinst_DATA += bindtests \
74 t/guestfs_070_threads \
75 t/guestfs_080_optargs \
76 t/guestfs_400_events \
77 t/guestfs_400_progress
79 bindtests: bindtests.cmx mlguestfs.cmxa
81 $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package unix -linkpkg mlguestfs.cmxa $< -o $@
83 t/guestfs_005_load: t/guestfs_005_load.cmx mlguestfs.cmxa
85 $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package unix -linkpkg mlguestfs.cmxa $< -o $@
87 t/guestfs_010_basic: t/guestfs_010_basic.cmx mlguestfs.cmxa
89 $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package unix -linkpkg mlguestfs.cmxa $< -o $@
91 t/guestfs_070_threads: t/guestfs_070_threads.cmx mlguestfs.cmxa
93 $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package unix,threads -thread -linkpkg mlguestfs.cmxa $< -o $@
95 t/guestfs_080_optargs: t/guestfs_080_optargs.cmx mlguestfs.cmxa
97 $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package unix -linkpkg mlguestfs.cmxa $< -o $@
99 t/guestfs_400_events: t/guestfs_400_events.cmx mlguestfs.cmxa
101 $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package unix -linkpkg mlguestfs.cmxa $< -o $@
103 t/guestfs_400_progress: t/guestfs_400_progress.cmx mlguestfs.cmxa
105 $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/src/.libs -I . -package unix -linkpkg mlguestfs.cmxa $< -o $@
107 # Need to rebuild the tests from source if the main library has
108 # changed at all, otherwise we get inconsistent assumptions.
109 t/guestfs_070_threads.cmx: t/guestfs_070_threads.ml mlguestfs.cmxa
110 $(OCAMLFIND) ocamlopt -package unix,threads -thread -linkpkg -c $< -o $@
112 t/%.cmx: t/%.ml mlguestfs.cmxa
113 $(OCAMLFIND) ocamlopt -package unix -linkpkg -c $< -o $@
116 $(OCAMLFIND) ocamlc -package unix -c $< -o $@
118 $(OCAMLFIND) ocamlc -package unix -c $< -o $@
120 $(OCAMLFIND) ocamlopt -package unix -c $< -o $@
124 .depend: $(wildcard *.mli) $(wildcard *.ml)
126 $(OCAMLFIND) ocamldep $^ | sed 's/ *$$//' | sort > $@-t
131 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
133 # Do the installation by hand, because we want to run ocamlfind.
135 mkdir -p $(DESTDIR)$(OCAMLLIB)
136 mkdir -p $(DESTDIR)$(OCAMLLIB)/stublibs
137 $(OCAMLFIND) install \
138 -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \
140 META *.so *.a *.cma *.cmx *.cmxa *.cmi *.mli
142 CLEANFILES += $(noinst_DATA)
146 # Tell version 3.79 and up of GNU make to not build goals in this
147 # directory in parallel. (Possible solution for RHBZ#502309).