#!/usr/bin/make -f

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

export DH_GOLANG_BUILDPKG := \
	github.com/pranshuparmar/witr/cmd/witr \
	github.com/pranshuparmar/witr/internal/tools/docgen
export DH_GOLANG_INSTALL_EXTRA := internal/version/VERSION

BUILD_DATE := $(shell date --utc --date="@$(SOURCE_DATE_EPOCH)" "+%Y-%m-%d")
LD_FLAGS := \
	-X 'github.com/pranshuparmar/witr/internal/version.Version=v$(DEB_UPSTREAM_VERSION)' \
	-X 'github.com/pranshuparmar/witr/internal/version.BuildDate=v$(BUILD_DATE)'

%:
	dh $@ --builddirectory=debian/build --buildsystem=golang

override_dh_auto_build:
	dh_auto_build -- -ldflags "$(LD_FLAGS)"

execute_after_dh_auto_build:
	debian/build/bin/docgen -format man
	rm -f debian/build/bin/docgen

override_dh_auto_install:
	dh_auto_install -- --no-source
