#!/usr/bin/make -f

export DH_VERBOSE=1
export PYBUILD_NAME=xraylarch
export PYBUILD_AFTER_TEST=rm -rfv {build_dir}/htmlcov/

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_build:
	# generate the desktop files
	cd $(CURDIR)/debian; ./build-desktop

ifeq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
	# build the doc
	env PYTHONPATH=$(shell pybuild --build -i python3 -s custom --build-args 'echo {build_dir}') \
	SPHINXBUILD="python3 -m sphinx" \
	SPHINXOPTS="-D mathjax_path=MathJax.js" \
	$(MAKE) -C doc html
endif

execute_after_dh_auto_install:
	$(RM) debian/python3-xraylarch/usr/bin/feff6l
	$(RM) debian/python3-xraylarch/usr/bin/feff8l
	find -name gse_xrfmap.ico -exec chmod 0644 {} \;
	find examples/ -executable -type f -exec chmod 0644 {} \;
	dh_install -p python3-xraylarch debian/*.desktop ./usr/share/applications/
