diff --git a/.gitignore b/.gitignore index 061a75d..238cfb8 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ *.so *.exe *.orig +*.gcda +*.gcno +*.gcov .deps/ .libs/ INSTALL diff --git a/Makefile.am b/Makefile.am index 0e58512..9c224ac 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,6 +24,7 @@ endif AM_CFLAGS = \ $(WARN_CFLAGS) \ + $(GCOV_CFLAGS) \ $(GLIB_CFLAGS) bin_PROGRAMS = pkg-config @@ -42,6 +43,12 @@ dist_doc_DATA = pkg-config-guide.html dist_man_MANS = pkg-config.1 EXTRA_DIST = README.win32 +# gcov test coverage +gcov: + -$(MAKE) $(AM_MAKEFLAGS) -k check + $(GCOV) $(pkg_config_SOURCES) +CLEANFILES = *.gcda *.gcno *.gcov + # Since we can't always have glib in DIST_SUBDIRS, we need to make sure # glib is configured when we want to run dist. Unfortunately, there's no # DIST_CONFIGURE_FLAGS. diff --git a/configure.ac b/configure.ac index c6c24a2..3909055 100644 --- a/configure.ac +++ b/configure.ac @@ -182,6 +182,27 @@ fi AC_SUBST(GLIB_LIBS) AC_SUBST(GLIB_CFLAGS) +dnl +dnl Optional gcov test coverage usage +dnl +AC_ARG_WITH([gcov], + [AS_HELP_STRING([--with-gcov], [gcov test coverage @<:@default=no@:>@])], + [], + [with_gcov=no]) +if test "x$with_gcov" = xyes; then + if test "$GCC" = no; then + AC_MSG_ERROR([gcov test coverage can only be used with GCC]) + fi + + AC_PATH_PROG([GCOV], [gcov], [AC_MSG_ERROR([could not find gcov program])]) + GCOV_CFLAGS="-fprofile-arcs -ftest-coverage" + + # Ensure there's no optimizing since last -O wins and CFLAGS is used + # at the end of COMPILE/LTCOMPILE. + CFLAGS="${CFLAGS+$CFLAGS }-O0" +fi +AC_SUBST([GCOV_CFLAGS]) + AC_CONFIG_FILES([ Makefile check/Makefile