xref: /freebsd/contrib/libucl/Makefile.am (revision d9f0ce31900a48d1a2bfc1c8c86f79d1e831451a)
1ACLOCAL_AMFLAGS = -I m4
2EXTRA_DIST = uthash klib README.md
3
4pkgconfigdir = $(libdir)/pkgconfig
5pkgconfig_DATA = libucl.pc
6
7if LUA_SUB
8  LUA_SUBDIR = lua
9endif
10
11COVERAGE_INFO_FILE = $(top_builddir)/coverage.info
12COVERAGE_REPORT_DIR = $(top_builddir)/coverage
13
14.PHONY = coverage-requirement-check clean-coverage-report
15
16coverage-requirement-check:
17	@if test ! -e $(GCOV); then \
18		echo "Cannot find $(GCOV). Please install gcov."; \
19		exit 1; \
20	fi
21
22coverage: coverage-requirement-check clean-coverage coverage-build coverage-check coverage-report
23	@echo "Please execute 'make clean' before 'make' or 'make check' to remove instrumented object files(compiled with -O0 etc.). Note that 'make clean' also remove coverage data."
24
25coverage-build: coverage-requirement-check
26	@if test `find $(top_builddir) -name "*.gcno" | wc -l` -eq 0; then \
27		echo "Start to remove old non-instrumented object files..."; \
28		$(MAKE) $(AM_MAKEFLAGS) clean; \
29		echo "Successfully removed old non-instrumented object files."; \
30	fi
31	@echo "Start to build libraries with coverage options..."
32	$(MAKE) $(AM_MAKEFLAGS) \
33		CFLAGS="$(CFLAGS) $(COVERAGE_CFLAGS) $(COVERAGE_OPTFLAGS)" \
34		CXXFLAGS="$(CXXFLAGS) $(COVERAGE_CXXFLAGS) $(COVERAGE_OPTFLAGS)" \
35		LDFLAGS="$(LDFLAGS) $(COVERAGE_LDFLAGS)" \
36		LIBS="$(LIBS) $(COVERAGE_LIBS)"
37	@echo "Successfully built libraries with coverage options."
38
39coverage-check: coverage-requirement-check
40	@echo "Start to run tests with instrumented libraries..."
41	$(MAKE) $(AM_MAKEFLAGS) check \
42		CFLAGS="$(CFLAGS) $(COVERAGE_CFLAGS) $(COVERAGE_OPTFLAGS)" \
43		CXXFLAGS="$(CXXFLAGS) $(COVERAGE_CXXFLAGS) $(COVERAGE_OPTFLAGS)" \
44		LDFLAGS="$(LDFLAGS) $(COVERAGE_LDFLAGS)" \
45		LIBS="$(LIBS) $(COVERAGE_LIBS)"
46	@echo "Successfully run tests with instrumented libraries."
47
48coverage-lcov: coverage-check coverage-requirement-check
49	$(LCOV) --capture \
50		--directory "$(top_builddir)/" \
51		--output-file $(COVERAGE_INFO_FILE) \
52		--gcov-tool $(GCOV) \
53		--compat-libtool --checksum
54	$(LCOV) --extract $(COVERAGE_INFO_FILE) `pwd`/src/ucl_\* \
55		--output-file $(COVERAGE_INFO_FILE)
56
57coverage-report: coverage-lcov
58	@echo "Start to create coverage reports..."
59	$(GENHTML) --prefix "$(top_srcdir)" \
60		--output-directory $(COVERAGE_REPORT_DIR) \
61		--title $(PACKAGE_NAME) \
62		--legend --show-details \
63		$(GENHTML_OPTIONS) \
64		$(COVERAGE_INFO_FILE)
65	@echo "Successfully created coverage reports into $(COVERAGE_REPORT_DIR) directory."
66
67clean-coverage-report:
68	-rm -rf $(COVERAGE_INFO_FILE)
69	-rm -rf $(COVERAGE_REPORT_DIR)
70
71clean-coverage: clean-coverage-report
72	-$(LCOV) --gcov-tool $(GCOV) --zerocounters --directory $(top_builddir)
73	@if xargs --version 2>/dev/null; then \
74		find $(top_builddir) -name "*.gcno" | xargs --no-run-if-empty rm; \
75	else \
76		find $(top_builddir) -name "*.gcno" | xargs rm; \
77	fi
78
79clean-local: clean-coverage
80
81SUBDIRS = src tests utils doc $(LUA_SUBDIR)
82