[libvirt] [PATCH 1/2] Don't make it possible to define HAVE_HAL but not enable it in automake.

With the previous logic, if libhal_get_all_devices function was not found, HAVE_HAL would be defined for the preprocessor but it wouldn't be enabled in automake conditionals, causing the final link to fail with missing references to HAL entries. --- configure.in | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index c86ee97..e2a0b00 100644 --- a/configure.in +++ b/configure.in @@ -1703,9 +1703,6 @@ if test "x$with_hal" = "xyes" -o "x$with_hal" = "xcheck"; then fi ]) if test "x$with_hal" = "xyes" ; then - AC_DEFINE_UNQUOTED([HAVE_HAL], 1, - [use HAL for host device enumeration]) - old_CFLAGS=$CFLAGS old_LDFLAGS=$LDFLAGS CFLAGS="$CFLAGS $HAL_CFLAGS" @@ -1715,6 +1712,10 @@ if test "x$with_hal" = "xyes" -o "x$with_hal" = "xcheck"; then CFLAGS="$old_CFLAGS" LDFLAGS="$old_LDFLAGS" fi + if test "x$with_hal" = "xyes" ; then + AC_DEFINE_UNQUOTED([HAVE_HAL], 1, + [use HAL for host device enumeration]) + fi fi AM_CONDITIONAL([HAVE_HAL], [test "x$with_hal" = "xyes"]) AC_SUBST([HAL_CFLAGS]) -- 1.6.6.rc3

If you pass libraries in the LDFLAGS variable, and then try AC_CHECK_FUNCS to find whether a function is present or not, it'll fail badly when using the --as-needed linker flag. Instead, pass the libraries through the LIBS library, so that they are passed after the conftest.c source file and the tests are done properly. --- configure.in | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) diff --git a/configure.in b/configure.in index e2a0b00..4eca25a 100644 --- a/configure.in +++ b/configure.in @@ -521,14 +521,14 @@ AC_SUBST([LIBXML_LIBS]) dnl xmlURI structure has query_raw? old_cflags="$CFLAGS" -old_ldflags="$LDFLAGS" +old_libs="$LIBS" CFLAGS="$CFLAGS $LIBXML_CFLAGS" -LDFLAGS="$LDFLAGS $LIBXML_LIBS" +LIBS="$LIBS $LIBXML_LIBS" AC_CHECK_MEMBER([struct _xmlURI.query_raw], [AC_DEFINE([HAVE_XMLURI_QUERY_RAW], [], [Have query_raw field in libxml2 xmlURI structure])],, [#include <libxml/uri.h>]) CFLAGS="$old_cflags" -LDFLAGS="$old_ldflags" +LIBS="$old_libs" dnl GnuTLS library GNUTLS_CFLAGS= @@ -560,15 +560,15 @@ dnl Old versions of GnuTLS uses types like 'gnutls_session' instead dnl of 'gnutls_session_t'. Try to detect this type if defined so dnl that we can offer backwards compatibility. old_cflags="$CFLAGS" -old_ldflags="$LDFLAGS" +old_libs="$LIBS" CFLAGS="$CFLAGS $GNUTLS_CFLAGS" -LDFLAGS="$LDFLAGS $GNUTLS_LIBS" +LIBS="$LIBS $GNUTLS_LIBS" AC_CHECK_TYPE([gnutls_session], AC_DEFINE([GNUTLS_1_0_COMPAT],[], [enable GnuTLS 1.0 compatibility macros]),, [#include <gnutls/gnutls.h>]) CFLAGS="$old_cflags" -LDFLAGS="$old_ldflags" +LIBS="$old_libs" dnl Cyrus SASL @@ -641,9 +641,9 @@ if test "x$with_yajl" != "xno"; then fi fail=0 old_cppflags="$CPPFLAGS" - old_ldflags="$LDFLAGS" + old_libs="$LIBS" CPPFLAGS="$CPPFLAGS $YAJL_CFLAGS" - LDFLAGS="$LDFLAGS $YAJL_LIBS" + LIBS="$LIBS $YAJL_LIBS" AC_CHECK_HEADER([yajl/yajl_common.h],[],[ if test "x$with_yajl" = "xcheck" ; then with_yajl=no @@ -665,7 +665,7 @@ if test "x$with_yajl" != "xno"; then test $fail = 1 && AC_MSG_ERROR([You must install the YAJL development package in order to compile libvirt]) CPPFLAGS="$old_cppflags" - LDFLAGS="$old_ldflags" + LIBS="$old_libs" if test "x$with_yajl" = "xyes" ; then AC_DEFINE_UNQUOTED([HAVE_YAJL], 1, [whether YAJL is available for JSON parsing/formatting]) @@ -716,12 +716,12 @@ if test "x$with_polkit" = "xyes" -o "x$with_polkit" = "xcheck"; then [use PolicyKit for UNIX socket access checks]) old_CFLAGS=$CFLAGS - old_LDFLAGS=$LDFLAGS + old_LIBS=$LIBS CFLAGS="$CFLAGS $POLKIT_CFLAGS" - LDFLAGS="$LDFLAGS $POLKIT_LIBS" + LIBS="$LIBS $POLKIT_LIBS" AC_CHECK_FUNCS([polkit_context_is_caller_authorized]) CFLAGS="$old_CFLAGS" - LDFLAGS="$old_LDFLAGS" + LIBS="$old_LIBS" AC_PATH_PROG([POLKIT_AUTH], [polkit-auth]) if test "x$POLKIT_AUTH" != "x"; then @@ -1704,13 +1704,13 @@ if test "x$with_hal" = "xyes" -o "x$with_hal" = "xcheck"; then ]) if test "x$with_hal" = "xyes" ; then old_CFLAGS=$CFLAGS - old_LDFLAGS=$LDFLAGS + old_LIBS=$LIBS CFLAGS="$CFLAGS $HAL_CFLAGS" - LDFLAGS="$LDFLAGS $HAL_LIBS" + LIBS="$LIBS $HAL_LIBS" AC_CHECK_FUNCS([libhal_get_all_devices],,[with_hal=no]) AC_CHECK_FUNCS([dbus_watch_get_unix_fd]) CFLAGS="$old_CFLAGS" - LDFLAGS="$old_LDFLAGS" + LIBS="$old_LIBS" fi if test "x$with_hal" = "xyes" ; then AC_DEFINE_UNQUOTED([HAVE_HAL], 1, -- 1.6.6.rc3

