Commit 6f7a2c74 authored by Pino Toscano's avatar Pino Toscano

build: use pkg-config to find libvirt

Rely on pkg-config to detect libvirt, and use its variables to locate
it.  The version required is taken from the API documentation.
Signed-off-by: Pino Toscano's avatarPino Toscano <ptoscano@redhat.com>
parent 113b4a02
......@@ -55,24 +55,8 @@ if test "x$PERL" = "xno"; then
fi
dnl Check for libvirt development environment.
AC_ARG_WITH(libvirt,
AC_HELP_STRING([--with-libvirt=PATH],[Set path to installed libvirt]),
[if test "x$withval" != "x"; then
CFLAGS="$CFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
fi
])
AC_CHECK_LIB(virt,virConnectOpen,
[],
AC_MSG_ERROR([You must install libvirt library]))
AC_CHECK_HEADER([libvirt/libvirt.h],
[],
AC_MSG_ERROR([You must install libvirt development package]))
dnl We also use <libvirt/virterror.h>
AC_CHECK_HEADER([libvirt/virterror.h],
[],
AC_MSG_ERROR([You must install libvirt development package]))
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES([LIBVIRT], [libvirt >= 1.0.2])
dnl Check for basic OCaml environment & findlib.
AC_PROG_OCAML
......
......@@ -18,10 +18,12 @@
WIN32 = @WIN32@
CFLAGS = @CFLAGS@ \
@LIBVIRT_CFLAGS@ \
-I.. \
-I"$(shell ocamlc -where)" \
@DEBUG@ @WARNINGS@ @CFLAGS_FPIC@
LDFLAGS = @LDFLAGS@
LDFLAGS = @LDFLAGS@ \
@LIBVIRT_LIBS@
# -L"$(shell ocamlc -where)"
OCAMLC = @OCAMLC@
......@@ -62,10 +64,10 @@ OPTOBJS := libvirt.cmx libvirt_version.cmx
ifneq ($(OCAMLMKLIB),)
# Good, we can just use ocamlmklib
mllibvirt.cma: libvirt_c.o $(COBJS)
$(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS) -lvirt
$(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS)
mllibvirt.cmxa: libvirt_c.o $(OPTOBJS)
$(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS) -lvirt
$(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS)
else
ifeq ($(WIN32),yes)
......@@ -74,15 +76,15 @@ ifeq ($(WIN32),yes)
mllibvirt.cma: dllmllibvirt.dll libmllibvirt.a $(COBJS)
$(OCAMLC) -a -linkall -o $@ $(COBJS) \
-dllib -lmllibvirt -cclib -lmllibvirt -cclib "$(LDFLAGS) -lvirt"
-dllib -lmllibvirt -cclib -lmllibvirt -cclib "$(LDFLAGS)"
mllibvirt.cmxa: libmllibvirt.a $(OPTOBJS)
$(OCAMLOPT) -a -linkall -o $@ $(OPTOBJS) \
-cclib -lmllibvirt -cclib "$(LDFLAGS) -lvirt"
-cclib -lmllibvirt -cclib "$(LDFLAGS)"
dllmllibvirt.dll: libvirt_c.o
$(CC) -shared -o $@ $^ \
$(LDFLAGS) "$(shell ocamlc -where)"/ocamlrun.a -lvirt
$(LDFLAGS) "$(shell ocamlc -where)"/ocamlrun.a
libmllibvirt.a: libvirt_c.o
ar rc $@ $^
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment