POSRC		= $(wildcard template/lang/*.po)
LANGS		= $(POSRC:template/lang/%.po=%)
HTMLS		= $(LANGS:%=template/sim.%.html)
TEMPLATE	= template/lang/NEW_LANGUAGE_TEMPLATE.pot
MAINHTML	= template/TEMPLATE.html
VERSION		= $(shell grep '^our \$$VERSION=' index.cgi \
			|sed 's/^.*VERSION=//' \
			|sed 's/;//' | sed 's/ //g')


all: $(TEMPLATE) $(POSRC) $(HTMLS) template/sim.en.html

$(TEMPLATE): $(MAINHTML) Makefile
	umask 022; \
	perl mlhtml/htmlgettext.pl \
		-sv $(VERSION) \
		-package ogamesim \
		-charset UTF-8 \
		-langteam 'Ogamesim language team <dimka@avanto.org>' \
		-desc 'Language file for LANGUAGE' \
		-copyright \
		 'Copyright (C) by Dmitry E. Oboukhov, 2006' \
		-email 'Dmitry E. Oboukhov <dimka@avanto.org>' \
		-o $@ $<

$(POSRC): template/lang/%.po: $(TEMPLATE)
	msgmerge --suffix=.previous --update $@ $<

$(HTMLS): template/sim.%.html:template/lang/%.po $(MAINHTML) Makefile
	umask 022; \
	perl mlhtml/htmlputtext.pl -p $< \
		-o $@ \
		-charset UTF-8 \
		$(MAINHTML)

template/sim.en.html:$(MAINHTML)
	umask 022; \
	perl mlhtml/htmlputtext.pl -o $@ \
		-charset UTF-8 \
		$(MAINHTML) 2>/dev/null


.PHONY: all
