#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow
export PYBUILD_NAME = ppl

%:
	dh $@ --with autoreconf --with python3,sphinxdoc  --buildsystem=pybuild

override_dh_auto_build: export http_proxy=127.0.0.1:9
override_dh_auto_build: export https_proxy=127.0.0.1:9
override_dh_auto_build:
	dh_auto_build
	cd docs && export PYTHONPATH=$(CURDIR)/.pybuild/cpython3_$(shell py3versions -dv)_ppl/build && $(MAKE) html

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS) $(DEB_BUILD_PROFILES)))
override_dh_auto_test:
	export PYTHONPATH=$(CURDIR)/.pybuild/cpython3_$(shell py3versions -dv)_ppl/build && python3 tests/runtests.py
	export PYTHONPATH=$(CURDIR)/.pybuild/cpython3_$(shell py3versions -dv)_ppl/build && cd tests && python3 setup.py build_ext --inplace
	export PYTHONPATH=$(CURDIR)/.pybuild/cpython3_$(shell py3versions -dv)_ppl/build && cd tests && python3 setup2.py build_ext --inplace
	export PYTHONPATH=$(CURDIR)/.pybuild/cpython3_$(shell py3versions -dv)_ppl/build && cd tests && python3 -c "import testpplpy; testpplpy.test(); testpplpy.example(); import testpplpy2; testpplpy2.test(); testpplpy2.example()"
else
override_dh_auto_test:
	@echo '*********************************************************'
	@echo '               Skip test suite                           '
	@echo '*********************************************************'
endif

override_dh_auto_clean:
	rm -f ppl/*.cpp ppl/*.so
	rm -rf docs/build
	rm -f tests/*.cpp tests/*.so
	rm -rf tests/build
	dh_auto_clean

override_dh_installdocs:
	dh_installdocs --doc-main-package python3-ppl -ppython-ppl-doc
	dh_installdocs -ppython3-ppl debian/copyright
