.PHONY: clean install

prefix:=@prefix@
exec_prefix:=@exec_prefix@
libdir:=@libdir@
datarootdir:=@datarootdir@
srcdir:=@srcdir@
top_builddir:=@top_builddir@
LOCALEDIR:=@localedir@

MANDIR:=doc
MSGDIR:=.

POFILES:=$(wildcard *.po)
MOFILES:=$(POFILES:.po=.mo)
MSGFILES:=$(MOFILES:.mo=)

INSTALL:=@INSTALL@
INSTALL_PROGRAM:=@INSTALL_PROGRAM@
INSTALL_DATA:=@INSTALL_DATA@

THISFILE:=Makefile
DOMAIN:=@PACKAGE_NAME@

all: $(MOFILES)

$(MOFILES): $(POFILES)
	msgfmt -o $@ $<

clean:
	$(RM) $(MOFILES)

distclean: clean

$(MSGFILES): $(MOFILES)
	${INSTALL} -d ${DESTDIR}$(LOCALEDIR)/${@}/LC_MESSAGES
	${INSTALL_DATA} $< ${DESTDIR}$(LOCALEDIR)/${@}/LC_MESSAGES/$(DOMAIN).mo


install: $(MSGFILES)

uninstall:
	for po in $(POFILES); do \
	  $(RM) ${DESTDIR}$(LOCALEDIR)/${po%.po}/LC_MESSAGES/$(DOMAIN).mo; \
	done

