#!/usr/bin/make -f

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

export DH_GOLANG_EXCLUDES := tinygotest
export GOPATH := $(CURDIR)/obj-$(DEB_BUILD_GNU_TYPE)

override_dh_auto_build:
	# build the "msgp" binary
	dh_auto_build
	# use new binary to refresh generated code
	DH_GOLANG_GO_GENERATE=1 DH_GOLANG_BUILDPKG="github.com/tinylib/msgp/_generated github.com/tinylib/msgp/gen github.com/tinylib/msgp/msgp github.com/tinylib/msgp/msgp/setof github.com/tinylib/msgp/parse github.com/tinylib/msgp/printer" PATH="$(GOPATH)/bin:$$PATH" \
		dh_auto_build

	# generate a man page
	mkdir man1/
	TZ=UTC help2man $(GOPATH)/bin/msgp -n "Go code generator for MessagePack" --no-info --no-discard-stderr --version-string=$(DEB_VERSION_UPSTREAM) > man1/msgp.1

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