blob: 8906ba0ff16693ad53072000b8b8219207738cf2 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# Makefile for PO directory in any package using GNU gettext.
2# Copyright (C) 1995-1997, 2000-2007, 2009-2010 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.19
12GETTEXT_MACRO_VERSION = 0.19
13
14PACKAGE = @PACKAGE@
15VERSION = @VERSION@
16PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
17
18SED = @SED@
19SHELL = /bin/sh
20@SET_MAKE@
21
22srcdir = @srcdir@
23top_srcdir = @top_srcdir@
24VPATH = @srcdir@
25
26prefix = @prefix@
27exec_prefix = @exec_prefix@
28datarootdir = @datarootdir@
29datadir = @datadir@
30localedir = @localedir@
31gettextsrcdir = $(datadir)/gettext/po
32
33INSTALL = @INSTALL@
34INSTALL_DATA = @INSTALL_DATA@
35
36MKDIR_P = @MKDIR_P@
37
38GMSGFMT_ = @GMSGFMT@
39GMSGFMT_no = @GMSGFMT@
40GMSGFMT_yes = @GMSGFMT_015@
41GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT))
42MSGFMT_ = @MSGFMT@
43MSGFMT_no = @MSGFMT@
44MSGFMT_yes = @MSGFMT_015@
45MSGFMT = $(MSGFMT_$(USE_MSGCTXT))
46XGETTEXT_ = @XGETTEXT@
47XGETTEXT_no = @XGETTEXT@
48XGETTEXT_yes = @XGETTEXT_015@
49XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT))
50MSGMERGE = msgmerge
51MSGMERGE_UPDATE = @MSGMERGE@ --update
52MSGINIT = msginit
53MSGCONV = msgconv
54MSGFILTER = msgfilter
55
56POFILES = @POFILES@
57GMOFILES = @GMOFILES@
58UPDATEPOFILES = @UPDATEPOFILES@
59DUMMYPOFILES = @DUMMYPOFILES@
60DISTFILES.common = Makefile.in.in remove-potcdate.sin \
61$(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
62DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \
63$(POFILES) $(GMOFILES) \
64$(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
65
66POTFILES = \
67
68CATALOGS = @CATALOGS@
69
70POFILESDEPS_ = $(srcdir)/$(DOMAIN).pot
71POFILESDEPS_yes = $(POFILESDEPS_)
72POFILESDEPS_no =
73POFILESDEPS = $(POFILESDEPS_$(PO_DEPENDS_ON_POT))
74
75DISTFILESDEPS_ = update-po
76DISTFILESDEPS_yes = $(DISTFILESDEPS_)
77DISTFILESDEPS_no =
78DISTFILESDEPS = $(DISTFILESDEPS_$(DIST_DEPENDS_ON_UPDATE_PO))
79
80# Makevars gets inserted here. (Don't remove this line!)
81
82.SUFFIXES:
83.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
84
85.po.mo:
86 @echo "$(MSGFMT) -c -o $@ $<"; \
87 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
88
89.po.gmo:
90 @lang=`echo $* | sed -e 's,.*/,,'`; \
91 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
92 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o $${lang}.gmo $${lang}.po"; \
93 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
94
95.sin.sed:
96 sed -e '/^#/d' $< > t-$@
97 mv t-$@ $@
98
99
100all: all-@USE_NLS@
101
102all-yes: stamp-po
103all-no:
104
105# Ensure that the gettext macros and this Makefile.in.in are in sync.
106CHECK_MACRO_VERSION = \
107 test "$(GETTEXT_MACRO_VERSION)" = "@GETTEXT_MACRO_VERSION@" \
108 || { echo "*** error: gettext infrastructure mismatch: using a Makefile.in.in from gettext version $(GETTEXT_MACRO_VERSION) but the autoconf macros are from gettext version @GETTEXT_MACRO_VERSION@" 1>&2; \
109 exit 1; \
110 }
111
112# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
113# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
114# we don't want to bother translators with empty POT files). We assume that
115# LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
116# In this case, stamp-po is a nop (i.e. a phony target).
117
118# stamp-po is a timestamp denoting the last time at which the CATALOGS have
119# been loosely updated. Its purpose is that when a developer or translator
120# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
121# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
122# invocations of "make" will do nothing. This timestamp would not be necessary
123# if updating the $(CATALOGS) would always touch them; however, the rule for
124# $(POFILES) has been designed to not touch files that don't need to be
125# changed.
126stamp-po: $(srcdir)/$(DOMAIN).pot
127 @$(CHECK_MACRO_VERSION)
128 test ! -f $(srcdir)/$(DOMAIN).pot || \
129 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
130 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
131 echo "touch stamp-po" && \
132 echo timestamp > stamp-poT && \
133 mv stamp-poT stamp-po; \
134 }
135
136# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
137# otherwise packages like GCC can not be built if only parts of the source
138# have been downloaded.
139
140# This target rebuilds $(DOMAIN).pot; it is an expensive operation.
141# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
142# The determination of whether the package xyz is a GNU one is based on the
143# heuristic whether some file in the top level directory mentions "GNU xyz".
144# If GNU 'find' is available, we avoid grepping through monster files.
145$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
146 package_gnu="$(PACKAGE_GNU)"; \
147 test -n "$$package_gnu" || { \
148 if { if (LC_ALL=C find --version) 2>/dev/null | grep GNU >/dev/null; then \
149 LC_ALL=C find -L $(top_srcdir) -maxdepth 1 -type f \
150 -size -10000000c -exec grep 'GNU @PACKAGE@' \
151 /dev/null '{}' ';' 2>/dev/null; \
152 else \
153 LC_ALL=C grep 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null; \
154 fi; \
155 } | grep -v 'libtool:' >/dev/null; then \
156 package_gnu=yes; \
157 else \
158 package_gnu=no; \
159 fi; \
160 }; \
161 if test "$$package_gnu" = "yes"; then \
162 package_prefix='GNU '; \
163 else \
164 package_prefix=''; \
165 fi; \
166 if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
167 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
168 else \
169 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
170 fi; \
171 case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
172 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
173 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
174 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
175 --files-from=$(srcdir)/POTFILES.in \
176 --copyright-holder='$(COPYRIGHT_HOLDER)' \
177 --msgid-bugs-address="$$msgid_bugs_address" \
178 ;; \
179 *) \
180 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
181 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
182 --files-from=$(srcdir)/POTFILES.in \
183 --copyright-holder='$(COPYRIGHT_HOLDER)' \
184 --package-name="$${package_prefix}@PACKAGE@" \
185 --package-version='@VERSION@' \
186 --msgid-bugs-address="$$msgid_bugs_address" \
187 ;; \
188 esac
189 test ! -f $(DOMAIN).po || { \
190 if test -f $(srcdir)/$(DOMAIN).pot; then \
191 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
192 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
193 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
194 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
195 else \
196 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
197 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
198 fi; \
199 else \
200 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
201 fi; \
202 }
203
204# This rule has no dependencies: we don't need to update $(DOMAIN).pot at
205# every "make" invocation, only create it when it is missing.
206# Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
207$(srcdir)/$(DOMAIN).pot:
208 $(MAKE) $(DOMAIN).pot-update
209
210# This target rebuilds a PO file if $(DOMAIN).pot has changed.
211# Note that a PO file is not touched if it doesn't need to be changed.
212$(POFILES): $(POFILESDEPS)
213 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
214 if test -f "$(srcdir)/$${lang}.po"; then \
215 test -f $(srcdir)/$(DOMAIN).pot || $(MAKE) $(srcdir)/$(DOMAIN).pot; \
216 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
217 echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot"; \
218 cd $(srcdir) \
219 && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
220 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
221 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \
222 *) \
223 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot;; \
224 esac; \
225 }; \
226 else \
227 $(MAKE) $${lang}.po-create; \
228 fi
229
230
231install: install-exec install-data
232install-exec:
233install-data: install-data-@USE_NLS@
234 if test "$(PACKAGE)" = "gettext-tools"; then \
235 $(MKDIR_P) $(DESTDIR)$(gettextsrcdir); \
236 for file in $(DISTFILES.common) Makevars.template; do \
237 $(INSTALL_DATA) $(srcdir)/$$file \
238 $(DESTDIR)$(gettextsrcdir)/$$file; \
239 done; \
240 for file in Makevars; do \
241 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
242 done; \
243 else \
244 : ; \
245 fi
246install-data-no: all
247install-data-yes: all
248 @catalogs='$(CATALOGS)'; \
249 for cat in $$catalogs; do \
250 cat=`basename $$cat`; \
251 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
252 dir=$(localedir)/$$lang/LC_MESSAGES; \
253 $(MKDIR_P) $(DESTDIR)$$dir; \
254 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
255 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
256 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
257 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
258 if test -n "$$lc"; then \
259 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
260 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
261 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
262 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
263 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
264 for file in *; do \
265 if test -f $$file; then \
266 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
267 fi; \
268 done); \
269 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
270 else \
271 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
272 :; \
273 else \
274 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
275 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
276 fi; \
277 fi; \
278 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
279 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
280 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
281 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
282 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
283 fi; \
284 done; \
285 done
286
287install-strip: install
288
289installdirs: installdirs-exec installdirs-data
290installdirs-exec:
291installdirs-data: installdirs-data-@USE_NLS@
292 if test "$(PACKAGE)" = "gettext-tools"; then \
293 $(MKDIR_P) $(DESTDIR)$(gettextsrcdir); \
294 else \
295 : ; \
296 fi
297installdirs-data-no:
298installdirs-data-yes:
299 @catalogs='$(CATALOGS)'; \
300 for cat in $$catalogs; do \
301 cat=`basename $$cat`; \
302 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
303 dir=$(localedir)/$$lang/LC_MESSAGES; \
304 $(MKDIR_P) $(DESTDIR)$$dir; \
305 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
306 if test -n "$$lc"; then \
307 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
308 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
309 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
310 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
311 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
312 for file in *; do \
313 if test -f $$file; then \
314 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
315 fi; \
316 done); \
317 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
318 else \
319 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
320 :; \
321 else \
322 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
323 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
324 fi; \
325 fi; \
326 fi; \
327 done; \
328 done
329
330# Define this as empty until I found a useful application.
331installcheck:
332
333uninstall: uninstall-exec uninstall-data
334uninstall-exec:
335uninstall-data: uninstall-data-@USE_NLS@
336 if test "$(PACKAGE)" = "gettext-tools"; then \
337 for file in $(DISTFILES.common) Makevars.template; do \
338 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
339 done; \
340 else \
341 : ; \
342 fi
343uninstall-data-no:
344uninstall-data-yes:
345 catalogs='$(CATALOGS)'; \
346 for cat in $$catalogs; do \
347 cat=`basename $$cat`; \
348 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
349 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
350 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
351 done; \
352 done
353
354check: all
355
356info dvi ps pdf html tags TAGS ctags CTAGS ID:
357
358mostlyclean:
359 rm -f remove-potcdate.sed
360 rm -f stamp-poT
361 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
362 rm -fr *.o
363
364clean: mostlyclean
365
366distclean: clean
367 rm -f Makefile Makefile.in POTFILES *.mo
368
369maintainer-clean: distclean
370 @echo "This command is intended for maintainers to use;"
371 @echo "it deletes files that may require special tools to rebuild."
372 rm -f stamp-po $(GMOFILES)
373
374distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
375dist distdir:
376 test -z "$(DISTFILESDEPS)" || $(MAKE) $(DISTFILESDEPS)
377 @$(MAKE) dist2
378# This is a separate target because 'update-po' must be executed before.
379dist2: stamp-po $(DISTFILES)
380 dists="$(DISTFILES)"; \
381 if test "$(PACKAGE)" = "gettext-tools"; then \
382 dists="$$dists Makevars.template"; \
383 fi; \
384 if test -f $(srcdir)/$(DOMAIN).pot; then \
385 dists="$$dists $(DOMAIN).pot stamp-po"; \
386 fi; \
387 if test -f $(srcdir)/ChangeLog; then \
388 dists="$$dists ChangeLog"; \
389 fi; \
390 for i in 0 1 2 3 4 5 6 7 8 9; do \
391 if test -f $(srcdir)/ChangeLog.$$i; then \
392 dists="$$dists ChangeLog.$$i"; \
393 fi; \
394 done; \
395 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
396 for file in $$dists; do \
397 if test -f $$file; then \
398 cp -p $$file $(distdir) || exit 1; \
399 else \
400 cp -p $(srcdir)/$$file $(distdir) || exit 1; \
401 fi; \
402 done
403
404update-po: Makefile
405 $(MAKE) $(DOMAIN).pot-update
406 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
407 $(MAKE) update-gmo
408
409# General rule for creating PO files.
410
411.nop.po-create:
412 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
413 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
414 exit 1
415
416# General rule for updating PO files.
417
418.nop.po-update:
419 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
420 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
421 tmpdir=`pwd`; \
422 echo "$$lang:"; \
423 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
424 echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
425 cd $(srcdir); \
426 if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
427 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
428 $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
429 *) \
430 $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
431 esac; \
432 }; then \
433 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
434 rm -f $$tmpdir/$$lang.new.po; \
435 else \
436 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
437 :; \
438 else \
439 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
440 exit 1; \
441 fi; \
442 fi; \
443 else \
444 echo "msgmerge for $$lang.po failed!" 1>&2; \
445 rm -f $$tmpdir/$$lang.new.po; \
446 fi
447
448$(DUMMYPOFILES):
449
450update-gmo: Makefile $(GMOFILES)
451 @:
452
453# Recreate Makefile by invoking config.status. Explicitly invoke the shell,
454# because execution permission bits may not work on the current file system.
455# Use @SHELL@, which is the shell determined by autoconf for the use by its
456# scripts, not $(SHELL) which is hardwired to /bin/sh and may be deficient.
457Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
458 cd $(top_builddir) \
459 && @SHELL@ ./config.status $(subdir)/$@.in po-directories
460
461force:
462
463# Tell versions [3.59,3.63) of GNU make not to export all variables.
464# Otherwise a system limit (for SysV at least) may be exceeded.
465.NOEXPORT: