1 # Makefile for PO directory in any package using GNU gettext.
2 # Copyright (C) 1995-1997, 2000-2006 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
4 # This file can be copied and used freely without restrictions. It can
5 # be used in projects which are not available under the GNU General Public
6 # License but which still want to provide support for the GNU gettext
8 # Please note that the actual code of GNU gettext is covered by the GNU
9 # General Public License and is *not* in the public domain.
11 # Origin: gettext-0.15
15 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
21 top_srcdir = @top_srcdir@
25 exec_prefix = @exec_prefix@
26 datarootdir = @datarootdir@
28 localedir = @localedir@
29 gettextsrcdir = $(datadir)/gettext/po
32 INSTALL_DATA = @INSTALL_DATA@
33 mkinstalldirs = $(SHELL) @install_sh@ -d
37 GMSGFMT_no = @GMSGFMT@
38 GMSGFMT_yes = @GMSGFMT_015@
39 GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT))
42 MSGFMT_yes = @MSGFMT_015@
43 MSGFMT = $(MSGFMT_$(USE_MSGCTXT))
44 XGETTEXT_ = @XGETTEXT@
45 XGETTEXT_no = @XGETTEXT@
46 XGETTEXT_yes = @XGETTEXT_015@
47 XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT))
49 MSGMERGE_UPDATE = @MSGMERGE@ --update
50 MSGATTRIB = msgattrib --no-obsolete
57 UPDATEPOFILES = @UPDATEPOFILES@
58 DUMMYPOFILES = @DUMMYPOFILES@
59 DISTFILES.common = Makefile.in.in remove-potcdate.sin \
60 $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
61 DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \
62 $(POFILES) $(GMOFILES) \
63 $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
69 # Makevars gets inserted here. (Don't remove this line!)
72 .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
75 @echo "$(MSGFMT) -c -o $@ $<"; \
76 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
79 @lang=`echo $* | sed -e 's,.*/,,'`; \
80 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
81 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
82 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
85 sed -e '/^#/d' $< > t-$@
94 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
95 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
96 # we don't want to bother translators with empty POT files). We assume that
97 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
98 # In this case, stamp-po is a nop (i.e. a phony target).
100 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
101 # been loosely updated. Its purpose is that when a developer or translator
102 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
103 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
104 # invocations of "make" will do nothing. This timestamp would not be necessary
105 # if updating the $(CATALOGS) would always touch them; however, the rule for
106 # $(POFILES) has been designed to not touch files that don't need to be
108 stamp-po: $(srcdir)/$(DOMAIN).pot
109 test ! -f $(srcdir)/$(DOMAIN).pot || \
110 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
111 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
112 echo "touch stamp-po" && \
113 echo timestamp > stamp-poT && \
114 mv stamp-poT stamp-po; \
117 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
118 # otherwise packages like GCC can not be built if only parts of the source
119 # have been downloaded.
121 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
122 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
123 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
124 if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
125 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
127 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
129 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
130 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
131 --files-from=$(srcdir)/POTFILES.in \
132 --copyright-holder='$(COPYRIGHT_HOLDER)' \
133 --msgid-bugs-address="$$msgid_bugs_address"
134 test ! -f $(DOMAIN).po || { \
135 if test -f $(srcdir)/$(DOMAIN).pot; then \
136 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
137 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
138 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
139 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
141 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
142 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
145 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
149 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
150 # every "make" invocation, only create it when it is missing.
151 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
152 $(srcdir)/$(DOMAIN).pot:
153 $(MAKE) $(DOMAIN).pot-update
155 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
156 # Note that a PO file is not touched if it doesn't need to be changed.
157 $(POFILES): $(srcdir)/$(DOMAIN).pot
158 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
159 if test -f "$(srcdir)/$${lang}.po"; then \
160 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
161 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
162 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
163 echo "$(MSGATTRIB) -o $${lang}.po $${lang}.po"; \
164 $(MSGATTRIB) -o $${lang}.po $${lang}.po; \
166 $(MAKE) $${lang}.po-create; \
170 install: install-exec install-data
172 install-data: install-data-@USE_NLS@
173 if test "$(PACKAGE)" = "gettext-tools"; then \
174 $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
175 for file in $(DISTFILES.common) Makevars.template; do \
176 $(INSTALL_DATA) $(srcdir)/$$file \
177 $(DESTDIR)$(gettextsrcdir)/$$file; \
179 for file in Makevars; do \
180 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
186 install-data-yes: all
187 $(mkdir_p) $(DESTDIR)$(datadir)
188 @catalogs='$(CATALOGS)'; \
189 for cat in $$catalogs; do \
190 cat=`basename $$cat`; \
191 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
192 dir=$(localedir)/$$lang/LC_MESSAGES; \
193 $(mkdir_p) $(DESTDIR)$$dir; \
194 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
195 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
196 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
197 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
198 if test -n "$$lc"; then \
199 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
200 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
201 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
202 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
203 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
205 if test -f $$file; then \
206 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
209 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
211 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
214 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
215 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
218 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
219 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
220 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
221 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
222 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
227 install-strip: install
229 installdirs: installdirs-exec installdirs-data
231 installdirs-data: installdirs-data-@USE_NLS@
232 if test "$(PACKAGE)" = "gettext-tools"; then \
233 $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
238 installdirs-data-yes:
239 $(mkdir_p) $(DESTDIR)$(datadir)
240 @catalogs='$(CATALOGS)'; \
241 for cat in $$catalogs; do \
242 cat=`basename $$cat`; \
243 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
244 dir=$(localedir)/$$lang/LC_MESSAGES; \
245 $(mkdir_p) $(DESTDIR)$$dir; \
246 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
247 if test -n "$$lc"; then \
248 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
249 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
250 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
251 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
252 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
254 if test -f $$file; then \
255 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
258 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
260 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
263 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
264 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
271 # Define this as empty until I found a useful application.
274 uninstall: uninstall-exec uninstall-data
276 uninstall-data: uninstall-data-@USE_NLS@
277 if test "$(PACKAGE)" = "gettext-tools"; then \
278 for file in $(DISTFILES.common) Makevars.template; do \
279 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
286 catalogs='$(CATALOGS)'; \
287 for cat in $$catalogs; do \
288 cat=`basename $$cat`; \
289 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
290 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
291 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
297 info dvi ps pdf html tags TAGS ctags CTAGS ID:
300 rm -f remove-potcdate.sed
302 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
308 rm -f Makefile Makefile.in POTFILES *.mo
310 maintainer-clean: distclean
311 @echo "This command is intended for maintainers to use;"
312 @echo "it deletes files that may require special tools to rebuild."
313 rm -f stamp-po $(GMOFILES)
315 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
319 # This is a separate target because 'update-po' must be executed before.
320 dist2: stamp-po $(DISTFILES)
321 dists="$(DISTFILES)"; \
322 if test "$(PACKAGE)" = "gettext-tools"; then \
323 dists="$$dists Makevars.template"; \
325 if test -f $(srcdir)/$(DOMAIN).pot; then \
326 dists="$$dists $(DOMAIN).pot stamp-po"; \
328 if test -f $(srcdir)/ChangeLog; then \
329 dists="$$dists ChangeLog"; \
331 for i in 0 1 2 3 4 5 6 7 8 9; do \
332 if test -f $(srcdir)/ChangeLog.$$i; then \
333 dists="$$dists ChangeLog.$$i"; \
336 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
337 for file in $$dists; do \
338 if test -f $$file; then \
339 cp -p $$file $(distdir) || exit 1; \
341 cp -p $(srcdir)/$$file $(distdir) || exit 1; \
346 $(MAKE) $(DOMAIN).pot-update
347 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
350 # General rule for creating PO files.
353 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
354 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
357 # General rule for updating PO files.
360 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
361 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
364 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
365 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
367 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
368 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
369 rm -f $$tmpdir/$$lang.new.po; \
371 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
374 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
379 echo "msgmerge for $$lang.po failed!" 1>&2; \
380 rm -f $$tmpdir/$$lang.new.po; \
385 update-gmo: Makefile $(GMOFILES)
388 Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
390 && $(SHELL) ./config.status $(subdir)/$@.in po-directories
394 # Tell versions [3.59,3.63) of GNU make not to export all variables.
395 # Otherwise a system limit (for SysV at least) may be exceeded.