#!/usr/bin/make -f
# -*- makefile -*-

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

include /usr/share/dpkg/pkg-info.mk

export DISABLE_NUMCODECS_SSE2=1
export DISABLE_NUMCODECS_AVX2=1

export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export PYBUILD_NAME=numcodecs

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

override_dh_auto_configure:
	echo "version = '$(DEB_VERSION_UPSTREAM)'" > numcodecs/version.py
	dh_auto_configure

override_dh_auto_build:
	dh_auto_build
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	cd docs && \
	PYTHONPATH=$(CURDIR) http_proxy='http://127.0.0.1:9/' https_proxy='https://127.0.0.1:9/' \
	sphinx-build -N -E -T -b html . $(CURDIR)/.pybuild/docs/html/
	rm -rf $(CURDIR)/.pybuild/docs/html/.doctrees
endif

override_dh_auto_clean:
	# does not work due to missing setuptools-scm
	# dh_auto_clean
	$(RM) numcodecs/version.py
	$(RM) -r .pytest_cache .pybuild build
	$(RM) -r numcodecs.egg-info/
	$(RM) numcodecs/*.c
	$(RM) -r $(shell find . -name __pycache__)
