#!/usr/bin/make -f

DATESTAMP	=	$(shell date +%Y%m%d)
DEBVERSION	=	$(shell dpkg-parsechangelog \
	|grep ^Version|awk '{print $$2}')
UVERSION	=	$(shell echo $(DEBVERSION) |sed 's/[~+-].*//')
DEBVERSION_NR	=	$(shell echo $(DEBVERSION) |sed 's/-[[:digit:]]\+$$//')

VERSEP		=	~

UPSTREAMGIT	=	https://github.com/goldendict/goldendict.git

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/qmake.mk
# include /usr/share/cdbs/1/rules/simple-patchsys.mk

export PREFIX=/usr
QMAKE		= 	qmake-qt4

install/goldendict::
	find debian/goldendict -type f -name '*.*' -exec chmod 0644 '{}' +
	pod2man debian/goldendict.pod debian/goldendict.1

clean::
	rm -f debian/goldendict.1 version.txt

git-pull:
	test `id -u` -eq 0 || fakeroot debian/rules clean
	git remote show github || \
		git remote add gitorious $(UPSTREAMGIT)
	git pull github master
	dch -m -D experimental \
		--newversion $(UVERSION)$(VERSEP)git$(DATESTAMP)-1 \
		"New GIT-snapshot"
	cd .. && tar --exclude=debian --exclude=.git \
		-czvf \
		goldendict_$(UVERSION)$(VERSEP)git$(DATESTAMP).orig.tar.gz \
		goldendict-$(UVERSION)$(VERSEP)git$(DATESTAMP)

tarball:
	test `id -u` -eq 0 || fakeroot debian/rules clean
	cd .. && tar --exclude=debian --exclude=.git \
		-czvf goldendict_$(DEBVERSION_NR).orig.tar.gz \
		goldendict-$(DEBVERSION_NR)
