1 # $Header: /cvsroot/pgsql/src/nls-global.mk,v 1.3 2001/07/15 11:43:55 petere Exp $
3 # Common rules for Native Language Support (NLS)
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
9 # CATALOG_NAME -- name of the message catalog (xxx.po); probably
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
16 # That's all, the rest is done here, if --enable-nls was specified.
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.
24 # existence checked by Makefile.global; otherwise we won't get here
25 include $(srcdir)/nls.mk
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))
32 LANGUAGES = $(AVAIL_LANGUAGES)
35 PO_FILES = $(addsuffix .po, $(LANGUAGES))
36 MO_FILES = $(addsuffix .mo, $(LANGUAGES))
39 XGETTEXT += --foreign-user -ctranslator
45 distprep: $(srcdir)/$(CATALOG_NAME).pot
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 $<
55 $(srcdir)/$(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)
62 @echo "You don't have 'xgettext'."; exit 1
66 install-po: all-po installdirs-po
67 for lang in $(LANGUAGES); do \
68 $(INSTALL_DATA) $$lang.mo $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(CATALOG_NAME).mo || exit 1; \
72 $(mkinstalldirs) $(foreach lang, $(LANGUAGES), $(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES)
75 rm -f $(foreach lang, $(LANGUAGES), $(DESTDIR)$(localedir)/$(lang)/LC_MESSAGES/$(CATALOG_NAME).mo)
80 @rm -f $(addsuffix .po.old, $(AVAIL_LANGUAGES))
82 maintainer-clean-po: clean-po
83 rm -f $(srcdir)/$(CATALOG_NAME).pot
86 maintainer-check-po: $(PO_FILES)
88 $(MSGFMT) -c -v -o /dev/null $$file || exit 1; \
92 init-po: $(srcdir)/$(CATALOG_NAME).pot
95 update-po: $(srcdir)/$(CATALOG_NAME).pot
97 # XXX should be $(LANGUAGES)?
98 @for lang in $(AVAIL_LANGUAGES); do \
99 echo "merging $$lang:"; \
100 if $(MSGMERGE) $(srcdir)/$$lang.po $< -o $$lang.po.new; \
102 mv $(srcdir)/$$lang.po $$lang.po.old; \
103 mv $$lang.po.new $(srcdir)/$$lang.po; \
105 echo "msgmerge for $$lang failed"; \
106 rm -f $$lang.po.new; \
110 @echo "You don't have 'msgmerge'." ; exit 1
116 installdirs: installdirs-po
117 uninstall: uninstall-po
118 clean distclean: clean-po
119 maintainer-clean: maintainer-clean-po
120 maintainer-check: maintainer-check-po
122 .PHONY: all-po install-po installdirs-po uninstall-po clean-po \
123 maintainer-clean-po maintainer-check-po init-po update-po