#!/usr/bin/make -f

LAST_CHANGE=$(shell dpkg-parsechangelog -S Date)
BUILD_DATE=$(shell LC_ALL=C date -u "+%B %d, %Y" -d "$(LAST_CHANGE)")

export PYBUILD_INSTALL_ARGS=--install-lib=/usr/share/alot/

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

override_dh_auto_build:
	dh_auto_build
	rm -rf $(CURDIR)/docs/build
	$(MAKE) -C docs html man SPHINXOPTS="-D today=\"$(BUILD_DATE)\""

override_dh_install:
	dh_install
	mv debian/alot/usr/bin/alot debian/alot/usr/share/alot/alot.bin
	dh_link -palot /usr/share/alot/alot.bin /usr/bin/alot
	# install the NEWS file as a changelog
	mkdir -p debian/alot/usr/share/doc/alot/ debian/alot-doc/usr/share/doc/alot-doc/
	cp NEWS debian/alot/usr/share/doc/alot/changelog
	cp NEWS debian/alot-doc/usr/share/doc/alot-doc/changelog

override_dh_compress:
	dh_compress -X.html -X.txt

override_dh_auto_clean:
	dh_auto_clean
	rm -rf docs/build/
