#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DH_GOLANG_INSTALL_EXTRA = tests/assets/example.json

VERSION := $(DEB_VERSION)
GO_LDFLAGS := -X 'github.com/tomwright/dasel/internal.Version=v$(VERSION)'

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

override_dh_auto_build:
	dh_auto_build -- -ldflags "$(GO_LDFLAGS)" -buildmode=pie

execute_before_dh_install:
	mkdir -p debian/tmp/completions
	_build/bin/dasel completion zsh > debian/tmp/completions/_dasel
	_build/bin/dasel completion bash > debian/tmp/completions/dasel
	_build/bin/dasel completion fish > debian/tmp/completions/dasel.fish

ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
execute_before_dh_installman:
	_build/bin/dasel man -o debian/tmp
endif
