#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1

export PYBUILD_NAME=rocm-docs
# Skip Online test
export PYBUILD_TEST_ARGS=--ignore tests/test_projects.py
URL=https://salsa.debian.org/rocm-team
# Indeed tests are done, but building the exemple doc is not yet working
# The module theme probably don't work yet, but should allow to decrease
# needed patch in many rocm packages
# ITP on missing dependancies going on (see README.source)
# true or false
WITHDOC=--with sphinxdoc
# Not building doc that is an exemple doc
# Requiring itself to build see comment below
WITHDOC=

export DOC_DIR=src/rocm_docs

%:
	dh $@ $(WITHDOC) --buildsystem=pybuild

# To rebuild the Sphinx documentation when it will be possible
#execute_after_dh_auto_build-indep: export http_proxy=127.0.0.1:9
#execute_after_dh_auto_build-indep: export https_proxy=127.0.0.1:9
#execute_after_dh_auto_build-indep:
		# Can't probably work when then package is not yet installed,
		# cirular dependancy, template extension, not yet available,... 
		# See Debian.source
		# Some dependancy are missing but provided test are integrated
		#PYTHONPATH=.:..:../build/lib:./build/lib:../src:./src ; cd docs ; python3 -m sphinx \
		#   -T -E -b html -d ../_build/doctrees \
		#   -D language=en \
		#   -D external_toc_path="../debian/_toc.yml" \
		#   . ../_build/html

override_dh_install:
	dh_install
	# Fix font files permissions
	find . -name '*.woff*' -exec chmod ugo-x {} \;
	# Remove vcs-control-file gitignore
	find . -name '*.gitignore*' -exec rm -f {} \;

override_dh_installexamples:
	dh_installexamples
	# Fix vectorial images permissions
	find . -name '*.svg*' -exec chmod ugo-x {} \;

	

override_dh_clean:
	dh_clean
	# Remove various possibly generated doc to allow easy local rebuild (debuild) \
	# See README.source for more info
	-rm -rf docs/_doxygen/ docs/demo/doxygen/html/ docs/_build/ \
		docs/demo/doxygen/xml/ .pybuild/ _build/ src/rocm_docs/_doxygen
	-rm -f docs/sphinx/_toc.yml



