Don't mix LDFLAGS and LIBS in the configure script

* configure.in: 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.
This commit is contained in:
Diego Elio Pettenò 2009-12-18 18:34:40 +01:00 committed by Daniel Veillard
parent 3a524a2b11
commit 1a43d0b2c2

View File

@ -541,14 +541,14 @@ AC_SUBST([LIBXML_LIBS])
dnl xmlURI structure has query_raw? dnl xmlURI structure has query_raw?
old_cflags="$CFLAGS" old_cflags="$CFLAGS"
old_ldflags="$LDFLAGS" old_libs="$LIBS"
CFLAGS="$CFLAGS $LIBXML_CFLAGS" CFLAGS="$CFLAGS $LIBXML_CFLAGS"
LDFLAGS="$LDFLAGS $LIBXML_LIBS" LIBS="$LIBS $LIBXML_LIBS"
AC_CHECK_MEMBER([struct _xmlURI.query_raw], AC_CHECK_MEMBER([struct _xmlURI.query_raw],
[AC_DEFINE([HAVE_XMLURI_QUERY_RAW], [], [Have query_raw field in libxml2 xmlURI structure])],, [AC_DEFINE([HAVE_XMLURI_QUERY_RAW], [], [Have query_raw field in libxml2 xmlURI structure])],,
[#include <libxml/uri.h>]) [#include <libxml/uri.h>])
CFLAGS="$old_cflags" CFLAGS="$old_cflags"
LDFLAGS="$old_ldflags" LIBS="$old_libs"
dnl GnuTLS library dnl GnuTLS library
GNUTLS_CFLAGS= GNUTLS_CFLAGS=
@ -580,15 +580,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 of 'gnutls_session_t'. Try to detect this type if defined so
dnl that we can offer backwards compatibility. dnl that we can offer backwards compatibility.
old_cflags="$CFLAGS" old_cflags="$CFLAGS"
old_ldflags="$LDFLAGS" old_libs="$LIBS"
CFLAGS="$CFLAGS $GNUTLS_CFLAGS" CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
LDFLAGS="$LDFLAGS $GNUTLS_LIBS" LIBS="$LIBS $GNUTLS_LIBS"
AC_CHECK_TYPE([gnutls_session], AC_CHECK_TYPE([gnutls_session],
AC_DEFINE([GNUTLS_1_0_COMPAT],[], AC_DEFINE([GNUTLS_1_0_COMPAT],[],
[enable GnuTLS 1.0 compatibility macros]),, [enable GnuTLS 1.0 compatibility macros]),,
[#include <gnutls/gnutls.h>]) [#include <gnutls/gnutls.h>])
CFLAGS="$old_cflags" CFLAGS="$old_cflags"
LDFLAGS="$old_ldflags" LIBS="$old_libs"
dnl Cyrus SASL dnl Cyrus SASL
@ -661,9 +661,9 @@ if test "x$with_yajl" != "xno"; then
fi fi
fail=0 fail=0
old_cppflags="$CPPFLAGS" old_cppflags="$CPPFLAGS"
old_ldflags="$LDFLAGS" old_libs="$LIBS"
CPPFLAGS="$CPPFLAGS $YAJL_CFLAGS" CPPFLAGS="$CPPFLAGS $YAJL_CFLAGS"
LDFLAGS="$LDFLAGS $YAJL_LIBS" LIBS="$LIBS $YAJL_LIBS"
AC_CHECK_HEADER([yajl/yajl_common.h],[],[ AC_CHECK_HEADER([yajl/yajl_common.h],[],[
if test "x$with_yajl" = "xcheck" ; then if test "x$with_yajl" = "xcheck" ; then
with_yajl=no with_yajl=no
@ -685,7 +685,7 @@ if test "x$with_yajl" != "xno"; then
test $fail = 1 && test $fail = 1 &&
AC_MSG_ERROR([You must install the YAJL development package in order to compile libvirt]) AC_MSG_ERROR([You must install the YAJL development package in order to compile libvirt])
CPPFLAGS="$old_cppflags" CPPFLAGS="$old_cppflags"
LDFLAGS="$old_ldflags" LIBS="$old_libs"
if test "x$with_yajl" = "xyes" ; then if test "x$with_yajl" = "xyes" ; then
AC_DEFINE_UNQUOTED([HAVE_YAJL], 1, AC_DEFINE_UNQUOTED([HAVE_YAJL], 1,
[whether YAJL is available for JSON parsing/formatting]) [whether YAJL is available for JSON parsing/formatting])
@ -736,12 +736,12 @@ if test "x$with_polkit" = "xyes" -o "x$with_polkit" = "xcheck"; then
[use PolicyKit for UNIX socket access checks]) [use PolicyKit for UNIX socket access checks])
old_CFLAGS=$CFLAGS old_CFLAGS=$CFLAGS
old_LDFLAGS=$LDFLAGS old_LIBS=$LIBS
CFLAGS="$CFLAGS $POLKIT_CFLAGS" CFLAGS="$CFLAGS $POLKIT_CFLAGS"
LDFLAGS="$LDFLAGS $POLKIT_LIBS" LIBS="$LIBS $POLKIT_LIBS"
AC_CHECK_FUNCS([polkit_context_is_caller_authorized]) AC_CHECK_FUNCS([polkit_context_is_caller_authorized])
CFLAGS="$old_CFLAGS" CFLAGS="$old_CFLAGS"
LDFLAGS="$old_LDFLAGS" LIBS="$old_LIBS"
AC_PATH_PROG([POLKIT_AUTH], [polkit-auth]) AC_PATH_PROG([POLKIT_AUTH], [polkit-auth])
if test "x$POLKIT_AUTH" != "x"; then if test "x$POLKIT_AUTH" != "x"; then
@ -1724,13 +1724,13 @@ if test "x$with_hal" = "xyes" -o "x$with_hal" = "xcheck"; then
]) ])
if test "x$with_hal" = "xyes" ; then if test "x$with_hal" = "xyes" ; then
old_CFLAGS=$CFLAGS old_CFLAGS=$CFLAGS
old_LDFLAGS=$LDFLAGS old_LIBS=$LIBS
CFLAGS="$CFLAGS $HAL_CFLAGS" 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([libhal_get_all_devices],,[with_hal=no])
AC_CHECK_FUNCS([dbus_watch_get_unix_fd]) AC_CHECK_FUNCS([dbus_watch_get_unix_fd])
CFLAGS="$old_CFLAGS" CFLAGS="$old_CFLAGS"
LDFLAGS="$old_LDFLAGS" LIBS="$old_LIBS"
fi fi
if test "x$with_hal" = "xyes" ; then if test "x$with_hal" = "xyes" ; then
AC_DEFINE_UNQUOTED([HAVE_HAL], 1, AC_DEFINE_UNQUOTED([HAVE_HAL], 1,