[PATCH] [build] Use AC_LINK_IFELSE for testing linker flags.
Chris Wilson
chris at chris-wilson.co.uk
Wed Oct 22 14:04:53 PDT 2008
Richard Hult reported that -Wl,--allow-shlib-undefined was incorrectly
being identified as supported by gcc under Mac OS/X:
configure:25103: checking whether gcc supports -Wl,--allow-shlib-undefined
configure:25117: gcc -c -Werror -Wl,--allow-shlib-undefined conftest.c
>&5
i686-apple-darwin9-gcc-4.0.1: --allow-shlib-undefined: linker input file
unused because linking not done
So instead of just checking whether the compiler accepts the flag, check
that we can actually link a dummy file.
---
build/aclocal.cairo.m4 | 20 ++++++++++++++++++++
build/configure.ac.warnings | 2 +-
2 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/build/aclocal.cairo.m4 b/build/aclocal.cairo.m4
index f00b137..1c898b9 100644
--- a/build/aclocal.cairo.m4
+++ b/build/aclocal.cairo.m4
@@ -93,6 +93,26 @@ AC_DEFUN([CAIRO_CC_TRY_FLAG],
AC_MSG_RESULT([$cairo_cc_flag])
])
+dnl check compiler/ld flags
+AC_DEFUN([CAIRO_CC_TRY_LINK_FLAG],
+[dnl
+ AC_MSG_CHECKING([whether $CC supports $1])
+
+ _save_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS -Werror $1"
+ AC_LINK_IFELSE([int main(void){ return 0;} ],
+ [cairo_cc_flag=yes],
+ [cairo_cc_flag=no])
+ CFLAGS="$_save_cflags"
+
+ if test "x$cairo_cc_flag" = "xyes"; then
+ ifelse([$2], , :, [$2])
+ else
+ ifelse([$3], , :, [$3])
+ fi
+ AC_MSG_RESULT([$cairo_cc_flag])
+])
+
dnl Usage:
dnl CAIRO_CHECK_NATIVE_ATOMIC_PRIMITIVES
AC_DEFUN([CAIRO_CHECK_NATIVE_ATOMIC_PRIMITIVES],
diff --git a/build/configure.ac.warnings b/build/configure.ac.warnings
index 2d111a0..c0cfe5e 100644
--- a/build/configure.ac.warnings
+++ b/build/configure.ac.warnings
@@ -69,7 +69,7 @@ AC_DEFINE_UNQUOTED([WARN_UNUSED_RESULT], [$cairo_cv_warn_unused_result],
dnl check linker flags
AC_CACHE_CHECK([how to allow undefined symbols in shared libraries used by test suite], cairo_cv_test_undefined_ldflags,
- [CAIRO_CC_TRY_FLAG([-Wl,--allow-shlib-undefined],
+ [CAIRO_CC_TRY_LINK_FLAG([-Wl,--allow-shlib-undefined],
[cairo_cv_test_undefined_ldflags="-Wl,--allow-shlib-undefined]")])
CAIRO_TEST_UNDEFINED_LDFLAGS="$cairo_cv_test_undefined_ldflags"
AC_SUBST(CAIRO_TEST_UNDEFINED_LDFLAGS)
--
1.5.6.3
--=-GBiDTAXrSv0P6avCTBQv--
More information about the cairo
mailing list