[PATCH 04/29] Convert yajl check to use LIBVIRT_CHECK_LIB_FALLBACK

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

 



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

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 configure.ac    | 86 ++-------------------------------------------------------
 m4/virt-yajl.m4 | 34 +++++++++++++++++++++++
 2 files changed, 36 insertions(+), 84 deletions(-)
 create mode 100644 m4/virt-yajl.m4

diff --git a/configure.ac b/configure.ac
index 738a611..ef07386 100644
--- a/configure.ac
+++ b/configure.ac
@@ -149,6 +149,7 @@ AC_MSG_RESULT([$VERSION_SCRIPT_FLAGS])
 LIBVIRT_COMPILE_WARNINGS
 
 LIBVIRT_CHECK_LIBATTR
+LIBVIRT_CHECK_YAJL
 
 AC_MSG_CHECKING([for CPUID instruction])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
@@ -1092,85 +1093,6 @@ AC_SUBST([SASL_CFLAGS])
 AC_SUBST([SASL_LIBS])
 
 
-dnl YAJL JSON library http://lloyd.github.com/yajl/
-AC_ARG_WITH([yajl],
-  AC_HELP_STRING([--with-yajl], [use YAJL for JSON parsing/formatting @<:@default=check@:>@]),
-  [],
-  [with_yajl=check])
-
-if test "$with_qemu:$with_yajl" = yes:check; then
-  dnl Some versions of qemu require the use of yajl; try to detect them
-  dnl here, although we do not require qemu to exist in order to compile.
-  dnl This check mirrors src/qemu/qemu_capabilities.c
-  AC_PATH_PROGS([QEMU], [qemu-kvm qemu kvm qemu-system-x86_64],
-                [], [$PATH:/usr/bin:/usr/libexec])
-  if test -x "$QEMU"; then
-    if `$QEMU -help | grep libvirt` >/dev/null; then
-      with_yajl=yes
-    else
-      [qemu_version_sed='s/.*ersion \([0-9.,]*\).*/\1/']
-      qemu_version=`$QEMU -version | sed "$qemu_version_sed"`
-      case $qemu_version in
-        [[1-9]].* | 0.15.* ) with_yajl=yes ;;
-        0.* | '' ) ;;
-        *) AC_MSG_ERROR([Unexpected qemu version string]) ;;
-      esac
-    fi
-  fi
-fi
-
-YAJL_CFLAGS=
-YAJL_LIBS=
-with_yajl2=no
-if test "x$with_yajl" != "xno"; then
-  if test "x$with_yajl" != "xyes" && test "x$with_yajl" != "xcheck"; then
-    YAJL_CFLAGS="-I$with_yajl/include"
-    YAJL_LIBS="-L$with_yajl/lib"
-  fi
-  fail=0
-  old_cppflags="$CPPFLAGS"
-  old_libs="$LIBS"
-  CPPFLAGS="$CPPFLAGS $YAJL_CFLAGS"
-  LIBS="$LIBS $YAJL_LIBS"
-  AC_CHECK_HEADER([yajl/yajl_common.h],[],[
-    if test "x$with_yajl" = "xcheck" ; then
-        with_yajl=no
-    else
-        fail=1
-    fi])
-  if test "x$with_yajl" != "xno" ; then
-    AC_CHECK_LIB([yajl], [yajl_parse],[
-      YAJL_LIBS="$YAJL_LIBS -lyajl"
-      with_yajl=yes
-      AC_CHECK_LIB([yajl], [yajl_tree_parse],[
-        with_yajl2=yes
-      ],[])
-    ],[
-      if test "x$with_yajl" = "xcheck" ; then
-        with_yajl=no
-      else
-        fail=1
-      fi
-    ])
-  fi
-  test $fail = 1 &&
-    AC_MSG_ERROR([You must install the YAJL development package in order to compile libvirt])
-  CPPFLAGS="$old_cppflags"
-  LIBS="$old_libs"
-  if test "x$with_yajl" = "xyes" ; then
-    AC_DEFINE_UNQUOTED([WITH_YAJL], 1,
-      [whether YAJL is available for JSON parsing/formatting])
-  fi
-  if test "x$with_yajl2" = "xyes" ; then
-    AC_DEFINE_UNQUOTED([WITH_YAJL2], 1,
-      [whether YAJL has API version 2])
-  fi
-fi
-AM_CONDITIONAL([WITH_YAJL], [test "x$with_yajl" = "xyes"])
-AC_SUBST([YAJL_CFLAGS])
-AC_SUBST([YAJL_LIBS])
-
-
 dnl SANLOCK https://fedorahosted.org/sanlock/
 AC_ARG_WITH([sanlock],
   AC_HELP_STRING([--with-sanlock], [build Sanlock plugin for lock management @<:@default=check@:>@]),
@@ -3083,6 +3005,7 @@ AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Libraries])
 AC_MSG_NOTICE([])
 LIBVIRT_RESULT_LIBATTR
