2 # Copyright (C) 2007 Red Hat Inc., Richard W.M. Jones
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2 of the License, or (at your option) any later version.
9 # This library 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 GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 -I"$(shell ocamlc -where)" \
23 @DEBUG@ @WARNINGS@ @CFLAGS_FPIC@
25 # -L"$(shell ocamlc -where)"
29 OCAMLFIND = @OCAMLFIND@
30 OCAMLMKLIB = @OCAMLMKLIB@
34 OCAMLCPACKAGES := -package unix
35 OCAMLCFLAGS := -g -warn-error CDEFLMPSUVYZX-3 -safe-string
36 OCAMLCLIBS := -linkpkg
39 OCAMLCFLAGS := -g -warn-error CDEFLMPSUVYZX-3 -safe-string
40 OCAMLCLIBS := unix.cma
43 OCAMLOPTFLAGS := $(OCAMLCFLAGS)
45 OCAMLOPTPACKAGES := $(OCAMLCPACKAGES)
46 OCAMLOPTLIBS := $(OCAMLCLIBS)
48 OCAMLOPTINCS := $(OCAMLCINCS)
49 OCAMLOPTLIBS := unix.cmxa
53 export LD_LIBRARY_PATH=.
55 BYTE_TARGETS := mllibvirt.cma
56 OPT_TARGETS := mllibvirt.cmxa
62 COBJS := libvirt.cmo libvirt_version.cmo
63 OPTOBJS := libvirt.cmx libvirt_version.cmx
65 ifneq ($(OCAMLMKLIB),)
66 # Good, we can just use ocamlmklib
67 mllibvirt.cma: libvirt_c.o $(COBJS)
68 $(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS) -lvirt
70 mllibvirt.cmxa: libvirt_c.o $(OPTOBJS)
71 $(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS) -lvirt
75 # Ugh, MinGW doesn't have ocamlmklib. This technique is copied from the
76 # example in OCaml distribution, otherlibs/win32unix/Makefile.nt
78 mllibvirt.cma: dllmllibvirt.dll libmllibvirt.a $(COBJS)
79 $(OCAMLC) -a -linkall -o $@ $(COBJS) \
80 -dllib -lmllibvirt -cclib -lmllibvirt -cclib "$(LDFLAGS) -lvirt"
82 mllibvirt.cmxa: libmllibvirt.a $(OPTOBJS)
83 $(OCAMLOPT) -a -linkall -o $@ $(OPTOBJS) \
84 -cclib -lmllibvirt -cclib "$(LDFLAGS) -lvirt"
86 dllmllibvirt.dll: libvirt_c.o
87 $(CC) -shared -o $@ $^ \
88 $(LDFLAGS) "$(shell ocamlc -where)"/ocamlrun.a -lvirt
90 libmllibvirt.a: libvirt_c.o
95 # Don't know how to build a library on this platform.
96 $(BYTE_TARGETS) $(OPT_TARGETS):
97 echo "Error: ocamlmklib missing, and no known way to build libraries on this platform"
102 # Automatically generate the C code from a Perl script 'generator.pl'.
103 libvirt_c.c: generator.pl
106 # Extra dependencies.
107 libvirt_c.c: libvirt_c_prologue.c
108 libvirt_c.c: libvirt_c_oneoffs.c
109 libvirt_c.c: libvirt_c_epilogue.c
111 # Status of automatically generated bindings.
112 autostatus: libvirt_c.c
113 @echo -n "Functions which have manual bindings: "
114 @grep ^ocaml_libvirt_ libvirt_c_oneoffs.c | wc -l
115 @echo -n "Functions which have automatic bindings: "
116 @grep ^ocaml_libvirt_ libvirt_c.c | wc -l
117 @echo -n "LOC in manual bindings: "
118 @wc -l < libvirt_c_oneoffs.c
119 @echo -n "LOC in automatic bindings: "
122 libvirt.cmo: libvirt.cmi
123 libvirt.cmi: libvirt.mli
125 libvirt_version.cmo: libvirt_version.cmi
126 libvirt_version.cmi: libvirt_version.mli
130 ocamlfind install $(OCAMLFIND_INSTFLAGS) -ldconf ignore libvirt \
131 ../META *.so *.a *.cma *.cmi *.mli
134 ocamlfind install $(OCAMLFIND_INSTFLAGS) -ldconf ignore libvirt \
135 ../META *.so *.a *.cma *.cmx *.cmxa *.cmi *.mli
137 include ../Make.rules