1 # Makefile for PO directory in any package using GNU gettext.
2 # Copyright (C) 1995-1997, 2000-2004 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
20 top_srcdir = @top_srcdir@
24 exec_prefix = @exec_prefix@
25 datarootdir = @datarootdir@
27 localedir = $(datadir)/locale
28 gettextsrcdir = $(datadir)/gettext/po
31 INSTALL_DATA = @INSTALL_DATA@
32 MKINSTALLDIRS = @MKINSTALLDIRS@
33 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 $(DOMAIN).pot stamp-po \
53 $(POFILES) $(GMOFILES) \
54 $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
56 POTFILE_IN_DEPS = $(shell find $(top_srcdir)/src -name Makefile.am)
62 # Makevars gets inserted here. (Don't remove this line!)
65 .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
68 @echo "$(MSGFMT) -c -o $@ $<"; \
69 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
72 @lang=`echo $* | sed -e 's,.*/,,'`; \
73 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
74 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
75 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
78 sed -e '/^#/d' $< > t-$@
87 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
88 # been loosely updated. Its purpose is that when a developer or translator
89 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
90 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
91 # invocations of "make" will do nothing. This timestamp would not be necessary
92 # if updating the $(CATALOGS) would always touch them; however, the rule for
93 # $(POFILES) has been designed to not touch files that don't need to be
95 stamp-po: $(srcdir)/$(DOMAIN).pot
96 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
97 @echo "touch stamp-po"
98 @echo timestamp > stamp-poT
99 @mv stamp-poT stamp-po
101 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
102 # otherwise packages like GCC can not be built if only parts of the source
103 # have been downloaded.
105 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
106 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
107 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
109 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
110 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
111 --files-from=$(srcdir)/POTFILES.in \
112 --copyright-holder='$(COPYRIGHT_HOLDER)' \
113 --msgid-bugs-address='$(MSGID_BUGS_ADDRESS)'
114 test ! -f $(DOMAIN).po || { \
115 if test -f $(srcdir)/$(DOMAIN).pot; then \
116 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
117 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
118 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
119 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
121 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
122 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
125 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
129 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
130 # every "make" invocation, only create it when it is missing.
131 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
132 $(srcdir)/$(DOMAIN).pot:
133 $(MAKE) $(DOMAIN).pot-update
135 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
136 # Note that a PO file is not touched if it doesn't need to be changed.
137 $(POFILES): $(srcdir)/$(DOMAIN).pot
138 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
139 if test -f "$(srcdir)/$${lang}.po"; then \
140 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
141 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
142 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
144 $(MAKE) $${lang}.po-create; \
148 install: install-exec install-data
150 install-data: install-data-@USE_NLS@
151 if test "$(PACKAGE)" = "gettext-tools"; then \
152 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
153 for file in $(DISTFILES.common) Makevars.template; do \
154 $(INSTALL_DATA) $(srcdir)/$$file \
155 $(DESTDIR)$(gettextsrcdir)/$$file; \
157 for file in Makevars; do \
158 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
164 install-data-yes: all
165 $(mkinstalldirs) $(DESTDIR)$(datadir)
166 @catalogs='$(CATALOGS)'; \
167 for cat in $$catalogs; do \
168 cat=`basename $$cat`; \
169 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
170 dir=$(localedir)/$$lang/LC_MESSAGES; \
171 $(mkinstalldirs) $(DESTDIR)$$dir; \
172 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
173 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
174 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
175 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
176 if test -n "$$lc"; then \
177 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
178 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
179 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
180 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
181 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
183 if test -f $$file; then \
184 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
187 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
189 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
192 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
193 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
196 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
197 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
198 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
199 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
200 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
205 install-strip: install
207 installdirs: installdirs-exec installdirs-data
209 installdirs-data: installdirs-data-@USE_NLS@
210 if test "$(PACKAGE)" = "gettext-tools"; then \
211 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
216 installdirs-data-yes:
217 $(mkinstalldirs) $(DESTDIR)$(datadir)
218 @catalogs='$(CATALOGS)'; \
219 for cat in $$catalogs; do \
220 cat=`basename $$cat`; \
221 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
222 dir=$(localedir)/$$lang/LC_MESSAGES; \
223 $(mkinstalldirs) $(DESTDIR)$$dir; \
224 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
225 if test -n "$$lc"; then \
226 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
227 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
228 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
229 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
230 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
232 if test -f $$file; then \
233 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
236 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
238 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
241 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
242 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
249 # Define this as empty until I found a useful application.
252 uninstall: uninstall-exec uninstall-data
254 uninstall-data: uninstall-data-@USE_NLS@
255 if test "$(PACKAGE)" = "gettext-tools"; then \
256 for file in $(DISTFILES.common) Makevars.template; do \
257 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
264 catalogs='$(CATALOGS)'; \
265 for cat in $$catalogs; do \
266 cat=`basename $$cat`; \
267 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
268 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
269 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
275 info dvi ps pdf html tags TAGS ctags CTAGS ID:
278 rm -f remove-potcdate.sed
280 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
286 rm -f Makefile Makefile.in POTFILES *.mo
288 maintainer-clean: distclean
289 @echo "This command is intended for maintainers to use;"
290 @echo "it deletes files that may require special tools to rebuild."
291 rm -f stamp-po $(GMOFILES)
293 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
297 # This is a separate target because 'update-po' must be executed before.
299 dists="$(DISTFILES)"; \
300 if test "$(PACKAGE)" = "gettext-tools"; then \
301 dists="$$dists Makevars.template"; \
303 if test -f $(srcdir)/ChangeLog; then \
304 dists="$$dists ChangeLog"; \
306 for i in 0 1 2 3 4 5 6 7 8 9; do \
307 if test -f $(srcdir)/ChangeLog.$$i; then \
308 dists="$$dists ChangeLog.$$i"; \
311 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
312 for file in $$dists; do \
313 if test -f $$file; then \
314 cp -p $$file $(distdir); \
316 cp -p $(srcdir)/$$file $(distdir); \
321 $(MAKE) $(DOMAIN).pot-update
322 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
325 # General rule for creating PO files.
328 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
329 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
332 # General rule for updating PO files.
335 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
336 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
339 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
340 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
342 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
343 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
344 rm -f $$tmpdir/$$lang.new.po; \
346 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
349 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
354 echo "msgmerge for $$lang.po failed!" 1>&2; \
355 rm -f $$tmpdir/$$lang.new.po; \
360 update-gmo: Makefile $(GMOFILES)
363 Makefile: Makefile.in.in $(top_builddir)/config.status @POMAKEFILEDEPS@
365 && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
366 $(SHELL) ./config.status
368 ${srcdir}/POTFILES.in: $(POTFILE_IN_DEPS)
369 LC_ALL=C ; export LC_ALL ; \
371 && ( cd $(top_srcdir); \
372 grep -l "_(\".*\")" `find src \( -name '*.[Cch]' -o -name '*.C.in' \) -print` |\
373 grep -v -e "src/support/package.C$$" |\
374 sort | uniq ) > $@-t \
377 l10n_pots: qt4_l10n.pot layouts_l10n.pot languages_l10n.pot ui_l10n.pot
379 msguniq -o $(DOMAIN).po && rm -f $^
382 qt4_l10n.pot: $(top_srcdir)/src/frontends/qt4/ui/*.ui
383 LC_ALL=C ; export LC_ALL ; \
384 $(AWK) -v top_srcdir="$(top_srcdir)" ' \
385 function fixupfilename() \
387 return substr(FILENAME, length(top_srcdir "/") + 1);\
393 if (!(previousline ~ /^ *< *property *name *= *"shortcut" *> *$$/) \
394 && $$0 ~ /<string>/) { \
396 sub(/.*<string>/, "", line); \
397 sub(/<\/string>.*/, "", line); \
398 gsub(/&/, "\\&", line); \
399 gsub(/</, "<", line); \
400 gsub(/>/, ">", line); \
401 gsub(/"/, "\\\"", line); \
402 if (length(line) > 0) { \
403 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
404 fixupfilename(), FNR, line); \
409 ${top_srcdir}/src/frontends/qt4/ui/*.ui > $@
411 layouts_l10n.pot: $(top_srcdir)/lib/layouts/*.layout $(top_srcdir)/lib/layouts/*.inc
412 LC_ALL=C ; export LC_ALL ; \
413 $(AWK) -v top_srcdir="$(top_srcdir)" ' \
414 function fixupfilename() \
416 return substr(FILENAME, length(top_srcdir "/") + 1);\
420 sub(/Style /, "", line); \
421 gsub(/"/, "", line); \
422 gsub(/_/, " ", line); \
423 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
424 fixupfilename(), FNR, line); \
426 /LabelString[A-Za-z]*/ { \
428 sub(/[[:space:]]*LabelString[A-Za-z]*[[:space:]]*/, "", line); \
429 gsub(/"/, "", line); \
431 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
432 fixupfilename(), FNR, line); \
436 sub(/[[:space:]]*GuiName[[:space:]]*/, "", line); \
437 gsub(/"/, "", line); \
438 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
439 fixupfilename(), FNR, line); \
443 sub(/[[:space:]]*ListName[[:space:]]*/, "", line); \
444 gsub(/"/, "", line); \
445 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
446 fixupfilename(), FNR, line); \
448 ${top_srcdir}/lib/layouts/*.layout ${top_srcdir}/lib/layouts/*.inc \
449 | sed 's/\\/\\\\/g' > $@
451 languages_l10n.pot: $(top_srcdir)/lib/languages
452 $(AWK) -v top_srcdir="$(top_srcdir)" ' \
453 function fixupfilename() \
455 return substr(FILENAME, length(top_srcdir "/") + 1);\
461 match($$0,"\"[^\"]*\""); \
462 lang=substr($$0,RSTART,RLENGTH); \
463 gsub(/"/, "", lang); \
464 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
465 fixupfilename(), FNR, lang); \
467 ${top_srcdir}/lib/languages > $@
469 ui_l10n.pot: $(top_srcdir)/lib/ui/*.ui
470 LC_ALL=C ; export LC_ALL ; \
471 $(AWK) -v top_srcdir="$(top_srcdir)" ' \
472 function fixupfilename() \
474 return substr(FILENAME, length(top_srcdir "/") + 1);\
478 sub(/[^"]*"/, "", line); \
479 sub(/".*/, "", line); \
480 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
481 fixupfilename(), FNR, line); \
483 /^[^#]*Toolbar[^s]/ { \
485 sub(/[^"]*"[^"]*"[^"]"*/, "", line); \
486 sub(/".*/, "", line); \
487 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
488 fixupfilename(), FNR, line); \
492 sub(/[^"]*"/, "", line); \
493 sub(/".*/, "", line); \
494 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
495 fixupfilename(), FNR, line); \
497 ${top_srcdir}/lib/ui/*.ui > $@
500 (cd $(srcdir) ; ./postats.sh $(POFILES)) >$@
504 # Tell versions [3.59,3.63) of GNU make not to export all variables.
505 # Otherwise a system limit (for SysV at least) may be exceeded.