#!/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
export DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow
export DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
# Force C++ library build to use Debian zlib1g-dev/libbz2-dev
export USE_SYSTEM_ZLIB=true
export USE_SYSTEM_LIBBZ2=true

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

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

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 src/oxli && $(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}; export PYTHONPATH=$$(pwd); {interpreter} -m pytest \
	    -m 'not known_failing and not jenkins and not huge'" dh_auto_test


override_dh_auto_clean:
	dh_auto_clean || /bin/true
	cd src/oxli && $(MAKE) clean
	rm -rf __pycache__ .eggs

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

override_dh_sphinxdoc:
	dh_sphinxdoc -X jquery.js

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