#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk # DEB_VERSION

%:
	dh $@ --builddirectory=_build --buildsystem=golang

B = $(CURDIR)/debian/tmp/usr/bin
M = $(CURDIR)/debian/tmp/usr/share/man/man1

ifeq (,$(filter nodoc,$(DEB_BUILD_PROFILES)))
execute_before_dh_installman-arch:
	mkdir -pv $(M)
	env PATH=$(PATH):$(B) \
		help2man \
		--no-info \
		--no-discard-stderr \
		--version-string="$(DEB_VERSION)" \
		--include debian/attest-tool.h2m \
		--output $(M)/attest-tool.1 \
		attest-tool
endif

# https://github.com/google/go-attestation/issues/514
ifeq ($(DEB_HOST_ARCH),s390x)
SKIP="TestSimKeyCreateAndLoad|TestSimKeySign|TestSimKeyOpts"
override_dh_auto_test:
	-dh_auto_test $(DH_BUILD_OPTS) -- -run=TestSimKeyCreateAndLoad
	-dh_auto_test $(DH_BUILD_OPTS) -- -run=TestSimKeySign
	-dh_auto_test $(DH_BUILD_OPTS) -- -run=TestSimKeyOpts
	dh_auto_test $(DH_BUILD_OPTS) -- -skip=$(SKIP)
endif
