#!/usr/bin/make -f

DH_ARGS ?=
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	DH_ARGS += --with sphinxdoc
endif

PYTHON_VERSION := $(shell python3 -c 'import sys; print("%s.%s" % sys.version_info[:2])')

%:
	dh $@ --buildsystem=pybuild --with python3 $(DH_ARGS)

override_dh_auto_clean:
	rm -rf doc/_build
	rm -f doc/dh_virtualenv.1
	rm -rf dh_virtualenv.egg-info
	dh_auto_clean

override_dh_auto_build:
	rst2man doc/dh_virtualenv.1.rst >doc/dh_virtualenv.1
	dh_auto_build

override_dh_gencontrol:
	dh_gencontrol -- -Vpyversion=$(PYTHON_VERSION)

ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
override_dh_installdocs:
	python3 setup.py build_sphinx
	dh_installdocs doc/_build/html
endif
