#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -Wextra
export DPKG_GENSYMBOLS_CHECK_LEVEL = 4

# running the test suite kernel needs some module
KCAPI_RNG ?= $(shell grep CONFIG_CRYPTO_USER_API_RNG /boot/config-$(shell uname -r) | cut -f2 -d=)

%:
	dh ${@}

override_dh_auto_configure:
	dh_auto_configure -- \
		--enable-kcapi-dgstapp \
		--enable-kcapi-encapp \
		--enable-kcapi-rngapp

override_dh_auto_build:
	dh_auto_build
	dh_auto_build -- html
	dh_auto_build -- man

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
ifeq ($(KCAPI_RNG), m)
	# required to be run within 'test' subdir:
	(cd test ; ENABLE_FUZZ_TEST=1 NO_32BIT_TEST=1 ./test-invocation.sh)
endif
endif

override_dh_auto_install:
	dh_auto_install
	dh_auto_install -- install-man
	dh_auto_install -- install-html

execute_after_dh_auto_install:
	# remove unused files
	rm -f debian/tmp/usr/lib/*/*.la
