]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
m4: virt-xdr: rewrite XDR check
authorPavel Hrdina <phrdina@redhat.com>
Thu, 18 Jun 2020 22:44:07 +0000 (00:44 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 10 Jul 2020 14:07:02 +0000 (16:07 +0200)
The current code to check XDR support was obsolete and way to
complicated.

On linux we can use pkg-config to check for libtirpc and have
the CFLAGS and LIBS configured by it as well.

On MinGW there is portablexdr library which installs header files
directly into system include directory.

On FreeBSD and macOS XDR functions are part of libc so there is
no library needed, we just need to call AM_CONDITIONAL to silence
configure which otherwise complains about missing WITH_XDR.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
libvirt.spec.in
m4/virt-xdr.m4
src/Makefile.am
src/admin/Makefile.inc.am
src/locking/Makefile.inc.am
src/logging/Makefile.inc.am
src/remote/Makefile.inc.am

index 9f24e06aa46565775dc8fd53e766d553c06da273..522e36b6a516d80403a7f4771616d10bc99de718 100644 (file)
@@ -406,11 +406,13 @@ BuildRequires: wireshark-devel >= 2.4.0
 BuildRequires: libssh-devel >= 0.7.0
 %endif
 
+# On RHEL-7 rpcgen is still part of glibc-common package
 %if 0%{?fedora} || 0%{?rhel} > 7
 BuildRequires: rpcgen
-BuildRequires: libtirpc-devel
 %endif
 
+BuildRequires: libtirpc-devel
+
 %if %{with_firewalld_zone}
 BuildRequires: firewalld-filesystem
 %endif
index 83754157d9aec5c82e475d4caea59c8cdc2f6f1d..09d0c2ba2f46585c242456128b08fb183ba2a7bb 100644 (file)
@@ -18,37 +18,20 @@ 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 -lxdr (some MinGW)
-    dnl -ltirpc (glibc 2.13.90 or newer) or none (most Unix)
-    AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
-      AC_SEARCH_LIBS([xdrmem_create],[xdr tirpc],[],
-        [AC_MSG_ERROR([Cannot find a XDR library])])
-    ])
+    dnl On MinGW portablexdr provides XDR functions, on linux they are
+    dnl provided by libtirpc and on FreeBSD/macOS there is no need to
+    dnl use extra library as it's provided by libc directly.
+
     with_xdr="yes"
 
-    dnl 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])
+    if test "$with_win" = "yes"; then
+      LIBVIRT_CHECK_LIB([XDR], [portablexdr], [xdrmem_create], [rpc/rpc.h])
+    elif test "$with_linux" = "yes"; then
+      LIBVIRT_CHECK_PKG([XDR], [libtirpc], [0.1.10])
+    else
+      AM_CONDITIONAL([WITH_XDR], [test "x$with_xdr" = "xyes"])
+    fi
   fi
 ])
 
index 57e1d4d95b3e9b0377a8a8853773d15428d59670..834e356b68b2c38aab1c4cc36ae31534ba6150cf 100644 (file)
@@ -434,7 +434,9 @@ libvirt_la_LDFLAGS = \
                $(AM_LDFLAGS) \
                $(NULL)
 libvirt_la_LIBADD += \
-                   $(DLOPEN_LIBS)
+               $(DLOPEN_LIBS) \
+               $(XDR_LIBS) \
+               $(NULL)
 libvirt_la_CFLAGS = -DIN_LIBVIRT $(AM_CFLAGS)
 # Because we specify libvirt_la_DEPENDENCIES for $(LIBVIRT_SYMBOL_FILE), we
 # lose automake's automatic dependencies on an appropriate subset of
index 0a9717adec6ac350782d5598344cef216ae70fca..8556a3b852317effc205702bb4e495dee70f62eb 100644 (file)
@@ -72,6 +72,7 @@ libvirt_admin_la_LDFLAGS = \
 
 libvirt_admin_la_LIBADD = \
        libvirt.la \
+       $(XDR_LIBS) \
        $(CAPNG_LIBS) \
        $(YAJL_LIBS) \
        $(DEVMAPPER_LIBS) \
index d1bf49cd3fb5ea5868b98656455a176d5d1e132f..ab01d8e0482e62e80f60bf960ac85ee428df6eee 100644 (file)
@@ -120,6 +120,7 @@ lockd_la_LDFLAGS = $(AM_LDFLAGS_MOD_NOUNDEF)
 lockd_la_LIBADD = \
        libvirt.la \
        $(GLIB_LIBS) \
+       $(XDR_LIBS) \
        $(NULL)
 augeas_DATA += locking/libvirt_lockd.aug
 if WITH_DTRACE_PROBES
@@ -161,6 +162,7 @@ virtlockd_CFLAGS = \
 virtlockd_LDFLAGS = \
        $(AM_LDFLAGS) \
        $(PIE_LDFLAGS) \
+       $(XDR_LIBS) \
        $(NO_UNDEFINED_LDFLAGS) \
        $(NULL)
 virtlockd_LDADD = \
index 64023aa672c7e562c0d955f49f5248a32558270b..873e6029dd5f13f26ae63bd3ddb0a87f62058df9 100644 (file)
@@ -98,6 +98,7 @@ virtlogd_CFLAGS = \
 virtlogd_LDFLAGS = \
                $(AM_LDFLAGS) \
                $(PIE_LDFLAGS) \
+               $(XDR_LIBS) \
                $(NO_UNDEFINED_LDFLAGS) \
                $(NULL)
 virtlogd_LDADD = \
index 5b8eb59bab32d5a868dc40f97260da8729bd7a35..80f4aad7828b52dc9fb537fb25a8d2abeabcf2b0 100644 (file)
@@ -64,6 +64,7 @@ REMOTE_DAEMON_LD_ADD = \
        $(LIBXML_LIBS) \
        $(GNUTLS_LIBS) \
        $(SASL_LIBS) \
+       $(XDR_LIBS) \
        $(DBUS_LIBS) \
        $(LIBNL_LIBS) \
        $(NULL)