#!/usr/bin/make -f

# export DH_VERBOSE = 1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# Use pytest, pointing it to the right test file.
export PYBUILD_TEST_PYTEST = 1
export PYBUILD_NAME = jellyfish
export PYBUILD_BEFORE_TEST = cp -R {dir}/testdata {build_dir}
export PYBUILD_AFTER_TEST = rm -R {build_dir}/testdata
export PYBUILD_TEST_ARGS = jellyfish/test.py

%:
	dh $@ --buildsystem=pybuild

ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
override_dh_auto_build-indep:
	dh_auto_build
	mkdocs build
	# Clean generated HTML files to avoid some privacy breaches
	# We cannot currently remove the Google fonts reference as
	# Roboto Mono is not suitably packaged in Debian.
	perl -i -ne '/<img .*src="http/ || print' site/index.html

override_dh_installdocs-indep:
	dh_installdocs -ppython-jellyfish-doc --doc-main-package=python3-jellyfish
	dh_installdocs --remaining-packages
	mv debian/python-jellyfish-doc/usr/share/doc/python3-jellyfish/site debian/python-jellyfish-doc/usr/share/doc/python3-jellyfish/html
endif

override_dh_installchangelogs:
	dh_installchangelogs docs/changelog.md

execute_after_dh_auto_clean:
	rm -rf site
