#!/usr/bin/make -f

# Don't use "cmd", as it will match "lintcmd".
export DH_GOLANG_EXCLUDES := website internal/cmd internal/gosmith \
	cmd/unused \
	cmd/keyify cmd/structlayout cmd/structlayout-optimize cmd/structlayout-pretty

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

ifneq (,$(filter $(DEB_HOST_ARCH), armhf))
override_dh_auto_test:
	# run out of memory: cannot allocate 4194304-byte block (3459678208 in use)
	-dh_auto_test
endif

# The build has a timeout on slow archs, so increase limit.
override_dh_auto_test:
	dh_auto_test -- -timeout=20m

execute_after_dh_auto_build:
	mv _build/bin/staticcheck _build/bin/go-staticcheck

EXTRA_GO_MODULES += golang.org/x/tools/go/expect
execute_before_dh_auto_configure:
	for i in $(EXTRA_GO_MODULES); do \
	    mkdir -p _build/src/$$(dirname $$i) ; \
	    ln -s $(CURDIR)/debian/go/src/$$i _build/src/$$(dirname $$i)/ ; \
	done
