summaryrefslogtreecommitdiff
path: root/m4/salut-gcov.m4
diff options
context:
space:
mode:
authorEmanuele Aina <em@nerd.ocracy.org>2007-06-25 07:57:42 +0000
committerEmanuele Aina <em@nerd.ocracy.org>2007-06-25 07:57:42 +0000
commitc5fbbdf2f1f5691d3d1dc6b6b30507624640bf4b (patch)
treec9d19fdce098c9c7002d647527a0a8cda3e54d3a /m4/salut-gcov.m4
parent97e025f19370a7b8d5170195683570390fdd6c3d (diff)
downloadtelepathy-salut-c5fbbdf2f1f5691d3d1dc6b6b30507624640bf4b.tar.gz
Split the command line settings from the detection of libraries and utilities
20070625075742-f974e-6695a3b35627caa5a09411094577c68d34a60d1e.gz
Diffstat (limited to 'm4/salut-gcov.m4')
-rw-r--r--m4/salut-gcov.m448
1 files changed, 48 insertions, 0 deletions
diff --git a/m4/salut-gcov.m4 b/m4/salut-gcov.m4
new file mode 100644
index 00000000..08c4ad3e
--- /dev/null
+++ b/m4/salut-gcov.m4
@@ -0,0 +1,48 @@
+dnl Detect and set flags for gcov
+
+AC_DEFUN([SALUT_GCOV],
+[
+ if test "x$GCC" != "xyes"
+ then
+ AC_MSG_ERROR([gcov only works if gcc is used])
+ fi
+
+ AS_COMPILER_FLAG(["-fprofile-arcs"],
+ [GCOV_CFLAGS="$GCOV_CFLAGS -fprofile-arcs"],
+ true)
+ AS_COMPILER_FLAG(["-ftest-coverage"],
+ [GCOV_CFLAGS="$GCOV_CFLAGS -ftest-coverage"],
+ true)
+ dnl remove any -O flags - FIXME: is this needed ?
+ GCOV_CFLAGS=`echo "$GCOV_CFLAGS" | sed -e 's/-O[[0-9]]*//g'`
+ dnl libtool 1.5.22 and lower strip -fprofile-arcs from the flags
+ dnl passed to the linker, which is a bug; -fprofile-arcs implicitly
+ dnl links in -lgcov, so we do it explicitly here for the same effect
+ GCOV_LIBS=-lgcov
+ AC_SUBST(GCOV_CFLAGS)
+ AC_SUBST(GCOV_LIBS)
+ GCOV=`echo $CC | sed s/gcc/gcov/g`
+ AC_SUBST(GCOV)
+
+ AC_SUBST([MOSTLYCLEANFILES], "*.bb *.bbg *.da *.gcov *.gcda *.gcno")
+
+ GCOV_ENABLED=yes
+ AC_DEFINE_UNQUOTED(HAVE_GCOV, 1,
+ [Defined if gcov is enabled to force a rebuild due to config.h changing])
+
+ dnl if gcov is used, we do not want default -O2 CFLAGS
+ if test "x$HAVE_GCOV" = "xyes"
+ then
+ CFLAGS="-O0"
+ AC_SUBST(CFLAGS)
+ CXXFLAGS="-O0"
+ AC_SUBST(CXXFLAGS)
+ FFLAGS="-O0"
+ AC_SUBST(FFLAGS)
+ CCASFLAGS="-O0"
+ AC_SUBST(CCASFLAGS)
+ AC_MSG_NOTICE([gcov enabled, setting CFLAGS and friends to $CFLAGS])
+ fi
+
+ AM_CONDITIONAL(HAVE_GCOV, test x$HAVE_GCOV = xyes)
+])