#!/usr/bin/make -f

export DH_VERBOSE=1

export PYBUILD_NAME=nacl
export PYBUILD_TEST_PYTEST=1
export PYBUILD_TEST_ARGS={dir}/tests/

export PY3DEFAULT=$(shell py3versions -d)

export PYTHONDONTWRITEBYTECODE=1

export DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow

# Make sure PyNaCl uses the system libsodium instead of trying to use the
# vendored copy
export SODIUM_INSTALL=system


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


override_dh_auto_clean:
	dh_auto_clean
	rm -rf src/nacl/_lib/__pycache__
	rm -rf $(CURDIR)/debian/hypothesis

override_dh_sphinxdoc:
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=debian/python3-nacl/usr/lib/$(PY3DEFAULT)/dist-packages http_proxy='127.0.0.1:9' python3 -m sphinx -N -bhtml docs debian/python-nacl-doc/usr/share/doc/python-nacl-doc/html
	dh_sphinxdoc
endif


override_dh_python3:
	dh_python3
	rm -rf debian/python3-nacl/usr/lib/python3.?
