Fix executable permissions added by Windoze.
[virt-top.git] / libvirt / Makefile.in
1 # ocaml-libvirt
2 # Copyright (C) 2007 Red Hat Inc., Richard W.M. Jones
3 #
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.
8 #
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.
13 #
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
17
18 WIN32           = @WIN32@
19
20 CFLAGS          = @CFLAGS@ \
21                    -I.. \
22                    -I"$(shell ocamlc -where)" \
23                    @DEBUG@ @WARNINGS@ @CFLAGS_FPIC@
24 LDFLAGS         = @LDFLAGS@
25 #                  -L"$(shell ocamlc -where)"
26
27 OCAMLC          = @OCAMLC@
28 OCAMLOPT        = @OCAMLOPT@
29 OCAMLFIND       = @OCAMLFIND@
30 OCAMLMKLIB      = @OCAMLMKLIB@
31
32 ifneq ($(OCAMLFIND),)
33 OCAMLCPACKAGES  := -package unix
34 OCAMLCFLAGS     := -g
35 OCAMLCLIBS      := -linkpkg
36 else
37 OCAMLCINCS      :=
38 OCAMLCFLAGS     := -g
39 OCAMLCLIBS      := unix.cma
40 endif
41
42 OCAMLOPTFLAGS   :=
43 ifneq ($(OCAMLFIND),)
44 OCAMLOPTPACKAGES := $(OCAMLCPACKAGES)
45 OCAMLOPTLIBS    := $(OCAMLCLIBS)
46 else
47 OCAMLOPTINCS    := $(OCAMLCINCS)
48 OCAMLOPTLIBS    := unix.cmxa
49 endif
50
51 export LIBRARY_PATH=.
52 export LD_LIBRARY_PATH=.
53
54 BYTE_TARGETS    := mllibvirt.cma
55 OPT_TARGETS     := mllibvirt.cmxa
56
57 all: $(BYTE_TARGETS)
58
59 opt: $(OPT_TARGETS)
60
61 COBJS := libvirt.cmo libvirt_version.cmo
62 OPTOBJS := libvirt.cmx libvirt_version.cmx
63
64 ifneq ($(OCAMLMKLIB),)
65 # Good, we can just use ocamlmklib
66 mllibvirt.cma: libvirt_c.o $(COBJS)
67         $(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS) -lvirt
68
69 mllibvirt.cmxa: libvirt_c.o $(OPTOBJS)
70         $(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS) -lvirt
71
72 else
73 ifeq ($(WIN32),yes)
74 # Ugh, MinGW doesn't have ocamlmklib.  This technique is copied from the
75 # example in OCaml distribution, otherlibs/win32unix/Makefile.nt
76
77 mllibvirt.cma: dllmllibvirt.dll libmllibvirt.a $(COBJS)
78         $(OCAMLC) -a -linkall -o $@ $(COBJS) \
79           -dllib -lmllibvirt -cclib -lmllibvirt -cclib "$(LDFLAGS) -lvirt"
80
81 mllibvirt.cmxa: libmllibvirt.a $(OPTOBJS)
82         $(OCAMLOPT) -a -linkall -o $@ $(OPTOBJS) \
83           -cclib -lmllibvirt -cclib "$(LDFLAGS) -lvirt"
84
85 dllmllibvirt.dll: libvirt_c.o
86         $(CC) -shared -o $@ $^ \
87           $(LDFLAGS) "$(shell ocamlc -where)"/ocamlrun.a -lvirt
88
89 libmllibvirt.a: libvirt_c.o
90         ar rc $@ $^
91         ranlib $@
92
93 else
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"
97         exit 1
98 endif
99 endif
100
101 libvirt.cmo: libvirt.cmi
102 libvirt.cmi: libvirt.mli
103
104 libvirt_version.cmo: libvirt_version.cmi
105 libvirt_version.cmi: libvirt_version.mli
106
107 install:
108         ocamlfind install libvirt ../META *.so *.a *.cmx *.cma *.cmxa *.mli
109
110 include ../Make.rules