#!/usr/bin/make -f

DH_GOPKG = github.com/dundee/gdu
PKD  = $(abspath $(dir $(MAKEFILE_LIST)))
VERSION ?= $(shell dpkg-parsechangelog -l$(PKD)/changelog | perl -ne 'print $$1 if m{^Version:\s*([\d\.]+)}')

PACKAGES := $(shell go list ./...)
GOLDFLAGS ?= \
	-X '$(DH_GOPKG)/build.Version=$(VERSION)' \
	-X '$(DH_GOPKG)/build.User=$(shell id -u -n)' \
	-X '$(DH_GOPKG)/build.Time=$(shell LC_ALL=en_US.UTF-8 date)'

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

override_dh_auto_install:
	dh_auto_install -- --no-source

override_dh_auto_build:
	dh_auto_build -- \
            -ldflags "$(GOLDFLAGS)"
