#!/usr/bin/make -f

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

export DH_GOLANG_INSTALL_EXTRA := config/keybindings.yaml

# export git commit, buildtime, put it into ldflags for a sensible version
BUILDTIME = $(shell date --date='@${SOURCE_DATE_EPOCH}' --utc +'%Y-%m-%dT%H:%M:%SZ')
GITCOMMIT = $(shell ./debian/helpers/gitcommit.sh cli $(DEB_VERSION_UPSTREAM))
GO_LDFLAGS := "-X 'main.Tag=$(DEB_VERSION_UPSTREAM)' -X 'main.Commit=$(GITCOMMIT)' -X 'main.BuildTime=$(BUILDTIME)'"

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

execute_before_dh_auto_configure:
	cp -a debian/vendor $(CURDIR)

override_dh_auto_build:
	dh_auto_build -O--buildsystem=golang -- --ldflags $(GO_LDFLAGS)

override_dh_auto_install:
	dh_auto_install -- --no-source
