summaryrefslogtreecommitdiffstats
path: root/Makefile.am
blob: e7a97e16ec38299cd1f19fb3da7e2dd67888aa5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = libtap src tests samples doc man

AM_DISTCHECK_CONFIGURE_FLAGS = \
	--disable-code-coverage

CODE_COVERAGE_INFO = coverage.info
CODE_COVERAGE_HTML = coverage.html
CODE_COVERAGE_DIRS =	\
	src/knot	\
	src/libknot	\
	src/zscanner	\
	src/dnssec/lib	\
	src/dnssec/shared

code_coverage_quiet = --quiet

check-code-coverage:
if CODE_COVERAGE_ENABLED
	$(MAKE) $(AM_MAKEFLAGS) code-coverage-initial
	-$(MAKE) $(AM_MAKEFLAGS) -k check
	$(MAKE) $(AM_MAKEFLAGS) code-coverage-capture
	$(MAKE) $(AM_MAKEFLAGS) code-coverage-html
	$(MAKE) $(AM_MAKEFLAGS) code-coverage-summary
else
	@echo "You need to run configure with --enable-code-coverage to enable code coverage"
endif

code-coverage-initial:
if CODE_COVERAGE_ENABLED
	$(LCOV) $(code_coverage_quiet) \
		--no-external \
		$(foreach dir, $(CODE_COVERAGE_DIRS), --directory $(top_builddir)/$(dir)) \
		--capture --initial \
		--ignore-errors source \
		--no-checksum \
		--compat-libtool \
		--output-file $(CODE_COVERAGE_INFO)
else
	@echo "You need to run configure with --enable-code-coverage to enable code coverage"
endif

code-coverage-capture:
if CODE_COVERAGE_ENABLED
	$(LCOV) $(code_coverage_quiet) \
		--no-external \
		$(foreach dir, $(CODE_COVERAGE_DIRS), --directory $(builddir)/$(dir)) \
		--capture \
		--ignore-errors source \
		--no-checksum \
		--compat-libtool \
		--output-file $(CODE_COVERAGE_INFO)
else
	@echo "You need to run configure with --enable-code-coverage to enable code coverage"
endif

code-coverage-html:
if CODE_COVERAGE_ENABLED
	@echo "Generating code coverage HTML report (this might take a while)"
	@cp src/knot/conf/cf-lex.l src/knot/conf/cf-parse.y src/
	LANG=C $(GENHTML) $(code_coverage_quiet) \
		--output-directory $(CODE_COVERAGE_HTML) \
		--title "Knot DNS $(PACKAGE_VERSION) Code Coverage" \
		--legend --show-details \
		--ignore-errors source \
		$(CODE_COVERAGE_INFO)
	-@rm src/cf-lex.l src/cf-parse.y
else
	@echo "You need to run configure with --enable-code-coverage to enable code coverage"
endif

code-coverage-summary:
if CODE_COVERAGE_ENABLED
	$(LCOV) \
		--summary $(CODE_COVERAGE_INFO)
else
	@echo "You need to run configure with --enable-code-coverage to enable code coverage"
endif

if CODE_COVERAGE_ENABLED
clean-local: code-coverage-clean
	-find . -name "*.gcno" -delete
code-coverage-clean:
	-$(LCOV) --directory $(top_builddir) -z
	-rm -rf $(CODE_COVERAGE_INFO) $(CODE_COVERAGE_HTML)
	-find . -name "*.gcda" -o -name "*.gcov" -delete
endif

.PHONY: check-code-coverage code-coverage-initial code-coverage-capture code-coverage-html code-coverage-summary code-coverage-clean