summaryrefslogtreecommitdiffstats
path: root/Makefile.am
blob: 18b34e7eb4e03f04835ad6bca2fa2b393ca82d7b (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
ACLOCAL_AMFLAGS = -I m4macros ${ACLOCAL_FLAGS}
# ^^^^^^^^ This has to be the first line and cannot come later in this
# Makefile.am due to some bork in some versions of autotools.

SUBDIRS = tools . ext src doc m4macros @PREMIUM_DIR@ @CONTRIB_DIR@

USE_LCOV=@USE_LCOV@
LCOV=@LCOV@
GENHTML=@GENHTML@
DISTCHECK_GTEST_CONFIGURE_FLAG=@DISTCHECK_GTEST_CONFIGURE_FLAG@
DISTCHECK_CRYPTO_CONFIGURE_FLAG=@DISTCHECK_CRYPTO_CONFIGURE_FLAG@
DISTCHECK_BOOST_CONFIGURE_FLAG=@DISTCHECK_BOOST_CONFIGURE_FLAG@
DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG=@DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG@
DISTCHECK_PERFDHCP_CONFIGURE_FLAG=@DISTCHECK_PERFDHCP_CONFIGURE_FLAG@
DISTCHECK_KEA_SHELL_CONFIGURE_FLAG=@DISTCHECK_KEA_SHELL_CONFIGURE_FLAG@
DISTCHECK_PREMIUM_CONFIGURE_FLAG=@DISTCHECK_PREMIUM_CONFIGURE_FLAG@
DISTCHECK_CONTRIB_CONFIGURE_FLAG=@DISTCHECK_CONTRIB_CONFIGURE_FLAG@
DISTCHECK_MYSQL_CONFIGURE_FLAG=@DISTCHECK_MYSQL_CONFIGURE_FLAG@
DISTCHECK_PGSQL_CONFIGURE_FLAG=@DISTCHECK_PGSQL_CONFIGURE_FLAG@
DISTCHECK_GSSAPI_CONFIGURE_FLAG=@DISTCHECK_GSSAPI_CONFIGURE_FLAG@
DISTCHECK_LIBYANG_CONFIGURE_FLAG=@DISTCHECK_LIBYANG_CONFIGURE_FLAG@
DISTCHECK_SYSREPO_CONFIGURE_FLAG=@DISTCHECK_SYSREPO_CONFIGURE_FLAG@

OVERALL_COVERAGE_DIR=$(abs_top_builddir)/coverage-cpp-html

DISTCLEANFILES = config.report

# When running distcheck target, do not install the configurations
DISTCHECK_CONFIGURE_FLAGS = --disable-install-configurations

# Use same --with-gtest flag if set
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_GTEST_CONFIGURE_FLAG)

# Keep the crypto backend config
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_CRYPTO_CONFIGURE_FLAG)

# Keep the Boost configuration which becomes sensible
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_BOOST_CONFIGURE_FLAG)

# Keep the log4cplus path too
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG)

# Keep perfdhcp if enabled
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_PERFDHCP_CONFIGURE_FLAG)

# Keep kea-shell if enabled
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_KEA_SHELL_CONFIGURE_FLAG)

# Keep the premium config
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_PREMIUM_CONFIGURE_FLAG)

# Keep the contrib config
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_CONTRIB_CONFIGURE_FLAG)

# Keep the mysql config
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_MYSQL_CONFIGURE_FLAG)

# Keep the pgsql config
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_PGSQL_CONFIGURE_FLAG)

# Keep the gssapi config
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_GSSAPI_CONFIGURE_FLAG)

# Keep the libyang config
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_LIBYANG_CONFIGURE_FLAG)

# Keep the sysrepo config
DISTCHECK_CONFIGURE_FLAGS += $(DISTCHECK_SYSREPO_CONFIGURE_FLAG)

dist_doc_DATA = AUTHORS COPYING ChangeLog README CONTRIBUTING.md platforms.rst code_of_conduct.md

.PHONY: check-valgrind check-valgrind-suppress

check-valgrind:
if HAVE_VALGRIND
	@VALGRIND_COMMAND="$(VALGRIND) -q --gen-suppressions=all --track-origins=yes --num-callers=48 --leak-check=full --fullpath-after=" \
	make -C $(abs_top_builddir) check
