#
# Makefile for the trans project
#

all:

PROJECT = translations
DATE    = $(shell date +"%y%m%d")
ARCHIVE = $(PROJECT)-$(DATE).tar.gz
CVSTAG  = trans-$(DATE)
FILES   = $(wildcard */*.po) $(wildcard */*.pot)

BASE    = $(PROJECT)-$(DATE).base.tar.gz
TMPREPO = $(patsubst %.po,%,$(notdir $(wildcard */*.po)))
REPORTS = $(addsuffix .report, $(filter-out C, $(sort $(TMPREPO))))

# gettext issues
MSGMERGE        = msgmerge -v
MSGFMT          = msgfmt -v --statistics

tar:
       @rm -f $(ARCHIVE)
       tar czf $(ARCHIVE) $(FILES)
       @echo Archive is in $(ARCHIVE)

base: $(wildcard */*.pot)
       @rm -f $(BASE)
       tar czf $(BASE) $^
       @echo Base is in $(BASE)

clean:
       @rm -f *~ */*~ $(PROJECT)-*.tar.gz
       @rm -f *.report

tag:
       @cvs tag -F $(CVSTAG)

report: $(REPORTS)

%.report: phony.po
       @echo "Making $@..."
       @for n in $(wildcard */$(basename $@).po) ; do \
           echo "Checking $$n for errors..." ; \
           if [ -f $$n ] ; then $(MSGFMT) -o /dev/null $$n ; fi ; \
           echo "Done checking $$n." ; \
           echo ; \
       done > $@ 2>&1

refresh:
       @for dir in $(dir $(wildcard */*.pot)) ; do \
               $(MAKE) refresh-po -C $$dir ; \
       done

PHONY: phony.po