Debian Codegraph @

po/Makefile

raw
1 # Makefile for various po files.
2
3 srcdir = .
4 libdir = ../lib
5
6 CATALOGS = $(LINGUAS)
7 MO_FILES = $(addsuffix .gmo, $(LINGUAS))
8
9 MSGMERGE = msgmerge
10 MSGFMT = msgfmt
11 XGETTEXT = xgettext
12 CATOBJEXT = .po
13
14 include PACKAGE
15
16 TD = $(strip $(TEXTDOMAIN))
17
18 default: help
19
20 all: $(TD).pot update-po update-mo install
21
22 help:
23 @echo "Available targets:"
24 @echo " pot - remake master catalog"
25 @echo " update-po - merge po files"
26 @echo " update-mo - regenerate mo files"
27 @echo " install - install mo files"
28 @echo " all - all of the above"
29
30 POTFILES = $(srcdir)/POTFILES \
31 $(shell cat $(srcdir)/POTFILES)
32
33 pot: $(TD).pot
34
35 clean:
36 rm -f *~ *.bak *.gmo
37
38 $(TD).pot: $(POTFILES)
39 $(XGETTEXT) --output=$(srcdir)/$(TD).pox --from-code=utf-8 \
40 --add-comments=TRANSLATORS: --files-from=$(srcdir)/POTFILES \
41 --language=Perl \
42 --copyright-holder="$(COPYRIGHT_HOLDER)" \
43 --msgid-bugs-address="$(MSGID_BUGS_ADDRESS)" \
44 --keyword --keyword='$$__' --keyword=__ --keyword=__x \
45 --keyword=__n:1,2 --keyword=__nx:1,2 --keyword=__xn:1,2 \
46 --keyword=__p:1c,2 --keyword=__np:1c,2,3 \
47 --keyword=__npx:1c,2,3 --keyword=N__ --keyword=N__n:1,2 \
48 --keyword=N__p:1c,2 --keyword=N__np:1c,2,3 --keyword=%__ && \
49 rm -f $@ && mv $(TD).pox $@
50
51 install: $(MO_FILES)
52 cd $(srcdir); \
53 targetdir='$(libdir)/LocaleData'; \
54 languages='$(LINGUAS)'; \
55 for lang in $$languages; do \
56 mkdir -p "$$targetdir/$$lang/LC_MESSAGES" || exit 1; \
57 dest="$$targetdir/$$lang/LC_MESSAGES/$(TD).mo"; \
58 cat="$$lang.gmo"; \
59 echo "installing $$cat as $$dest"; \
60 cp -f $$cat $$dest && chmod 644 $$dest || exit 1; \
61 done
62
63 update-mo: $(MO_FILES)
64
65 update-po:
66 $(MAKE) $(TD).pot
67 cd $(srcdir); \
68 catalogs='$(CATALOGS)'; \
69 for cat in $$catalogs; do \
70 cat=`basename $$cat`; \
71 lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
72 mv $$lang.po $$lang.old.po; \
73 echo "$$lang:"; \
74 if $(MSGMERGE) $$lang.old.po $(TD).pot -o $$lang.po; then \
75 rm -f $$lang.old.po; \
76 else \
77 echo "msgmerge for $$cat failed!"; \
78 rm -f $$lang.po; \
79 mv $$lang.old.po $$lang.po; \
80 fi; \
81 done
82
83 .SUFFIXES:
84 .SUFFIXES: .po .gmo
85
86 .po.gmo:
87 $(MSGFMT) --check --statistics --verbose -o $@ $<
88