build: force libnl1 if netcf also used libnl1

Recent spec file changes ensure that in distro situations, netcf
and libvirt will link against the same libnl in order to avoid
dumping core.  But for every-day development, if you use F17 and
have the libnl3-devel headers available, libvirt was blindly
linking against libnl3 even though F17 netcf still links against
libnl1, making testing a self-built binary on F17 impossible.

By making configure a little bit smarter, we can avoid this
situation - we merely skip the probe of libnl-3 if we can prove
that netcf is still using libnl-1.  I intentionally wrote the
test so that we still favor libnl-3 if netcf is not installed or
if we couldn't use ldd to determine things.

Defaults being what they are, someone will invariably complain
that our smarts were wrong.  Never fear - in that case, just run
./configure LIBNL_CFLAGS=..., where the fact that you set
LIBNL_CFLAGS (even to the empty string) will go back to probing
for libnl-3, regardless of netcf's choice.

* configure.ac (LIBNL): Don't probe libnl3 if netcf doesn't use it.
This commit is contained in:
Eric Blake 2012-09-07 16:38:52 -06:00
parent 2387aa26c1
commit 9298bfbcb4

View File

@ -2902,14 +2902,32 @@ LIBNL_LIBS=""
have_libnl=no have_libnl=no
if test "$with_linux" = "yes"; then if test "$with_linux" = "yes"; then
PKG_CHECK_MODULES([LIBNL], [libnl-3.0], [ # When linking with netcf, we must ensure that we pick the same version
have_libnl=yes # of libnl that netcf picked. Prefer libnl-3 unless we can prove
AC_DEFINE([HAVE_LIBNL3], [1], [Use libnl-3.0]) # netcf linked against libnl-1, or unless the user set LIBNL_CFLAGS.
AC_DEFINE([HAVE_LIBNL], [1], [whether the netlink library is available]) # (Setting LIBNL_CFLAGS is already used by PKG_CHECK_MODULES to
PKG_CHECK_MODULES([LIBNL_ROUTE3], [libnl-route-3.0]) # override any probing, so if it set, you know which libnl is in use.)
LIBNL_CFLAGS="$LIBNL_CFLAGS $LIBNL_ROUTE3_CFLAGS" libnl_ldd=
LIBNL_LIBS="$LIBNL_LIBS $LIBNL_ROUTE3_LIBS" for dir in /usr/lib64 /usr/lib; do
], [PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [ if test -f $dir/libnetcf.so; then
libnl_ldd=`(ldd $dir/libnetcf.so) 2>&1`
break
fi
done
case $libnl_ldd:${LIBNL_CFLAGS+set} in
*libnl.so.1*:) ;;
*)
PKG_CHECK_MODULES([LIBNL], [libnl-3.0], [
have_libnl=yes
AC_DEFINE([HAVE_LIBNL3], [1], [Use libnl-3.0])
AC_DEFINE([HAVE_LIBNL], [1], [whether the netlink library is available])
PKG_CHECK_MODULES([LIBNL_ROUTE3], [libnl-route-3.0])
LIBNL_CFLAGS="$LIBNL_CFLAGS $LIBNL_ROUTE3_CFLAGS"
LIBNL_LIBS="$LIBNL_LIBS $LIBNL_ROUTE3_LIBS"
], []) ;;
esac
if test "$have_libnl" = no; then
PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [
have_libnl=yes have_libnl=yes
AC_DEFINE_UNQUOTED([HAVE_LIBNL], [1], AC_DEFINE_UNQUOTED([HAVE_LIBNL], [1],
[whether the netlink library is available]) [whether the netlink library is available])
@ -2920,7 +2938,7 @@ if test "$with_linux" = "yes"; then
AC_MSG_ERROR([libnl-devel >= $LIBNL_REQUIRED is required for macvtap support]) AC_MSG_ERROR([libnl-devel >= $LIBNL_REQUIRED is required for macvtap support])
fi fi
]) ])
]) fi
fi fi
AM_CONDITIONAL([HAVE_LIBNL], [test "$have_libnl" = "yes"]) AM_CONDITIONAL([HAVE_LIBNL], [test "$have_libnl" = "yes"])