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@
33 OCAMLCPACKAGES := -package unix
35 OCAMLCLIBS := -linkpkg
39 OCAMLCLIBS := unix.cma
44 OCAMLOPTPACKAGES := $(OCAMLCPACKAGES)
45 OCAMLOPTLIBS := $(OCAMLCLIBS)
47 OCAMLOPTINCS := $(OCAMLCINCS)
48 OCAMLOPTLIBS := unix.cmxa
52 export LD_LIBRARY_PATH=.
54 BYTE_TARGETS := mllibvirt.cma
55 OPT_TARGETS := mllibvirt.cmxa
61 COBJS := libvirt.cmo libvirt_version.cmo
62 OPTOBJS := libvirt.cmx libvirt_version.cmx
64 ifneq ($(OCAMLMKLIB),)
65 # Good, we can just use ocamlmklib
66 mllibvirt.cma: libvirt_c.o $(COBJS)
67 $(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS) -lvirt
69 mllibvirt.cmxa: libvirt_c.o $(OPTOBJS)
70 $(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS) -lvirt
74 # Ugh, MinGW doesn't have ocamlmklib. This technique is copied from the
75 # example in OCaml distribution, otherlibs/win32unix/Makefile.nt
77 mllibvirt.cma: dllmllibvirt.dll libmllibvirt.a $(COBJS)
78 $(OCAMLC) -a -linkall -o $@ $(COBJS) \
79 -dllib -lmllibvirt -cclib -lmllibvirt -cclib "$(LDFLAGS) -lvirt"
81 mllibvirt.cmxa: libmllibvirt.a $(OPTOBJS)
82 $(OCAMLOPT) -a -linkall -o $@ $(OPTOBJS) \
83 -cclib -lmllibvirt -cclib "$(LDFLAGS) -lvirt"
85 dllmllibvirt.dll: libvirt_c.o
86 $(CC) -shared -o $@ $^ \
87 $(LDFLAGS) "$(shell ocamlc -where)"/ocamlrun.a -lvirt
89 libmllibvirt.a: libvirt_c.o
94 # Don't know how to build a library on this platform.
95 $(BYTE_TARGETS) $(OPT_TARGETS):
96 echo "Error: ocamlmklib missing, and no known way to build libraries on this platform"
101 # Automatically generate the C code from a Perl script 'generator.pl'.
102 libvirt_c.c: generator.pl
105 # Extra dependencies.
106 libvirt_c.c: libvirt_c_prologue.c
107 libvirt_c.c: libvirt_c_oneoffs.c
108 libvirt_c.c: libvirt_c_epilogue.c
110 # Status of automatically generated bindings.
111 autostatus: libvirt_c.c
112 @echo -n "Functions which have manual bindings: "
113 @grep ^ocaml_libvirt_ libvirt_c_oneoffs.c | wc -l
114 @echo -n "Functions which have automatic bindings: "
115 @grep ^ocaml_libvirt_ libvirt_c.c | wc -l
116 @echo -n "LOC in manual bindings: "
117 @wc -l < libvirt_c_oneoffs.c
118 @echo -n "LOC in automatic bindings: "
121 libvirt.cmo: libvirt.cmi
122 libvirt.cmi: libvirt.mli
124 libvirt_version.cmo: libvirt_version.cmi
125 libvirt_version.cmi: libvirt_version.mli
129 ocamlfind install $(OCAMLFIND_INSTFLAGS) -ldconf ignore libvirt \
130 ../META *.so *.a *.cma *.cmi *.mli
133 ocamlfind install $(OCAMLFIND_INSTFLAGS) -ldconf ignore libvirt \
134 ../META *.so *.a *.cma *.cmx *.cmxa *.cmi *.mli
136 include ../Make.rules