else
	@echo "*** Valgrind is required for check-valgrind ***"; exit 1;
endif

check-valgrind-suppress:
if HAVE_VALGRIND
	@VALGRIND_COMMAND="$(VALGRIND) -q --gen-suppressions=all --track-origins=yes --error-exitcode=1 --suppressions=$(abs_top_srcdir)/src/valgrind-suppressions --suppressions=$(abs_top_srcdir)/src/valgrind-suppressions.revisit --num-callers=48 --leak-check=full --fullpath-after=" \
	make -C $(abs_top_builddir) check
else
	@echo "*** Valgrind is required for check-valgrind-suppress ***"; exit 1;
endif

clean-cpp-coverage:
	@if [ $(USE_LCOV) = yes ] ; then \
		$(LCOV) --directory . --zerocounters; \
		rm -rf $(OVERALL_COVERAGE_DIR); \
	else \
		echo "C++ code coverage not enabled at configuration time." ; \
		echo "Use: ./configure --with-lcov" ; \
	fi

perform-coverage:
	find src -mindepth 2 -maxdepth 2 -type d | xargs -I{} bash -c "cd {}; make check || true"

report-cpp-coverage:
if HAVE_BOTAN
BOTAN_PATH=botan/\*
else
BOTAN_PATH=
endif
if HAVE_OPENSSL
OPENSSL_PATH=openssl/\*
else
OPENSSL_PATH=
endif
	@if [ $(USE_LCOV) = yes ] ; then \
		$(LCOV) --capture --directory . \
			--ignore-errors gcov,source,graph \
			--output-file all.info; \
		$(LCOV) --remove all.info \
			c++/* \
			boost/\* \
if HAVE_BOTAN
			botan/\* \
endif
			ext/coroutine/\* \
			gtest/\* \
			include/\* \
			lib/\eval/\* \
			log4cplus/\* \
			unittests/\* \
			tests/\* \
			testutils/\* \
			valgrind/\* \
			$(BOTAN_PATH) \
			$(OPENSSL_PATH) \
			--ignore-errors gcov,source,graph \
			--output report.info; \
		sed --in-place --expression "s|$(abs_top_srcdir)|$(abs_top_builddir)|g" report.info; \
		"$(GENHTML)" \
		--frames --show-details --title 'Kea code coverage report' --legend \
		--function-coverage --ignore-errors source --demangle-cpp \
		--output "$(OVERALL_COVERAGE_DIR)" report.info; \
		printf "Generated C++ code coverage report in HTML at %s.\n" "$(OVERALL_COVERAGE_DIR)"; \
	else \
		echo "C++ code coverage not enabled at configuration time." ; \
		echo "Use: ./configure --with-lcov" ; \
	fi

# for c++ test coverage
.NOTPARALLEL: coverage

coverage: clean-coverage perform-coverage report-coverage

clean-coverage: clean-cpp-coverage

report-coverage: report-cpp-coverage

# for static C++ check using cppcheck (when available)
cppcheck:
	cppcheck -I./src/lib -I./src/bin --enable=all \
		--suppressions-list=src/cppcheck-suppress.lst --inline-suppr \
		--quiet --error-exitcode=1 \
		--template '{file}:{line}: check_fail: {message} ({severity},{id})' \
		src

# this is a shortcut that builds only documentation dependencies and documentation itself
docs:
	$(MAKE) -C doc/sphinx


# These steps are necessary during installation
install-exec-hook:
	mkdir -p $(DESTDIR)${localstatedir}/log/
	mkdir -p $(DESTDIR)${localstatedir}/lib/${PACKAGE_NAME}
	mkdir -p $(DESTDIR)${runstatedir}/${PACKAGE_NAME}

EXTRA_DIST  = tools/path_replacer.sh
EXTRA_DIST += tools/mk_cfgrpt.sh

#### include external sources in the distributed tarball:
EXTRA_DIST += ext/coroutine/coroutine.hpp

CLEANFILES = $(abs_top_builddir)/logger_lockfile

# config.h may be included by headers supplied for building user-written
# hooks libraries, so we need to include it in the distribution.
pkginclude_HEADERS = config.h kea_version.h