#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk

BUILD_DATE=$(shell LC_ALL=C date -u "+%B %d, %Y" -d "@$(SOURCE_DATE_EPOCH)")

export DEB_VERSION_UPSTREAM  # used by patched docs/source/conf.py

export LC_ALL=C.UTF-8
export PYBUILD_INSTALL_DIR=/usr/share/alot/

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

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

override_dh_auto_test:

execute_after_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/
	cp NEWS debian/alot/usr/share/doc/alot/changelog

override_dh_compress:
	dh_compress -X.html -X.txt

execute_after_dh_auto_clean:
	rm -rf docs/build/
