#! /usr/bin/make -f

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

execute_after_dh_auto_build-indep:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	cd docs && \
	PYTHONPATH=$(CURDIR) http_proxy='http://127.0.0.1:9/' https_proxy='https://127.0.0.1:9/' \
	sphinx-build -N -E -T -b html . $(CURDIR)/.pybuild/docs/html/
	rm -rf $(CURDIR)/.pybuild/docs/html/.doctrees
endif

override_dh_installexamples:
	dh_installexamples -X.gitignore
	# Remove execute permission from VHDL files and Makefiles:
	find debian/python3-pyuvm/usr/share/doc/python3-pyuvm/examples/ -name "*.vhd" -exec chmod -x {} \;
	find debian/python3-pyuvm/usr/share/doc/python3-pyuvm/examples/ -name Makefile -exec chmod -x {} \;
	# Remove include ../../checkclean.mk from examples' Makefiles, as
	# checkclean.mk isn't installed with examples:
	sed -e '/checkclean\.mk/d' -i debian/python3-pyuvm/usr/share/doc/python3-pyuvm/examples/*/Makefile
