#!/usr/bin/make -f
# -*- makefile -*-
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
#
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
	dh $@ 

override_dh_clean:
	dh_testdir
	dh_auto_clean
	dh_clean
	rm -rf obj-* CMakeFiles CMakeCache.txt
	rm -rf tests-build

ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
override_dh_auto_test:
	dh_testdir
	mkdir tests-build
	cd tests-build ; cmake ../tests/
	$(MAKE) -C tests-build
	ls
	cd tests-build ; export PATH=`echo $$PWD/../obj-*/src`:$$PATH ; \
		sh run-all.sh 2>&1 | tee tests.log
	rm -rf /tmp/kcov
	if grep -q FAIL tests-build/tests.log ; then \
		echo "Test suite failure" ; \
		exit 1 ; \
	fi
endif
endif

