1# Makefile for various po files.
2
3srcdir = .
4libdir = ../lib
5
6include PACKAGE
7
8#CATALOGS = $(addsuffix .po, LINGUAS)
9CATALOGS = $(LINGUAS)
10MO_FILES = $(addsuffix .mo, $(LINGUAS))
11
12MSGMERGE = msgmerge
13MSGFMT   = msgfmt
14XGETTEXT = xgettext
15CATOBJEXT = .po
16
17default: help
18
19all: $(TEXTDOMAIN).pot update-po update-mo install
20
21help:
22	@echo "Available targets:"
23	@echo "  pot                       - remake master catalog"
24	@echo "  update-po                 - merge po files"
25	@echo "  update-mo                 - regenerate mo files"
26	@echo "  install                   - install mo files"
27	@echo "  all			   - all of the above"
28
29POTFILES = $(srcdir)/POTFILES.in \
30	$(shell cat $(srcdir)/POTFILES.in)
31
32pot: $(TEXTDOMAIN).pot
33
34clean:
35	rm -f *~ *.bak *.mo
36
37# FIXME: The parameter --from-code is only needed if your sources contain
38# any 8 bit data (even in comments).  UTF-8 is only a guess here, but it
39# will at least accept any 8 bit data.
40#
41# The parameter "--language=perl" is not strictly needed because the
42# source language of all our files will be auto-detected by xgettext
43# by their filename extension.  You should even avoid this parameter
44# if you want to extract strings from multiple source languages.
45$(TEXTDOMAIN).pot: $(POTFILES)
46	$(XGETTEXT) --output=$(srcdir)/$(TEXTDOMAIN).pox --from-code=utf-8 \
47		--add-comments=TRANSLATORS: --files-from=$(srcdir)/POTFILES.in \
48		--copyright-holder="$(COPYRIGHT_HOLDER)" \
49		--msgid-bugs-address="$(MSGID_BUGS_ADDRESS)" \
50		--keyword --keyword='$$__' --keyword=__ --keyword=__x \
51		--keyword=__n:1,2 --keyword=__nx:1,2 --keyword=__xn:1,2 \
52		--keyword=N__ --language=perl && \
53	rm -f $@ && mv $(TEXTDOMAIN).pox $@
54
55install: $(MO_FILES)
56	cd $(srcdir); \
57	targetdir='$(libdir)/LocaleData'; \
58	languages='$(LINGUAS)'; \
59	for lang in $$languages; do \
60		mkdir -p "$$targetdir/$$lang/LC_MESSAGES" || exit 1; \
61		dest="$$targetdir/$$lang/LC_MESSAGES/$(TEXTDOMAIN).mo"; \
62		cat="$$lang.mo"; \
63		echo "installing $$cat as $$dest"; \
64		cp -f $$cat $$dest && chmod 644 $$dest || exit 1; \
65	done
66
67update-mo: $(MO_FILES)
68
69update-po:
70	$(MAKE) $(TEXTDOMAIN).pot
71	cd $(srcdir); \
72        catalogs='$(CATALOGS)'; \
73        for cat in $$catalogs; do \
74          cat=`basename $$cat`; \
75          lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
76          mv $$lang.po $$lang.old.po; \
77          echo "$$lang:"; \
78          if $(MSGMERGE) $$lang.old.po $(TEXTDOMAIN).pot -o $$lang.po; then \
79            rm -f $$lang.old.po; \
80          else \
81            echo "msgmerge for $$cat failed!"; \
82            rm -f $$lang.po; \
83            mv $$lang.old.po $$lang.po; \
84          fi; \
85        done
86
87.SUFFIXES:
88.SUFFIXES: .po .mo
89
90.po.mo:
91	$(MSGFMT) --check --statistics --verbose -o $@ $<
92
93