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@
26 localedir = $(datadir)/locale
27 gettextsrcdir = $(datadir)/gettext/po
30 INSTALL_DATA = @INSTALL_DATA@
31 MKINSTALLDIRS = @MKINSTALLDIRS@
32 mkinstalldirs = $(SHELL) $(MKINSTALLDIRS)
38 MSGMERGE_UPDATE = @MSGMERGE@ --update
45 UPDATEPOFILES = @UPDATEPOFILES@
46 DUMMYPOFILES = @DUMMYPOFILES@
47 DISTFILES.common = Makefile.in.in remove-potcdate.sin \
48 $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
49 DISTFILES = $(DISTFILES.common) Makevars POTFILES.in $(DOMAIN).pot stamp-po \
50 $(POFILES) $(GMOFILES) \
51 $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
53 POTFILE_IN_DEPS = $(shell find $(top_srcdir)/src -name Makefile.am)
59 # Makevars gets inserted here. (Don't remove this line!)
62 .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
65 @echo "$(MSGFMT) -c -o $@ $<"; \
66 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
69 @lang=`echo $* | sed -e 's,.*/,,'`; \
70 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
71 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
72 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
75 sed -e '/^#/d' $< > t-$@
84 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
85 # been loosely updated. Its purpose is that when a developer or translator
86 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
87 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
88 # invocations of "make" will do nothing. This timestamp would not be necessary
89 # if updating the $(CATALOGS) would always touch them; however, the rule for
90 # $(POFILES) has been designed to not touch files that don't need to be
92 stamp-po: $(srcdir)/$(DOMAIN).pot
93 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
94 @echo "touch stamp-po"
95 @echo timestamp > stamp-poT
96 @mv stamp-poT stamp-po
98 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
99 # otherwise packages like GCC can not be built if only parts of the source
100 # have been downloaded.
102 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
103 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
104 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in l10n_pots remove-potcdate.sed
105 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
106 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
107 --files-from=$(srcdir)/POTFILES.in \
108 --copyright-holder='$(COPYRIGHT_HOLDER)' \
109 --msgid-bugs-address='$(MSGID_BUGS_ADDRESS)'
110 test ! -f $(DOMAIN).po || { \
111 if test -f $(srcdir)/$(DOMAIN).pot; then \
112 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
113 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
114 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
115 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
117 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
118 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
121 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
125 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
126 # every "make" invocation, only create it when it is missing.
127 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
128 $(srcdir)/$(DOMAIN).pot:
129 $(MAKE) $(DOMAIN).pot-update
131 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
132 # Note that a PO file is not touched if it doesn't need to be changed.
133 $(POFILES): $(srcdir)/$(DOMAIN).pot
134 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
135 if test -f "$(srcdir)/$${lang}.po"; then \
136 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
137 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
138 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
140 $(MAKE) $${lang}.po-create; \
144 install: install-exec install-data
146 install-data: install-data-@USE_NLS@
147 if test "$(PACKAGE)" = "gettext-tools"; then \
148 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
149 for file in $(DISTFILES.common) Makevars.template; do \
150 $(INSTALL_DATA) $(srcdir)/$$file \
151 $(DESTDIR)$(gettextsrcdir)/$$file; \
153 for file in Makevars; do \
154 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
160 install-data-yes: all
161 $(mkinstalldirs) $(DESTDIR)$(datadir)
162 @catalogs='$(CATALOGS)'; \
163 for cat in $$catalogs; do \
164 cat=`basename $$cat`; \
165 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
166 dir=$(localedir)/$$lang/LC_MESSAGES; \
167 $(mkinstalldirs) $(DESTDIR)$$dir; \
168 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
169 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
170 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
171 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
172 if test -n "$$lc"; then \
173 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
174 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
175 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
176 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
177 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
179 if test -f $$file; then \
180 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
183 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
185 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
188 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
189 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
192 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
193 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
194 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
195 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
196 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
201 install-strip: install
203 installdirs: installdirs-exec installdirs-data
205 installdirs-data: installdirs-data-@USE_NLS@
206 if test "$(PACKAGE)" = "gettext-tools"; then \
207 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
212 installdirs-data-yes:
213 $(mkinstalldirs) $(DESTDIR)$(datadir)
214 @catalogs='$(CATALOGS)'; \
215 for cat in $$catalogs; do \
216 cat=`basename $$cat`; \
217 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
218 dir=$(localedir)/$$lang/LC_MESSAGES; \
219 $(mkinstalldirs) $(DESTDIR)$$dir; \
220 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
221 if test -n "$$lc"; then \
222 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
223 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
224 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
225 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
226 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
228 if test -f $$file; then \
229 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
232 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
234 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
237 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
238 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
245 # Define this as empty until I found a useful application.
248 uninstall: uninstall-exec uninstall-data
250 uninstall-data: uninstall-data-@USE_NLS@
251 if test "$(PACKAGE)" = "gettext-tools"; then \
252 for file in $(DISTFILES.common) Makevars.template; do \
253 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
260 catalogs='$(CATALOGS)'; \
261 for cat in $$catalogs; do \
262 cat=`basename $$cat`; \
263 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
264 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
265 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
271 info dvi ps pdf html tags TAGS ctags CTAGS ID:
274 rm -f remove-potcdate.sed
276 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
282 rm -f Makefile Makefile.in POTFILES *.mo
284 maintainer-clean: distclean
285 @echo "This command is intended for maintainers to use;"
286 @echo "it deletes files that may require special tools to rebuild."
287 rm -f stamp-po $(GMOFILES)
289 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
293 # This is a separate target because 'update-po' must be executed before.
295 dists="$(DISTFILES)"; \
296 if test "$(PACKAGE)" = "gettext-tools"; then \
297 dists="$$dists Makevars.template"; \
299 if test -f $(srcdir)/ChangeLog; then \
300 dists="$$dists ChangeLog"; \
302 for i in 0 1 2 3 4 5 6 7 8 9; do \
303 if test -f $(srcdir)/ChangeLog.$$i; then \
304 dists="$$dists ChangeLog.$$i"; \
307 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
308 for file in $$dists; do \
309 if test -f $$file; then \
310 cp -p $$file $(distdir); \
312 cp -p $(srcdir)/$$file $(distdir); \
317 $(MAKE) $(DOMAIN).pot-update
318 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
321 # General rule for creating PO files.
324 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
325 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
328 # General rule for updating PO files.
331 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
332 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
335 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
336 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
338 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
339 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
340 rm -f $$tmpdir/$$lang.new.po; \
342 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
345 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
350 echo "msgmerge for $$lang.po failed!" 1>&2; \
351 rm -f $$tmpdir/$$lang.new.po; \
356 update-gmo: Makefile $(GMOFILES)
359 Makefile: Makefile.in.in $(top_builddir)/config.status @POMAKEFILEDEPS@
361 && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
362 $(SHELL) ./config.status
364 ${srcdir}/POTFILES.in: $(POTFILE_IN_DEPS)
365 LC_ALL=C ; export LC_ALL ; \
367 && ( cd $(top_srcdir); \
368 grep -l "_(\".*\")" `find src -name \*.[hHC] -print` |\
369 sed -e '/xforms.forms/d' | \
370 sort | uniq ) > $@-t \
373 l10n_pots: $(srcdir)/xforms_l10n.pot $(srcdir)/qt_l10n.pot $(srcdir)/layouts_l10n.pot $(srcdir)/languages_l10n.pot $(srcdir)/ui_l10n.pot
374 cat $(srcdir)/xforms_l10n.pot $(srcdir)/qt_l10n.pot $(srcdir)/layouts_l10n.pot $(srcdir)/languages_l10n.pot $(srcdir)/ui_l10n.pot | \
375 msguniq -o $(PACKAGE).po
377 $(srcdir)/xforms_l10n.pot: $(top_srcdir)/src/frontends/xforms/forms/*.fd
379 LC_ALL=C ; export LC_ALL ; \
383 print "msgid \"\""; \
384 print "msgstr \"\""; \
385 print "\"Content-Type: text/plain; charset=ISO-8859-1\\n\""; \
386 print "\"Content-Transfer-Encoding: 8bit\\n\""; \
394 if (NF > 1 && skip == 0) { \
396 sub(/label: /,"",line);\
397 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", FILENAME, FNR, line);\
401 ../src/frontends/xforms/forms/*.fd > xforms_l10n.pot
403 $(srcdir)/qt_l10n.pot: $(top_srcdir)/src/frontends/qt2/ui/*.ui
405 LC_ALL=C ; export LC_ALL ; \
409 sub(/.*<string>/, "", line); \
410 sub(/<\/string>.*/, "", line); \
411 gsub(/&/, "\\&", line); \
412 gsub(/</, "<", line); \
413 gsub(/>/, ">", line); \
414 gsub(/\"/, "\\\"", line); \
415 if (length(line) > 0) \
416 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n",\
417 FILENAME, FNR, line); \
419 ../src/frontends/qt2/ui/*.ui > qt_l10n.pot
421 $(srcdir)/layouts_l10n.pot: $(top_srcdir)/lib/layouts/*.layout $(top_srcdir)/lib/layouts/*.inc
423 LC_ALL=C ; export LC_ALL ; \
427 sub(/Style /, "", line); \
428 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
429 FILENAME, FNR, line); \
433 sub(/[[:space:]]*GuiName[[:space:]]*/, "", line); \
434 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
435 FILENAME, FNR, line); \
437 ../lib/layouts/*.layout ../lib/layouts/*.inc > layouts_l10n.pot
439 $(srcdir)/languages_l10n.pot: $(top_srcdir)/lib/languages
446 match($$0,"\"[^\"]*\""); \
447 lang=substr($$0,RSTART,RLENGTH); \
448 gsub(/\"/, "", lang); \
449 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
450 FILENAME, FNR, lang); \
452 ../lib/languages > languages_l10n.pot
454 $(srcdir)/ui_l10n.pot: $(top_srcdir)/lib/ui/*.ui
456 LC_ALL=C ; export LC_ALL ; \
460 sub(/[^"]*"/, "", line); \
461 sub(/".*/, "", line); \
462 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
463 FILENAME, FNR, line); \
467 sub(/[^"]*"/, "", line); \
468 sub(/".*/, "", line); \
469 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
470 FILENAME, FNR, line); \
474 sub(/[^"]*"/, "", line); \
475 sub(/".*/, "", line); \
476 printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
477 FILENAME, FNR, line); \
479 ../lib/ui/*.ui > ui_l10n.pot
483 # Tell versions [3.59,3.63) of GNU make not to export all variables.
484 # Otherwise a system limit (for SysV at least) may be exceeded.