| 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 |
AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes") |
| 17 |
|
| 18 |
if test "x$use_gcov" = "xyes"; then |
| 19 |
# we need gcc: |
| 20 |
if test "$GCC" != "yes"; then |
| 21 |
AC_MSG_ERROR([GCC is required for --enable-gcov]) |
| 22 |
fi |
| 23 |
|
| 24 |
# Check if ccache is being used |
| 25 |
AC_CHECK_PROG(SHTOOL, shtool, shtool) |
| 26 |
if test "$SHTOOL"; then |
| 27 |
AS_CASE([`$SHTOOL path $CC`], |
| 28 |
[*ccache*], [gcc_ccache=yes], |
| 29 |
[gcc_ccache=no]) |
| 30 |
fi |
| 31 |
|
| 32 |
if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then |
| 33 |
AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) |
| 34 |
fi |
| 35 |
|
| 36 |
lcov_version_list="1.6 1.7 1.8 1.9 1.10" |
| 37 |
AC_CHECK_PROG(LCOV, lcov, lcov) |
| 38 |
AC_CHECK_PROG(GENHTML, genhtml, genhtml) |
| 39 |
|
| 40 |
if test "$LCOV"; then |
| 41 |
AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ |
| 42 |
glib_cv_lcov_version=invalid |
| 43 |
lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` |
| 44 |
for lcov_check_version in $lcov_version_list; do |
| 45 |
if test "$lcov_version" = "$lcov_check_version"; then |
| 46 |
glib_cv_lcov_version="$lcov_check_version (ok)" |
| 47 |
fi |
| 48 |
done |
| 49 |
]) |
| 50 |
else |
| 51 |
lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" |
| 52 |
AC_MSG_ERROR([$lcov_msg]) |
| 53 |
fi |
| 54 |
|
| 55 |
case $glib_cv_lcov_version in |
| 56 |
""|invalid[)] |
| 57 |
lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." |
| 58 |
AC_MSG_ERROR([$lcov_msg]) |
| 59 |
LCOV="exit 0;" |
| 60 |
;; |
| 61 |
esac |
| 62 |
|
| 63 |
if test -z "$GENHTML"; then |
| 64 |
AC_MSG_ERROR([Could not find genhtml from the lcov package]) |
| 65 |
fi |
| 66 |
|
| 67 |
ac_cv_check_gcov=yes |
| 68 |
ac_cv_check_lcov=yes |
| 69 |
|
| 70 |
# Remove all optimization flags from CFLAGS |
| 71 |
changequote({,}) |
| 72 |
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` |
| 73 |
changequote([,]) |
| 74 |
|
| 75 |
# Add the special gcc flags |
| 76 |
COVERAGE_CFLAGS="-O0 --coverage" |
| 77 |
COVERAGE_CXXFLAGS="-O0 --coverage" |
| 78 |
COVERAGE_LDFLAGS="-lgcov" |
| 79 |
|
| 80 |
# Check availability of gcovr |
| 81 |
AC_CHECK_PROG(GCOVR, gcovr, gcovr) |
| 82 |
if test -z "$GCOVR"; then |
| 83 |
ac_cv_check_gcovr=no |
| 84 |
else |
| 85 |
ac_cv_check_gcovr=yes |
| 86 |
fi |
| 87 |
fi |
| 88 |
]) # AC_TDD_GCOV |
| 89 |
|