From 9298bfbcb483e2ad4023705c7cf718495bf8cd0c Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 7 Sep 2012 16:38:52 -0600 Subject: [PATCH] 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. --- configure.ac | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 47a72b9b74..690de2a720 100644 --- a/configure.ac +++ b/configure.ac @@ -2902,14 +2902,32 @@ LIBNL_LIBS="" have_libnl=no if test "$with_linux" = "yes"; then - 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" - ], [PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [ + # When linking with netcf, we must ensure that we pick the same version + # of libnl that netcf picked. Prefer libnl-3 unless we can prove + # netcf linked against libnl-1, or unless the user set LIBNL_CFLAGS. + # (Setting LIBNL_CFLAGS is already used by PKG_CHECK_MODULES to + # override any probing, so if it set, you know which libnl is in use.) + libnl_ldd= + for dir in /usr/lib64 /usr/lib; do + 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 AC_DEFINE_UNQUOTED([HAVE_LIBNL], [1], [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]) fi ]) - ]) + fi fi AM_CONDITIONAL([HAVE_LIBNL], [test "$have_libnl" = "yes"])