1 # Gettext stuff; based on the contents of the Makefile.in.in file
2 # distributed with GNU Gettext.
4 # The original copyright notice follows:
6 # Makefile for PO directory in any package using GNU gettext.
7 # Copyright (C) 1995-1997, 2000-2007 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
9 # This file can be copied and used freely without restrictions. It can
10 # be used in projects which are not available under the GNU General Public
11 # License but which still want to provide support for the GNU gettext
13 # Please note that the actual code of GNU gettext is covered by the GNU
14 # General Public License and is *not* in the public domain.
16 # Origin: gettext-0.17
18 DOMAIN += $(GETTEXT_PACKAGE)
20 MSGFMT := $(shell which msgfmt)
22 XGETTEXT := $(shell which xgettext)
24 MSGMERGE := $(shell which msgmerge)
26 MSGMERGE_UPDATE := $(MSGMERGE) --update
28 POFILES += $(shell ls $(srcdir)/Source/WebKit/gtk/po/*.po)
30 MOFILES += $(shell echo $(POFILES) | tr ' ' '\n' | sed "s,^$(srcdir)/,,g" | sed 's/\.po/.mo/g')
33 test -d Source/WebKit/gtk/po/ || mkdir -p Source/WebKit/gtk/po/
34 @echo "$(MSGFMT) -c -o $@ $<"; \
37 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
38 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
39 # we don't want to bother translators with empty POT files). We assume that
40 # LINGUAS is empty in this case, i.e. $(POFILES) and $(MOFILES) are empty.
41 # In this case, stamp-po is a nop (i.e. a phony target).
43 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
44 # been loosely updated. Its purpose is that when a developer or translator
45 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
46 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
47 # invocations of "make" will do nothing. This timestamp would not be necessary
48 # if updating the $(CATALOGS) would always touch them; however, the rule for
49 # $(POFILES) has been designed to not touch files that don't need to be
51 stamp-po: $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot $(MOFILES)
52 test ! -d $(top_builddir)/Source/WebKit/gtk/po || \
53 mkdir -p $(top_builddir)/Source/WebKit/gtk/po
54 test ! -f $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot || \
55 test -z "$(MOFILES)" || $(MAKE) $(MOFILES)
56 @test ! -f $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot || { \
57 echo "touch stamp-po" && \
58 echo timestamp > stamp-poT && \
59 mv stamp-poT stamp-po; \
62 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
63 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
64 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/Source/WebKit/gtk/po/POTFILES
65 test -d Source/WebKit/gtk/po/ || mkdir -p Source/WebKit/gtk/po/
67 if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
68 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
70 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
72 case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
73 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
74 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(srcdir) \
75 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
76 --files-from=$(srcdir)/Source/WebKit/gtk/po/POTFILES \
77 --copyright-holder='$(COPYRIGHT_HOLDER)' \
78 --msgid-bugs-address="$$msgid_bugs_address" \
79 --keyword=_ --keyword=N_ -o $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot \
82 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(srcdir) \
83 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
84 --files-from=$(srcdir)/Source/WebKit/gtk/po/POTFILES \
85 --copyright-holder='$(COPYRIGHT_HOLDER)' \
86 --package-name="$${package_gnu}@PACKAGE@" \
87 --package-version='@VERSION@' \
88 --msgid-bugs-address="$$msgid_bugs_address" \
89 --keyword=_ --keyword=N_ -o $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot \
93 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
94 # every "make" invocation, only create it when it is missing.
95 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
96 $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot:
97 $(MAKE) $(DOMAIN).pot-update
99 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
100 # Note that a PO file is not touched if it doesn't need to be changed.
101 update-po-files: $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot
102 @for pofile in $(POFILES); do \
103 lang=`echo $$pofile | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
104 if test -f "$(srcdir)/Source/WebKit/gtk/po/$${lang}.po"; then \
105 echo "$${cdcmd}$(MSGMERGE_UPDATE) $(top_srcdir)/Source/WebKit/gtk/po/$${lang}.po $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot"; \
106 $(MSGMERGE_UPDATE) $(top_srcdir)/Source/WebKit/gtk/po/$${lang}.po $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot; \
108 $(MAKE) $${lang}.po-create; \
112 update-po: GNUmakefile
113 $(MAKE) $(DOMAIN).pot-update
114 $(MAKE) update-po-files
118 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
119 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
124 $(top_builddir)/stamp-po
126 MAINTAINERCLEANFILES += \
128 $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot
132 $(top_builddir)/Source/WebKit/gtk/po/$(DOMAIN).pot
134 po-install-data-local: all
135 $(mkdir_p) $(DESTDIR)$(datadir)
136 @catalogs='$(MOFILES)'; \
137 for cat in $$catalogs; do \
138 cat=`basename $$cat`; \
139 lang=`echo $$cat | sed -e 's/\.mo$$//'`; \
140 dir=$(localedir)/$$lang/LC_MESSAGES; \
141 $(mkdir_p) $(DESTDIR)$$dir; \
142 if test -r Source/WebKit/gtk/po/$$cat; then realcat=Source/WebKit/gtk/po/$$cat; else realcat=$(srcdir)/$$cat; fi; \
143 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
144 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
145 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
146 if test -n "$$lc"; then \
147 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
148 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
149 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
150 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
151 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
153 if test -f $$file; then \
154 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
157 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
159 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
162 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
163 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
166 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
167 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
168 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
169 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
170 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
175 po-installdirs-data-local:
176 $(mkdir_p) $(DESTDIR)$(datadir)
177 @catalogs='$(MOFILES)'; \
178 for cat in $$catalogs; do \
179 cat=`basename $$cat`; \
180 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
181 dir=$(localedir)/$$lang/LC_MESSAGES; \
182 $(mkdir_p) $(DESTDIR)$$dir; \
183 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
184 if test -n "$$lc"; then \
185 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
186 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
187 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
188 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
189 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
191 if test -f $$file; then \
192 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
195 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
197 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
200 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
201 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
209 catalogs='$(MOFILES)'; \
210 for cat in $$catalogs; do \
211 cat=`basename $$cat`; \
212 lang=`echo $$cat | sed -e 's/\.mo$$//'`; \
213 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
214 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \