#!/usr/bin/make -f
# -*- makefile -*-

#export DH_VERBOSE := 1

# Exclude "cover" since it is included in core as of Go 1.5+.
# Exclude "gopls" as it requires honnef.co/go/tools which has not
# been packaged for Debian.
export DH_GOLANG_EXCLUDES := cmd/cover gopls internal/lsp

# godoc/static is needed for tests.
export DH_GOLANG_INSTALL_EXTRA := godoc/static

override_dh_auto_install:
	dh_auto_install
	# Rename “eg” to “golang-eg” (#753978)
	# Rename “stress” to “golang-stress” (#793693)
	# Rename “bundle” to “golang-bundle” (#818551)
	# Rename “guru” to “golang-guru”
	# Rename “findcall” to “golang-findcall”, etc. (#953725)
	for i in eg stress bundle guru \
		 findcall ifaceassert lostcancel nilness stringintconv shadow unmarshal \
		 authtest cookieauth gitauth netrcauth; \
	do \
	    mv debian/tmp/usr/bin/$$i debian/tmp/usr/bin/golang-$$i; \
	done

	# Remove “helper”, “server”, etc. (#953725)
	for i in helper server; do \
	    $(RM) debian/tmp/usr/bin/$$i; \
	done

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# use short tests where possible (especially to skip tests like
	# TestWebIndex which are very slow)
	dh_auto_test -- -test.short
endif

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