#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1


# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

include /usr/share/dpkg/pkg-info.mk

%:
	dh $@ --with sphinxdoc

override_dh_install:
	dh_install
	sed -i 's:/bin/tcsh:/usr/bin/tcsh:g' bin/*
	mv bin/starch bin/bedops-starch
	cp bin/* debian/bedops/usr/bin/

override_dh_installdocs:
	cd docs && make html
	cp -r docs/_build/html debian/bedops/usr/share/doc/bedops/
	find debian/bedops/usr/share/doc/bedops/html/content/usage-examples -type f | xargs sed -i 's;https://cdn.mathjax.org/mathjax/latest/MathJax.js;../../_static/mathjax.js;g'
	find debian/bedops/usr/share/doc/bedops/html/content -type f | xargs sed -i 's;https://cdn.mathjax.org/mathjax/latest/MathJax.js;../_static/mathjax.js;g'
	find debian/bedops/usr/share/doc/bedops/html -type f | xargs sed -i 's;https://cdn.mathjax.org/mathjax/latest/MathJax.js;_static/mathjax.js;g'
	ln -s /usr/share/javascript/mathjax/MathJax.js  debian/bedops/usr/share/doc/bedops/html/_static/mathjax.js
	dh_installdocs

override_dh_installman:
	cd bin && for f in * ; do help2man --no-discard-stderr --version-string="$(DEB_VERSION_UPSTREAM)" -o $$f.1 ./$$f; done
	dh_installman



