include ../Makefile.config

MLFILES = $(wildcard ../src/*.ml)
POFILES = $(wildcard *.po)
MOFILES = $(POFILES:%.po=%.mo)
LANGS = $(POFILES:%.po=%)

mofiles: $(MOFILES)

$(PRODUCT).pot: $(MLFILES)
	xgettext-ocaml -o $@ $^

$(POFILES): $(PRODUCT).pot
	cat $@ > $@t
	msgmerge $@t $< > $@
	rm $@t

clean:
	rm -rf messages tmp.pot *.mo $(POFILES:%=%t)

install:
	for l in $(LANGS); do \
		$(SUDO) install -d $(DESTDIR)$(LOCALEDIR)/$$l/LC_MESSAGES; \
		$(SUDO) install -m 644 $$l.mo $(DESTDIR)$(LOCALEDIR)/$$l/LC_MESSAGES/$(PRODUCT).mo; \
	done

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