# Makefile
INSTALL = install
MSGFMT = msgfmt

EXES = all

.PHONY : all install update update_pot 

all:

LANGS = ru fr bg

cl_kernel_%.mo: cl_kernel_%.po
	${MSGFMT} -o $@ $(subst .mo,.po,$@)

cl_theme_%.mo: cl_theme_%.po
	${MSGFMT} -o $@ $(subst .mo,.po,$@)

MOFILE = $(subst install_,,$@)
LOCALEMO = $(subst .mo,,$(subst install_cl_theme_,,$(subst install_cl_kernel_,,$@)))

install_cl_kernel_%.mo: cl_kernel_%.mo
	${INSTALL} -D -m 0644 $(MOFILE) ${DESTDIR}/usr/share/locale/$(LOCALEMO)/LC_MESSAGES/cl_kernel.mo

install_cl_theme_%.mo: cl_theme_%.mo
	${INSTALL} -D -m 0644 $(MOFILE) ${DESTDIR}/usr/share/locale/$(LOCALEMO)/LC_MESSAGES/cl_theme.mo

update_pot: FORCE
	bash --dump-po-strings ../cl-kernel | msguniq >cl_kernel.pot
	bash --dump-po-strings ../cl-theme | msguniq >cl_theme.pot

POFILE = $(subst update_,,$@)

update_cl_kernel_%.po: cl_kernel.pot
	msgmerge --update $(POFILE) cl_kernel.pot

update_cl_theme_%.po: cl_theme.pot
	msgmerge --update $(POFILE) cl_theme.pot

update_kernel: $(addsuffix .po,$(addprefix update_cl_kernel_,$(LANGS)))
update_theme: $(addsuffix .po,$(addprefix update_cl_theme_,$(LANGS)))

update: update_kernel update_theme

install: all $(addsuffix .mo,$(addprefix install_cl_kernel_,$(LANGS))) $(addsuffix .mo,$(addprefix install_cl_theme_,$(LANGS)))

#install_cl_kernel_ru.mo install_cl_kernel_fr.mo

FORCE:
