#!/usr/bin/make -f

export USE_TRILINOS=1
export ZOLTAN_INCLUDE=/usr/include/trilinos
export ZOLTAN_LIBRARY=/usr/lib
export NPROCS=2
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export PYBUILD_TEST_ARGS=-k 'not test_sph_evaluator and not TestInterpolator'

%:
	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)))
	env PYTHONPATH=$(shell pybuild --build -i python3 -s custom --build-args 'echo {build_dir}') \
	python3 -m sphinx -M html $(CURDIR)/docs/source $(CURDIR)/docs/build -N
	find $(CURDIR)/docs/build/html -type f -print0 | xargs --no-run-if-empty -0 sed -i 's/https:\/\/www.youtube.com//g'
endif

override_dh_python3:
	dh_python3 -N pysph-doc
	dh_numpy3 -N pysph-doc

override_dh_auto_clean:
	dh_auto_clean
	$(MAKE) clean
	$(MAKE) -C docs clean
	$(RM) -r PySPH.egg-info
	$(RM) pysph/base/gpu_helper_functions
	$(RM) pysph/base/stratified_sfc_gpu_nnps
	$(RM) pysph/base/z_order_gpu_nnps
	$(RM) pysph/tools/geometry_stl.cpp
	find . -name '*.pyc' -delete
	$(RM) -r .pytest_cache