#!/usr/bin/make -f

export DEBIAN_VERBOSE=1
export DH_VERBOSE=1

export PYBUILD_TEST_ARGS=-v -k 'not test_getters'

%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure --buildsystem=cmake -- -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_BUILD_TYPE=Release -DCRYSFML_PREFIX=lib/$(DEB_HOST_GNU_TYPE) -DPYTHON_API=ON

override_dh_auto_test:

# The extension doesn't use Python headers, ship it for all supported versions
execute_after_dh_install:
	cd debian/python3-crysfml/usr/lib/python3/dist-packages/CFML_api && \
	so=crysfml08lib.cpython-$$(py3versions -dv | tr -d .)-$(DEB_HOST_MULTIARCH).so && \
	mv crysfml08lib.so $$so && \
	for v in $$(py3versions -sv | tr -d .); do \
		[ -e crysfml08lib.cpython-$$v-$(DEB_HOST_MULTIARCH).so ] || \
			ln -s $$so crysfml08lib.cpython-$$v-$(DEB_HOST_MULTIARCH).so; \
	done
