#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

# copy the tests to the build dir to be able to pass nose
export PYBUILD_NAME=xrayutilities
export PYBUILD_BEFORE_TEST=cp -r tests {build_dir}; cp -r examples {build_dir}; cp -r lib/xrayutilities/materials/data {build_dir}/xrayutilities/materials/
export PYBUILD_AFTER_TEST=rm -rf {build_dir}/tests; rm -rf {build_dir}/xrayutilities/materials/data; rm -rf {build_dir}/examples

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

override_dh_auto_clean:
	rm -rf build
	dh_auto_clean

override_dh_strip:
	dh_strip --no-automatic-dbgsym

override_dh_auto_install:
	dh_numpy3
	dh_auto_install

override_dh_auto_test:
	dh_auto_test -- -s custom --test-args="{interpreter} {dir}/setup.py egg_info -e {build_dir}; cd {build_dir}; {interpreter} -m unittest2 discover -v;"

override_dh_sphinxdoc:
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	# build doc
	dh_auto_build -- -s custom --build-args="env PYTHONPATH={build_dir} {interpreter} setup.py build_doc"
	dh_installdocs -p python-xrayutilities-doc build/sphinx/html
	dh_sphinxdoc -O--buildsystem=pybuild
endif
