1 AC_DEFUN([GI_ENABLE_GCOV],
4 AC_HELP_STRING([--enable-gcov],
5 [compile with coverage profiling instrumentation (gcc only)]),
6 enable_gcov=$enableval,
8 if test x$enable_gcov = xyes ; then
9 if test "x$GCC" != "xyes"
11 AC_MSG_ERROR([gcov only works if gcc is used])
14 AS_COMPILER_FLAG(["-fprofile-arcs"],
15 [GCOV_CFLAGS="$GCOV_CFLAGS -fprofile-arcs"],
17 AS_COMPILER_FLAG(["-ftest-coverage"],
18 [GCOV_CFLAGS="$GCOV_CFLAGS -ftest-coverage"],
20 dnl libtool 1.5.22 and lower strip -fprofile-arcs from the flags
21 dnl passed to the linker, which is a bug; -fprofile-arcs implicitly
22 dnl links in -lgcov, so we do it explicitly here for the same effect
26 GCOV=`echo $CC | sed s/gcc/gcov/g`
30 AC_DEFINE_UNQUOTED(GI_GCOV_ENABLED, 1,
31 [Defined if gcov is enabled to force a rebuild due to config.h changing])
32 dnl if gcov is used, we do not want default -O2 CFLAGS
33 if test "x$GI_GCOV_ENABLED" = "xyes"
43 AC_MSG_NOTICE([gcov enabled, setting CFLAGS and friends to $CFLAGS])
46 AM_CONDITIONAL(GI_GCOV_ENABLED, test x$enable_gcov = xyes)