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@
25 exec_prefix = @exec_prefix@
26 datarootdir = @datarootdir@
28 localedir = $(datadir)/locale
29 gettextsrcdir = $(datadir)/gettext/po
32 INSTALL_DATA = @INSTALL_DATA@
33 MKINSTALLDIRS = @MKINSTALLDIRS@
34 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)
56 DISTFILES.extra1 = lyx_pot.py postats.sh pocheck.pl
58 POTFILE_IN_DEPS = $(shell find $(top_srcdir)/src -name Makefile.am)
64 # Makevars gets inserted here. (Don't remove this line!)
67 .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
70 @echo "$(MSGFMT) -c -o $@ $<"; \
71 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
74 @lang=`echo $* | sed -e 's,.*/,,'`; \
75 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
76 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
77 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
80 sed -e '/^#/d' $< > t-$@
89 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
90 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
91 # we don't want to bother translators with empty POT files). We assume that
92 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
93 # In this case, stamp-po is a nop (i.e. a phony target).
95 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
96 # been loosely updated. Its purpose is that when a developer or translator
97 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
98 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
99 # invocations of "make" will do nothing. This timestamp would not be necessary
100 # if updating the $(CATALOGS) would always touch them; however, the rule for
101 # $(POFILES) has been designed to not touch files that don't need to be
103 stamp-po: $(srcdir)/$(DOMAIN).pot
104 test ! -f $(srcdir)/$(DOMAIN).pot || \
105 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
106 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
107 echo "touch stamp-po" && \
108 echo timestamp > stamp-poT && \
109 mv stamp-poT stamp-po; \
112 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
113 # otherwise packages like GCC can not be built if only parts of the source
114 # have been downloaded.
116 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
117 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
118 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
120 if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
121 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
123 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
125 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
126 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
127 --files-from=$(srcdir)/POTFILES.in \
128 --copyright-holder='$(COPYRIGHT_HOLDER)' \
129 --msgid-bugs-address="$$msgid_bugs_address"
130 test ! -f $(DOMAIN).po || { \
131 if test -f $(srcdir)/$(DOMAIN).pot; then \
132 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
133 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
134 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
135 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
137 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
138 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
141 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
145 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
146 # every "make" invocation, only create it when it is missing.
147 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
148 $(srcdir)/$(DOMAIN).pot:
149 $(MAKE) $(DOMAIN).pot-update
151 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
152 # Note that a PO file is not touched if it doesn't need to be changed.
153 $(POFILES): $(srcdir)/$(DOMAIN).pot
154 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
155 if test -f "$(srcdir)/$${lang}.po"; then \
156 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
157 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
158 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
160 $(MAKE) $${lang}.po-create; \
164 install: install-exec install-data
166 install-data: install-data-@USE_NLS@
167 if test "$(PACKAGE)" = "gettext-tools"; then \
168 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
169 for file in $(DISTFILES.common) Makevars.template; do \
170 $(INSTALL_DATA) $(srcdir)/$$file \
171 $(DESTDIR)$(gettextsrcdir)/$$file; \
173 for file in Makevars; do \
174 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
180 install-data-yes: all
181 $(mkinstalldirs) $(DESTDIR)$(datadir)
182 @catalogs='$(CATALOGS)'; \
183 for cat in $$catalogs; do \
184 cat=`basename $$cat`; \
185 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
186 dir=$(localedir)/$$lang/LC_MESSAGES; \
187 $(mkinstalldirs) $(DESTDIR)$$dir; \
188 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
189 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
190 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
191 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
192 if test -n "$$lc"; then \
193 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
194 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
195 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
196 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
197 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
199 if test -f $$file; then \
200 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
203 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
205 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
208 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
209 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
212 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
213 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
214 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
215 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
216 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
221 install-strip: install
223 installdirs: installdirs-exec installdirs-data
225 installdirs-data: installdirs-data-@USE_NLS@
226 if test "$(PACKAGE)" = "gettext-tools"; then \
227 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
232 installdirs-data-yes:
233 $(mkinstalldirs) $(DESTDIR)$(datadir)
234 @catalogs='$(CATALOGS)'; \
235 for cat in $$catalogs; do \
236 cat=`basename $$cat`; \
237 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
238 dir=$(localedir)/$$lang/LC_MESSAGES; \
239 $(mkinstalldirs) $(DESTDIR)$$dir; \
240 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
241 if test -n "$$lc"; then \
242 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
243 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
244 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
245 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
246 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
248 if test -f $$file; then \
249 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
252 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
254 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
257 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
258 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
265 # Define this as empty until I found a useful application.
268 uninstall: uninstall-exec uninstall-data
270 uninstall-data: uninstall-data-@USE_NLS@
271 if test "$(PACKAGE)" = "gettext-tools"; then \
272 for file in $(DISTFILES.common) Makevars.template; do \
273 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
280 catalogs='$(CATALOGS)'; \
281 for cat in $$catalogs; do \
282 cat=`basename $$cat`; \
283 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
284 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
285 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
291 info dvi ps pdf html tags TAGS ctags CTAGS ID:
294 rm -f remove-potcdate.sed
296 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
302 rm -f Makefile Makefile.in POTFILES *.mo
304 maintainer-clean: distclean
305 @echo "This command is intended for maintainers to use;"
306 @echo "it deletes files that may require special tools to rebuild."
307 rm -f stamp-po $(GMOFILES)
309 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
313 # This is a separate target because 'update-po' must be executed before.
314 dist2: stamp-po $(DISTFILES)
315 dists="$(DISTFILES)"; \
316 if test "$(PACKAGE)" = "gettext-tools"; then \
317 dists="$$dists Makevars.template"; \
319 if test -f $(srcdir)/$(DOMAIN).pot; then \
320 dists="$$dists $(DOMAIN).pot stamp-po"; \
322 if test -f $(srcdir)/ChangeLog; then \
323 dists="$$dists ChangeLog"; \
325 for i in 0 1 2 3 4 5 6 7 8 9; do \
326 if test -f $(srcdir)/ChangeLog.$$i; then \
327 dists="$$dists ChangeLog.$$i"; \
330 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
331 for file in $$dists; do \
332 if test -f $$file; then \
333 cp -p $$file $(distdir) || exit 1; \
335 cp -p $(srcdir)/$$file $(distdir) || exit 1; \
340 $(MAKE) $(DOMAIN).pot-update
341 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
344 # General rule for creating PO files.
347 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
348 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
351 # General rule for updating PO files.
354 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
355 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
358 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
359 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
361 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
362 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
363 rm -f $$tmpdir/$$lang.new.po; \
365 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
368 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
373 echo "msgmerge for $$lang.po failed!" 1>&2; \
374 rm -f $$tmpdir/$$lang.new.po; \
379 update-gmo: Makefile $(GMOFILES)
382 Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
384 && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
385 $(SHELL) ./config.status
387 ${srcdir}/POTFILES.in: $(POTFILE_IN_DEPS)
388 LC_ALL=C ; export LC_ALL ; \
390 && ( cd $(top_srcdir); \
391 grep -l "_(\".*\")" `find src \( -name '*.h' -o -name '*.cpp' -o -name '*.cpp.in' \) -print` |\
392 grep -v -e "src/support/Package.cpp$$" |\
393 sort | uniq ) > $@-t \
396 l10n_pots: qt4_l10n.pot layouts_l10n.pot languages_l10n.pot ui_l10n.pot external_l10n.pot
398 msguniq -o $(DOMAIN).po && rm -f $^
401 qt4_l10n.pot: $(top_srcdir)/src/frontends/qt4/ui/*.ui
402 LC_ALL=C ; export LC_ALL ; \
403 python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t qt4 ${top_srcdir}/src/frontends/qt4/ui/*.ui
405 layouts_l10n.pot: $(top_srcdir)/lib/layouts/*.layout $(top_srcdir)/lib/layouts/*.inc
406 LC_ALL=C ; export LC_ALL ; \
407 python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t layouts ${top_srcdir}/lib/layouts/*.layout ${top_srcdir}/lib/layouts/*.inc
409 languages_l10n.pot: $(top_srcdir)/lib/languages
410 python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t languages ${top_srcdir}/lib/languages
412 ui_l10n.pot: $(top_srcdir)/lib/ui/*.ui $(top_srcdir)/lib/ui/*.inc
413 LC_ALL=C ; export LC_ALL ; \
414 python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t ui ${top_srcdir}/lib/ui/*.ui ${top_srcdir}/lib/ui/*.inc
416 i18n.php: $(POFILES) postats.sh
417 (cd $(srcdir) ; ./postats.sh $(POFILES)) >$@
419 external_l10n.pot: $(top_srcdir)/lib/external_templates
420 python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t external ${top_srcdir}/lib/external_templates
424 # Tell versions [3.59,3.63) of GNU make not to export all variables.
425 # Otherwise a system limit (for SysV at least) may be exceeded.