~ted/indicator-network/add-title

« back to all changes in this revision

Viewing changes to m4/gcov.m4

  • Committer: Tarmac
  • Author(s): Pete Woods
  • Date: 2013-08-27 14:43:59 UTC
  • mfrom: (273.1.5 cmake)
  • Revision ID: tarmac-20130827144359-n3jdv10adh2x5gms
Re-write build scripts in preparation for merging the secret agent codebase and tests.

Approved by Charles Kerr, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Checks for existence of coverage tools:
2
 
#  * gcov
3
 
#  * lcov
4
 
#  * genhtml
5
 
#  * gcovr
6
 
7
 
# Sets ac_cv_check_gcov to yes if tooling is present
8
 
# and reports the executables to the variables LCOV, GCOVR and GENHTML.
9
 
AC_DEFUN([AC_TDD_GCOV],
10
 
[
11
 
  AC_ARG_ENABLE(gcov,
12
 
  AS_HELP_STRING([--enable-gcov],
13
 
                 [enable coverage testing with gcov]),
14
 
  [use_gcov=$enableval], [use_gcov=no])
15
 
 
16
 
  if test "x$use_gcov" = "xyes"; then
17
 
  # we need gcc:
18
 
  if test "$GCC" != "yes"; then
19
 
    AC_MSG_ERROR([GCC is required for --enable-gcov])
20
 
  fi
21
 
 
22
 
  # Check if ccache is being used
23
 
  AC_CHECK_PROG(SHTOOL, shtool, shtool)
24
 
  case `$SHTOOL path $CC` in
25
 
    *ccache*[)] gcc_ccache=yes;;
26
 
    *[)] gcc_ccache=no;;
27
 
  esac
28
 
 
29
 
  if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
30
 
    AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
31
 
  fi
32
 
 
33
 
  lcov_version_list="1.6 1.7 1.8 1.9"
34
 
  AC_CHECK_PROG(LCOV, lcov, lcov)
35
 
  AC_CHECK_PROG(GENHTML, genhtml, genhtml)
36
 
 
37
 
  if test "$LCOV"; then
38
 
    AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
39
 
      glib_cv_lcov_version=invalid
40
 
      lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
41
 
      for lcov_check_version in $lcov_version_list; do
42
 
        if test "$lcov_version" = "$lcov_check_version"; then
43
 
          glib_cv_lcov_version="$lcov_check_version (ok)"
44
 
        fi
45
 
      done
46
 
    ])
47
 
  else
48
 
    lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
49
 
    AC_MSG_ERROR([$lcov_msg])
50
 
  fi
51
 
 
52
 
  case $glib_cv_lcov_version in
53
 
    ""|invalid[)]
54
 
      lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
55
 
      AC_MSG_ERROR([$lcov_msg])
56
 
      LCOV="exit 0;"
57
 
      ;;
58
 
  esac
59
 
 
60
 
  if test -z "$GENHTML"; then
61
 
    AC_MSG_ERROR([Could not find genhtml from the lcov package])
62
 
  fi
63
 
 
64
 
  ac_cv_check_gcov=yes
65
 
  ac_cv_check_lcov=yes
66
 
 
67
 
  # Remove all optimization flags from CFLAGS
68
 
  changequote({,})
69
 
  CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
70
 
  changequote([,])
71
 
 
72
 
  # Add the special gcc flags
73
 
  COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
74
 
  COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"        
75
 
  COVERAGE_LDFLAGS="-lgcov"
76
 
 
77
 
  # Check availability of gcovr
78
 
  AC_CHECK_PROG(GCOVR, gcovr, gcovr)
79
 
  if test -z "$GCOVR"; then
80
 
    ac_cv_check_gcovr=no
81
 
  else
82
 
    ac_cv_check_gcovr=yes
83
 
  fi
84
 
 
85
 
fi
86
 
]) # AC_TDD_GCOV