PLUGIN = guillotine-into-layers
LOCALEDIR = /usr/share/locale
PROCEDURE_NAME = "gimp-plugin-$(PLUGIN)"
LANGUAGES = fr de

.PHONY: all install userinstall uninstall useruninstall clean $(LANGUAGES)
.PHONY: update-po update-pot

all: $(LANGUAGES)

$(LANGUAGES):
	msgfmt -v -o $@.mo $@.po

install: $(LANGUAGES)
	for L in $(LANGUAGES); \
	do install -v -m 0644 $$L.mo "$(LOCALEDIR)/$$L/LC_MESSAGES/$(PROCEDURE_NAME).mo"; \
done

userinstall:
	$(warning Will not install gettext files for user installation!)

PO_FILES = $(foreach lang, $(LANGUAGES), $(lang).po)

uninstall: $(LANGUAGES)
	for L in $(LANGUAGES); \
	do rm -vf "$(LOCALEDIR)/$$L/LC_MESSAGES/$(PROCEDURE_NAME).mo"; \
done

useruninstall:
	$(warning Will not uninstall gettext files for user installation!)

clean:
	rm -f *.po~ *.mo

update-po: $(PO_FILES)

$(PO_FILES): $(PLUGIN).pot
	if [[ -e $@ ]]; \
	then msgmerge -U $@ $^; \
	else msginit -l $(subst .po,,$@) -o $@ -i $^; \
fi

update-pot: $(PLUGIN).pot

$(PLUGIN).pot: ../src/*.h ../src/*.c
	xgettext -C '-k_' -kN_ -d $(PLUGIN) -o $@ $^

