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.
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.
8 dnl Usage: EFL_CHECK_TESTS(EFL[, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
9 dnl Define the automake conditionnal EFL_ENABLE_TESTS
11 AC_DEFUN([EFL_CHECK_TESTS],
13 m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
17 AC_ARG_ENABLE([tests],
18 [AC_HELP_STRING([--enable-tests], [enable tests @<:@default=disabled@:>@])],
20 if test "x${enableval}" = "xyes" ; then
21 _efl_enable_tests="yes"
23 _efl_enable_tests="no"
26 [_efl_enable_tests="no"])
28 AC_MSG_CHECKING([whether tests are built])
29 AC_MSG_RESULT([${_efl_enable_tests}])
31 AC_REQUIRE([PKG_PROG_PKG_CONFIG])
33 if test "x${_efl_enable_tests}" = "xyes" ; then
34 PKG_CHECK_MODULES([CHECK],
37 [_efl_enable_tests="no"])
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"
50 m4_defn([UPEFL])[]_CFLAGS="${m4_defn([UPEFL])[]_CFLAGS} -g -O0 -DDEBUG"
52 _efl_enable_coverage="yes"
54 AC_MSG_WARN([lcov is not found, disable profiling instrumentation])
58 AM_CONDITIONAL(EFL_ENABLE_TESTS, test "x${_efl_enable_tests}" = "xyes")
59 AM_CONDITIONAL(EFL_ENABLE_COVERAGE, test "x${_efl_enable_coverage}" = "xyes")
61 AS_IF([test "x$_efl_enable_tests" = "xyes"], [$2], [$3])
66 dnl End of efl_tests.m4