#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
	dh $@

ifeq (amd64,$(DEB_HOST_ARCH))
execute_before_dh_auto_configure:
	CFLAGS="${CFLAGS} -march=x86-64-v3" \
				dh_auto_configure -Bx86-64-v3 -- \
				-DSHA3=avx2 \
				--libdir lib/$(DEB_HOST_MULTIARCH)/glibc-hwcaps/x86-64-v3 \
				|| rm -rf x86-64-v3

execute_before_dh_auto_build:
	if [ -d x86-64-v3 ]; then dh_auto_build -Bx86-64-v3; fi

execute_before_dh_auto_install:
	if [ -d x86-64-v3 ]; then dh_auto_install -Bx86-64-v3; fi

execute_before_dh_install:
	if [ -d x86-64-v3 ]; then dh_install -plibfaest1 usr/lib/$(DEB_HOST_MULTIARCH)/glibc-hwcaps/x86-64-v3/libfaest.so.*; fi

execute_before_dh_auto_clean:
	rm -rf x86-64-v3
endif
