EFL 1.7 svn doobies
[profile/ivi/efreet.git] / m4 / efl_coverage.m4
1 dnl Copyright (C) 2008 Vincent Torri <vtorri at univ-evry dot fr>
2 dnl That code is public domain and can be freely used or copied.
3
4 dnl Macro that check if coverage support is wanted and, if yes, if
5 dnl lcov is available.
6
7 dnl Usage: EFL_CHECK_COVERAGE(tests [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
8 dnl The parameter 'tests' is used if a dependency is needed. If set to "yes",
9 dnl the dependency is available.
10 dnl Defines EFL_COVERAGE_CFLAGS and EFL_COVERAGE_LIBS variables
11 dnl Defines the automake conditionnal EFL_ENABLE_COVERAGE
12
13 AC_DEFUN([EFL_CHECK_COVERAGE],
14 [
15
16 dnl configure option
17
18 AC_ARG_ENABLE([coverage],
19    [AC_HELP_STRING([--enable-coverage], [enable coverage profiling instrumentation @<:@default=disabled@:>@])],
20    [
21     if test "x${enableval}" = "xyes" ; then
22        _efl_enable_coverage="yes"
23     else
24        _efl_enable_coverage="no"
25     fi
26    ],
27    [_efl_enable_coverage="no"])
28
29 AC_MSG_CHECKING([whether to use profiling instrumentation])
30 AC_MSG_RESULT([$_efl_enable_coverage])
31
32 dnl lcov check
33
34 if test "x$_efl_enable_coverage" = "xyes" && test ! "x$1" = "xyes" ; then
35    AC_MSG_WARN([Coverage report requested but tests not being built, disable profiling instrumentation.])
36    AC_MSG_WARN([Run configure with --enable-tests])
37    _efl_enable_coverage="no"
38 fi
39
40 if test "x$_efl_enable_coverage" = "xyes" ; then
41    AC_CHECK_PROG(have_lcov, [lcov], [yes], [no])
42    if test "x$have_lcov" = "xyes" ; then
43       EFL_COVERAGE_CFLAGS="-fprofile-arcs -ftest-coverage"
44       EFL_COVERAGE_LIBS="-lgcov"
45 # remove any optimisation flag and force debug symbols
46       EFL_DEBUG_CFLAGS="-g -O0 -DDEBUG"
47    else
48       AC_MSG_WARN([lcov is not found, disable profiling instrumentation])
49       _efl_enable_coverage="no"
50    fi
51 fi
52
53 dnl Substitution
54 AC_SUBST(EFL_COVERAGE_CFLAGS)
55 AC_SUBST(EFL_COVERAGE_LIBS)
56
57 AM_CONDITIONAL(EFL_ENABLE_COVERAGE, test "x${_efl_enable_coverage}" = "xyes")
58
59 AS_IF([test "x$_efl_enable_coverage" = "xyes"], [$2], [$3])
60 ])
61
62 dnl End of efl_coverage.m4