From nobody Wed May 14 15:41:48 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539612407926162.8457866864112; Mon, 15 Oct 2018 07:06:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F35830B477C; Mon, 15 Oct 2018 14:06:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 372DA2BE7C; Mon, 15 Oct 2018 14:06:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AAAD8180B5B7; Mon, 15 Oct 2018 14:06:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9FE2j3R004017 for ; Mon, 15 Oct 2018 10:02:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C80E1064257; Mon, 15 Oct 2018 14:02:45 +0000 (UTC) Received: from thyrus.usersys.redhat.com (unknown [10.34.246.230]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82669100164E; Mon, 15 Oct 2018 14:02:44 +0000 (UTC) From: Pino Toscano To: libvir-list@redhat.com Date: Mon, 15 Oct 2018 16:02:35 +0200 Message-Id: <20181015140235.29263-5-ptoscano@redhat.com> In-Reply-To: <20181015140235.29263-1-ptoscano@redhat.com> References: <20181015140235.29263-1-ptoscano@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [ocaml PATCH 4/4] build: use pkg-config to find libvirt X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 15 Oct 2018 14:06:46 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 --- configure.ac | 20 ++------------------ libvirt/Makefile.in | 14 ++++++++------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/configure.ac b/configure.ac index 11ff2bf..7d923bf 100644 --- a/configure.ac +++ b/configure.ac @@ -55,24 +55,8 @@ if test "x$PERL" =3D "xno"; then fi =20 dnl Check for libvirt development environment. -AC_ARG_WITH(libvirt, - AC_HELP_STRING([--with-libvirt=3DPATH],[Set path to installed libvirt]), - [if test "x$withval" !=3D "x"; then - CFLAGS=3D"$CFLAGS -I$withval/include" - LDFLAGS=3D"$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 -AC_CHECK_HEADER([libvirt/virterror.h], - [], - AC_MSG_ERROR([You must install libvirt development package])) +PKG_PROG_PKG_CONFIG +PKG_CHECK_MODULES([LIBVIRT], [libvirt >=3D 1.0.2]) =20 dnl Check for basic OCaml environment & findlib. AC_PROG_OCAML diff --git a/libvirt/Makefile.in b/libvirt/Makefile.in index faca5ee..3a68aed 100644 --- a/libvirt/Makefile.in +++ b/libvirt/Makefile.in @@ -18,10 +18,12 @@ WIN32 =3D @WIN32@ =20 CFLAGS =3D @CFLAGS@ \ + @LIBVIRT_CFLAGS@ \ -I.. \ -I"$(shell ocamlc -where)" \ @DEBUG@ @WARNINGS@ @CFLAGS_FPIC@ -LDFLAGS =3D @LDFLAGS@ +LDFLAGS =3D @LDFLAGS@ \ + @LIBVIRT_LIBS@ # -L"$(shell ocamlc -where)" =20 OCAMLC =3D @OCAMLC@ @@ -62,10 +64,10 @@ OPTOBJS :=3D 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) =20 mllibvirt.cmxa: libvirt_c.o $(OPTOBJS) - $(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS) -lvirt + $(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS) =20 else ifeq ($(WIN32),yes) @@ -74,15 +76,15 @@ ifeq ($(WIN32),yes) =20 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)" =20 mllibvirt.cmxa: libmllibvirt.a $(OPTOBJS) $(OCAMLOPT) -a -linkall -o $@ $(OPTOBJS) \ - -cclib -lmllibvirt -cclib "$(LDFLAGS) -lvirt" + -cclib -lmllibvirt -cclib "$(LDFLAGS)" =20 dllmllibvirt.dll: libvirt_c.o $(CC) -shared -o $@ $^ \ - $(LDFLAGS) "$(shell ocamlc -where)"/ocamlrun.a -lvirt + $(LDFLAGS) "$(shell ocamlc -where)"/ocamlrun.a =20 libmllibvirt.a: libvirt_c.o ar rc $@ $^ --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list