#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
include /usr/share/dpkg/architecture.mk

ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
ifeq (,$(findstring armel,$(DEB_BUILD_ARCH)))
ENABLE_TESTING=ON
endif
endif

%:
	dh $@ -Scmake+ninja

# We are not building the DFT library.
# https://github.com/shibatch/sleef/issues/214#issuecomment-413746187
override_dh_auto_configure:
	dh_auto_configure -- \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DBUILD_SHARED_LIBS=ON \
		-DBUILD_DFT=OFF \
		-DSLEEF_BUILD_TESTS=$(ENABLE_TESTING) \
		-DSLEEF_ENABLE_TESTER4=$(ENABLE_TESTING) \
		-DSLEEF_TEST_ALL_IUT=$(ENABLE_TESTING) \
		-DSLEEF_ENABLE_TLFLOAT=OFF \
		-DCMAKE_C_COMPILER=clang \
		-DCMAKE_CXX_COMPILER=clang++

override_dh_auto_test:
ifeq ($(ENABLE_TESTING),ON)
	dh_auto_test
endif

# noop dwz because some architectures would fail.
override_dh_dwz:
	true
