DOMAIN=ltsp-cluster-control
POFILES=$(wildcard *.po)
MOFILES=$(patsubst %.po,%.mo,$(POFILES))
LINGUAS=$(basename $(POFILES))
GETTEXTFILES=$(shell find ../ -type f -name "*.php")
POTFILE=$(DOMAIN).pot
DESTDIR=/

%.mo: %.po
	msgfmt --statistics -o $@ $<

%.po: $(DOMAIN).pot
	msgmerge -U $*.po $(DOMAIN).pot

$(DOMAIN).pot: $(GETTEXTFILES)
	$(shell xgettext -L php -o $(DOMAIN).pot $(GETTEXTFILES) --from-code utf-8)

update-po:
	-for lang in $(LINGUAS); do\
		msgmerge -U $$lang.po $(DOMAIN).pot; \
	done

install: $(MOFILES)
	-for lang in $(LINGUAS); do\
		mkdir -p $$lang/LC_MESSAGES/; \
		mv $$lang.mo $$lang/LC_MESSAGES/$(DOMAIN).mo; \
	done

all: update-po $(MOFILES)

distclean: clean
clean:
	- rm *.mo *~

.PHONY: update-po check
