#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export PYBUILD_AFTER_TEST=rm -rf {build_dir}/cdm6.sqlite {build_dir}/.pytest_cache

%:
	dh $@ --with sphinxdoc --buildsystem=pybuild

execute_before_dh_sphinxdoc:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=$(CURDIR) python3 -m sphinx -b html -d $(CURDIR)/docs/.build/.doctrees -N $(CURDIR)/docs $(CURDIR)/debian/python-pyomop-doc/usr/share/doc/python-pyomop-doc/html
endif

execute_after_dh_clean:
	rm -rf $(CURDIR)/docs/.build

execute_before_dh_installman:
	PYTHONPATH=$(CURDIR)/src help2man --no-discard-stderr -n 'OHSDI OMOP Common Data Model tools' $(CURDIR)/debian/tmp/usr/bin/pyomop >$(CURDIR)/pyomop.1
