#!/usr/bin/make -f

# en is default language, so no additional declaration is necasarry
LANGS = ar cs de es fr it ja pt sk sv tr vi zh_CN zh_TW

MSGID_BUGS_EMAIL = Kartik Mistry <kartik@debian.org>
PO4A_OPTS = --msgid-bugs-address "$(MSGID_BUGS_EMAIL)" --previous
PO4A = po4a $(PO4A_OPTS)

update-po:
	$(PO4A) --no-translations --force po4a.cfg

%:
	dh $@

override_dh_auto_build:
	strfile hints
	$(PO4A) po4a.cfg
	strfile hints-ar
	strfile hints-cs
	strfile hints-de
	strfile hints-es
	strfile hints-fr
	strfile hints-it
	strfile hints-ja
	strfile hints-pt
	strfile hints-sk
	strfile hints-sv
	strfile hints-tr
	strfile hints-vi
	strfile hints-zh_CN
	strfile hints-zh_TW

override_dh_auto_install:
	install -m 0755 -d $(CURDIR)/debian/tmp/usr/share/games/fortunes
	install -m 0644 hints \
		$(CURDIR)/debian/tmp/usr/share/games/fortunes/debian-hints
	install -m 0644 hints.dat \
		$(CURDIR)/debian/tmp/usr/share/games/fortunes/debian-hints.dat

	$(foreach lang,$(LANGS),\
		install -m 0755 -d $(CURDIR)/debian/tmp/usr/share/games/fortunes/$(lang) ; \
		install -m 0644 hints-$(lang) \
			$(CURDIR)/debian/tmp/usr/share/games/fortunes/$(lang)/debian-hints ; \
		install -m 0644 hints-$(lang).dat \
			$(CURDIR)/debian/tmp/usr/share/games/fortunes/$(lang)/debian-hints.dat ; \
	)

override_dh_auto_clean:
	dh_auto_clean
	rm -f *.dat
	$(PO4A) --rm-translations --rm-backups po4a.cfg
