#!/usr/bin/make -f
include /usr/share/dpkg/default.mk
TESTDIR := debian/$(DEB_SOURCE)/usr/share/doc/$(DEB_SOURCE)/tests
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_fixperms:
	find debian -name checkLibraries.R -exec chmod +x \{\} \;
	find debian -name runGeneral.R     -exec chmod +x \{\} \;

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	set -e \
	; for py3 in $(shell py3versions -vs) \
	; do cd mapdamage \
	;    PATH=$(PATH):$(CURDIR)/.pybuild/cpython3_$${py3}/scripts \
	     PYTHONPATH=$(shell pybuild --print build_dir --interpreter python3) \
	     python3 mp_test.py \
	; done
endif

override_dh_python3:
	dh_python3 --no-ext-rename

execute_after_dh_auto_clean:
	rm -f mapdamage/_version.py
	rm -f mapdamage/tests/results/Fragmisincorporation_plot.pdf
	rm -f mapdamage/tests/results/Length_plot.pdf
	rm -f mapdamage/tests/fake1.fasta.fai
	rm -f mapdamage/tests/results/3pGtoA_freq.txt
	rm -f mapdamage/tests/results/5pCtoT_freq.txt
	rm -f mapdamage/tests/results/Runtime_log.txt
	rm -f mapdamage/tests/results/dnacomp.txt
	rm -f mapdamage/tests/results/lgdistribution.txt
	rm -f mapdamage/tests/results/misincorporation.txt
	rm -f mapdamage/tests/test.rescaled.sam
