1 # Makefile for PO directory in any package using GNU gettext.
2 # Copyright (C) 1995-1997, 2000-2005 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.14.4
15 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
21 top_srcdir = @top_srcdir@
22 top_builddir = @top_builddir@
26 exec_prefix = @exec_prefix@
28 datarootdir = @datarootdir@
29 localedir = $(datadir)/locale
30 gettextsrcdir = $(datadir)/gettext/po
33 INSTALL_DATA = @INSTALL_DATA@
34 MKINSTALLDIRS = @MKINSTALLDIRS@
35 mkinstalldirs = $(SHELL) $(MKINSTALLDIRS)
41 MSGMERGE_UPDATE = @MSGMERGE@ --update
48 UPDATEPOFILES = @UPDATEPOFILES@
49 DUMMYPOFILES = @DUMMYPOFILES@
50 DISTFILES.common = Makefile.in.in remove-potcdate.sin \
51 $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
52 DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \
53 $(POFILES) $(GMOFILES) \
54 $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
60 # Makevars gets inserted here. (Don't remove this line!)
63 .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
66 @echo "$(MSGFMT) -c -o $@ $<"; \
67 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
70 @lang=`echo $* | sed -e 's,.*/,,'`; \
71 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
72 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
73 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
76 sed -e '/^#/d' $< > t-$@
85 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
86 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
87 # we don't want to bother translators with empty POT files). We assume that
88 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
89 # In this case, stamp-po is a nop (i.e. a phony target).
91 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
92 # been loosely updated. Its purpose is that when a developer or translator
93 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
94 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
95 # invocations of "make" will do nothing. This timestamp would not be necessary
96 # if updating the $(CATALOGS) would always touch them; however, the rule for
97 # $(POFILES) has been designed to not touch files that don't need to be
99 stamp-po: $(srcdir)/$(DOMAIN).pot
100 test ! -f $(srcdir)/$(DOMAIN).pot || \
101 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
102 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
103 echo "touch stamp-po" && \
104 echo timestamp > stamp-poT && \
105 mv stamp-poT stamp-po; \
108 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
109 # otherwise packages like GCC can not be built if only parts of the source
110 # have been downloaded.
112 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
113 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
114 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
115 if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
116 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
118 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
120 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
121 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
122 --files-from=$(srcdir)/POTFILES.in \
123 --copyright-holder='$(COPYRIGHT_HOLDER)' \
124 --msgid-bugs-address="$$msgid_bugs_address"
125 test ! -f $(DOMAIN).po || { \
126 if test -f $(srcdir)/$(DOMAIN).pot; then \
127 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
128 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
129 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
130 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
132 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
133 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
136 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
140 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
141 # every "make" invocation, only create it when it is missing.
142 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
143 $(srcdir)/$(DOMAIN).pot:
144 $(MAKE) $(DOMAIN).pot-update
146 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
147 # Note that a PO file is not touched if it doesn't need to be changed.
148 $(POFILES): $(srcdir)/$(DOMAIN).pot
149 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
150 if test -f "$(srcdir)/$${lang}.po"; then \
151 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
152 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
153 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
155 $(MAKE) $${lang}.po-create; \
159 install: install-exec install-data
161 install-data: install-data-@USE_NLS@
162 if test "$(PACKAGE)" = "gettext-tools"; then \
163 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
164 for file in $(DISTFILES.common) Makevars.template; do \
165 $(INSTALL_DATA) $(srcdir)/$$file \
166 $(DESTDIR)$(gettextsrcdir)/$$file; \
168 for file in Makevars; do \
169 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
175 install-data-yes: all
176 $(mkinstalldirs) $(DESTDIR)$(datadir)
177 @catalogs='$(CATALOGS)'; \
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 $(mkinstalldirs) $(DESTDIR)$$dir; \
183 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
184 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
185 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
186 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
187 if test -n "$$lc"; then \
188 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
189 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
190 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
191 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
192 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
194 if test -f $$file; then \
195 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
198 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
200 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
203 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
204 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
207 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
208 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
209 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
210 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
211 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
216 install-strip: install
218 installdirs: installdirs-exec installdirs-data
220 installdirs-data: installdirs-data-@USE_NLS@
221 if test "$(PACKAGE)" = "gettext-tools"; then \
222 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
227 installdirs-data-yes:
228 $(mkinstalldirs) $(DESTDIR)$(datadir)
229 @catalogs='$(CATALOGS)'; \
230 for cat in $$catalogs; do \
231 cat=`basename $$cat`; \
232 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
233 dir=$(localedir)/$$lang/LC_MESSAGES; \
234 $(mkinstalldirs) $(DESTDIR)$$dir; \
235 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
236 if test -n "$$lc"; then \
237 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
238 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
239 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
240 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
241 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
243 if test -f $$file; then \
244 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
247 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
249 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
252 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
253 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
260 # Define this as empty until I found a useful application.
263 uninstall: uninstall-exec uninstall-data
265 uninstall-data: uninstall-data-@USE_NLS@
266 if test "$(PACKAGE)" = "gettext-tools"; then \
267 for file in $(DISTFILES.common) Makevars.template; do \
268 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
275 catalogs='$(CATALOGS)'; \
276 for cat in $$catalogs; do \
277 cat=`basename $$cat`; \
278 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
279 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
280 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
286 info dvi ps pdf html tags TAGS ctags CTAGS ID:
289 rm -f remove-potcdate.sed
291 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
297 rm -f Makefile Makefile.in POTFILES *.mo
299 maintainer-clean: distclean
300 @echo "This command is intended for maintainers to use;"
301 @echo "it deletes files that may require special tools to rebuild."
302 rm -f stamp-po $(GMOFILES)
304 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
308 # This is a separate target because 'update-po' must be executed before.
309 dist2: stamp-po $(DISTFILES)
310 dists="$(DISTFILES)"; \
311 if test "$(PACKAGE)" = "gettext-tools"; then \
312 dists="$$dists Makevars.template"; \
314 if test -f $(srcdir)/$(DOMAIN).pot; then \
315 dists="$$dists $(DOMAIN).pot stamp-po"; \
317 if test -f $(srcdir)/ChangeLog; then \
318 dists="$$dists ChangeLog"; \
320 for i in 0 1 2 3 4 5 6 7 8 9; do \
321 if test -f $(srcdir)/ChangeLog.$$i; then \
322 dists="$$dists ChangeLog.$$i"; \
325 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
326 for file in $$dists; do \
327 if test -f $$file; then \
328 cp -p $$file $(distdir) || exit 1; \
330 cp -p $(srcdir)/$$file $(distdir) || exit 1; \
335 $(MAKE) $(DOMAIN).pot-update
336 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
339 # General rule for creating PO files.
342 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
343 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
346 # General rule for updating PO files.
349 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
350 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
353 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
354 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
356 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
357 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
358 rm -f $$tmpdir/$$lang.new.po; \
360 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
363 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
368 echo "msgmerge for $$lang.po failed!" 1>&2; \
369 rm -f $$tmpdir/$$lang.new.po; \
374 update-gmo: Makefile $(GMOFILES)
377 Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
379 && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
380 $(SHELL) ./config.status
387 echo "# List of source files containing translatable strings." > POTFILES.in
388 echo "# To generate this file, type 'make gen-potfiles'" >> POTFILES.in
389 cd .. && find -name "*.c" >> po/POTFILES.in
390 cd .. && find -name "*.h" >> po/POTFILES.in
391 cd .. && find -name "*.cpp" >> po/POTFILES.in
393 # Tell versions [3.59,3.63) of GNU make not to export all variables.
394 # Otherwise a system limit (for SysV at least) may be exceeded.