1
# Checks for existence of coverage tools:
7
# Sets ac_cv_check_gcov to yes if tooling is present
8
# and reports the executables to the variables LCOV, GCOVR and GENHTML.
9
AC_DEFUN([AC_TDD_GCOV],
12
AS_HELP_STRING([--enable-gcov],
13
[enable coverage testing with gcov]),
14
[use_gcov=$enableval], [use_gcov=no])
16
if test "x$use_gcov" = "xyes"; then
18
if test "$GCC" != "yes"; then
19
AC_MSG_ERROR([GCC is required for --enable-gcov])
22
# Check if ccache is being used
23
AC_CHECK_PROG(SHTOOL, shtool, shtool)
24
case `test "$SHTOOL" && $SHTOOL path $CC` in
25
*ccache*[)] gcc_ccache=yes;;
29
if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
30
AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
33
AC_CHECK_PROG(LCOV, lcov, lcov)
34
AC_CHECK_PROG(GENHTML, genhtml, genhtml)
36
if test -z "$LCOV"; then
37
AC_MSG_ERROR([To enable code coverage reporting you must have lcov installed])
40
if test -z "$GENHTML"; then
41
AC_MSG_ERROR([Could not find genhtml from the lcov package])
47
# Remove all optimization flags from CFLAGS
49
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
52
# Add the special gcc flags
53
COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
54
COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
55
COVERAGE_LDFLAGS="-lgcov"
57
# Check availability of gcovr
58
AC_CHECK_PROG(GCOVR, gcovr, gcovr)
59
if test -z "$GCOVR"; then
60
AC_MSG_ERROR([To enable code coverage reporting you must have gcovr installed])