2 # Copyright © 2010 Guillem Jover <guillem@debian.org>
6 # Add configuration option to enable code coverage support.
7 AC_DEFUN([DPKG_CODE_COVERAGE], [
8 AC_ARG_ENABLE([coverage],
9 [AS_HELP_STRING([--enable-coverage], [whether to enable code coverage])],
10 [], [enable_coverage=no])
11 AM_CONDITIONAL([COVERAGE_ENABLED], [test x$enable_coverage = xyes])
13 AS_IF([test "x$enable_coverage" = "xyes"], [
14 AS_IF([test "x$GCC" = "xno"], [
15 AC_MSG_ERROR([not compiling with gcc, which is required for C coverage support])
18 AC_CHECK_PROGS([GCOV], [gcov])
19 AS_IF([test -z "$GCOV"], [
20 AC_MSG_ERROR([missing gcov, which is required for C coverage support])
23 AC_CHECK_PROGS([LCOV], [lcov])
24 AS_IF([test -z "$LCOV"], [
25 AC_MSG_ERROR([missing lcov, which is required for C coverage support])
28 AC_CHECK_PROGS([LCOV_GENHTML], [genhtml])
29 AS_IF([test -z "$LCOV_GENHTML"], [
30 AC_MSG_ERROR([missing genhtml, which is required for C coverage support])
33 CFLAGS="$CFLAGS --coverage -O0"
34 LDFLAGS="$LDFLAGS --coverage -O0"
36 AC_MSG_CHECKING([for Devel::Cover perl module])
37 AS_IF([$($PERL -e "require Devel::Cover;" 2>/dev/null)], [
38 PERL_COVERAGE="-MDevel::Cover"
39 AC_SUBST(PERL_COVERAGE)
42 AC_MSG_ERROR([Devel::Cover perl module is required for coverage support])
44 AC_CHECK_PROGS([PERL_COVER], [cover])
45 AS_IF([test -z "$PERL_COVER"], [
46 AC_MSG_ERROR([missing cover, which is required for perl coverage support])
49 AC_MSG_CHECKING([whether to build with code coverage])
50 AC_MSG_RESULT([$enable_coverage])