#!/usr/bin/make -f
export DH_VERBOSE=1

export PYBUILD_NAME=plip
%:
	dh $@ --with python3 --buildsystem=pybuild

include /usr/share/dpkg/pkg-info.mk

mandir := $(CURDIR)/debian/$(PYBUILD_NAME)/usr/share/man/man1
HELP2MAN := help2man --no-info --no-discard-stderr --version-string="$(DEB_VERSION)"
PYTHON_DEFAULT_VERSION := $(shell py3versions -d)

override_dh_auto_install:
	dh_auto_install
	rm -rvf $(CURDIR)/debian/$(PYBUILD_NAME)/usr/bin/plip
	mv $(CURDIR)/debian/$(PYBUILD_NAME)/usr/bin/plipcmd.py \
           $(CURDIR)/debian/$(PYBUILD_NAME)/usr/bin/plipcmd
	mkdir -p $(mandir)
	export PYTHONPATH=$(CURDIR)/debian/$(PYBUILD_NAME)/usr/lib/$(PYTHON_DEFAULT_VERSION)/dist-packages/:\
	$(CURDIR)/plip/modules; \
    $(HELP2MAN)  --name='Protein-Ligand Interaction Profiler (PLIP)' \
    $(CURDIR)/debian/$(PYBUILD_NAME)/usr/bin/plipcmd > $(mandir)/plipcmd.1

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# skip all other tests since they require exluded pdb files
	export PYTHONPATH=$(CURDIR)/.pybuild/cpython3_$(shell py3versions -dv)_plip/build/; \
	debian/tests/xml-parser
endif
