#!/usr/bin/make -f

export PYBUILD_NAME=powerline

include /usr/share/dpkg/default.mk

%:
	dh $@ --with python2,sphinxdoc --buildsystem=pybuild

# Build sphinx HTML documentation
override_dh_installdocs:
	PYTHONPATH=. sphinx-build -b html -N docs/source docs/build/html
	dh_installdocs -ppython-powerline-doc docs/build/html
	dh_installdocs -A

# Build manpages
override_dh_installman:
	help2man \
		--name "Powerline prompt and statusline script." \
		--section 1 \
		--source=Debian \
		--no-info \
		--help-option="-h" \
		--version-string="$(DEB_VERSION_UPSTREAM)" \
		--output powerline.1 \
		./scripts/powerline
	PYTHONPATH=. help2man \
		--name "Powerline configuration checker." \
		--section 1 \
		--source=Debian \
		--no-info \
		--help-option="-h" \
		--version-string="$(DEB_VERSION_UPSTREAM)" \
		--output powerline-lint.1 \
		./scripts/powerline-lint
	dh_installman

# Remove scripts from library package
override_dh_install:
	dh_install
	rm -rf debian/python-powerline/usr/bin

# Remove files generated during build
override_dh_auto_clean:
	dh_auto_clean
	find . -name "*.pyc" -delete
	rm -rf build docs/build .pybuild Powerline.egg-info
