#!/usr/bin/make -f

export DH_VERBOSE=1

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
LIBDIR:=/usr/lib/$(DEB_HOST_MULTIARCH)
AUTOGENERATED:= libcoarrays-dev.install libcaf-mpi2.links


# The magic debhelper  rule
%:
	dh $@ --buildsystem=cmake --no-parallel --with fortran_mod

DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
# DISABLED_TESTS:= "powerpc alpha"

override_dh_auto_configure:
	for f in ${AUTOGENERATED} ; do \
                sed -e 's%@TRIPLET@%${DEB_HOST_MULTIARCH}%g' < debian/$$f.in  > debian/$$f ; \
                done
	dh_auto_configure 

override_dh_auto_clean:
	dh_clean
	rm -f $(patsubst %, debian/%, ${AUTOGENERATED})

override_dh_auto_test:
ifneq (,$(findstring  "$(DEB_HOST_ARCH)",$(DISABLED_TESTS)))
	@echo "Tests disabled on this arch: known failures being investigated"
else
	@echo "Tests may hang/timeout due to lack of processors. "
	-dh_auto_test --timeout 30
endif
