| 1 |
# Checks for existence of coverage tools: |
| 2 |
# * gcov |
| 3 |
# * lcov |
| 4 |
# * genhtml |
| 5 |
# * gcovr |
| 6 |
# |
| 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], |
| 10 |
[ |
| 11 |
AC_ARG_ENABLE(gcov, |
| 12 |
AS_HELP_STRING([--enable-gcov], |
| 13 |
[enable coverage testing with gcov]), |
| 14 |
[use_gcov=$enableval], [use_gcov=no]) |
| 15 |
|
| 16 |
if test "x$use_gcov" = "xyes"; then |
| 17 |
# we need gcc: |
| 18 |
if test "$GCC" != "yes"; then |
| 19 |
AC_MSG_ERROR([GCC is required for --enable-gcov]) |
| 20 |
fi |
| 21 |
|
| 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;; |
| 26 |
*[)] gcc_ccache=no;; |
| 27 |
esac |
| 28 |
|
| 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.]) |
| 31 |
fi |
| 32 |
|
| 33 |
AC_CHECK_PROG(LCOV, lcov, lcov) |
| 34 |
AC_CHECK_PROG(GENHTML, genhtml, genhtml) |
| 35 |
|
| 36 |
if test -z "$LCOV"; then |
| 37 |
AC_MSG_ERROR([To enable code coverage reporting you must have lcov installed]) |
| 38 |
fi |
| 39 |
|
| 40 |
if test -z "$GENHTML"; then |
| 41 |
AC_MSG_ERROR([Could not find genhtml from the lcov package]) |
| 42 |
fi |
| 43 |
|
| 44 |
ac_cv_check_gcov=yes |
| 45 |
ac_cv_check_lcov=yes |
| 46 |
|
| 47 |
# Remove all optimization flags from CFLAGS |
| 48 |
changequote({,}) |
| 49 |
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` |
| 50 |
changequote([,]) |
| 51 |
|
| 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" |
| 56 |
|
| 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]) |
| 61 |
fi |
| 62 |
ac_cv_check_gcovr=yes |
| 63 |
|
| 64 |
fi |
| 65 |
]) # AC_TDD_GCOV |