#!/usr/bin/make -f

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

export DH_GOLANG_BUILDPKG="github.com/sigstore/rekor/cmd/rekor-cli"

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

execute_before_dh_auto_build:
	rm -rfv _build/src/github.com/sigstore/rekor/pkg/types/rpm
	rm -rfv _build/src/github.com/sigstore/rekor/pkg/types/tuf
	rm -rfv _build/src/github.com/sigstore/rekor/pkg/pki/tuf

B = $(CURDIR)/debian/tmp/usr/bin
M = $(CURDIR)/debian/rekor/usr/share/man/man1

ifeq (,$(filter nodoc,$(DEB_BUILD_PROFILES)))
execute_before_dh_installman-arch:
	mkdir -pv $(M)
	env PATH=$(PATH):$(B) \
		help2man --no-info --version-string="$(DEB_VERSION)" \
		--no-discard-stderr -Idebian/rekor-cli.h2m \
		rekor-cli -o $(M)/rekor-cli.1
endif
