#!/usr/bin/make -f

include /usr/share/dpkg/default.mk

BUILDPKG   := github.com/elves/elvish/pkg/buildinfo
BUILDFLAGS := -ldflags \
  "-X $(BUILDPKG).Version=$(DEB_VERSION)"
DATE := $(shell date -u --date=@$(SOURCE_DATE_EPOCH) "+%b %d, %Y")
VER := $(shell echo $(DEB_VERSION_UPSTREAM) | sed -e 's/+ds[0-9]*//')
PANDOC_ARG := -s -f gfm -t man -V section:7 \
  -V header:"Miscellaneous Information Manual" \
  -V footer:"Elvish $(VER)" -M date:"$(DATE)"

export DH_GOLANG_EXCLUDES := website examples
export ELVISH_TEST_UI_TIMEOUT := 5s

%:
	dh $@ --buildsystem=golang --with=golang

override_dh_auto_build:
	for file in builtin bundled edit epm language name philosophy re store; do \
	  pandoc $(PANDOC_ARG) -M title:"elvish-$$file" -o debian/elvish-$$file.7 website/ref/$$file.md; \
	done
	dh_auto_build -- $(BUILDFLAGS)

override_dh_auto_install:
	dh_auto_install -- --no-source
