#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@ --buildsystem=cmake

# Ignore only CTest's display of this compile-only test command.
execute_before_dh_auto_configure:
	@echo 'blhc: ignore-line-regexp: [0-9]+:.*Test.command:.*"-c".*/tests/compile_pass_harness_control[.]cpp.*'

# These optional adapters require libQD3, which is not packaged in Debian.
# Keep them upstream, but omit them from the initial MPFR-focused package.
execute_after_dh_install:
	set -eu; \
	for header in dd_real dd_complex qd_real qd_complex ds_real ts_real qs_real td_real edd_real single_real; do \
		rm debian/libgmpfrxx-mkii-dev/usr/include/gmpfrxx_mkII/adapters/$$header.hpp; \
	done

override_dh_auto_configure:
	dh_auto_configure -- \
		-DGMPFRXX_MKII_COMPONENTS=GMP,MPFR,MPC \
		-DGMPFRXX_MKII_DEPS_AUTO_FETCH=OFF \
		-DGMPFRXX_MKII_BUILD_EXAMPLES=OFF \
		-DGMPFRXX_MKII_BUILD_BENCHMARKS=OFF \
		-DBUILD_TESTING=ON \
		-DCMAKE_INSTALL_LIBDIR=lib/$(DEB_HOST_MULTIARCH)
