Commit 659dba2156b956c5b54254b7f9a046de6cef0145

Authored by Georg Hopp
1 parent 317cc63d

add missing non generated m4 macro and Makefile

  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 + AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes")
  16 +
  17 + # if test "x$use_gcov" = "xyes"; then
  18 + # we need gcc:
  19 + if test "$GCC" != "yes"; then
  20 + AC_MSG_ERROR([GCC is required for --enable-gcov])
  21 + fi
  22 +
  23 + # Check if ccache is being used
  24 + AC_CHECK_PROG(SHTOOL, shtool, shtool)
  25 + case `$SHTOOL path $CC` in
  26 + *ccache*[)] gcc_ccache=yes;;
  27 + *[)] gcc_ccache=no;;
  28 + esac
  29 +
  30 + if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
  31 + AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
  32 + fi
  33 +
  34 + lcov_version_list="1.6 1.7 1.8 1.9"
  35 + AC_CHECK_PROG(LCOV, lcov, lcov)
  36 + AC_CHECK_PROG(GENHTML, genhtml, genhtml)
  37 +
  38 + if test "$LCOV"; then
  39 + AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
  40 + glib_cv_lcov_version=invalid
  41 + lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
  42 + for lcov_check_version in $lcov_version_list; do
  43 + if test "$lcov_version" = "$lcov_check_version"; then
  44 + glib_cv_lcov_version="$lcov_check_version (ok)"
  45 + fi
  46 + done
  47 + ])
  48 + else
  49 + lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
  50 + AC_MSG_ERROR([$lcov_msg])
  51 + fi
  52 +
  53 + case $glib_cv_lcov_version in
  54 + ""|invalid[)]
  55 + lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
  56 + AC_MSG_ERROR([$lcov_msg])
  57 + LCOV="exit 0;"
  58 + ;;
  59 + esac
  60 +
  61 + if test -z "$GENHTML"; then
  62 + AC_MSG_ERROR([Could not find genhtml from the lcov package])
  63 + fi
  64 +
  65 + # Remove all optimization flags from CFLAGS
  66 + changequote({,})
  67 + CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
  68 + changequote([,])
  69 +
  70 + # Add the special gcc flags
  71 + COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
  72 + COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
  73 + COVERAGE_LDFLAGS="-lgcov"
  74 +
  75 +#fi
  76 +]) # AC_TDD_GCOV
  77 +
  1 +vpath %.c ../../src/stream
  2 +vpath %.c ../../src/stream/interface
  3 +
  4 +OBJECTS = stream.o read.o write.o reader.o writer.o
  5 +
  6 +%.o: %.c
  7 + gcc -Wall -ggdb -O0 -fprofile-arcs -ftest-coverage -I ../../include -c $< -o $@
  8 +
  9 +.PHONY: all clean check distclean check-build
  10 +all: check-build
  11 +check: check-build
  12 +check-build: $(OBJECTS)
  13 +distclean: clean
  14 +clean:
  15 + rm -rf $(OBJECTS)
Please register or login to post a comment