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@
27 localedir = $(datadir)/locale
28 gettextsrcdir = $(datadir)/gettext/po
31 INSTALL_DATA = @INSTALL_DATA@
32 MKINSTALLDIRS = @MKINSTALLDIRS@
33 mkinstalldirs = $(SHELL) $(MKINSTALLDIRS)
39 MSGMERGE_UPDATE = @MSGMERGE@ --update
46 UPDATEPOFILES = @UPDATEPOFILES@
47 DUMMYPOFILES = @DUMMYPOFILES@
48 DISTFILES.common = Makefile.in.in remove-potcdate.sin \
49 $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
50 DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \
51 $(POFILES) $(GMOFILES) \
52 $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
58 # Makevars gets inserted here. (Don't remove this line!)
61 .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
64 @echo "$(MSGFMT) -c -o $@ $<"; \
65 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
68 @lang=`echo $* | sed -e 's,.*/,,'`; \
69 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
70 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
71 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
74 sed -e '/^#/d' $< > t-$@
83 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
84 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
85 # we don't want to bother translators with empty POT files). We assume that
86 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
87 # In this case, stamp-po is a nop (i.e. a phony target).
89 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
90 # been loosely updated. Its purpose is that when a developer or translator
91 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
92 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
93 # invocations of "make" will do nothing. This timestamp would not be necessary
94 # if updating the $(CATALOGS) would always touch them; however, the rule for
95 # $(POFILES) has been designed to not touch files that don't need to be
97 stamp-po: $(srcdir)/$(DOMAIN).pot
98 test ! -f $(srcdir)/$(DOMAIN).pot || \
99 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
100 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
101 echo "touch stamp-po" && \
102 echo timestamp > stamp-poT && \
103 mv stamp-poT stamp-po; \
106 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
107 # otherwise packages like GCC can not be built if only parts of the source
108 # have been downloaded.
110 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
111 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
112 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
113 if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
114 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
116 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
118 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
119 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
120 --files-from=$(srcdir)/POTFILES.in \
121 --copyright-holder='$(COPYRIGHT_HOLDER)' \
122 --msgid-bugs-address="$$msgid_bugs_address"
123 test ! -f $(DOMAIN).po || { \
124 if test -f $(srcdir)/$(DOMAIN).pot; then \
125 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
126 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
127 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
128 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
130 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
131 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
134 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
138 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
139 # every "make" invocation, only create it when it is missing.
140 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
141 $(srcdir)/$(DOMAIN).pot:
142 $(MAKE) $(DOMAIN).pot-update
144 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
145 # Note that a PO file is not touched if it doesn't need to be changed.
146 $(POFILES): $(srcdir)/$(DOMAIN).pot
147 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
148 if test -f "$(srcdir)/$${lang}.po"; then \
149 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
150 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
151 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
153 $(MAKE) $${lang}.po-create; \
157 install: install-exec install-data
159 install-data: install-data-@USE_NLS@
160 if test "$(PACKAGE)" = "gettext-tools"; then \
161 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
162 for file in $(DISTFILES.common) Makevars.template; do \
163 $(INSTALL_DATA) $(srcdir)/$$file \
164 $(DESTDIR)$(gettextsrcdir)/$$file; \
166 for file in Makevars; do \
167 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
173 install-data-yes: all
174 $(mkinstalldirs) $(DESTDIR)$(datadir)
175 @catalogs='$(CATALOGS)'; \
176 for cat in $$catalogs; do \
177 cat=`basename $$cat`; \
178 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
179 dir=$(localedir)/$$lang/LC_MESSAGES; \
180 $(mkinstalldirs) $(DESTDIR)$$dir; \
181 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
182 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
183 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
184 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
185 if test -n "$$lc"; then \
186 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
187 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
188 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
189 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
190 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
192 if test -f $$file; then \
193 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
196 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
198 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
201 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
202 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
205 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
206 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
207 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
208 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
209 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
214 install-strip: install
216 installdirs: installdirs-exec installdirs-data
218 installdirs-data: installdirs-data-@USE_NLS@
219 if test "$(PACKAGE)" = "gettext-tools"; then \
220 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
225 installdirs-data-yes:
226 $(mkinstalldirs) $(DESTDIR)$(datadir)
227 @catalogs='$(CATALOGS)'; \
228 for cat in $$catalogs; do \
229 cat=`basename $$cat`; \
230 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
231 dir=$(localedir)/$$lang/LC_MESSAGES; \
232 $(mkinstalldirs) $(DESTDIR)$$dir; \
233 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
234 if test -n "$$lc"; then \
235 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
236 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
237 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
238 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
239 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
241 if test -f $$file; then \
242 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
245 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
247 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
250 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
251 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
258 # Define this as empty until I found a useful application.
261 uninstall: uninstall-exec uninstall-data
263 uninstall-data: uninstall-data-@USE_NLS@
264 if test "$(PACKAGE)" = "gettext-tools"; then \
265 for file in $(DISTFILES.common) Makevars.template; do \
266 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
273 catalogs='$(CATALOGS)'; \
274 for cat in $$catalogs; do \
275 cat=`basename $$cat`; \
276 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
277 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
278 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
284 info dvi ps pdf html tags TAGS ctags CTAGS ID:
287 rm -f remove-potcdate.sed
289 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
295 rm -f Makefile Makefile.in POTFILES *.mo
297 maintainer-clean: distclean
298 @echo "This command is intended for maintainers to use;"
299 @echo "it deletes files that may require special tools to rebuild."
300 rm -f stamp-po $(GMOFILES)
302 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
306 # This is a separate target because 'update-po' must be executed before.
307 dist2: stamp-po $(DISTFILES)
308 dists="$(DISTFILES)"; \
309 if test "$(PACKAGE)" = "gettext-tools"; then \
310 dists="$$dists Makevars.template"; \
312 if test -f $(srcdir)/$(DOMAIN).pot; then \
313 dists="$$dists $(DOMAIN).pot stamp-po"; \
315 if test -f $(srcdir)/ChangeLog; then \
316 dists="$$dists ChangeLog"; \
318 for i in 0 1 2 3 4 5 6 7 8 9; do \
319 if test -f $(srcdir)/ChangeLog.$$i; then \
320 dists="$$dists ChangeLog.$$i"; \
323 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
324 for file in $$dists; do \
325 if test -f $$file; then \
326 cp -p $$file $(distdir) || exit 1; \
328 cp -p $(srcdir)/$$file $(distdir) || exit 1; \
333 $(MAKE) $(DOMAIN).pot-update
334 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
337 # General rule for creating PO files.
340 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
341 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
344 # General rule for updating PO files.
347 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
348 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
351 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
352 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
354 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
355 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
356 rm -f $$tmpdir/$$lang.new.po; \
358 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
361 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
366 echo "msgmerge for $$lang.po failed!" 1>&2; \
367 rm -f $$tmpdir/$$lang.new.po; \
372 update-gmo: Makefile $(GMOFILES)
375 Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
377 && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
378 $(SHELL) ./config.status
382 # Tell versions [3.59,3.63) of GNU make not to export all variables.
383 # Otherwise a system limit (for SysV at least) may be exceeded.