From 362e50254e6ca4ebac1ffaf9d7463d1571977bf0 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Wed, 8 Feb 2012 22:14:56 +0100 Subject: [PATCH] Add gcov target for code coverage --- Makefile | 8 +++++++- tests/config.mk | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 73488a3..fe70487 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ ${PROJECT}: ${OBJECTS} clean: $(QUIET)rm -rf ${PROJECT} ${OBJECTS} ${PROJECT}-${VERSION}.tar.gz \ - ${DOBJECTS} ${PROJECT}-debug .depend ${PROJECT}.pc doc + ${DOBJECTS} ${PROJECT}-debug .depend ${PROJECT}.pc doc *gcda *gcno $(PROJECT).info gcov $(QUIET)make -C tests clean ${PROJECT}-debug: ${DOBJECTS} @@ -87,6 +87,12 @@ dist: clean doc: clean $(QUIET)doxygen Doxyfile +gcov: clean + $(QUIET)CFLAGS+="-fprofile-arcs -ftest-coverage" LDFLAGS+="-fprofile-arcs" $(MAKE) $(PROJECT) + $(QUIET)make -C tests + $(QUIET)lcov --directory . --capture --output-file $(PROJECT).info + $(QUIET)genhtml --output-directory gcov $(PROJECT).info + install: all ${PROJECT}.pc $(ECHO) installing executable file $(QUIET)mkdir -p ${DESTDIR}${PREFIX}/bin diff --git a/tests/config.mk b/tests/config.mk index 12780b6..00e774d 100644 --- a/tests/config.mk +++ b/tests/config.mk @@ -4,3 +4,6 @@ CHECK_INC ?= $(shell pkg-config --cflags check) CHECK_LIB ?= $(shell pkg-config --libs check) LIBS += ${CHECK_LIB} + +CFLAGS += -fprofile-arcs -ftest-coverage +LDFLAGS += -fprofile-arcs