#!/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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

%:
	dh $@ 

override_dh_clean:
	dh_testdir
	dh_auto_clean
	dh_clean
	rm -rf obj-* CMakeFiles CMakeCache.txt
	rm -rf tests-build kcov
	rm -f tests/python/second.pyc
	rm -f tests/python/unittest/unitundertest.pyc
	rm -rf debian/robotframework-2.8.7
	rm -f build

ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
override_dh_auto_test:
	dh_testdir
	cd debian ; tar xzf robotframework-2.8.7.tar.gz
	cd debian/robotframework-2.8.7 && python setup.py build
	mkdir tests-build
	cd tests-build ; cmake ../tests/
	$(MAKE) -C tests-build
	ln -s obj-* build
	# need to debug tests first
	#export PYTHONPATH=`echo $$PWD/debian/robotframework-2.8.7/build/lib.linux-*/`:$$PYTHONPATH ; \
	#	export PATH=`echo $$PWD/debian/robotframework-2.8.7/build/scripts-*/`:$$PATH ; \
	#	cd tests-build && \
	#	WORKSPACE=$$PWD/../ pybot --noncritical not_ready ../tests/robot-framework/kcov-tests.txt
endif
endif

