#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=-lto
DPKG_EXPORT_BUILDFLAGS = 1

include /usr/share/dpkg/buildflags.mk
include /usr/share/dpkg/pkg-info.mk

%:
	dh $@ --buildsystem=cmake+ninja --builddir=build

override_dh_auto_configure:
	dh_auto_configure -- -DKLEIDIAI_BUILD_TESTS=$(if $(filter nocheck,$(DEB_BUILD_OPTIONS)),OFF,ON) -DCMAKE_INSTALL_LIBDIR=lib/$(DEB_HOST_MULTIARCH) -DCMAKE_INSTALL_INCLUDEDIR=include/$(DEB_HOST_MULTIARCH) -DKLEIDIAI_BUILD_EXPERIMENTAL_OPS=ON

override_dh_auto_install:
	dh_auto_install
	find debian/libkleidiai-dev/usr/include/$(DEB_HOST_MULTIARCH)/kai -depth -type d -empty -delete

override_dh_auto_test:
# running all tests is too slow, choose baseline NEON FP32 packing and output
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	build/kleidiai_test --gtest_filter='MatMul/MatMul*Test.*matmul_nt_nt_fp32_fp32_fp32_6x8_neon_mla*:-*sme*:*sve*'
endif
