#!/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:
# Exclude test_decode in s390x
ifeq ($(DEB_HOST_ARCH), s390x)
	PYBUILD_SYSTEM=custom \
	PYBUILD_TEST_ARGS="unset LANGUAGE; cd {dir}/tests; ln -sf {build_dir}/djvu djvu; {interpreter} -m pytest --verbose -k 'not test_decode and not test_export_ps'; rm djvu" \
	dh_auto_test
else
	PYBUILD_SYSTEM=custom \
	PYBUILD_TEST_ARGS="unset LANGUAGE; cd {dir}/tests; ln -sf {build_dir}/djvu djvu; {interpreter} -m pytest --verbose -k 'not test_export_ps'; rm djvu" \
	dh_auto_test
endif

override_dh_installdocs:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	python3 setup.py build_ext -i
	http_proxy='127.0.0.1:9' sphinx-build -b html doc/api build/sphinx/html
endif
	dh_installdocs -Xobjects.inv

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