From d7147b3797380de2d159ce6324536f3e1f2d97e3 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Fri, 19 Jun 2020 00:44:07 +0200 Subject: [PATCH] m4: virt-xdr: rewrite XDR check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- libvirt.spec.in | 4 +++- m4/virt-xdr.m4 | 39 +++++++++++-------------------------- src/Makefile.am | 4 +++- src/admin/Makefile.inc.am | 1 + src/locking/Makefile.inc.am | 2 ++ src/logging/Makefile.inc.am | 1 + src/remote/Makefile.inc.am | 1 + 7 files changed, 22 insertions(+), 30 deletions(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index 9f24e06aa4..522e36b6a5 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -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 diff --git a/m4/virt-xdr.m4 b/m4/virt-xdr.m4 index 83754157d9..09d0c2ba2f 100644 --- a/m4/virt-xdr.m4 +++ b/m4/virt-xdr.m4 @@ -18,37 +18,20 @@ dnl . 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 - old_CFLAGS=$CFLAGS - AC_CACHE_CHECK([where to find ], [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 - ]])], [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 ]) ;; - *) 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 ]) diff --git a/src/Makefile.am b/src/Makefile.am index 57e1d4d95b..834e356b68 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/admin/Makefile.inc.am b/src/admin/Makefile.inc.am index 0a9717adec..8556a3b852 100644 --- a/src/admin/Makefile.inc.am +++ b/src/admin/Makefile.inc.am @@ -72,6 +72,7 @@ libvirt_admin_la_LDFLAGS = \ libvirt_admin_la_LIBADD = \ libvirt.la \ + $(XDR_LIBS) \ $(CAPNG_LIBS) \ $(YAJL_LIBS) \ $(DEVMAPPER_LIBS) \ diff --git a/src/locking/Makefile.inc.am b/src/locking/Makefile.inc.am index d1bf49cd3f..ab01d8e048 100644 --- a/src/locking/Makefile.inc.am +++ b/src/locking/Makefile.inc.am @@ -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 = \ diff --git a/src/logging/Makefile.inc.am b/src/logging/Makefile.inc.am index 64023aa672..873e6029dd 100644 --- a/src/logging/Makefile.inc.am +++ b/src/logging/Makefile.inc.am @@ -98,6 +98,7 @@ virtlogd_CFLAGS = \ virtlogd_LDFLAGS = \ $(AM_LDFLAGS) \ $(PIE_LDFLAGS) \ + $(XDR_LIBS) \ $(NO_UNDEFINED_LDFLAGS) \ $(NULL) virtlogd_LDADD = \ diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am index 5b8eb59bab..80f4aad782 100644 --- a/src/remote/Makefile.inc.am +++ b/src/remote/Makefile.inc.am @@ -64,6 +64,7 @@ REMOTE_DAEMON_LD_ADD = \ $(LIBXML_LIBS) \ $(GNUTLS_LIBS) \ $(SASL_LIBS) \ + $(XDR_LIBS) \ $(DBUS_LIBS) \ $(LIBNL_LIBS) \ $(NULL)