#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export PYBUILD_NAME = pyro4

DOCDIR=$(CURDIR)/debian/pyro4-doc/usr/share/doc/pyro4-doc/
EXAMPLESDIR=$(CURDIR)/debian/pyro4-examples/usr/share/doc/pyro4/examples/

override_dh_auto_build:
	dh_auto_build
	cd $(CURDIR)/docs/ && $(MAKE) html

override_dh_installdocs:
	dh_installdocs
	find $(DOCDIR) -name \*.html -exec \
		sed -i 's|_static/jquery.js|/usr/share/javascript/jquery/jquery.js|' {} \;
	find $(DOCDIR) -name \*.html -exec \
		sed -i 's|_static/underscore.js|/usr/share/javascript/underscore/underscore.js|' {} \;
	rm -r $(DOCDIR)/html/_sources/
	rm $(DOCDIR)/html/_static/jquery.js
	rm $(DOCDIR)/html/_static/underscore.js

override_dh_fixperms:
	find $(EXAMPLESDIR) -type f -exec chmod a-x {} \;
	dh_fixperms

override_dh_installinit:
	dh_installinit -ppyro4 --name=pyro4-nsd --no-enable

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

.PHONY: override_dh_auto_build override_dh_installdocs \
	override_dh_fixperms override_dh_installinit
