]> granicus.if.org Git - postgresql/blob - src/nls-global.mk
Don't try to free executor state of an InitPlan early --- this breaks
[postgresql] / src / nls-global.mk
1 # $Header: /cvsroot/pgsql/src/nls-global.mk,v 1.7 2002/09/02 22:19:42 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 = $(addprefix po/, $(addsuffix .po, $(LANGUAGES)))
36 MO_FILES = $(addprefix po/, $(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)/po/$(CATALOG_NAME).pot
46
47 %.mo: %.po
48         $(MSGFMT) -o $@ $<
49
50 ifdef XGETTEXT
51 ifeq ($(word 1,$(GETTEXT_FILES)),+)
52 $(srcdir)/po/$(CATALOG_NAME).pot: $(word 2, $(GETTEXT_FILES))
53         $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) -f $<
54 else
55 $(srcdir)/po/$(CATALOG_NAME).pot: $(GETTEXT_FILES)
56 # Change to srcdir explicitly, don't rely on $^.  That way we get
57 # consistent #: file references in the po files.
58         $(XGETTEXT) -D $(srcdir) -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(GETTEXT_FILES)
59 endif
60         @$(mkinstalldirs) $(dir $@)
61         mv messages.po $@
62 else # not XGETTEXT
63         @echo "You don't have 'xgettext'."; exit 1
64 endif # not XGETTEXT
65
66
67 install-po: all-po installdirs-po
68 ifneq (,$(LANGUAGES))
69         for lang in $(LANGUAGES); do \
70           $(INSTALL_DATA) po/$$lang.mo $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(CATALOG_NAME).mo || exit 1; \
71         done
72 endif
73
74 installdirs-po:
75         $(mkinstalldirs) $(foreach lang, $(LANGUAGES), $(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES)
76
77 uninstall-po:
78         rm -f $(foreach lang, $(LANGUAGES), $(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES/$(CATALOG_NAME).mo)
79
80
81 clean-po:
82         rm -f $(MO_FILES)
83         @rm -f $(addsuffix .old, $(PO_FILES))
84
85 maintainer-clean-po: clean-po
86         rm -f $(srcdir)/po/$(CATALOG_NAME).pot
87
88
89 maintainer-check-po: $(PO_FILES)
90         for file in $^; do \
91           $(MSGFMT) -c -v -o /dev/null $$file || exit 1; \
92         done
93
94
95 init-po: $(srcdir)/po/$(CATALOG_NAME).pot
96
97
98 update-po: $(srcdir)/po/$(CATALOG_NAME).pot
99 ifdef MSGMERGE
100         @for lang in $(LANGUAGES); do \
101           echo "merging $$lang:"; \
102           if $(MSGMERGE) $(srcdir)/po/$$lang.po $< -o po/$$lang.po.new; \
103           then \
104             mv $(srcdir)/po/$$lang.po po/$$lang.po.old; \
105             mv po/$$lang.po.new $(srcdir)/po/$$lang.po; \
106           else \
107             echo "msgmerge for $$lang failed"; \
108             rm -f po/$$lang.po.new; \
109           fi; \
110         done
111 else
112         @echo "You don't have 'msgmerge'." ; exit 1
113 endif
114
115
116 all: all-po
117 install: install-po
118 installdirs: installdirs-po
119 uninstall: uninstall-po
120 clean distclean: clean-po
121 maintainer-clean: maintainer-clean-po
122 maintainer-check: maintainer-check-po
123
124 .PHONY: all-po install-po installdirs-po uninstall-po clean-po \
125         maintainer-clean-po maintainer-check-po init-po update-po
126 .SILENT: installdirs-po