#!/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

build-arch:
build-indep:
	dh_testdir
	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

build: build-arch build-indep

install-indep: build-indep
	dh_testdir
	dh_testroot
	dh_installdirs
	dh_prep

	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 ; \
	)

clean:
	dh_testdir
	dh_testroot
	rm -f *.dat

	$(PO4A) --rm-translations --rm-backups po4a.cfg

	dh_clean

binary-arch:

binary-indep: install-indep
	dh_testdir
	dh_testroot
	dh_installdirs -i
	dh_install -i
	dh_link -i
	dh_installdocs -i
	dh_installchangelogs -i
	dh_compress -i
	dh_fixperms -i
	dh_md5sums -i
	dh_gencontrol -i
	dh_installdeb -i
	dh_builddeb -i

binary: binary-arch binary-indep

.PHONY: binary binary-indep binary-arch build build-indep build-arch clean install-indep
