#!/usr/bin/make -f

export PYBUILD_NAME=bleak
export PYBUILD_TEST_PYTEST=1
export DH_ALWAYS_EXCLUDE=.gitignore
export PYBUILD_AFTER_INSTALL=rm -rf {destdir}/usr/lib/python3*/dist-packages/bleak/backends/p4android \
	                                {destdir}/usr/lib/python3*/dist-packages/bleak/backends/winrt

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_clean:
	dh_auto_clean
	rm -rf bleak.egg-info/ debian/bleak.1 docs/bleak.backends.* docs/bleak.rst; rm -f docs/modules.rst
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	make -C docs clean
endif

override_dh_installdocs:
	dh_installdocs --doc-main-package=python3-bleak -p python-bleak-doc
	dh_installdocs -p python3-bleak

execute_after_dh_auto_build:
	python3 $(CURDIR)/debian/build_manpage.py > debian/bleak.1
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	sphinx-apidoc -o docs/ bleak
	cd docs && LC_ALL=C.UTF-8 LANGUAGE=C.UTF-8 sphinx-build -b html -d _build/doctrees   . _build/html
endif
