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 BuildRequires: libssh-devel >= 0.7.0
%endif %endif
# On RHEL-7 rpcgen is still part of glibc-common package
%if 0%{?fedora} || 0%{?rhel} > 7 %if 0%{?fedora} || 0%{?rhel} > 7
BuildRequires: rpcgen BuildRequires: rpcgen
BuildRequires: libtirpc-devel
%endif %endif
BuildRequires: libtirpc-devel
%if %{with_firewalld_zone} %if %{with_firewalld_zone}
BuildRequires: firewalld-filesystem BuildRequires: firewalld-filesystem
%endif %endif

View File

@ -18,37 +18,20 @@ dnl <http://www.gnu.org/licenses/>.
dnl dnl
AC_DEFUN([LIBVIRT_CHECK_XDR], [ AC_DEFUN([LIBVIRT_CHECK_XDR], [
with_xdr="no"
if test x"$with_remote" = x"yes" || test x"$with_libvirtd" = x"yes"; then if test x"$with_remote" = x"yes" || test x"$with_libvirtd" = x"yes"; then
dnl Where are the XDR functions? dnl On MinGW portablexdr provides XDR functions, on linux they are
dnl If portablexdr is installed, prefer that. dnl provided by libtirpc and on FreeBSD/macOS there is no need to
dnl Otherwise try -lxdr (some MinGW) dnl use extra library as it's provided by libc directly.
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])])
])
with_xdr="yes" with_xdr="yes"
dnl Recent glibc requires -I/usr/include/tirpc for <rpc/rpc.h> if test "$with_win" = "yes"; then
old_CFLAGS=$CFLAGS LIBVIRT_CHECK_LIB([XDR], [portablexdr], [xdrmem_create], [rpc/rpc.h])
AC_CACHE_CHECK([where to find <rpc/rpc.h>], [lv_cv_xdr_cflags], [ elif test "$with_linux" = "yes"; then
for add_CFLAGS in '' '-I/usr/include/tirpc' 'missing'; do LIBVIRT_CHECK_PKG([XDR], [libtirpc], [0.1.10])
if test x"$add_CFLAGS" = xmissing; then else
lv_cv_xdr_cflags=missing; break AM_CONDITIONAL([WITH_XDR], [test "x$with_xdr" = "xyes"])
fi 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 fi
]) ])

View File

@ -434,7 +434,9 @@ libvirt_la_LDFLAGS = \
$(AM_LDFLAGS) \ $(AM_LDFLAGS) \
$(NULL) $(NULL)
libvirt_la_LIBADD += \ libvirt_la_LIBADD += \
$(DLOPEN_LIBS) $(DLOPEN_LIBS) \
$(XDR_LIBS) \
$(NULL)
libvirt_la_CFLAGS = -DIN_LIBVIRT $(AM_CFLAGS) libvirt_la_CFLAGS = -DIN_LIBVIRT $(AM_CFLAGS)
# Because we specify libvirt_la_DEPENDENCIES for $(LIBVIRT_SYMBOL_FILE), we # Because we specify libvirt_la_DEPENDENCIES for $(LIBVIRT_SYMBOL_FILE), we
# lose automake's automatic dependencies on an appropriate subset of # 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_admin_la_LIBADD = \
libvirt.la \ libvirt.la \
$(XDR_LIBS) \
$(CAPNG_LIBS) \ $(CAPNG_LIBS) \
$(YAJL_LIBS) \ $(YAJL_LIBS) \
$(DEVMAPPER_LIBS) \ $(DEVMAPPER_LIBS) \

View File

@ -120,6 +120,7 @@ lockd_la_LDFLAGS = $(AM_LDFLAGS_MOD_NOUNDEF)
lockd_la_LIBADD = \ lockd_la_LIBADD = \
libvirt.la \ libvirt.la \
$(GLIB_LIBS) \ $(GLIB_LIBS) \
$(XDR_LIBS) \
$(NULL) $(NULL)
augeas_DATA += locking/libvirt_lockd.aug augeas_DATA += locking/libvirt_lockd.aug
if WITH_DTRACE_PROBES if WITH_DTRACE_PROBES
@ -161,6 +162,7 @@ virtlockd_CFLAGS = \
virtlockd_LDFLAGS = \ virtlockd_LDFLAGS = \
$(AM_LDFLAGS) \ $(AM_LDFLAGS) \
$(PIE_LDFLAGS) \ $(PIE_LDFLAGS) \
$(XDR_LIBS) \
$(NO_UNDEFINED_LDFLAGS) \ $(NO_UNDEFINED_LDFLAGS) \
$(NULL) $(NULL)
virtlockd_LDADD = \ virtlockd_LDADD = \

View File

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

View File

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