#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

export DH_VERBOSE := 3
export DH_GOLANG_INSTALL_ALL := 1

export GOROOT := $(strip $(or \
	$(if $(findstring $(shell go version | sed -e 's,.* go\(1[.].*\)[.].* .*,\1,'),\
			1.8 1.9 1.10 1.11),\
		$(info *** Using default go.)\
			$(shell go env GOROOT)),\
		$(info *** Cannot use default go. Forcing go-1.8.)\
			/usr/lib/go-1.8))

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

# Instead of using DH_GOLANG_GO_GENERATE which builds everything, even
# under vendor/ (and fails for github.com/jmank88/nuts), only generate
# code for the dep package.
override_dh_auto_build:
	GOPATH=$(CURDIR)/obj-$(DEB_BUILD_GNU_TYPE) go generate github.com/golang/dep
	dh_auto_build

override_dh_auto_test:

override_dh_auto_install:
	dh_auto_install
	rm -rf debian/go-dep/usr/share/gocode debian/go-dep/usr/bin/licenseok
