#!/usr/bin/make -f

%:
	dh $@ 

override_dh_auto_build:
	#translate source files before building pdf
	po4a po4a/po4a.cfg --verbose
	dh_auto_build

override_dh_clean:
	dh_clean
	#remove translated source files
	rm -f packaging-tutorial.*.tex debiantutorial.*.sty

override_dh_compress:
	dh_compress -X.pdf

#extract version number and date from Debian changelog
VERSION := $(shell dpkg-parsechangelog | grep "^Version:" | cut -d\  -f2)
YEAR    := $(shell dpkg-parsechangelog | grep "^Date:" | cut -d\  -f2-5 | date +"%Y")
MONTH   := $(shell dpkg-parsechangelog | grep "^Date:" | cut -d\  -f2-5 | date +"%m")
DAY    := $(shell dpkg-parsechangelog | grep "^Date:" | cut -d\  -f2-5 | date +"%d")

update-version-date:
	sed -i -e "s/.* % DATE - use debian\/rules update-version-date/\\\\date{\\\\footnotesize version $(VERSION) -- $(YEAR)-$(MONTH)-$(DAY)} \% DATE - use debian\/rules update-version-date/" packaging-tutorial.tex
