#!/usr/bin/make -f

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

TIMESTAMP := $(shell date -d @$(SOURCE_DATE_EPOCH) -u +%Y-%m-%dT%H:%M:%SZ)

export DH_GOPKG := github.com/arduino/mdns-discovery
LDFLAGS := -X $(DH_GOPKG)/version.Version=$(DEB_VERSION_UPSTREAM)
LDFLAGS += -X $(DH_GOPKG)/version.Commit=$(DEB_VERSION)
LDFLAGS += -X $(DH_GOPKG)/version.Timestamp=$(TIMESTAMP)

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

override_dh_auto_build:
	dh_auto_build -- -ldflags '$(LDFLAGS)'

override_dh_auto_install:
	# Disable dh_auto_install to install binary in specific location with dh_install
