#!/usr/bin/make -f
export DH_VERBOSE=1
export PYBUILD_NAME=khmer
export PYBUILD_INSTALL_ARGS='--install-scripts=/usr/lib/khmer/bin'
export PYBUILD_DESTDIR_python3=debian/khmer

# Force C++ library build to use Debian zlib1g-dev/libbz2-dev
export USE_SYSTEM_ZLIB=true
export USE_SYSTEM_LIBBZ2=true

export PACKAGE_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')

export HOME=$(shell echo $$PWD"/fakehome")

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

override_dh_auto_build:
	dh_auto_build
	ln -sf "`pwd`"/.pybuild/pythonX.Y_*/build/khmer/*.so khmer && \
		./setup.py develop --user && ./setup.py build_sphinx
	asciidoctor --backend manpage -a reproducible debian/khmer.1.adoc
	cd lib && $(MAKE) clean all

override_dh_auto_test:
	dh_auto_install
	PYBUILD_SYSTEM=custom \
	    PYBUILD_TEST_ARGS="cd {dir}; export PATH={destdir}/usr/lib/khmer/bin:$$PATH ; \
	    cd {build_dir}; {interpreter} -m nose --attr \
	    '!known_failing,!jenkins,!huge'" dh_auto_test


override_dh_auto_clean:
	#dh_auto_clean
	rm -f khmer/*.so
	rm -f debian/*.1
	cd lib && $(MAKE) clean
	rm -Rf fakehome

override_dh_install:
	cd lib && $(MAKE) PREFIX=../debian/tmp install
	dh_install
	find debian/khmer -name .gitignore -delete

get-orig-source:
	uscan --verbose --force-download --repack --compression xz
