#!/usr/bin/make -f

export DH_VERBOSE = 1
include /usr/share/dpkg/pkg-info.mk

# The tarball source does not include the upstream version, so let's
# get it from the source package and inject it at build time
# (see packages gdu and golang-github-micromdm-scep for similar)
#
export CGO_ENABLED := 0
DH_GOPKG := github.com/gokcehan/lf

VERSION = $(DEB_VERSION_UPSTREAM)
GO_LDFLAGS := -ldflags '-X "main.gVersion=$(VERSION)"'

override_dh_auto_build:
	dh_auto_build -- $(GO_LDFLAGS)

override_dh_auto_install:
	dh_auto_install -- --no-source

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

override_dh_auto_install:
	dh_auto_install -- --no-source
	# Install completions
	install -D -m644 $(CURDIR)/etc/lf.bash \
		$(CURDIR)/debian/lf/usr/share/bash-completion/completions/lf
	install -D -m644 $(CURDIR)/etc/lf.zsh \
		$(CURDIR)/debian/lf/usr/share/zsh/vendor-completions/_lf
	install -D -m644 $(CURDIR)/etc/lf.fish \
		$(CURDIR)/debian/lf/usr/share/fish/vendor_completions.d/lf.fish
