#!/usr/bin/make -f
export DH_VERBOSE=1
export PYBUILD_NAME=djvu
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
ifneq (,$(filter nodoc,$(DEB_BUILD_PROFILES)))
	dh $@ --buildsystem=pybuild

else
	dh $@ --with sphinxdoc --buildsystem=pybuild
endif

override_dh_auto_test:
	PYBUILD_SYSTEM=custom \
	PYBUILD_TEST_ARGS="unset LANGUAGE; cd {dir}/tests; ln -sf {build_dir}/djvu djvu; {interpreter} -m nose --verbose --no-skip; rm djvu" \
	dh_auto_test

override_dh_install:
	rm -r debian/python*-djvu/usr/lib/python*/dist-packages/djvu/dllpath.py

override_dh_installdocs:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	python3 setup.py build_ext -i
	http_proxy='127.0.0.1:9' python3 setup.py build_sphinx
endif
	dh_installdocs -Xobjects.inv -A doc/credits

override_dh_strip:
ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
	dh_strip -ppython3-djvu
endif
