#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

# DH_GOPKG is the upstream path which you would normally “go get”.
# Using it allows us to build applications without patching locations.
export DH_GOPKG := github.com/prometheus/client_golang

# Exclude test code from compilation and installation.
export DH_GOLANG_EXCLUDES := examples

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

# All this is a hack to embed cleanly the protobuf definition which upstream
# maintains in a separate repo. The upstream .proto is included in the debian/
# directory, then compiled into a go source file in the place expected by the
# rest of the code.

BUILDDIR := $(shell perl -w -MDebian::Debhelper::Buildsystem::golang -e \
    'print Debian::Debhelper::Buildsystem::golang->new()->get_builddir()')
PROTODIR := $(CURDIR)/$(BUILDDIR)/src/github.com/prometheus/client_model/go

override_dh_auto_configure:
	dh_auto_configure -O--buildsystem=golang
	mkdir -p $(PROTODIR)
	cd debian; protoc metrics.proto --go_out=$(PROTODIR)
	# Include test fixtures.
	cp -av extraction/fixtures $(BUILDDIR)/src/$(DH_GOPKG)/extraction
