#!/usr/bin/make -f

export PYBUILD_NAME=cassandra

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# In case there's something wrong during cython generation, you may want to enable this
#export CASS_DRIVER_NO_CYTHON=1

# Enable parallel build
export CASS_DRIVER_BUILD_CONCURRENCY=$(shell nproc)

export PYBUILD_TEST_NOSE=1
# For some reasons evenlet.monkey_patch is not available in dbg version of the package
# Careful: Nose --ignore-files is basically not working correctly, adding folders before the file
# never worked, no matter how many .* I used...
export PYBUILD_TEST_ARGS_python3-dbg=$(PYBUILD_TEST_ARGS) --ignore-files="test_eventletreactor\.py"

%:
ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),)
	dh $@ --with python3,sphinxdoc --buildsystem=pybuild
else
	dh $@ --with python3 --buildsystem=pybuild
endif

override_dh_auto_clean:
	dh_auto_clean
	rm -rf build/ cassandra_driver.egg-info/
	# Do not delete cmurmur3.c because we don't have proper Python extension
	# so it cannot be regenerated with cython
	find cassandra -maxdepth 1 -type f -name '*.c' ! -name 'cmurmur3.c' -delete

override_dh_auto_build:
	dh_auto_build
ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),)
	PYTHONPATH=. http_proxy='127.0.0.1:9' sphinx-build -N -bhtml docs/ build/html
endif

override_dh_auto_test:
ifeq ($(filter nocheck,$(DEB_BUILD_PROFILES)),)
	dh_auto_test
endif

override_dh_auto_install:
	dh_auto_install
	rm -rf debian/python*-dbg/usr/lib/python*/dist-packages/cassandra/numpyFlags.h
