#!/usr/bin/make -f

#export DH_VERBOSE=1

# For c/cpp elements within package.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export PYBUILD_NAME=pyregion

SPHINXOPTS := -D today="$(BUILD_DATE)" -D html_last_updated_fmt="$(BUILD_DATE)" -D html_show_copyright=0

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

override_dh_auto_install:
	sed -i "s#https.*modernizr\.#/usr/share/javascript/modernizr/modernizr\.#" build/html/*.html
	rm -rf build/html/plot_directive
	sed -i "s#_images#examples#g" build/html/examples.html
	rm -f build/html/_images/demo_region*
	sed -i "s#_images/\(region_draw\|demo\)#figures/\1#g" build/html/getting_started.html
	rm -f build/html/_images/region_draw*
	rm -f build/html/_images/demo_filter_mask.png
	dh_auto_install
	dh_numpy3

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=. sphinx-build $(SPHINXOPTS) -N -bhtml docs/ build/html

execute_after_dh_link-indep:
	jdupes -rl debian/python-pyregion-doc/usr
