summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2009-09-15 21:13:00 -0700
committerPeter Hutterer <peter.hutterer@who-t.net>2009-09-17 10:06:37 +1000
commit715953bf5c00b4605dd6ab45c92140c0e81174ee (patch)
tree480943d04e4d53fe8cf24d0b7b728463c3248f92 /configure.ac
parente2c64551808988657069006f74c6780973ec0557 (diff)
Check for -wrap support in the linker
Allows unit tests to be built with non-gnu-linkers that also have -wrap support Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac37
1 files changed, 31 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac
index f13ec5c76..89836971b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1173,20 +1173,45 @@ if test "x$DEBUGGING" = xyes; then
fi
AM_CONDITIONAL(DEBUG, [test "x$DEBUGGING" = xyes])
+# If unittests aren't explicitly disabled, check for required support
+if test "x$UNITTESTS" != xno ; then
+ PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.16],
+ [HAVE_GLIB=yes], [HAVE_GLIB=no])
+
+ # Check if linker supports -wrap, passed via compiler flags
+ # When cross-compiling, reports no, since unit tests run from
+ # "make check", so would be running on build machine, not target
+ AC_MSG_CHECKING([whether the linker supports -wrap])
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -Wl,-wrap,exit"
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+ void __wrap_exit (int s)
+ {
+ __real_exit (0);
+ }]],
+ [[exit (1);]])],
+ [linker_can_wrap="yes"],
+ [linker_can_wrap="no"],
+ [linker_can_wrap="no"])
+ AC_MSG_RESULT([$linker_can_wrap])
+ LDFLAGS="$save_LDFLAGS"
+fi
+
if test "x$UNITTESTS" = xauto; then
- PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.16], [HAVE_GLIB=yes], [HAVE_GLIB=no])
- if test "x$HAVE_GLIB" = xyes && test "x$with_gnu_ld" = xyes; then
+ if test "x$HAVE_GLIB" = xyes && test "x$linker_can_wrap" = xyes; then
UNITTESTS=yes
else
UNITTESTS=no
fi
fi
if test "x$UNITTESTS" = xyes; then
- AC_DEFINE(UNITTESTS, 1, [Enable unit tests])
- PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.16])
- if test "x$with_gnu_ld" = xno; then
- AC_MSG_ERROR([GNU ld required to build unit tests])
+ if test "x$HAVE_GLIB" = xno; then
+ AC_MSG_ERROR([glib required to build unit tests])
fi
+ if test "x$linker_can_wrap" = xno; then
+ AC_MSG_ERROR([ld -wrap support required to build unit tests])
+ fi
+ AC_DEFINE(UNITTESTS, 1, [Enable unit tests])
AC_SUBST([GLIB_LIBS])
AC_SUBST([GLIB_CFLAGS])
fi