1dnl Copyright (C) 2013 Cedric BAIL <cedric.bail at free dot fr> 2dnl That code is public domain and can be freely used or copied. 3 4dnl Macro for checking availability of tests and coverage infra structure 5 6dnl Usage: EFL_TESTS(profile) 7dnl Valid profile are auto, tests, coverage, no 8dnl Call PKG_CHECK_MODULES, AC_CHECK_PROG, define CHECK_CFLAGS/CHECK_LIBS and modify CFLAGS/LIBS 9dnl It define EFL_HAVE_TESTS/EFL_HAVE_LCOV for use in Makefile.am 10dnl It set have_test and have_coverage to yes/no depending if found 11 12AC_DEFUN([EFL_TESTS], 13[ 14build_tests=$1 15 16case "${build_tests}" in 17 auto) 18 check_tests="auto" 19 check_coverage="auto" 20 ;; 21 tests) 22 check_tests="yes" 23 check_coverage="auto" 24 ;; 25 coverage) 26 check_tests="yes" 27 check_coverage="yes" 28 ;; 29 no) 30 check_tests="no" 31 check_coverage="no" 32 ;; 33 *) 34 AC_MSG_ERROR([Unknow tests profile]) 35esac 36 37have_tests="no" 38if test "x${check_tests}" = "xyes" -o "x${check_tests}" = "xauto"; then 39 PKG_CHECK_MODULES([CHECK], [check >= 0.9.5], [have_tests="yes"], [have_tests="no"]) 40 if test "${check_tests}" = "xyes" -a "x${have_tests}" = "xno"; then 41 AC_MSG_ERROR([Impossible to find check package to build tests]) 42 fi 43fi 44 45if test "x${have_tests}" = "xyes"; then 46 if test "x${check_coverage}" = "xyes" -o "x${check_coverage}" = "xauto"; then 47 AC_CHECK_PROG([have_lcov], [lcov], [yes], [no]) 48 if test "x${have_lcov}" = "xyes" ; then 49 CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage" 50 LIBS="${LIBS} -lgcov" 51 fi 52 if test "x${have_lcov}" = "xno" -a "x${check_coverage}" = "xyes"; then 53 AC_MSG_ERROR([Impossible to find lcov package to build with coverage support]) 54 fi 55 else 56 have_coverage="no" 57 fi 58else 59 have_coverage="no" 60fi 61 62AM_CONDITIONAL([EFL_HAVE_TESTS], [test "x${have_tests}" = "xyes"]) 63AM_CONDITIONAL([EFL_HAVE_LCOV], [test "x${have_lcov}" = "xyes"]) 64 65]) 66