#!/usr/bin/make -f

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

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

override_dh_auto_test:
	env DH_GOLANG_EXCLUDES=sigsum.org/sigsum-go/pkg/server dh_auto_test $(DH_BUILD_OPTS)
	-env DH_GOLANG_BUILDPKG=sigsum.org/sigsum-go/pkg/server dh_auto_test $(DH_BUILD_OPTS)

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

execute_after_dh_auto_install:
	rm -fv $(B)/mk-add-tree-request $(B)/mk-add-checkpoint-request
	rm -fv $(B)/sha256-n $(B)/use-agent
ifeq (,$(filter nodoc,$(DEB_BUILD_PROFILES)))
	mkdir -pv $(M)
	for p in key monitor submit token verify witness; do \
		help2man --no-info --version-string="$(DEB_VERSION)" \
			-Idebian/sigsum-$$p.h2m $(B)/sigsum-$$p \
			-o $(M)/sigsum-$$p.1; \
	done
endif
