EFL 1.7 svn doobies
[profile/ivi/eina.git] / m4 / common / efl_tests.m4
1 dnl Copyright (C) 2008-2012 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 tests programs are wanted and if yes, if
5 dnl the Check library is available.
6 dnl the lcov program is available.
7
8 dnl Usage: EFL_CHECK_TESTS(EFL[, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
9 dnl Define the automake conditionnal EFL_ENABLE_TESTS
10
11 AC_DEFUN([EFL_CHECK_TESTS],
12 [
13 m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
14
15 dnl configure option
16
17 AC_ARG_ENABLE([tests],
18    [AC_HELP_STRING([--enable-tests], [enable tests @<:@default=disabled@:>@])],
19    [
20     if test "x${enableval}" = "xyes" ; then
21        _efl_enable_tests="yes"
22     else
23        _efl_enable_tests="no"
24     fi
25    ],
26    [_efl_enable_tests="no"])
27
28 AC_MSG_CHECKING([whether tests are built])
29 AC_MSG_RESULT([${_efl_enable_tests}])
30
31 AC_REQUIRE([PKG_PROG_PKG_CONFIG])
32
33 if test "x${_efl_enable_tests}" = "xyes" ; then
34    PKG_CHECK_MODULES([CHECK],
35       [check >= 0.9.5],
36       [dummy="yes"],
37       [_efl_enable_tests="no"])
38 fi
39
40 efl_enable_coverage="no"
41 if test "x${_efl_enable_tests}" = "xyes" ; then
42    AC_CHECK_PROG(have_lcov, [lcov], [yes], [no])
43    if test "x$have_lcov" = "xyes" ; then
44       m4_defn([UPEFL])[]_CFLAGS="${m4_defn([UPEFL])[]_CFLAGS} -fprofile-arcs -ftest-coverage"
45       m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} -lgcov"
46 # remove any optimisation flag and force debug symbols
47       if test "x${prefer_assert}" = "xno"; then
48          m4_defn([UPEFL])[]_CFLAGS="${m4_defn([UPEFL])[]_CFLAGS} -DNDEBUG"
49       else
50          m4_defn([UPEFL])[]_CFLAGS="${m4_defn([UPEFL])[]_CFLAGS} -g -O0 -DDEBUG"
51       fi
52       efl_enable_coverage="yes"
53    else
54       AC_MSG_WARN([lcov is not found, disable profiling instrumentation])
55    fi
56 fi
57
58 AM_CONDITIONAL(EFL_ENABLE_TESTS, test "x${_efl_enable_tests}" = "xyes")
59
60 AS_IF([test "x$_efl_enable_tests" = "xyes"], [$2], [$3])
61
62 m4_popdef([UPEFL])
63 ])
64
65 dnl End of efl_tests.m4