[PATCH] Check for -wrap support in the linker
Alan Coopersmith
alan.coopersmith at sun.com
Tue Sep 15 21:13:00 PDT 2009
Allows unit tests to be built with non-gnu-linkers that
also have -wrap support
Signed-off-by: Alan Coopersmith <alan.coopersmith at sun.com>
---
configure.ac | 37 +++++++++++++++++++++++++++++++------
1 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index f6b91cd..9541a59 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1157,20 +1157,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
--
1.5.6.5
More information about the xorg-devel
mailing list