#!/usr/bin/make -f
# -*- Makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export DH_ALWAYS_EXCLUDE=.gitignore:LICENSE

PKD   = $(abspath $(dir $(MAKEFILE_LIST)))
PKG   = "phabricator"
UVER  = $(shell dpkg-parsechangelog -l$(PKD)/changelog -SVersion | sed -E -e 's/-[0-9]+//')
DTYPE =
VER  ?= $(subst $(DTYPE),,$(UVER))

%:
	dh $@

override_dh_clean:
	debconf-updatepo
	dh_clean

UDATE = $(shell date --rfc-3339=seconds --date='TZ="UTC" $(shell echo $(VER) | perl -ne 'print "$$1-$$2-$$3" if m/\+(?:git|svn|hg)(\d{4})(\d{2})(\d{2})/')')
get-orig-source: $(info I: UDATE=$(UDATE))
	$(if $(wildcard $(PKG)-$(VER)),$(error $(PKG)-$(VER) exist, aborting..))
	debian/get-orig-source $(VER)

generate-manpage: debian/doc/arc.1

debian/doc/arc.pod: debian/doc/arc.cat1
	debian/cat2pod < $< > $@

debian/doc/arc.1: debian/doc/arc.pod
	pod2man -r "" -c "User Commands" $< $@

.PHONY: override_dh_clean get-orig-source generate-manpage