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

#export DH_VERBOSE=1

export DISABLE_NUMCODECS_SSE2=1
export DISABLE_NUMCODECS_AVX2=1

export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export PYBUILD_NAME=numcodecs
export DEFAULT_PYTHON=$(shell py3versions -d | cut -d n -f 2)

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

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

override_dh_auto_install:
	dh_auto_install
	$(RM) -r $(CURDIR)/debian/python3-numcodecs/usr/lib/python3*/dist-packages/fixture

override_dh_auto_clean:
	dh_auto_clean
	$(RM) numcodecs/version.py
	$(RM) -r numcodecs.egg-info/
	$(RM) numcodecs/*.c
	$(RM) -r $(shell find . -name __pycache__)
