NULL =

TEST_SUPPRESSIONS = $(top_builddir)/build/valgrind-suppressions

perform-memcheck: $(TEST_PROGS) $(TEST_SUPPRESSIONS)
	@make -C $(top_builddir)/build all
	@for test in $(TEST_PROGS); do \
		G_SLICE=always-malloc libtool --mode=execute \
			valgrind --trace-children=no --gen-suppressions=all \
			--suppressions=$(TEST_SUPPRESSIONS) \
			--leak-check=full --show-reachable=yes --num-callers=16 \
			--quiet --error-exitcode=33 \
			$(builddir)/$$test; \
	done

if WITH_COVERAGE
coverage:
	mkdir -p $(top_builddir)/build/coverage
	$(LCOV) --directory . --capture --output-file $(top_builddir)/build/coverage.info
	$(GENHTML) --output-directory $(top_builddir)/build/coverage $(top_builddir)/build/coverage.info
	$(LCOV) --directory . --zerocounters
	@echo "file://$(abs_top_builddir)/build/coverage/index.html"

clear-coverage:
	$(LCOV) --directory . --zerocounters

endif

V_SED = $(V_SED_$(V))
V_SED_ = $(V_SED_$(AM_DEFAULT_VERBOSITY))
V_SED_0 = @echo "  SED   " $@;

SED_SUBST = sed \
	-e 's,[@]datadir[@],$(datadir),g' \
	-e 's,[@]libexecdir[@],$(libexecdir),g' \
	-e 's,[@]libdir[@],$(libdir),g' \
	-e 's,[@]includedir[@],$(includedir),g' \
	-e 's,[@]datarootdir[@],$(datarootdir),g' \
	-e 's,[@]sysconfdir[@],$(sysconfdir),g' \
	-e 's,[@]bindir[@],$(bindir),g' \
	-e 's,[@]exec_prefix[@],$(exec_prefix),g' \
	-e 's,[@]prefix[@],$(prefix),g' \
	-e 's,[@]abs_srcdir[@],$(abs_srcdir),g' \
	-e 's,[@]srcdir[@],$(srcdir),g' \
	-e 's,[@]privatedir[@],$(privatedir),g' \
	-e 's,[@]PACKAGE[@],$(PACKAGE),g' \
	-e 's,[@]VERSION[@],$(VERSION),g' \
	$(NULL)

.desktop.in.in.desktop.in:
	$(V_SED) $(SED_SUBST) $< > $@

@INTLTOOL_DESKTOP_RULE@

.service.in.service:
	$(V_SED) $(SED_SUBST) $< > $@

.conf.in.conf:
	$(V_SED) $(SED_SUBST) $< > $@

SUFFIXES = .conf .conf.in .desktop.in .desktop.in.in .service .service.in