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 datarootdir = @datarootdir@
28 localedir = @localedir@
29 gettextsrcdir = $(datadir)/gettext/po
32 INSTALL_DATA = @INSTALL_DATA@
33 MKINSTALLDIRS = @MKINSTALLDIRS@
34 mkinstalldirs = $(SHELL) $(MKINSTALLDIRS)
40 MSGMERGE_UPDATE = @MSGMERGE@ --update
47 UPDATEPOFILES = @UPDATEPOFILES@
48 DUMMYPOFILES = @DUMMYPOFILES@
49 DISTFILES.common = Makefile.in.in remove-potcdate.sin \
50 $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
51 DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \
52 $(POFILES) $(GMOFILES) \
53 $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
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 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
85 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
86 # we don't want to bother translators with empty POT files). We assume that
87 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
88 # In this case, stamp-po is a nop (i.e. a phony target).
90 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
91 # been loosely updated. Its purpose is that when a developer or translator
92 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
93 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
94 # invocations of "make" will do nothing. This timestamp would not be necessary
95 # if updating the $(CATALOGS) would always touch them; however, the rule for
96 # $(POFILES) has been designed to not touch files that don't need to be
98 stamp-po: $(srcdir)/$(DOMAIN).pot
99 test ! -f $(srcdir)/$(DOMAIN).pot || \
100 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
101 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
102 echo "touch stamp-po" && \
103 echo timestamp > stamp-poT && \
104 mv stamp-poT stamp-po; \
107 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
108 # otherwise packages like GCC can not be built if only parts of the source
109 # have been downloaded.
111 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
112 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
113 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
114 if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
115 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
117 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
119 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
120 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
121 --files-from=$(srcdir)/POTFILES.in \
122 --copyright-holder='$(COPYRIGHT_HOLDER)' \
123 --msgid-bugs-address="$$msgid_bugs_address"
124 test ! -f $(DOMAIN).po || { \
125 if test -f $(srcdir)/$(DOMAIN).pot; then \
126 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
127 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
128 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
129 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
131 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
132 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
135 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
139 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
140 # every "make" invocation, only create it when it is missing.
141 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
142 $(srcdir)/$(DOMAIN).pot:
143 $(MAKE) $(DOMAIN).pot-update
145 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
146 # Note that a PO file is not touched if it doesn't need to be changed.
147 $(POFILES): $(srcdir)/$(DOMAIN).pot
148 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
149 if test -f "$(srcdir)/$${lang}.po"; then \
150 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
151 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
152 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
154 $(MAKE) $${lang}.po-create; \
158 install: install-exec install-data
160 install-data: install-data-@USE_NLS@
161 if test "$(PACKAGE)" = "gettext-tools"; then \
162 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
163 for file in $(DISTFILES.common) Makevars.template; do \
164 $(INSTALL_DATA) $(srcdir)/$$file \
165 $(DESTDIR)$(gettextsrcdir)/$$file; \
167 for file in Makevars; do \
168 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
174 install-data-yes: all
175 $(mkinstalldirs) $(DESTDIR)$(datadir)
176 @catalogs='$(CATALOGS)'; \
177 for cat in $$catalogs; do \
178 cat=`basename $$cat`; \
179 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
180 dir=$(localedir)/$$lang/LC_MESSAGES; \
181 $(mkinstalldirs) $(DESTDIR)$$dir; \
182 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
183 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
184 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
185 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
186 if test -n "$$lc"; then \
187 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
188 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
189 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
190 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
191 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
193 if test -f $$file; then \
194 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
197 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
199 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
202 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
203 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
206 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
207 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
208 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
209 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
210 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
215 install-strip: install
217 installdirs: installdirs-exec installdirs-data
219 installdirs-data: installdirs-data-@USE_NLS@
220 if test "$(PACKAGE)" = "gettext-tools"; then \
221 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
226 installdirs-data-yes:
227 $(mkinstalldirs) $(DESTDIR)$(datadir)
228 @catalogs='$(CATALOGS)'; \
229 for cat in $$catalogs; do \
230 cat=`basename $$cat`; \
231 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
232 dir=$(localedir)/$$lang/LC_MESSAGES; \
233 $(mkinstalldirs) $(DESTDIR)$$dir; \
234 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
235 if test -n "$$lc"; then \
236 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
237 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
238 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
239 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
240 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
242 if test -f $$file; then \
243 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
246 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
248 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
251 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
252 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
259 # Define this as empty until I found a useful application.
262 uninstall: uninstall-exec uninstall-data
264 uninstall-data: uninstall-data-@USE_NLS@
265 if test "$(PACKAGE)" = "gettext-tools"; then \
266 for file in $(DISTFILES.common) Makevars.template; do \
267 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
274 catalogs='$(CATALOGS)'; \
275 for cat in $$catalogs; do \
276 cat=`basename $$cat`; \
277 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
278 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
279 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
285 info dvi ps pdf html tags TAGS ctags CTAGS ID:
288 rm -f remove-potcdate.sed
290 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
296 rm -f Makefile Makefile.in POTFILES *.mo
298 maintainer-clean: distclean
299 @echo "This command is intended for maintainers to use;"
300 @echo "it deletes files that may require special tools to rebuild."
301 rm -f stamp-po $(GMOFILES)
303 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
307 # This is a separate target because 'update-po' must be executed before.
308 dist2: stamp-po $(DISTFILES)
309 dists="$(DISTFILES)"; \
310 if test "$(PACKAGE)" = "gettext-tools"; then \
311 dists="$$dists Makevars.template"; \
313 if test -f $(srcdir)/$(DOMAIN).pot; then \
314 dists="$$dists $(DOMAIN).pot stamp-po"; \
316 if test -f $(srcdir)/ChangeLog; then \
317 dists="$$dists ChangeLog"; \
319 for i in 0 1 2 3 4 5 6 7 8 9; do \
320 if test -f $(srcdir)/ChangeLog.$$i; then \
321 dists="$$dists ChangeLog.$$i"; \
324 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
325 for file in $$dists; do \
326 if test -f $$file; then \
327 cp -p $$file $(distdir) || exit 1; \
329 cp -p $(srcdir)/$$file $(distdir) || exit 1; \
334 $(MAKE) $(DOMAIN).pot-update
335 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
338 # General rule for creating PO files.
341 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
342 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
345 # General rule for updating PO files.
348 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
349 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
352 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
353 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
355 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
356 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
357 rm -f $$tmpdir/$$lang.new.po; \
359 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
362 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
367 echo "msgmerge for $$lang.po failed!" 1>&2; \
368 rm -f $$tmpdir/$$lang.new.po; \
373 update-gmo: Makefile $(GMOFILES)
376 Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
378 && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
379 $(SHELL) ./config.status
383 # Tell versions [3.59,3.63) of GNU make not to export all variables.
384 # Otherwise a system limit (for SysV at least) may be exceeded.