summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorThomas Voß <thomas.voss@rub.de>2011-12-05 17:27:29 +0100
committerThomas Voß <thomas.voss@rub.de>2011-12-05 17:27:29 +0100
commit1ff7a967e0648d6f71bf3bc30e3642431765da7e (patch)
treee54e766b582e023575a7fe8bdb8445530f360023 /m4
init checkin.
Diffstat (limited to 'm4')
-rw-r--r--m4/gcov.m483
-rw-r--r--m4/gtest.m424
2 files changed, 107 insertions, 0 deletions
diff --git a/m4/gcov.m4 b/m4/gcov.m4
new file mode 100644
index 0000000..0a619fa
--- /dev/null
+++ b/m4/gcov.m4
@@ -0,0 +1,83 @@
+# Checks for existence of coverage tools:
+# * gcov
+# * lcov
+# * genhtml
+# * gcovr
+#
+# Sets ac_cv_check_gcov to yes if tooling is present
+# and reports the executables to the variables LCOV, GCOVR and GENHTML.
+AC_DEFUN([AC_TDD_GCOV],
+[
+ AC_ARG_ENABLE(gcov,
+ AS_HELP_STRING([--enable-gcov],
+ [enable coverage testing with gcov]),
+ [use_gcov=$enableval], [use_gcov=no])
+
+ if test "x$use_gcov" = "xyes"; then
+ # we need gcc:
+ if test "$GCC" != "yes"; then
+ AC_MSG_ERROR([GCC is required for --enable-gcov])
+ fi
+
+ # Check if ccache is being used
+ AC_CHECK_PROG(SHTOOL, shtool, shtool)
+ case `$SHTOOL path $CC` in
+ *ccache*[)] gcc_ccache=yes;;
+ *[)] gcc_ccache=no;;
+ esac
+
+ if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
+ AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
+ fi
+
+ lcov_version_list="1.6 1.7 1.8 1.9"
+ AC_CHECK_PROG(LCOV, lcov, lcov)
+ AC_CHECK_PROG(GENHTML, genhtml, genhtml)
+ AC_CHECK_PROG(GCOVR, gcovr, gcovr)
+
+ if test "$LCOV"; then
+ AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
+ glib_cv_lcov_version=invalid
+ lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
+ for lcov_check_version in $lcov_version_list; do
+ if test "$lcov_version" = "$lcov_check_version"; then
+ glib_cv_lcov_version="$lcov_check_version (ok)"
+ fi
+ done
+ ])
+ else
+ lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
+ AC_MSG_ERROR([$lcov_msg])
+ fi
+
+ case $glib_cv_lcov_version in
+ ""|invalid[)]
+ lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
+ AC_MSG_ERROR([$lcov_msg])
+ LCOV="exit 0;"
+ ;;
+ esac
+
+ if test -z "$GENHTML"; then
+ AC_MSG_ERROR([Could not find genhtml from the lcov package])
+ fi
+
+ if test -z "$GCOVR"; then
+ AC_MSG_ERROR([Could not find gcovr; easy_install (or pip) gcovr])
+ fi
+
+ ac_cv_check_gcov=yes
+
+ # Remove all optimization flags from CFLAGS
+ changequote({,})
+ CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
+ changequote([,])
+
+ # Add the special gcc flags
+ COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
+ COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
+ COVERAGE_LDFLAGS="-lgcov"
+
+fi
+]) # AC_TDD_GCOV
+
diff --git a/m4/gtest.m4 b/m4/gtest.m4
new file mode 100644
index 0000000..459d1f5
--- /dev/null
+++ b/m4/gtest.m4
@@ -0,0 +1,24 @@
+# Checks whether the gtest library is available on the system
+# Allows for adjusting the include and library path.
+# Sets have_gtest=yes if the library is present and
+# reports the compiler and linker flags in
+# GTEST_CXXFLAGS AND GTEST_LDFLAGS, respectively.
+AC_DEFUN([AC_CHECK_GTEST],
+[
+ AC_ARG_WITH([gtest-include-path],
+ [AS_HELP_STRING([--with-gtest-include-path],
+ [location of the Google test headers, defaults to /usr/include])],
+ [GTEST_CXXFLAGS="-I$withval"],
+ [GTEST_CXXFLAGS='-I/usr/include'])
+
+ AC_ARG_WITH([gtest-lib-path],
+ [AS_HELP_STRING([--with-gtest-lib-path], [location of the Google test libraries])],
+ [GTEST_LDFLAGS="-L$withval -lpthread"],
+ [GTEST_LDFLAGS='-lgtest -lpthread'])
+
+ AC_HAVE_LIBRARY( [gtest],
+ [have_gtest=yes],
+ AC_MSG_WARN([package 'gtest' not found: tests disabled]))
+
+]) # AC_CHECK_GTEST
+