On Thu, Dec 17, 2009 at 10:56:25PM +0100, Diego Elio 'Flameeyes' Petten? wrote:
If you pass libraries in the LDFLAGS variable, and then try AC_CHECK_FUNCS to find whether a function is present or not, it'll fail badly when using the --as-needed linker flag.
Instead, pass the libraries through the LIBS library, so that they are passed after the conftest.c source file and the tests are done properly. --- configure.in | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-)
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Fri, Dec 18, 2009 at 10:48:28AM +0000, Daniel P. Berrange wrote:
On Thu, Dec 17, 2009 at 10:56:25PM +0100, Diego Elio 'Flameeyes' Petten? wrote:
If you pass libraries in the LDFLAGS variable, and then try AC_CHECK_FUNCS to find whether a function is present or not, it'll fail badly when using the --as-needed linker flag.
Instead, pass the libraries through the LIBS library, so that they are passed after the conftest.c source file and the tests are done properly. --- configure.in | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-)
ACK
Yup, looks fine, applied both, thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Thu, Dec 17, 2009 at 10:56:24PM +0100, Diego Elio 'Flameeyes' Petten? wrote:
With the previous logic, if libhal_get_all_devices function was not found, HAVE_HAL would be defined for the preprocessor but it wouldn't be enabled in automake conditionals, causing the final link to fail with missing references to HAL entries. --- configure.in | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/configure.in b/configure.in index c86ee97..e2a0b00 100644 --- a/configure.in +++ b/configure.in @@ -1703,9 +1703,6 @@ if test "x$with_hal" = "xyes" -o "x$with_hal" = "xcheck"; then fi ]) if test "x$with_hal" = "xyes" ; then - AC_DEFINE_UNQUOTED([HAVE_HAL], 1, - [use HAL for host device enumeration]) - old_CFLAGS=$CFLAGS old_LDFLAGS=$LDFLAGS CFLAGS="$CFLAGS $HAL_CFLAGS" @@ -1715,6 +1712,10 @@ if test "x$with_hal" = "xyes" -o "x$with_hal" = "xcheck"; then CFLAGS="$old_CFLAGS" LDFLAGS="$old_LDFLAGS" fi + if test "x$with_hal" = "xyes" ; then + AC_DEFINE_UNQUOTED([HAVE_HAL], 1, + [use HAL for host device enumeration]) + fi fi AM_CONDITIONAL([HAVE_HAL], [test "x$with_hal" = "xyes"]) AC_SUBST([HAL_CFLAGS])
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Diego Elio 'Flameeyes' Pettenò