Makefile.am 2.52 KB
Newer Older
1
ACLOCAL_AMFLAGS = -I m4
2
SUBDIRS = libtap src tests samples doc man patches
3

4
AM_DISTCHECK_CONFIGURE_FLAGS = \
5 6
	--disable-code-coverage

7 8 9
CODE_COVERAGE_INFO = coverage.info
CODE_COVERAGE_HTML = coverage.html
CODE_COVERAGE_DIRS = \
10 11
	src/knot \
	src/libknot \
12 13
	src/zscanner

14
code_coverage_quiet = --quiet
15 16 17

check-code-coverage:
if CODE_COVERAGE_ENABLED
18
	$(MAKE) $(AM_MAKEFLAGS) code-coverage-initial
19 20 21
	-$(MAKE) $(AM_MAKEFLAGS) -k check
	$(MAKE) $(AM_MAKEFLAGS) code-coverage-capture
	$(MAKE) $(AM_MAKEFLAGS) code-coverage-html
22 23 24 25 26 27 28 29
	$(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) \
30 31
		--no-external \
		$(foreach dir, $(CODE_COVERAGE_DIRS), --directory $(top_builddir)/$(dir)) \
32 33
		--capture --initial \
		--ignore-errors source \
34 35 36
		--no-checksum \
		--compat-libtool \
		--output-file $(CODE_COVERAGE_INFO)
37 38 39 40 41 42 43
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) \
44 45
		--no-external \
		$(foreach dir, $(CODE_COVERAGE_DIRS), --directory $(builddir)/$(dir)) \
46 47
		--capture \
		--ignore-errors source \
48 49 50
		--no-checksum \
		--compat-libtool \
		--output-file $(CODE_COVERAGE_INFO)
51 52 53 54 55 56 57
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)"
58
	@cp src/knot/conf/cf-lex.l src/knot/conf/cf-parse.y src/
59 60 61 62 63 64
	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)
65
	-@rm src/cf-lex.l src/cf-parse.y
66 67 68 69
else
	@echo "You need to run configure with --enable-code-coverage to enable code coverage"
endif

70 71 72
code-coverage-summary:
if CODE_COVERAGE_ENABLED
	$(LCOV) \
73
		--summary $(CODE_COVERAGE_INFO)
74 75 76 77
else
	@echo "You need to run configure with --enable-code-coverage to enable code coverage"
endif

78 79
if CODE_COVERAGE_ENABLED
clean-local: code-coverage-clean
80
	-find . -name "*.gcno" -delete
81 82
code-coverage-clean:
	-$(LCOV) --directory $(top_builddir) -z
83
	-rm -rf $(CODE_COVERAGE_INFO) $(CODE_COVERAGE_HTML)
84 85 86
	-find . -name "*.gcda" -o -name "*.gcov" -delete
endif

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