summaryrefslogtreecommitdiff
path: root/libvirt/Makefile.in
blob: d0bc51bc1d18a56f96b40d1ee594faf0aaaef232 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# ocaml-libvirt
# Copyright (C) 2007 Red Hat Inc., Richard W.M. Jones
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

WIN32		= @WIN32@

CFLAGS		= @CFLAGS@ \
		   @LIBVIRT_CFLAGS@ \
		   -DCAML_NAME_SPACE \
		   -I.. \
		   -I"$(shell ocamlc -where)" \
		   @DEBUG@ @WARNINGS@ @CFLAGS_FPIC@
LDFLAGS		= @LDFLAGS@ \
		   @LIBVIRT_LIBS@
#		   -L"$(shell ocamlc -where)"
CPPFLAGS	= @CPPFLAGS@ -D_FORTIFY_SOURCE=2

OCAMLC		= @OCAMLC@
OCAMLOPT	= @OCAMLOPT@
OCAMLFIND	= @OCAMLFIND@
OCAMLMKLIB	= @OCAMLMKLIB@
PERL		= @PERL@

ifneq ($(OCAMLFIND),)
OCAMLCPACKAGES	:= -package unix
OCAMLCFLAGS	:= -g -warn-error CDEFLMPSUVYZX-3 -safe-string
OCAMLCLIBS	:= -linkpkg
else
OCAMLCINCS	:=
OCAMLCFLAGS	:= -g -warn-error CDEFLMPSUVYZX-3 -safe-string
OCAMLCLIBS	:= unix.cma
endif

OCAMLOPTFLAGS	:= $(OCAMLCFLAGS)
ifneq ($(OCAMLFIND),)
OCAMLOPTPACKAGES := $(OCAMLCPACKAGES)
OCAMLOPTLIBS	:= $(OCAMLCLIBS)
else
OCAMLOPTINCS	:= $(OCAMLCINCS)
OCAMLOPTLIBS	:= unix.cmxa
endif

BYTE_TARGETS	:= mllibvirt.cma
OPT_TARGETS	:= mllibvirt.cmxa

all: $(BYTE_TARGETS)

opt: $(OPT_TARGETS)

COBJS := libvirt.cmo libvirt_version.cmo
OPTOBJS := libvirt.cmx libvirt_version.cmx

ifneq ($(OCAMLMKLIB),)
# Good, we can just use ocamlmklib
mllibvirt.cma: libvirt_c.o $(COBJS)
	$(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS)

mllibvirt.cmxa: libvirt_c.o $(OPTOBJS)
	$(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS)

else
ifeq ($(WIN32),yes)
# Ugh, MinGW doesn't have ocamlmklib.  This technique is copied from the
# example in OCaml distribution, otherlibs/win32unix/Makefile.nt

mllibvirt.cma: dllmllibvirt.dll libmllibvirt.a $(COBJS)
	$(OCAMLC) -a -linkall -o $@ $(COBJS) \
	  -dllib -lmllibvirt -cclib -lmllibvirt -cclib "$(LDFLAGS)"

mllibvirt.cmxa: libmllibvirt.a $(OPTOBJS)
	$(OCAMLOPT) -a -linkall -o $@ $(OPTOBJS) \
	  -cclib -lmllibvirt -cclib "$(LDFLAGS)"

dllmllibvirt.dll: libvirt_c.o
	$(CC) -shared -o $@ $^ \
	  $(LDFLAGS) "$(shell ocamlc -where)"/ocamlrun.a

libmllibvirt.a: libvirt_c.o
	ar rc $@ $^
	ranlib $@

else
# Don't know how to build a library on this platform.
$(BYTE_TARGETS) $(OPT_TARGETS):
	echo "Error: ocamlmklib missing, and no known way to build libraries on this platform"
	exit 1
endif
endif

# Automatically generate the C code from a Perl script 'generator.pl'.
libvirt_c.c: generator.pl
	$(PERL) -w $<

# Extra dependencies.
libvirt_c.c: libvirt_c_prologue.c
libvirt_c.c: libvirt_c_oneoffs.c
libvirt_c.c: libvirt_c_epilogue.c

# Status of automatically generated bindings.
autostatus: libvirt_c.c
	@echo -n "Functions which have manual bindings:    "
	@grep ^ocaml_libvirt_ libvirt_c_oneoffs.c  | wc -l
	@echo -n "Functions which have automatic bindings: "
	@grep ^ocaml_libvirt_ libvirt_c.c  | wc -l
	@echo -n "LOC in manual bindings:    "
	@wc -l < libvirt_c_oneoffs.c
	@echo -n "LOC in automatic bindings: "
	@wc -l < libvirt_c.c

libvirt.cmo: libvirt.cmi
libvirt.cmi: libvirt.mli

libvirt_version.cmo: libvirt_version.cmi
libvirt_version.cmi: libvirt_version.mli


install-byte:
	ocamlfind install $(OCAMLFIND_INSTFLAGS) -ldconf ignore libvirt \
	  ../META *.so *.a *.cma *.cmi *.mli

install-opt:
	ocamlfind install $(OCAMLFIND_INSTFLAGS) -ldconf ignore libvirt \
	  ../META *.so *.a *.cma *.cmx *.cmxa *.cmi *.mli

include ../Make.rules