1 dnl ===========================================================================
7 AS_HELP_STRING([--enable-gcov],
9 [use_gcov=$enableval], [use_gcov=no])
11 if test "x$use_gcov" = "xyes"; then
13 if test "$GCC" != "yes"; then
14 AC_MSG_ERROR([GCC is required for --enable-gcov])
17 dnl Check if ccache is being used
18 AC_CHECK_PROG(SHTOOL, shtool, shtool)
19 case `$SHTOOL path $CC` in
20 *ccache*[)] gcc_ccache=yes;;
24 if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
25 AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
28 ltp_version_list="1.6 1.5 1.4"
29 AC_CHECK_PROG(LTP, lcov, lcov)
30 AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
33 AC_CACHE_CHECK([for ltp version], cairo_cv_ltp_version, [
34 cairo_cv_ltp_version=invalid
35 ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
36 for ltp_check_version in $ltp_version_list; do
37 if test "$ltp_version" = "$ltp_check_version"; then
38 cairo_cv_ltp_version="$ltp_check_version (ok)"
44 case $cairo_cv_ltp_version in
52 if test "x$cairo_has_lcov" != "xyes"; then
53 AC_MSG_ERROR([[To enable code coverage reporting you must have one of the following LTP versions installed: $ltp_version_list.
54 Please install the Linux Test Project [http://ltp.sourceforge.net/], and try again.]])
57 if test -z "$LTP_GENHTML"; then
58 AC_MSG_ERROR([[Could not find genhtml from the LTP package.
59 Please install the Linux Test Project [http://ltp.sourceforge.net/], and try again.]])
62 AC_DEFINE(HAVE_GCOV, 1, [Whether you have gcov])
63 dnl PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/Makefile.gcov, $abs_srcdir)
65 dnl Remove all optimization flags from CFLAGS
67 CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
68 CAIRO_CFLAGS=`echo "$CAIRO_CFLAGS" | $SED -e 's/-O[0-9]*//g'`
71 dnl Add the special gcc flags
72 dnl In order to workaround a debian bug in libtool where they strip
73 dnl $dependency_libs from the link line and CFLAGS, we need to pass
74 dnl --coverage via LDFLAGS.
75 CAIRO_CC_TRY_FLAG([--coverage], [CAIRO_CFLAGS="$CAIRO_CFLAGS -O0 --coverage"])
77 AM_CONDITIONAL(CAIRO_HAS_LCOV, test "x$cairo_has_lcov" = "xyes")
79 dnl ===========================================================================
80 dnl Check for some custom valgrind modules
81 PKG_CHECK_MODULES(VALGRIND, valgrind, [
82 _save_CFLAGS="$CFLAGS"
83 _save_CPPFLAGS="$CPPFLAGS"
84 CFLAGS="$CFLAGS $VALGRIND_CFLAGS"
85 CPPFLAGS="$CPPFLAGS $VALGRIND_CFLAGS"
86 AC_CHECK_HEADER([valgrind.h], [AC_DEFINE([HAVE_VALGRIND], [1],
87 [Define to 1 if you have Valgrind])])
88 AC_CHECK_HEADER([lockdep.h], [AC_DEFINE([HAVE_LOCKDEP], [1],
89 [Define to 1 if you have the Valgrind lockdep tool])])
90 AC_CHECK_HEADER([memfault.h], [AC_DEFINE([HAVE_MEMFAULT], [1],
91 [Define to 1 if you have the Valgrind memfault tool])])
92 CAIRO_CFLAGS="$VALGRIND_CFLAGS $CAIRO_CFLAGS"
93 CFLAGS="$_save_CFLAGS"
94 CPPFLAGS="$_save_CPPFLAGS"