+LIBVIRT_RESULT_YAJL
 AC_MSG_NOTICE([  libxml: $LIBXML_CFLAGS $LIBXML_LIBS])
 AC_MSG_NOTICE([  dlopen: $DLOPEN_LIBS])
 if test "$with_esx" = "yes" ; then
@@ -3106,11 +3029,6 @@ AC_MSG_NOTICE([    sasl: $SASL_CFLAGS $SASL_LIBS])
 else
 AC_MSG_NOTICE([    sasl: no])
 fi
-if test "$with_yajl" != "no" ; then
-AC_MSG_NOTICE([    yajl: $YAJL_CFLAGS $YAJL_LIBS])
-else
-AC_MSG_NOTICE([    yajl: no])
-fi
 if test "$with_sanlock" != "no" ; then
 AC_MSG_NOTICE([ sanlock: $SANLOCK_CFLAGS $SANLOCK_LIBS])
 else
diff --git a/m4/virt-yajl.m4 b/m4/virt-yajl.m4
new file mode 100644
index 0000000..c1ffc64
--- /dev/null
+++ b/m4/virt-yajl.m4
@@ -0,0 +1,34 @@
+dnl The libyajl.so library
+
+AC_DEFUN([LIBVIRT_CHECK_YAJL],[
+  dnl YAJL JSON library http://lloyd.github.com/yajl/
+  if test "$with_qemu:$with_yajl" = yes:check; then
+    dnl Some versions of qemu require the use of yajl; try to detect them
+    dnl here, although we do not require qemu to exist in order to compile.
+    dnl This check mirrors src/qemu/qemu_capabilities.c
+    AC_PATH_PROGS([QEMU], [qemu-kvm qemu kvm qemu-system-x86_64],
+                  [], [$PATH:/usr/bin:/usr/libexec])
+    if test -x "$QEMU"; then
+      if `$QEMU -help | grep libvirt` >/dev/null; then
+        with_yajl=yes
+      else
+        [qemu_version_sed='s/.*ersion \([0-9.,]*\).*/\1/']
+        qemu_version=`$QEMU -version | sed "$qemu_version_sed"`
+        case $qemu_version in
+          [[1-9]].* | 0.15.* ) with_yajl=yes ;;
+          0.* | '' ) ;;
+          *) AC_MSG_ERROR([Unexpected qemu version string]) ;;
+        esac
+      fi
+    fi
+  fi
+
+  LIBVIRT_CHECK_LIB_FALLBACK([YAJL], [YAJL2], [yajl],
+                             [yajl], [yajl],
+                             [yajl_parse_complete], [yajl_tree_parse],
+                             [yajl/yajl_common.h])
+])
+
+AC_DEFUN([LIBVIRT_RESULT_YAJL],[
+  LIBVIRT_RESULT_LIB([YAJL], [yajl])
+])
-- 
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]