#!/usr/bin/make -f

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

BRANCH := debian/sid
BUILD_DATE := $(shell date --utc --date='@$(SOURCE_DATE_EPOCH)' +%Y%m%d-%H:%M:%S)
GO_VERSION := $(shell go version | sed 's/go version \(\S*\).*/\1/')
USER := team+pkg-go@tracker.debian.org
BUILDFLAGS = -ldflags \
    "-X github.com/prometheus/common/version.Branch=$(BRANCH)\
    -X github.com/prometheus/common/version.BuildDate=$(BUILD_DATE)\
    -X github.com/prometheus/common/version.BuildUser=$(USER)\
    -X github.com/prometheus/common/version.GoVersion=$(GO_VERSION)\
    -X github.com/prometheus/common/version.Revision=$(DEB_VERSION)\
	-X github.com/prometheus/common/version.Version=$(DEB_VERSION_UPSTREAM)"

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

override_dh_auto_build:
	dh_auto_build -- $(BUILDFLAGS)
	asciidoctor -b manpage man/prometheus-sensor-exporter.1.adoc

override_dh_auto_test:
	dh_auto_test -- $(BUILDFLAGS)

override_dh_auto_install:
	dh_auto_install -- --no-source
