#!/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 LC_ALL=C.UTF-8

%:
	dh $@ --with python2 --buildsystem=pybuild

override_dh_shlibdeps:
	dh_shlibdeps
	dh_numpy

override_dh_installchangelogs:
	dh_installchangelogs docs/changelog.rst

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

override_dh_python2:
	dh_python2
	dh_python-ply $$(find $(PYBUILD_DESTDIR_python2) -name '*tab.py')

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

override_dh_strip_nondeterminism:
	dh_strip_nondeterminism -Xinvalid.dat.gz
