#! /usr/bin/make -f

ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
export DH_VERBOSE = 1
export PYBUILD_VERBOSE=1
else
export DH_QUIET = 1
endif

export PYBUILD_DESTDIR_python2=debian/python-pytools/
export PYBUILD_DESTDIR_python3=debian/python3-pytools/

BUILD_DATE=$(shell LC_ALL=C date -u "+%B %d, %Y" -d "@$(SOURCE_DATE_EPOCH)")
SPHINXOPTS:=-D today=\"$(BUILD_DATE)\"
SPHINXOPTS+=-D html_last_updated_fmt=\"$(BUILD_DATE)\"

%:
	dh $@ --with python3,sphinxdoc --buildsystem pybuild

override_dh_auto_build:
	find pytools/ -name decorator.py -delete
	find pytools/ -name log.py -delete
	dh_auto_build

override_dh_installdocs:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	$(MAKE) -C doc html SPHINXOPTS="$(SPHINXOPTS)"
	dh_installdocs
endif

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	dh_auto_test --buildsystem pybuild -- --test-pytest
endif

