[PATCH 18/29] Add LIBVIRT_CHECK_PKG wrapper around pkg-config

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

To simplify use of PKG_CHECK_MODULES in association with a
--with-XXX arg, introduce LIBVIRT_CHECK_PKG

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 m4/virt-lib.m4 | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/m4/virt-lib.m4 b/m4/virt-lib.m4
index 86a6aa0..cff9ac7 100644
--- a/m4/virt-lib.m4
+++ b/m4/virt-lib.m4
@@ -197,6 +197,62 @@ AC_DEFUN([LIBVIRT_CHECK_LIB_FALLBACK],[
 ])
 
 dnl
+dnl Probe for existance of libXXXX and set WITH_XXX
+dnl config header var, WITH_XXXX make conditional and
+dnl with_XXX configure shell var.
+dnl
+dnl  LIBVIRT_CHECK_PKG([WITH_VAR],[NAME_VAR],[LIBNAME],[FUNCNAME],[HDRNAME])
+dnl
+dnl    WITH_VAR: Suffix for the WITH_XXX variable in config.h & conditional in make,
+dnl              and prefix for the XXX_CFLAGS and XXX_LIBS make variables
+dnl    NAME_VAR: Suffix for the --with-XXX configure arg and $with_XXX configure variable
+dnl    PKG_NAME: Name of the pkg-config module
+dnl     PKG_VER: Version of the pkg-config module
+dnl
+dnl eg
+dnl
+dnl  LIBVIRT_CHECK_PKG([NETCF],[netcf],[netcf], [0.1.4])
+dnl
+AC_DEFUN([LIBVIRT_CHECK_PKG],[
+  AS_VAR_PUSHDEF([mod_var],[$1])
+  AS_VAR_PUSHDEF([config_var],[WITH_$1])
+  AS_VAR_PUSHDEF([make_var],[WITH_$1])
+  AS_VAR_PUSHDEF([cflags_var],[$1_CFLAGS])
+  AS_VAR_PUSHDEF([libs_var],[$1_LIBS])
+  AS_VAR_PUSHDEF([name_var],[$2])
+  AS_VAR_PUSHDEF([arg_var],[with-$2])
+  AS_VAR_PUSHDEF([with_var],[with_$2])
+  dnl AS_VAR_PUSHDEF([pkk_name],[$3])
+  dnl AS_VAR_PUSHDEF([pkg_ver],[$4])
+
+  AC_ARG_WITH([name_var],
+    AC_HELP_STRING([--arg_var],
+                   [with $3 support @<:@default=check@:>@]),[],[with_var][=check])
+
+  fail=0
+  if test "$with_var" != "no" ; then
+    PKG_CHECK_MODULES(mod_var, $3 >= $4,[
+      AS_VAR_SET([with_var],[yes])
+    ],[
+      if test "$with_var" != "check"; then
+        fail=1
+      fi
+      AS_VAR_SET([with_var],[no])
+    ])
+  fi
+
+  if test $fail = 1; then
+    AC_MSG_ERROR([You must install the $3 pkg-config module to compile libvirt])
+  fi
+
+  if test "$with_var" = "yes" ; then
+    AC_DEFINE_UNQUOTED(config_var, 1, [whether $3 is available])
+  fi
+
+  AM_CONDITIONAL(make_var, [test "$with_var" = "yes"])
+])
+
+dnl
 dnl To be called after a LIBVIRT_CHECK_LIB or LIBVIRT_CHECK_LIB_FALLBACK
 dnl invocation to print the result status
 dnl
-- 
1.7.11.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]