#!/usr/bin/make -f

# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

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

export GOCACHE=$(CURDIR)/vendor
export GOPATH=$(CURDIR)/vendor
export GO111MODULE=on
export GOPROXY=off
export GOTOOLCHAIN=local

# Needed to run sliver binaries to create shell autocompletions
export SLIVER_ROOT_DIR=/tmp

%:
	dh $@

override_dh_auto_build:
	VERSION=$(DEB_VERSION_UPSTREAM) make

# Ideally we'd run the test suite, however there are two issues:
# 1. warning that it might take a LONG time -- if that's true that it really
#    takes too long, maybe patching go-tests.sh to add the '-short' argument
#    to 'go test' is enough.
# 2. multiple failures anyway -- needs some time to dive in and fix it all. 
#override_dh_auto_test:
#	./go-tests.sh

execute_after_dh_auto_install:
	# install bash/zsh completion
	mkdir -p debian/sliver/usr/share/bash-completion/completions debian/sliver/usr/share/zsh/vendor-completions/
	./sliver-server completion bash > debian/sliver/usr/share/bash-completion/completions/sliver-server
	./sliver-client completion bash > debian/sliver/usr/share/bash-completion/completions/sliver-client
	./sliver-server completion zsh > debian/sliver/usr/share/zsh/vendor-completions/_sliver-server
	./sliver-client completion zsh > debian/sliver/usr/share/zsh/vendor-completions/_sliver-client
