]> granicus.if.org Git - postgresql/blob - src/nls-global.mk
Add missing dependency and fix thinko.
[postgresql] / src / nls-global.mk
1 # $Header: /cvsroot/pgsql/src/nls-global.mk,v 1.2 2001/06/30 21:58:06 petere Exp $
2
3 # Common rules for Native Language Support (NLS)
4 #
5 # If some subdirectory of the source tree wants to provide NLS, it
6 # needs to contain a file 'nls.mk' with the following make variable
7 # assignments:
8 #
9 # CATALOG_NAME          -- name of the message catalog (xxx.po); probably
10 #                          name of the program
11 # AVAIL_LANGUAGES       -- list of languages that are provided/supported
12 # GETTEXT_FILES         -- list of source files that contain message strings
13 # GETTEXT_TRIGGERS      -- (optional) list of functions that contain
14 #                          translatable strings
15 #
16 # That's all, the rest is done here, if --enable-nls was specified.
17 #
18 # The only user-visible targets here are 'init-po', to make an initial
19 # "blank" catalog from program sources, and 'update-po', which is to
20 # be called if the messages in the program source have changed, in
21 # order to merge the changes into the existing .po files.
22
23
24 # existence checked by Makefile.global; otherwise we won't get here
25 include $(srcdir)/nls.mk
26
27 # If user specified the languages he wants in --enable-nls=LANGUAGES,
28 # filter out the rest.  Else use all available ones.
29 ifdef WANTED_LANGUAGES
30 LANGUAGES = $(filter $(WANTED_LANGUAGES), $(AVAIL_LANGUAGES))
31 else
32 LANGUAGES = $(AVAIL_LANGUAGES)
33 endif
34
35 PO_FILES = $(addsuffix .po, $(LANGUAGES))
36 MO_FILES = $(addsuffix .mo, $(LANGUAGES))
37
38 ifdef XGETTEXT
39 XGETTEXT += --foreign-user -ctranslator
40 endif
41
42
43 all-po: $(MO_FILES)
44
45 distprep: $(srcdir)/$(CATALOG_NAME).pot
46
47 %.mo: %.po
48         $(MSGFMT) -o $@ $<
49
50 ifdef XGETTEXT
51 ifeq ($(word 1,$(GETTEXT_FILES)),+)
52 $(srcdir)/$(CATALOG_NAME).pot: $(word 2, $(GETTEXT_FILES))
53         $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) -f $<
54 else
55 $(srcdir)/$(CATALOG_NAME).pot: $(GETTEXT_FILES)
56         $(XGETTEXT) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $^
57 endif
58         mv messages.po $@
59 else # not XGETTEXT
60         @echo "You don't have 'xgettext'."; exit 1
61 endif # not XGETTEXT
62
63
64 install-po: all-po installdirs-po
65         for lang in $(LANGUAGES); do \
66           $(INSTALL_DATA) $$lang.mo $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(CATALOG_NAME).mo || exit 1; \
67         done
68
69 installdirs-po:
70         $(mkinstalldirs) $(foreach lang, $(LANGUAGES), $(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES)
71
72 uninstall-po:
73         rm -f $(foreach lang, $(LANGUAGES), $(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES/$(CATALOG_NAME).mo)
74
75
76 clean-po:
77         rm -f $(MO_FILES)
78         @rm -f $(addsuffix .po.old, $(AVAIL_LANGUAGES))
79
80 maintainer-clean-po: clean-po
81         rm -f $(srcdir)/$(CATALOG_NAME).pot
82
83
84 maintainer-check-po: $(PO_FILES)
85         for file in $^; do \
86           $(MSGFMT) -v -o /dev/null $$file || exit 1; \
87         done
88
89
90 init-po: $(srcdir)/$(CATALOG_NAME).pot
91
92
93 update-po: $(srcdir)/$(CATALOG_NAME).pot
94 ifdef MSGMERGE
95 #       XXX  should be $(LANGUAGES)?
96         @for lang in $(AVAIL_LANGUAGES); do \
97           echo "merging $$lang:"; \
98           if $(MSGMERGE) $(srcdir)/$$lang.po $< -o $$lang.po.new; \
99           then \
100             mv $(srcdir)/$$lang.po $$lang.po.old; \
101             mv $$lang.po.new $(srcdir)/$$lang.po; \
102           else \
103             echo "msgmerge for $$lang failed"; \
104             rm -f $$lang.po.new; \
105           fi; \
106         done
107 else
108         @echo "You don't have 'msgmerge'." ; exit 1
109 endif
110
111
112 all: all-po
113 install: install-po
114 installdirs: installdirs-po
115 uninstall: uninstall-po
116 clean distclean: clean-po
117 maintainer-clean: maintainer-clean-po
118 maintainer-check: maintainer-check-po
119
120 .PHONY: all-po install-po installdirs-po uninstall-po clean-po \
121         maintainer-clean-po maintainer-check-po init-po update-po