[libvirt] [PATCH 1/2] Use AC_SEARCH_LIBS to find the library to use for dlopen().

Instead of using AC_CHECK_LIB and hardcoding -ldl, search for the library needed to get dlopen() and then use the cached value. --- configure.ac | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 5b1eb5f..a3f28c4 100644 --- a/configure.ac +++ b/configure.ac @@ -1705,7 +1705,7 @@ if test "x$with_driver_modules" = "xyes" ; then old_libs="$LIBS" fail=0 AC_CHECK_HEADER([dlfcn.h],[],[fail=1]) - AC_CHECK_LIB([dl], [dlopen],[],[fail=1]) + AC_SEARCH_LIBS([dlopen], [dl], [], [fail=1]) test $fail = 1 && AC_MSG_ERROR([You must have dlfcn.h / dlopen() support to build driver modules]) @@ -1714,7 +1714,7 @@ if test "x$with_driver_modules" = "xyes" ; then fi if test "$with_driver_modules" = "yes"; then DRIVER_MODULES_CFLAGS="-export-dynamic" - DRIVER_MODULES_LIBS="-ldl" + DRIVER_MODULES_LIBS="$ac_cv_search_dlopen" AC_DEFINE_UNQUOTED([WITH_DRIVER_MODULES], 1, [whether to build drivers as modules]) fi AM_CONDITIONAL([WITH_DRIVER_MODULES], [test "$with_driver_modules" != "no"]) -- 1.7.0

With the recent changes to the linking defaults in Fedora 13 (namely enabling --no-add-needed behaviour by default), we have to pass the dlopen()-providing libraries directly at the link of the module; use the same AC_SEARCH_LIBS function as used before to look for it and add it to the Makefile. --- configure.ac | 2 ++ src/Makefile.am | 1 + 2 files changed, 3 insertions(+), 0 deletions(-) diff --git a/configure.ac b/configure.ac index a3f28c4..d3d7340 100644 --- a/configure.ac +++ b/configure.ac @@ -303,6 +303,8 @@ fi AM_CONDITIONAL([WITH_OPENVZ], [test "$with_openvz" = "yes"]) if test "x$with_vbox" = "xyes"; then + AC_SEARCH_LIBS([dlopen], [dl], [], [AC_MSG_ERROR([Unable to find dlopen()])]) + AC_SUBST([DLOPEN_LIBS], [$ac_cv_search_dlopen]) AC_DEFINE_UNQUOTED([WITH_VBOX], 1, [whether VirtualBox driver is enabled]) fi AM_CONDITIONAL([WITH_VBOX], [test "$with_vbox" = "yes"]) diff --git a/src/Makefile.am b/src/Makefile.am index 46acb7d..87fe65c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -464,6 +464,7 @@ libvirt_driver_vbox_la_CFLAGS = \ if WITH_DRIVER_MODULES libvirt_driver_vbox_la_LDFLAGS = -module -avoid-version endif +libvirt_driver_vbox_la_LIBADD = $(DLOPEN_LIBS) libvirt_driver_vbox_la_SOURCES = $(VBOX_DRIVER_SOURCES) endif -- 1.7.0

According to Diego Elio Pettenò on 2/24/2010 8:36 AM:
if test "x$with_vbox" = "xyes"; then + AC_SEARCH_LIBS([dlopen], [dl], [], [AC_MSG_ERROR([Unable to find dlopen()])]) + AC_SUBST([DLOPEN_LIBS], [$ac_cv_search_dlopen])
Same problem with $ac_cv_search_dlopen possibly being 'no' or 'none required'. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Eric Blake wrote:
According to Diego Elio Pettenò on 2/24/2010 8:36 AM:
if test "x$with_vbox" = "xyes"; then + AC_SEARCH_LIBS([dlopen], [dl], [], [AC_MSG_ERROR([Unable to find dlopen()])]) + AC_SUBST([DLOPEN_LIBS], [$ac_cv_search_dlopen])
Same problem with $ac_cv_search_dlopen possibly being 'no' or 'none required'.
Hi Diego, Did you already write a patch for this? I never saw a follow-up, and the build still fails on rawhide.

According to Diego Elio Pettenò on 2/24/2010 8:36 AM:
Instead of using AC_CHECK_LIB and hardcoding -ldl, search for the library needed to get dlopen() and then use the cached value. - DRIVER_MODULES_LIBS="-ldl" + DRIVER_MODULES_LIBS="$ac_cv_search_dlopen"
Does this properly handle the case of 'no' or 'none required'? I think you need: case $ac_cv_search_dlopen in no*) DRIVER_MODULES_LIBS= ;; *) DRIVER_MODULES_LIBS=$ac_cv_search_dlopen ;; esac By the way, shell assignment is another case where no field splitting is performed, so your use of "" was redundant. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Il giorno mer, 24/02/2010 alle 09.23 -0700, Eric Blake ha scritto:
Does this properly handle the case of 'no' or 'none required'? I think you need:
Gha you're right, not sure why I assumed that it used "c" for "none required" And yes I'm an overquoter in sh :P
-- Diego Elio Pettenò — “Flameeyes” http://blog.flameeyes.eu/ If you found a .asc file in this mail and know not what it is, it's a GnuPG digital signature: http://www.gnupg.org/
participants (4)
-
Diego Elio Pettenò
-
Diego Elio “Flameeyes” Pettenò
-
Eric Blake
-
Jim Meyering