#! /usr/bin/make -f

include /usr/share/dune/dune-debian.mk

# 跳过上游测试：nonoverlappingcouplingtest-mpi-2 在本构建环境中触发
# std::vector 越界断言而失败；dune-debian.mk 自带的 override_dh_auto_test
# 不遵循 DEB_BUILD_OPTIONS=nocheck，因此在此显式遵循。
export DEB_BUILD_OPTIONS := $(DEB_BUILD_OPTIONS) nocheck

%:
	dh $@ --builddirectory=build

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	dh_auto_build -- $(DUNE_TEST_BUILD_TARGETS)
	cd build; PATH=$(CURDIR)/debian/tmp-test:$$PATH $(DUNE_CTEST) $(DUNE_CTEST_OPTIONS) $(DUNE_TEST_CTEST_LABELS)
else
	@echo "Skipping dune test suite (DEB_BUILD_OPTIONS contains nocheck)."
endif

override_dh_install:
	# Manual delete runpath set by openmpi 5.0.5
	# See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1085509
	find debian/tmp/ -name \*.so -o  -name \*.so.\* -exec chrpath -d '{}' \; || true
	find debian/tmp/ -name \*.so -o  -name \*.so.\* -exec chrpath '{}' \; || true
	dh_install
