#!/usr/bin/make -f

#export DH_VERBOSE = 1

export PYBUILD_NAME=sasmodels

# opencl needs somewhere to cache compiled objects
export POCL_CACHE_DIR=$(CURDIR)/.cache/
# and also tell pyopencl not to cache
export PYOPENCL_NO_CACHE=1

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

override_dh_clean:
	dh_clean
	make -C doc clean
	rm -rf $(POCL_CACHE_DIR)

override_dh_auto_build:
	dh_auto_build
	mkdir -p $(POCL_CACHE_DIR)
	MPLBACKEND=Agg make -C doc html
	ln -sf /usr/share/javascript/mathjax/ doc/_build/html/_static/mathjax

override_dh_auto_test:
	# don't run the tests if suppressed with DEB_BUILD_OPTIONS=nocheck
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	mkdir -p $(POCL_CACHE_DIR)
	PYBUILD_SYSTEM=custom \
	  PYBUILD_TEST_ARGS='cd {build_dir}; \
	    {interpreter} -m sasmodels.model_test opencl all; \
	    {interpreter} -m unittest -v sasmodels.resolution; \
	    ' \
          dh_auto_test --buildsystem=pybuild
endif
