#!/usr/bin/make -f

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

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

override_dh_auto_clean:
	rm -f debian/*.init debian/*.service debian/*.upstart
	rm -rf build
	rm -rf adjutant.sqlite
	rm -f debian/adjutant-api.postinst debian/adjutant-api.config

override_dh_auto_build:
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func adjutant-api.postinst
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func adjutant-api.config
	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func adjutant-common.postinst
	pkgos-merge-templates adjutant-api adjutant endpoint

override_dh_auto_test:
	echo "Do nothing..."

override_dh_auto_install:
	echo "Do nothing..."

override_dh_install:
	for i in $(PYTHON3S) ; do \
		python$$i setup.py install --root=debian/tmp --install-layout=deb ; \
	done

	install -D $(CURDIR)/adjutant/wsgi.py $(CURDIR)/debian/tmp/usr/bin/adjutant-wsgi-api

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	echo "Currently no test to run..."
#	pkgos-dh_auto_test --no-py2 'adjutant\.tests\.*'
endif

	dh_install
	dh_missing --fail-missing

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

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