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>
3 #
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
7 # functionality.
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.
10 #
11 # Origin: gettext-0.14.4
13 PACKAGE = @PACKAGE@
14 VERSION = @VERSION@
15 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
17 SHELL = /bin/sh
18 @SET_MAKE@
20 srcdir = @srcdir@
21 top_srcdir = @top_srcdir@
22 VPATH = @srcdir@
24 prefix = @prefix@
25 exec_prefix = @exec_prefix@
26 datadir = @datadir@
27 localedir = $(datadir)/locale
28 gettextsrcdir = $(datadir)/gettext/po
30 INSTALL = @INSTALL@
31 INSTALL_DATA = @INSTALL_DATA@
32 MKINSTALLDIRS = @MKINSTALLDIRS@
33 mkinstalldirs = $(SHELL) $(MKINSTALLDIRS)
35 GMSGFMT = @GMSGFMT@
36 MSGFMT = @MSGFMT@
37 XGETTEXT = @XGETTEXT@
38 MSGMERGE = msgmerge
39 MSGMERGE_UPDATE = @MSGMERGE@ --update
40 MSGINIT = msginit
41 MSGCONV = msgconv
42 MSGFILTER = msgfilter
44 POFILES = @POFILES@
45 GMOFILES = @GMOFILES@
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)
54 POTFILES = \
56 CATALOGS = @CATALOGS@
58 # Makevars gets inserted here. (Don't remove this line!)
60 .SUFFIXES:
61 .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
63 .po.mo:
64 @echo "$(MSGFMT) -c -o $@ $<"; \
65 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
67 .po.gmo:
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
73 .sin.sed:
74 sed -e '/^#/d' $< > t-$@
75 mv t-$@ $@
78 all: all-@USE_NLS@
80 all-yes: stamp-po
81 all-no:
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
96 # changed.
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; \
104 }
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)'; \
115 else \
116 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
117 fi; \
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; \
129 else \
130 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
131 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
132 fi; \
133 else \
134 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
135 fi; \
136 }
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; \
152 else \
153 $(MAKE) $${lang}.po-create; \
154 fi
157 install: install-exec install-data
158 install-exec:
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; \
165 done; \
166 for file in Makevars; do \
167 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
168 done; \
169 else \
170 : ; \
171 fi
172 install-data-no: all
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 && \
191 for file in *; do \
192 if test -f $$file; then \
193 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
194 fi; \
195 done); \
196 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
197 else \
198 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
199 :; \
200 else \
201 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
202 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
203 fi; \
204 fi; \
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"; \
210 fi; \
211 done; \
212 done
214 install-strip: install
216 installdirs: installdirs-exec installdirs-data
217 installdirs-exec:
218 installdirs-data: installdirs-data-@USE_NLS@
219 if test "$(PACKAGE)" = "gettext-tools"; then \
220 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
221 else \
222 : ; \
223 fi
224 installdirs-data-no:
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 && \
240 for file in *; do \
241 if test -f $$file; then \
242 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
243 fi; \
244 done); \
245 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
246 else \
247 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
248 :; \
249 else \
250 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
251 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
252 fi; \
253 fi; \
254 fi; \
255 done; \
256 done
258 # Define this as empty until I found a useful application.
259 installcheck:
261 uninstall: uninstall-exec uninstall-data
262 uninstall-exec:
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; \
267 done; \
268 else \
269 : ; \
270 fi
271 uninstall-data-no:
272 uninstall-data-yes:
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; \
279 done; \
280 done
282 check: all
284 info dvi ps pdf html tags TAGS ctags CTAGS ID:
286 mostlyclean:
287 rm -f remove-potcdate.sed
288 rm -f stamp-poT
289 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
290 rm -fr *.o
292 clean: mostlyclean
294 distclean: clean
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)
303 dist distdir:
304 $(MAKE) update-po
305 @$(MAKE) dist2
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"; \
311 fi; \
312 if test -f $(srcdir)/$(DOMAIN).pot; then \
313 dists="$$dists $(DOMAIN).pot stamp-po"; \
314 fi; \
315 if test -f $(srcdir)/ChangeLog; then \
316 dists="$$dists ChangeLog"; \
317 fi; \
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"; \
321 fi; \
322 done; \
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; \
327 else \
328 cp -p $(srcdir)/$$file $(distdir) || exit 1; \
329 fi; \
330 done
332 update-po: Makefile
333 $(MAKE) $(DOMAIN).pot-update
334 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
335 $(MAKE) update-gmo
337 # General rule for creating PO files.
339 .nop.po-create:
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; \
342 exit 1
344 # General rule for updating PO files.
346 .nop.po-update:
347 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
348 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
349 tmpdir=`pwd`; \
350 echo "$$lang:"; \
351 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
352 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
353 cd $(srcdir); \
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; \
357 else \
358 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
359 :; \
360 else \
361 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
362 exit 1; \
363 fi; \
364 fi; \
365 else \
366 echo "msgmerge for $$lang.po failed!" 1>&2; \
367 rm -f $$tmpdir/$$lang.new.po; \
368 fi
370 $(DUMMYPOFILES):
372 update-gmo: Makefile $(GMOFILES)
373 @:
375 Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
376 cd $(top_builddir) \
377 && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
378 $(SHELL) ./config.status
380 force:
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.
384 .NOEXPORT: