#!/usr/bin/make -f

# DH_VERBOSE := 1
include /usr/share/dpkg/default.mk

TESTDIR        := debian/$(DEB_SOURCE)/usr/share/doc/$(DEB_SOURCE)/tests

%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_fixperms:
	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)))
	cd mapdamage && \
	PATH=$(PATH):$(CURDIR)/bin \
	PYTHONPATH=$(shell pybuild --print build_dir --interpreter python3) \
	python3 mp_test.py
endif

override_dh_python3:
	dh_python3 --no-ext-rename

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