File b9031e08-search-for-standalone-xdr-library.patch of Package virt-sandbox

From b9031e08f031124d18b416a4cbebbd6eeb0ea9f8 Mon Sep 17 00:00:00 2001
From: "Daniel P. Berrange" <berrange@redhat.com>
Date: Thu, 18 Jan 2018 16:03:52 +0000
Subject: [sandbox] Search for standalone xdr library

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 configure.ac                |  1 +
 libvirt-sandbox/Makefile.am |  4 ++++
 m4/virt-xdr.m4              | 29 +++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 100644 m4/virt-xdr.m4

diff --git a/configure.ac b/configure.ac
index 00c2d7e..5d64f0d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,7 @@ LIBVIRT_SANDBOX_WIN32
 LIBVIRT_SANDBOX_COVERAGE
 LIBVIRT_SANDBOX_RPCGEN
 LIBVIRT_SANDBOX_SELINUX
+LIBVIRT_SANDBOX_XDR
 
 LIBVIRT_SANDBOX_STATIC_LIBC
 
diff --git a/libvirt-sandbox/Makefile.am b/libvirt-sandbox/Makefile.am
index b303078..48cc997 100644
--- a/libvirt-sandbox/Makefile.am
+++ b/libvirt-sandbox/Makefile.am
@@ -157,6 +157,7 @@ libvirt_sandbox_1_0_la_CFLAGS = \
 			$(LIBVIRT_GLIB_CFLAGS) \
 			$(LIBVIRT_GOBJECT_CFLAGS) \
 			$(SELINUX_CFLAGS) \
+			$(XDR_CFLAGS) \
 			$(WARN_CFLAGS) \
 			$(NULL)
 libvirt_sandbox_1_0_la_LIBADD = \
@@ -165,6 +166,7 @@ libvirt_sandbox_1_0_la_LIBADD = \
 			$(LIBVIRT_GOBJECT_LIBS) \
 			$(SELINUX_LIBS) \
 			$(CYGWIN_EXTRA_LIBADD) \
+			$(XDR_LIBS) \
 			$(NULL)
 libvirt_sandbox_1_0_la_DEPENDENCIES = \
                         libvirt-sandbox.sym
@@ -194,6 +196,7 @@ libvirt_sandbox_init_common_CFLAGS = \
 			$(GIO_UNIX_CFLAGS) \
 			$(CAPNG_CFLAGS) \
 			$(SELINUX_CFLAGS) \
+			$(XDR_CFLAGS) \
 			$(WARN_CFLAGS) \
 			$(NULL)
 libvirt_sandbox_init_common_LDFLAGS = \
@@ -203,6 +206,7 @@ libvirt_sandbox_init_common_LDFLAGS = \
 			$(LIBVIRT_GCONFIG_LIBS) \
 			$(CAPNG_LIBS) \
 			$(SELINUX_LIBS) \
+			$(XDR_LIBS) \
 			$(WARN_CFLAGS) \
 			$(NULL)
 libvirt_sandbox_init_common_LDADD = \
diff --git a/m4/virt-xdr.m4 b/m4/virt-xdr.m4
new file mode 100644
index 0000000..f67b4c9
--- /dev/null
+++ b/m4/virt-xdr.m4
@@ -0,0 +1,29 @@
+AC_DEFUN([LIBVIRT_SANDBOX_XDR], [
+    old_LIBS="$LIBS"
+    AC_SEARCH_LIBS([xdrmem_create], [portablexdr rpc xdr nsl tirpc], [
+      XDR_LIBS="$ac_cv_search_xdrmem_create"
+    ],[
+      AC_MSG_ERROR([Cannot find a XDR library])
+    ])
+    LIBS="$old_LIBS"
+
+    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_LIBS])
+    AC_SUBST([XDR_CFLAGS])
+])
-- 
2.16.1

openSUSE Build Service is sponsored by