#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

export DH_GOLANG_EXCLUDES := benchautogen

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

override_dh_auto_install:
	dh_auto_install -O--builddirectory=_build -O--buildsystem=golang
	find
	rm -f debian/golang-gonum-v1-gonum-dev/usr/share/gocode/src/gonum.org/v1/gonum/graph/formats/dot/testdata/.gitignore
	rm -f debian/golang-gonum-v1-gonum-dev/usr/share/gocode/src/gonum.org/v1/gonum/graph/layout/testdata/.gitignore
	rm -f debian/golang-gonum-v1-gonum-dev/usr/share/gocode/src/gonum.org/v1/gonum/graph/formats/cytoscapejs/testdata/LICENSE
	rm -f debian/golang-gonum-v1-gonum-dev/usr/share/gocode/src/gonum.org/v1/gonum/graph/formats/sigmajs/testdata/LICENSE.txt
	rm -f debian/golang-gonum-v1-gonum-dev/usr/share/gocode/src/gonum.org/v1/gonum/graph/path/testdata/flow/README

# Some slower architectures (armel, i386, riscv64) take a _very_ long time to run the tests.
# While the i386 tests pass on the buildds, autopkgtests on ci.d.n are exceeding the default
# timeout of 10,000 seconds. As we can't enable a per-package timeout (see #970675) and per
# https://wiki.debian.org/ContinuousIntegration/AutopkgtestBestPractices, we skip tests for
# i386 for the time being. (armel and armhf are 32bit architectures that successfully pass.)
# Additionally, upstream has declared that some architectures are unsupported (see
# https://github.com/gonum/gonum/issues/1751 and https://github.com/gonum/gonum/issues/1873),
# so we skip running tests on ppc64el and s390x.
override_dh_auto_test:
ifneq ($(DEB_HOST_ARCH),i386)
ifneq ($(DEB_HOST_ARCH),ppc64el)
ifneq ($(DEB_HOST_ARCH),s390x)
	dh_auto_test -- -timeout 150m
endif
endif
endif
