f7d26ced1e3c8c9fa519d50d69d6f843568bac55
[hivex.git] / ocaml / Makefile.am
1 # hivex OCaml bindings
2 # Copyright (C) 2009-2010 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         .depend META.in \
20         hivex.mli hivex.ml \
21         hivex_c.c \
22         t/*.ml
23
24 CLEANFILES = *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so
25 CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so
26
27 AM_CPPFLAGS = \
28   -I$(top_builddir) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml \
29   -I$(top_srcdir)/lib \
30   $(WARN_CFLAGS) $(WERROR_CFLAGS)
31
32 if HAVE_OCAML
33
34 noinst_DATA = mlhivex.cma mlhivex.cmxa META
35
36 OBJS = hivex_c.o hivex.cmo
37 XOBJS = $(OBJS:.cmo=.cmx)
38
39 mlhivex.cma: $(OBJS)
40         $(OCAMLMKLIB) -o mlhivex $^ -L$(top_builddir)/lib/.libs -lhivex
41
42 mlhivex.cmxa: $(XOBJS)
43         $(OCAMLMKLIB) -o mlhivex $^ -L$(top_builddir)/lib/.libs -lhivex
44
45 hivex_c.o: hivex_c.c
46         $(CC) $(AM_CPPFLAGS) $(CFLAGS) -fPIC -Wall -c $<
47
48 TESTS_ENVIRONMENT = \
49         LD_LIBRARY_PATH=$(top_builddir)/lib/.libs \
50         $(VG)
51
52 TESTS = t/hivex_005_load
53 noinst_DATA += $(TESTS)
54
55 t/hivex_005_load: t/hivex_005_load.cmx mlhivex.cmxa
56         mkdir -p t
57         $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@
58
59 # Need to rebuild the tests from source if the main library has
60 # changed at all, otherwise we get inconsistent assumptions.
61 t/%.cmx: t/%.ml mlhivex.cmxa
62         $(OCAMLFIND) ocamlopt -package unix -linkpkg -c $< -o $@
63
64 .mli.cmi:
65         $(OCAMLFIND) ocamlc -package unix -c $< -o $@
66 .ml.cmo:
67         $(OCAMLFIND) ocamlc -package unix -c $< -o $@
68 .ml.cmx:
69         $(OCAMLFIND) ocamlopt -package unix -c $< -o $@
70
71 depend: .depend
72
73 .depend: $(wildcard *.mli) $(wildcard *.ml)
74         rm -f $@ $@-t
75         $(OCAMLFIND) ocamldep $^ | sed 's/  *$$//' | sort > $@-t
76         mv $@-t $@
77
78 include .depend
79
80 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
81
82 # Do the installation by hand, because we want to run ocamlfind.
83 install-data-hook:
84         mkdir -p $(DESTDIR)$(OCAMLLIB)
85         mkdir -p $(DESTDIR)$(OCAMLLIB)/stublibs
86         $(OCAMLFIND) install \
87           -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \
88           hivex \
89           META *.so *.a *.cma *.cmx *.cmxa *.cmi *.mli
90
91 CLEANFILES += $(noinst_DATA)
92
93 endif
94
95 # Tell version 3.79 and up of GNU make to not build goals in this
96 # directory in parallel.  (See RHBZ#502309).
97 .NOTPARALLEL: