#!/usr/bin/make -f

export PYBUILD_NAME=sqlite-utils
%:
	dh $@ --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build $@ --buildsystem=pybuild
	cd docs; make man; LC_ALL=C.UTF-8 LANGUAGE=C.UTF-8 sphinx-build -bhtml . _build/html

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(eval BUILD_DIR=$(shell pybuild --print '{build_dir}'))
	for dir in $(BUILD_DIR); do \
		mkdir $$dir/docs; \
		cp docs/*.rst $$dir/docs ; \
	done
	dh_auto_test
	for dir in $(BUILD_DIR); do \
		rm -r $$dir/docs ; \
	done
endif

override_dh_auto_clean:
	dh_auto_clean
	rm -rf sqlite_utils.egg-info docs/_build
