#!/usr/bin/make -f

# set the MPLCONFIGDIR to avoid writing into non writable location
export HOME=$(CURDIR)/build
export MPLCONFIGDIR=$(CURDIR)/build

# Use agg Matplotlib backend for testing on headless machines.
export MPLBACKEND=agg

export PYBUILD_BUILD_ARGS=--use-system-libraries

export LC_ALL=C.UTF-8

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

override_dh_shlibdeps:
	dh_shlibdeps
	dh_numpy3

override_dh_installdocs-indep:
	python3 setup.py build_docs
	dh_installdocs

override_dh_sphinxdoc-arch:
	# sphinxdoc is only needed on indep and does not work here.

override_dh_installchangelogs:
	dh_installchangelogs docs/changelog.rst

override_dh_auto_clean:
	dh_auto_clean
	rm -rf astropy/extern/configobj
	rm -rf build astropy.egg-info
	rm -rf astropy_helpers-*.egg
	rm -rf docs/_build docs/_generated

override_dh_python3:
	dh_python3
	dh_python3-ply $$(find $(PYBUILD_DESTDIR_python3) -name '*tab.py')

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	python3 setup.py test -vv --args "-vv --mpl"
endif

override_dh_strip_nondeterminism:
	dh_strip_nondeterminism -Xinvalid.dat.gz
