m4: virt-xdr: rewrite XDR check

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>
This commit is contained in:
Pavel Hrdina 2020-06-19 00:44:07 +02:00
parent d3a1a3d708
commit d7147b3797
7 changed files with 22 additions and 30 deletions

View 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

View 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
])

View 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

View File

@ -72,6 +72,7 @@ libvirt_admin_la_LDFLAGS = \
libvirt_admin_la_LIBADD = \
libvirt.la \
$(XDR_LIBS) \
$(CAPNG_LIBS) \
$(YAJL_LIBS) \
$(DEVMAPPER_LIBS) \

View 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 = \

View File

@ -98,6 +98,7 @@ virtlogd_CFLAGS = \
virtlogd_LDFLAGS = \
$(AM_LDFLAGS) \
$(PIE_LDFLAGS) \
$(XDR_LIBS) \
$(NO_UNDEFINED_LDFLAGS) \
$(NULL)
virtlogd_LDADD = \

View File

@ -64,6 +64,7 @@ REMOTE_DAEMON_LD_ADD = \
$(LIBXML_LIBS) \
$(GNUTLS_LIBS) \
$(SASL_LIBS) \
$(XDR_LIBS) \
$(DBUS_LIBS) \
$(LIBNL_LIBS) \
$(NULL)