#!/usr/bin/make -f

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

override_dh_installchangelogs:
	if [ -e $(CURDIR)/debian/CHANGELOG ] ; then \
		dh_installchangelogs $(CURDIR)/debian/CHANGELOG ; \
	else \
		dh_installchangelogs ; \
	fi

override_dh_clean:
	dh_clean
	rm -rf docs/build

override_dh_sphinxdoc:
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	sphinx-build -b man docs/source docs/build/man
	sed -i 's/.TH "WATCHDOG" "1"/.TH "WATCHDOG" "3"/g' docs/build/man/watchdog.1
	PYTHONPATH=. sphinx-build -b html docs/source $(CURDIR)/debian/python-watchdog/usr/share/doc/python-watchdog/html
	dh_sphinxdoc -O--buildsystem=python_distutils
endif
