#!/usr/bin/make -f

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

export DH_GOLANG_INSTALL_EXTRA := pkg/tuf/repository pkg/testing/data \
	examples/trusted-root-public-good.json

export DH_GOLANG_EXCLUDES := \
	github.com/sigstore/sigstore-go/examples/custom-certificate-validator

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

execute_before_dh_auto_test:
	rm -fv _build/src/github.com/sigstore/sigstore-go/pkg/verify/sct_test.go

execute_after_dh_auto_install:
	rm -fv $(CURDIR)/debian/tmp/usr/share/gocode/src/github.com/sigstore/sigstore-go/pkg/tuf/testing.local.json
	rm -fv $(CURDIR)/debian/tmp/usr/bin/conformance

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

ifeq (,$(filter nodoc,$(DEB_BUILD_PROFILES)))
execute_before_dh_installman-arch:
	mkdir -pv $(M)
	help2man --version-string="$(DEB_VERSION)" \
		--name="Sigstore OCI image verification" \
		--no-info --no-discard-stderr \
		$(B)/oci-image-verification -o $(M)/oci-image-verification.1
	help2man --version-string="$(DEB_VERSION)" \
		--name="Sigstore signing tool" \
		--no-info --no-discard-stderr \
		$(B)/sigstore-go-signing -o $(M)/sigstore-go-signing.1
	help2man --version-string="$(DEB_VERSION)" \
		--name="Sigstore verification tool" \
		--no-info --no-discard-stderr \
		$(B)/sigstore-go-verification -o $(M)/sigstore-go-verification.1
endif
