#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
export DH_GOLANG_INSTALL_EXTRA := man/man1 shell

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

# we are not using the Makefile for build. hence the FZF_VERSION and FZF_REVISION are not used.
execute_before_dh_auto_configure:
	cp main.go main.go.bak
	sed -e '/^var version =/s@"[0-9.]*"@"$(DEB_VERSION_UPSTREAM)"@' \
	    -e '/^var revision =/s@"devel"@"debian"@' -i main.go

override_dh_auto_install:
	FZF_VERSION=$(DEB_VERSION_UPSTREAM) \
        FZF_REVISION=debian \
        dh_auto_install -- --no-source

override_dh_compress:
	dh_compress -Xkey-bindings -Xcompletion -Xfzf.vim

override_dh_auto_clean:
	-mv main.go.bak main.go
	dh_auto_clean
