[libvirt] [PATCH 22/89] configure: move XDR check to its own file

Pavel Hrdina phrdina at redhat.com
Fri Dec 16 09:10:50 UTC 2016


Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 configure.ac   | 40 ++-------------------------------------
 m4/virt-xdr.m4 | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 38 deletions(-)
 create mode 100644 m4/virt-xdr.m4

diff --git a/configure.ac b/configure.ac
index 57f7728c63..e80528d211 100644
--- a/configure.ac
+++ b/configure.ac
@@ -471,39 +471,7 @@ dnl
 dnl check for XDR
 dnl
 
-if test x"$with_remote" = x"yes" || test x"$with_libvirtd" = x"yes"; then
-    dnl Where are the XDR functions?
-    dnl If portablexdr is installed, prefer that.
-    dnl Otherwise try -lrpc (Cygwin) -lxdr (some MinGW), -lnsl (Solaris)
-    dnl -ltirpc (glibc 2.13.90 or newer) or none (most Unix)
-    AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
-        AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl tirpc],[],
-            [AC_MSG_ERROR([Cannot find a XDR library])])
-        ])
-
-    dnl check for cygwin's variation in xdr function names
-    AC_CHECK_FUNCS([xdr_u_int64_t],[],[],[#include <rpc/xdr.h>])
-
-    dnl Cygwin/recent glibc requires -I/usr/include/tirpc for <rpc/rpc.h>
-    old_CFLAGS=$CFLAGS
-    AC_CACHE_CHECK([where to find <rpc/rpc.h>], [lv_cv_xdr_cflags], [
-      for add_CFLAGS in '' '-I/usr/include/tirpc' 'missing'; do
-        if test x"$add_CFLAGS" = xmissing; then
-          lv_cv_xdr_cflags=missing; break
-        fi
-        CFLAGS="$old_CFLAGS $add_CFLAGS"
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <rpc/rpc.h>
-        ]])], [lv_cv_xdr_cflags=${add_CFLAGS:-none}; break])
-      done
-    ])
-    CFLAGS=$old_CFLAGS
-    case $lv_cv_xdr_cflags in
-      none) XDR_CFLAGS= ;;
-      missing) AC_MSG_ERROR([Unable to find <rpc/rpc.h>]) ;;
-      *) XDR_CFLAGS=$lv_cv_xdr_cflags ;;
-    esac
-    AC_SUBST([XDR_CFLAGS])
-fi
+LIBVIRT_CHECK_XDR
 
 
 dnl
@@ -2207,6 +2175,7 @@ LIBVIRT_RESULT_SASL
 LIBVIRT_RESULT_SELINUX
 LIBVIRT_RESULT_SSH2
 LIBVIRT_RESULT_UDEV
+LIBVIRT_RESULT_XDR
 LIBVIRT_RESULT_YAJL
 if test "$with_xen" = "yes" ; then
 AC_MSG_NOTICE([     xen: $XEN_CFLAGS $XEN_LIBS])
@@ -2238,11 +2207,6 @@ AC_MSG_NOTICE([   mscom: $MSCOM_LIBS])
 else
 AC_MSG_NOTICE([   mscom: no])
 fi
-if test "$with_remote" = "yes" || test "$with_libvirtd" = "yes" ; then
-AC_MSG_NOTICE([     xdr: $XDR_CFLAGS])
-else
-AC_MSG_NOTICE([     xdr: no])
-fi
 if test "$with_storage_rbd" = "yes" ; then
 AC_MSG_NOTICE([     rbd: $LIBRBD_LIBS])
 else
diff --git a/m4/virt-xdr.m4 b/m4/virt-xdr.m4
new file mode 100644
index 0000000000..a65407d955
--- /dev/null
+++ b/m4/virt-xdr.m4
@@ -0,0 +1,60 @@
+dnl The XDR implementation check
+dnl
+dnl Copyright (C) 2016 Red Hat, Inc.
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library.  If not, see
+dnl <http://www.gnu.org/licenses/>.
+dnl
+
+AC_DEFUN([LIBVIRT_CHECK_XDR], [
+  with_xdr="no"
+  if test x"$with_remote" = x"yes" || test x"$with_libvirtd" = x"yes"; then
+    dnl Where are the XDR functions?
+    dnl If portablexdr is installed, prefer that.
+    dnl Otherwise try -lrpc (Cygwin) -lxdr (some MinGW), -lnsl (Solaris)
+    dnl -ltirpc (glibc 2.13.90 or newer) or none (most Unix)
+    AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
+      AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl tirpc],[],
+        [AC_MSG_ERROR([Cannot find a XDR library])])
+    ])
+    with_xdr="yes"
+
+    dnl check for cygwin's variation in xdr function names
+    AC_CHECK_FUNCS([xdr_u_int64_t],[],[],[#include <rpc/xdr.h>])
+
+    dnl Cygwin/recent glibc requires -I/usr/include/tirpc for <rpc/rpc.h>
+    old_CFLAGS=$CFLAGS
+    AC_CACHE_CHECK([where to find <rpc/rpc.h>], [lv_cv_xdr_cflags], [
+      for add_CFLAGS in '' '-I/usr/include/tirpc' 'missing'; do
+        if test x"$add_CFLAGS" = xmissing; then
+          lv_cv_xdr_cflags=missing; break
+        fi
+        CFLAGS="$old_CFLAGS $add_CFLAGS"
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <rpc/rpc.h>
+        ]])], [lv_cv_xdr_cflags=${add_CFLAGS:-none}; break])
+      done
+    ])
+    CFLAGS=$old_CFLAGS
+    case $lv_cv_xdr_cflags in
+      none) XDR_CFLAGS= ;;
+      missing) AC_MSG_ERROR([Unable to find <rpc/rpc.h>]) ;;
+      *) XDR_CFLAGS=$lv_cv_xdr_cflags ;;
+    esac
+    AC_SUBST([XDR_CFLAGS])
+  fi
+])
+
+AC_DEFUN([LIBVIRT_RESULT_XDR], [
+  LIBVIRT_RESULT_LIB([XDR])
+])
-- 
2.11.0




More information about the libvir-list mailing list