#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/pkg-info.mk

export DH_GOLANG_INSTALL_EXTRA := tests/

ifneq ($(filter $(DEB_HOST_ARCH),amd64 arm64 ppc64el s390x),)
RACE:=-race
else
RACE:=
endif

override_dh_auto_install:
	dh_auto_install -- --no-source

override_dh_auto_build:
	dh_auto_build -- $(RACE) -ldflags "-X main.buildversion=$(DEB_VERSION_UPSTREAM) -X main.buildtime=$(SOURCE_DATE_EPOCH)"
	# update version number in manpage
	@echo DEB_VERSION_UPSTREAM $(DEB_VERSION_UPSTREAM)
	sed -e "s/__VERSION__/$(DEB_VERSION_UPSTREAM)/g" < debian/g10k.1.md.in > debian/g10k.1.md
	# build custom manpages from markdown
	pandoc debian/g10k.1.md -s -f markdown -t man -o debian/g10k.1

override_dh_auto_install:
	dh_auto_install -- --no-source

override_dh_auto_test:
	echo "most tests use the network, skipping test suite"

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