1 # Makefile for PO directory in any package using GNU gettext.
2 # Copyright (C) 1995-1997, 2000-2006 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.15
15 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
21 top_srcdir = @top_srcdir@
25 exec_prefix = @exec_prefix@
26 datarootdir = @datarootdir@
28 localedir = @localedir@
29 gettextsrcdir = $(datadir)/gettext/po
32 INSTALL_DATA = @INSTALL_DATA@
33 mkinstalldirs = $(SHELL) @install_sh@ -d
37 GMSGFMT_no = @GMSGFMT@
38 GMSGFMT_yes = @GMSGFMT_015@
39 GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT))
42 MSGFMT_yes = @MSGFMT_015@
43 MSGFMT = $(MSGFMT_$(USE_MSGCTXT))
44 XGETTEXT_ = @XGETTEXT@
45 XGETTEXT_no = @XGETTEXT@
46 XGETTEXT_yes = @XGETTEXT_015@
47 XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT))
49 MSGMERGE_UPDATE = @MSGMERGE@ --update
56 UPDATEPOFILES = @UPDATEPOFILES@
57 DUMMYPOFILES = @DUMMYPOFILES@
58 DISTFILES.common = Makefile.in.in remove-potcdate.sin \
59 $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
60 DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \
61 $(POFILES) $(GMOFILES) \
62 $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
68 # Makevars gets inserted here. (Don't remove this line!)
71 .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
74 @echo "$(MSGFMT) -c -o $@ $<"; \
75 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
78 @lang=`echo $* | sed -e 's,.*/,,'`; \
79 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
80 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
81 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
84 sed -e '/^#/d' $< > t-$@
93 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
94 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
95 # we don't want to bother translators with empty POT files). We assume that
96 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
97 # In this case, stamp-po is a nop (i.e. a phony target).
99 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
100 # been loosely updated. Its purpose is that when a developer or translator
101 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
102 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
103 # invocations of "make" will do nothing. This timestamp would not be necessary
104 # if updating the $(CATALOGS) would always touch them; however, the rule for
105 # $(POFILES) has been designed to not touch files that don't need to be
107 stamp-po: $(srcdir)/$(DOMAIN).pot
108 test ! -f $(srcdir)/$(DOMAIN).pot || \
109 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
110 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
111 echo "touch stamp-po" && \
112 echo timestamp > stamp-poT && \
113 mv stamp-poT stamp-po; \
116 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
117 # otherwise packages like GCC can not be built if only parts of the source
118 # have been downloaded.
120 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
121 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
122 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
123 if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
124 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
126 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
128 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
129 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
130 --files-from=$(srcdir)/POTFILES.in \
131 --copyright-holder='$(COPYRIGHT_HOLDER)' \
132 --msgid-bugs-address="$$msgid_bugs_address"
133 test ! -f $(DOMAIN).po || { \
134 if test -f $(srcdir)/$(DOMAIN).pot; then \
135 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
136 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
137 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
138 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
140 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
141 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
144 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
148 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
149 # every "make" invocation, only create it when it is missing.
150 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
151 $(srcdir)/$(DOMAIN).pot:
152 $(MAKE) $(DOMAIN).pot-update
154 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
155 # Note that a PO file is not touched if it doesn't need to be changed.
156 $(POFILES): $(srcdir)/$(DOMAIN).pot
157 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
158 if test -f "$(srcdir)/$${lang}.po"; then \
159 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
160 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
161 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
163 $(MAKE) $${lang}.po-create; \
167 install: install-exec install-data
169 install-data: install-data-@USE_NLS@
170 if test "$(PACKAGE)" = "gettext-tools"; then \
171 $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
172 for file in $(DISTFILES.common) Makevars.template; do \
173 $(INSTALL_DATA) $(srcdir)/$$file \
174 $(DESTDIR)$(gettextsrcdir)/$$file; \
176 for file in Makevars; do \
177 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
183 install-data-yes: all
184 $(mkdir_p) $(DESTDIR)$(datadir)
185 @catalogs='$(CATALOGS)'; \
186 for cat in $$catalogs; do \
187 cat=`basename $$cat`; \
188 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
189 dir=$(localedir)/$$lang/LC_MESSAGES; \
190 $(mkdir_p) $(DESTDIR)$$dir; \
191 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
192 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
193 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
194 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
195 if test -n "$$lc"; then \
196 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
197 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
198 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
199 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
200 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
202 if test -f $$file; then \
203 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
206 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
208 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
211 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
212 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
215 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
216 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
217 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
218 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
219 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
224 install-strip: install
226 installdirs: installdirs-exec installdirs-data
228 installdirs-data: installdirs-data-@USE_NLS@
229 if test "$(PACKAGE)" = "gettext-tools"; then \
230 $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
235 installdirs-data-yes:
236 $(mkdir_p) $(DESTDIR)$(datadir)
237 @catalogs='$(CATALOGS)'; \
238 for cat in $$catalogs; do \
239 cat=`basename $$cat`; \
240 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
241 dir=$(localedir)/$$lang/LC_MESSAGES; \
242 $(mkdir_p) $(DESTDIR)$$dir; \
243 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
244 if test -n "$$lc"; then \
245 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
246 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
247 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
248 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
249 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
251 if test -f $$file; then \
252 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
255 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
257 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
260 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
261 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
268 # Define this as empty until I found a useful application.
271 uninstall: uninstall-exec uninstall-data
273 uninstall-data: uninstall-data-@USE_NLS@
274 if test "$(PACKAGE)" = "gettext-tools"; then \
275 for file in $(DISTFILES.common) Makevars.template; do \
276 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
283 catalogs='$(CATALOGS)'; \
284 for cat in $$catalogs; do \
285 cat=`basename $$cat`; \
286 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
287 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
288 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
294 info dvi ps pdf html tags TAGS ctags CTAGS ID:
297 rm -f remove-potcdate.sed
299 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
305 rm -f Makefile Makefile.in POTFILES *.mo
307 maintainer-clean: distclean
308 @echo "This command is intended for maintainers to use;"
309 @echo "it deletes files that may require special tools to rebuild."
310 rm -f stamp-po $(GMOFILES)
312 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
316 # This is a separate target because 'update-po' must be executed before.
317 dist2: stamp-po $(DISTFILES)
318 dists="$(DISTFILES)"; \
319 if test "$(PACKAGE)" = "gettext-tools"; then \
320 dists="$$dists Makevars.template"; \
322 if test -f $(srcdir)/$(DOMAIN).pot; then \
323 dists="$$dists $(DOMAIN).pot stamp-po"; \
325 if test -f $(srcdir)/ChangeLog; then \
326 dists="$$dists ChangeLog"; \
328 for i in 0 1 2 3 4 5 6 7 8 9; do \
329 if test -f $(srcdir)/ChangeLog.$$i; then \
330 dists="$$dists ChangeLog.$$i"; \
333 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
334 for file in $$dists; do \
335 if test -f $$file; then \
336 cp -p $$file $(distdir) || exit 1; \
338 cp -p $(srcdir)/$$file $(distdir) || exit 1; \
343 $(MAKE) $(DOMAIN).pot-update
344 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
347 # General rule for creating PO files.
350 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
351 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
354 # General rule for updating PO files.
357 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
358 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
361 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
362 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
364 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
365 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
366 rm -f $$tmpdir/$$lang.new.po; \
368 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
371 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
376 echo "msgmerge for $$lang.po failed!" 1>&2; \
377 rm -f $$tmpdir/$$lang.new.po; \
382 update-gmo: Makefile $(GMOFILES)
385 Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
387 && $(SHELL) ./config.status $(subdir)/$@.in po-directories
391 # Tell versions [3.59,3.63) of GNU make not to export all variables.
392 # Otherwise a system limit (for SysV at least) may be exceeded.