#!/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)")
SPHINXOPTS := -D html_last_updated_fmt="$(BUILD_DATE)"

include /usr/share/openstack-pkg-tools/pkgos.make

export RES_OPTIONS=attempts:0

%:
	dh $@ --buildsystem=python_distutils --with python3,sphinxdoc

override_dh_auto_clean:
	rm -rf .testrepository

override_dh_auto_build:
	echo "Do nothing..."

override_dh_auto_test:
	echo "Do nothing..."

override_dh_auto_install:
	pkgos-dh_auto_install --no-py2 --in-tmp

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	pkgos-dh_auto_test --no-py2
	# 'keystoneclient\.tests\.(?!.*memcache_set_expired.*|.*test_encrypt_cache_data.*|.*test_sign_cache_data.*)'
endif

override_dh_clean:
	dh_clean

override_dh_sphinxdoc:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=. python3 -m sphinx -b html doc/source $(CURDIR)/debian/python-keystoneclient-doc/usr/share/doc/python-keystoneclient-doc/html
	dh_sphinxdoc -O--buildsystem=python_distutils
endif

override_dh_python3:
	dh_python3 --shebang=/usr/bin/python3
