#!/usr/bin/make -f

export PYBUILD_NAME=pyerfa
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export PYERFA_USE_SYSTEM_LIBERFA=1

DEFAULT_PYVER=$(shell python3 -c "import sys;print('{}.{}'.format(*sys.version_info[:2]))")

include /usr/share/dpkg/pkg-info.mk
export SETUPTOOLS_SCM_PRETEND_VERSION=$(DEB_VERSION_UPSTREAM:+ds=)

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

override_dh_auto_build: export http_proxy=127.0.0.1:9
override_dh_auto_build: export https_proxy=127.0.0.1:9
override_dh_auto_build:
	dh_auto_build
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	cd docs && \
	PYTHONPATH=$(CURDIR)/.pybuild/cpython3_$(DEFAULT_PYVER)_pyerfa/build \
	python3 -m sphinx -N -bhtml $(CURDIR)/docs $(CURDIR)/build/html
endif

override_dh_python3:
	dh_python3
	dh_numpy3 -ppython3-erfa

override_dh_auto_clean:
	# dh_auto_clean
	$(RM) -r build .pybuild
	$(RM) -r .pytest_cache  *.egg-info docs/api
