DOMAIN=ltsp-live
POFILES=$(wildcard *.po)
MOFILES=$(patsubst %.po,%.mo,$(POFILES))
LINGUAS=$(basename $(POFILES))
POTFILE=$(DOMAIN).pot

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

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

$(DOMAIN).pot:
	pygettext -d $(DOMAIN) -a -D ../ltsp-live
	xgettext -L glade -o $(DOMAIN).pot -j ../ltsp-live.xml
	sh extract-desktop.sh ../ltsp-live.desktop ltsp-live.pot
	sed "/#, fuzzy/d" -i ltsp-live.pot

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

install: $(MOFILES)
	-for lang in $(LINGUAS); do\
	    install -d $(DESTDIR)/usr/share/locale/$$lang/LC_MESSAGES/; \
	    install -m 644 $$lang.mo $(DESTDIR)/usr/share/locale/$$lang/LC_MESSAGES/$(DOMAIN).mo; \
	done

all: update-po $(MOFILES)

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

.PHONY: update-po check
