#!/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

execute_after_dh_auto_install:
	rm -fv $(B)/mk-add-checkpoint-request
	rm -fv $(B)/sha256-n $(B)/use-agent
ifeq (,$(filter nodoc,$(DEB_BUILD_PROFILES)))
	PATH="$(CURDIR)/_build/bin:$$PATH" make doc VERSION=$(DEB_VERSION)
	mkdir -pv $(M)/man1 $(M)/man5
	help2man --no-info --version-string="$(DEB_VERSION)" \
			-Idebian/sigsum-witness.h2m $(B)/sigsum-witness \
			-o $(M)/man1/sigsum-witness.1
	cp -v doc/*.1 $(M)/man1/
	mv -v $(M)/man1/sigsum-tools.1 $(M)/man5/sigsum-tools.5
endif
