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@
25 datarootdir = @datarootdir@
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 $(DOMAIN).pot stamp-po \
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 $(E) "$(MSGFMT) -c -o $@ $<"
65 $(Q) $(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-$@
80 all-yes: @MAINTAINER_CMT@stamp-po
83 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
84 # been loosely updated. Its purpose is that when a developer or translator
85 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
86 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
87 # invocations of "make" will do nothing. This timestamp would not be necessary
88 # if updating the $(CATALOGS) would always touch them; however, the rule for
89 # $(POFILES) has been designed to not touch files that don't need to be
91 stamp-po: $(srcdir)/$(DOMAIN).pot
92 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
93 @echo "touch stamp-po"
94 @echo timestamp > stamp-poT
95 @mv stamp-poT stamp-po
97 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
98 # otherwise packages like GCC can not be built if only parts of the source
99 # have been downloaded.
101 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
102 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
103 $(DOMAIN).pot-update: $(srcdir)/POTFILES.in remove-potcdate.sed \
104 $(srcdir)/at-expand.pl
105 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
106 --directory=$(top_builddir) \
107 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
108 --files-from=$(srcdir)/POTFILES.in \
109 --copyright-holder='$(COPYRIGHT_HOLDER)' \
110 --msgid-bugs-address='$(MSGID_BUGS_ADDRESS)'
111 perl $(srcdir)/at-expand.pl < $(DOMAIN).po > $(DOMAIN).po.new
112 mv $(DOMAIN).po $(DOMAIN).po.bak
113 mv $(DOMAIN).po.new $(DOMAIN).po
114 test ! -f $(DOMAIN).po || { \
115 if test -f $(srcdir)/$(DOMAIN).pot; then \
116 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
117 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
118 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
119 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
121 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
122 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
125 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
129 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
130 # every "make" invocation, only create it when it is missing.
131 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
132 $(srcdir)/$(DOMAIN).pot:
133 $(MAKE) $(DOMAIN).pot-update
135 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
136 # Note that a PO file is not touched if it doesn't need to be changed.
137 $(POFILES): $(srcdir)/$(DOMAIN).pot
138 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
139 if test -f "$(srcdir)/$${lang}.po"; then \
140 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
141 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
142 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
144 $(MAKE) $${lang}.po-create; \
148 install: install-exec install-data
150 install-data: install-data-@USE_NLS@
151 if test "$(PACKAGE)" = "gettext-tools"; then \
152 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
153 for file in $(DISTFILES.common) Makevars.template; do \
154 $(INSTALL_DATA) $(srcdir)/$$file \
155 $(DESTDIR)$(gettextsrcdir)/$$file; \
157 for file in Makevars; do \
158 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
164 install-data-yes: all
165 $(mkinstalldirs) $(DESTDIR)$(datadir)
166 @catalogs='$(CATALOGS)'; \
167 for cat in $$catalogs; do \
168 cat=`basename $$cat`; \
169 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
170 dir=$(localedir)/$$lang/LC_MESSAGES; \
171 $(mkinstalldirs) $(DESTDIR)$$dir; \
172 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
173 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
174 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
175 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
176 if test -n "$$lc"; then \
177 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
178 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
179 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
180 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
181 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
183 if test -f $$file; then \
184 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
187 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
189 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
192 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
193 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
196 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
197 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
198 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
199 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
200 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
205 install-strip: install
207 installdirs: installdirs-exec installdirs-data
209 installdirs-data: installdirs-data-@USE_NLS@
210 if test "$(PACKAGE)" = "gettext-tools"; then \
211 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
216 installdirs-data-yes:
217 $(mkinstalldirs) $(DESTDIR)$(datadir)
218 @catalogs='$(CATALOGS)'; \
219 for cat in $$catalogs; do \
220 cat=`basename $$cat`; \
221 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
222 dir=$(localedir)/$$lang/LC_MESSAGES; \
223 $(mkinstalldirs) $(DESTDIR)$$dir; \
224 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
225 if test -n "$$lc"; then \
226 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
227 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
228 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
229 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
230 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
232 if test -f $$file; then \
233 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
236 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
238 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
241 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
242 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
249 # Define this as empty until I found a useful application.
252 uninstall: uninstall-exec uninstall-data
254 uninstall-data: uninstall-data-@USE_NLS@
255 if test "$(PACKAGE)" = "gettext-tools"; then \
256 for file in $(DISTFILES.common) Makevars.template; do \
257 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
264 catalogs='$(CATALOGS)'; \
265 for cat in $$catalogs; do \
266 cat=`basename $$cat`; \
267 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
268 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
269 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
275 info dvi ps pdf html tags TAGS ctags CTAGS ID:
278 rm -f remove-potcdate.sed
280 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
281 rm -f $(DOMAIN).po.bak
287 rm -f Makefile Makefile.in POTFILES *.mo
289 maintainer-clean: distclean
290 @echo "This command is intended for maintainers to use;"
291 @echo "it deletes files that may require special tools to rebuild."
292 rm -f stamp-po $(GMOFILES)
294 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
298 # This is a separate target because 'update-po' must be executed before.
300 dists="$(DISTFILES)"; \
301 if test "$(PACKAGE)" = "gettext-tools"; then \
302 dists="$$dists Makevars.template"; \
304 if test -f $(srcdir)/ChangeLog; then \
305 dists="$$dists ChangeLog"; \
307 for i in 0 1 2 3 4 5 6 7 8 9; do \
308 if test -f $(srcdir)/ChangeLog.$$i; then \
309 dists="$$dists ChangeLog.$$i"; \
312 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
313 for file in $$dists; do \
314 if test -f $$file; then \
315 cp -p $$file $(distdir); \
317 cp -p $(srcdir)/$$file $(distdir); \
322 $(MAKE) $(DOMAIN).pot-update
323 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
326 # General rule for creating PO files.
329 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
330 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
333 # General rule for updating PO files.
336 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
337 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
340 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
341 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
343 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
344 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
345 rm -f $$tmpdir/$$lang.new.po; \
347 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
350 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
355 echo "msgmerge for $$lang.po failed!" 1>&2; \
356 rm -f $$tmpdir/$$lang.new.po; \
361 update-gmo: Makefile $(GMOFILES)
364 Makefile: Makefile.in.in $(top_builddir)/config.status @POMAKEFILEDEPS@
366 && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
367 $(SHELL) ./config.status
371 # Tell versions [3.59,3.63) of GNU make not to export all variables.
372 # Otherwise a system limit (for SysV at least) may be exceeded.