#!/usr/bin/make -f

export DH_GOLANG_EXCLUDES := scripts

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

execute_after_dh_auto_configure:
	find . -name "*.go" -executable -exec chmod -x {} +
	# Regenerate cols.go from the vendored colour data so that the
	# build is reproducible from source-package material only. The
	# 0001 patch makes regenerate.go read scripts/data.json instead
	# of fetching it over HTTP. GO111MODULE=off keeps `go run` from
	# attempting to resolve the package's go.mod test deps over the
	# network during this generator step (the generator itself uses
	# only the stdlib). GOCACHE points at the build directory because
	# sbuild's HOME is /sbuild-nonexistent.
	cp debian/missing-sources/colors-data.json scripts/data.json
	cd scripts && GO111MODULE=off GOCACHE=$(CURDIR)/_build/.gocache go run regenerate.go
	gofmt -w cols.go
