1 # Makefile for PO directory in any package using GNU gettext.
2 # Copyright (C) 1995-2000 Ulrich Drepper <drepper@gnu.ai.mit.edu>
3 # Copyright (C) 2000-2019 Free Software Foundation, Inc.
5 # Copying and distribution of this file, with or without modification,
6 # are permitted in any medium without royalty provided the copyright
7 # notice and this notice are preserved. This file is offered as-is,
8 # without any warranty.
10 # Origin: gettext-0.20
11 GETTEXT_MACRO_VERSION = 0.20
15 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
22 top_srcdir = @top_srcdir@
26 exec_prefix = @exec_prefix@
27 datarootdir = @datarootdir@
29 localedir = @localedir@
30 gettextsrcdir = $(datadir)/gettext/po
33 INSTALL_DATA = @INSTALL_DATA@
36 # In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as
37 # "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions,
38 # @install_sh@ does not start with $(SHELL), so we add it.
39 # In automake >= 1.10, @mkdir_p@ is derived from ${MKDIR_P}, which is defined
40 # either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake
41 # versions, $(mkinstalldirs) and $(install_sh) are unused.
42 mkinstalldirs = $(SHELL) @install_sh@ -d
43 install_sh = $(SHELL) @install_sh@
47 # When building gettext-tools, we prefer to use the built programs
48 # rather than installed programs. However, we can't do that when we
49 # are cross compiling.
50 CROSS_COMPILING = @CROSS_COMPILING@
53 GMSGFMT_no = @GMSGFMT@
54 GMSGFMT_yes = @GMSGFMT_015@
55 GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT))
56 XGETTEXT_ = @XGETTEXT@
57 XGETTEXT_no = @XGETTEXT@
58 XGETTEXT_yes = @XGETTEXT_015@
59 XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT))
61 MSGMERGE_UPDATE = @MSGMERGE@ --update
62 MSGMERGE_FOR_MSGFMT_OPTION = @MSGMERGE_FOR_MSGFMT_OPTION@
69 UPDATEPOFILES = @UPDATEPOFILES@
70 DUMMYPOFILES = @DUMMYPOFILES@
71 DISTFILES.common = Makefile.in.in remove-potcdate.sin \
72 $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
73 DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \
74 $(POFILES) $(GMOFILES) \
75 $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
81 POFILESDEPS_ = $(srcdir)/$(DOMAIN).pot
82 POFILESDEPS_yes = $(POFILESDEPS_)
84 POFILESDEPS = $(POFILESDEPS_$(PO_DEPENDS_ON_POT))
86 DISTFILESDEPS_ = update-po
87 DISTFILESDEPS_yes = $(DISTFILESDEPS_)
89 DISTFILESDEPS = $(DISTFILESDEPS_$(DIST_DEPENDS_ON_UPDATE_PO))
91 # Makevars gets inserted here. (Don't remove this line!)
94 .SUFFIXES: .po .gmo .sed .sin .nop .po-create .po-update
96 # The .pot file, stamp-po, .po files, and .gmo files appear in release tarballs.
97 # The GNU Coding Standards say in
98 # <https://www.gnu.org/prep/standards/html_node/Makefile-Basics.html>:
99 # "GNU distributions usually contain some files which are not source files
100 # ... . Since these files normally appear in the source directory, they
101 # should always appear in the source directory, not in the build directory.
102 # So Makefile rules to update them should put the updated files in the
104 # Therefore we put these files in the source directory, not the build directory.
106 # During .po -> .gmo conversion, take into account the most recent changes to
107 # the .pot file. This eliminates the need to update the .po files when the
108 # .pot file has changed, which would be troublesome if the .po files are put
109 # under version control.
110 .po.gmo: $(srcdir)/$(DOMAIN).pot
111 @lang=`echo $* | sed -e 's,.*/,,'`; \
112 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
113 echo "$${cdcmd}rm -f $${lang}.gmo && $(MSGMERGE) $(MSGMERGE_FOR_MSGFMT_OPTION) -o $${lang}.1po $${lang}.po $(DOMAIN).pot && $(GMSGFMT) -c --statistics --verbose -o $${lang}.gmo $${lang}.1po && rm -f $${lang}.1po"; \
115 rm -f $${lang}.gmo && \
116 $(MSGMERGE) $(MSGMERGE_FOR_MSGFMT_OPTION) -o $${lang}.1po $${lang}.po $(DOMAIN).pot && \
117 $(GMSGFMT) -c --statistics --verbose -o t-$${lang}.gmo $${lang}.1po && \
118 mv t-$${lang}.gmo $${lang}.gmo && \
122 sed -e '/^#/d' $< > t-$@
128 all-yes: $(srcdir)/stamp-po
131 # Ensure that the gettext macros and this Makefile.in.in are in sync.
132 CHECK_MACRO_VERSION = \
133 test "$(GETTEXT_MACRO_VERSION)" = "@GETTEXT_MACRO_VERSION@" \
134 || { 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; \
138 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
139 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
140 # we don't want to bother translators with empty POT files). We assume that
141 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
142 # In this case, $(srcdir)/stamp-po is a nop (i.e. a phony target).
144 # $(srcdir)/stamp-po is a timestamp denoting the last time at which the CATALOGS
145 # have been loosely updated. Its purpose is that when a developer or translator
146 # checks out the package from a version control system, and the $(DOMAIN).pot
147 # file is not under version control, "make" will update the $(DOMAIN).pot and
148 # the $(CATALOGS), but subsequent invocations of "make" will do nothing. This
149 # timestamp would not be necessary if updating the $(CATALOGS) would always
150 # touch them; however, the rule for $(POFILES) has been designed to not touch
151 # files that don't need to be changed.
152 $(srcdir)/stamp-po: $(srcdir)/$(DOMAIN).pot
153 @$(CHECK_MACRO_VERSION)
154 test ! -f $(srcdir)/$(DOMAIN).pot || \
155 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
156 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
157 echo "touch $(srcdir)/stamp-po" && \
158 echo timestamp > $(srcdir)/stamp-poT && \
159 mv $(srcdir)/stamp-poT $(srcdir)/stamp-po; \
162 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
163 # otherwise packages like GCC can not be built if only parts of the source
164 # have been downloaded.
166 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
167 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
168 # The determination of whether the package xyz is a GNU one is based on the
169 # heuristic whether some file in the top level directory mentions "GNU xyz".
170 # If GNU 'find' is available, we avoid grepping through monster files.
171 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
172 package_gnu="$(PACKAGE_GNU)"; \
173 test -n "$$package_gnu" || { \
174 if { if (LC_ALL=C find --version) 2>/dev/null | grep GNU >/dev/null; then \
175 LC_ALL=C find -L $(top_srcdir) -maxdepth 1 -type f -size -10000000c -exec grep -i 'GNU @PACKAGE@' /dev/null '{}' ';' 2>/dev/null; \
177 LC_ALL=C grep -i 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null; \
179 } | grep -v 'libtool:' >/dev/null; then \
185 if test "$$package_gnu" = "yes"; then \
186 package_prefix='GNU '; \
190 if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
191 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
193 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
195 case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
196 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
197 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
198 --add-comments=TRANSLATORS: \
199 --files-from=$(srcdir)/POTFILES.in \
200 --copyright-holder='$(COPYRIGHT_HOLDER)' \
201 --msgid-bugs-address="$$msgid_bugs_address" \
202 $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
205 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
206 --add-comments=TRANSLATORS: \
207 --files-from=$(srcdir)/POTFILES.in \
208 --copyright-holder='$(COPYRIGHT_HOLDER)' \
209 --package-name="$${package_prefix}@PACKAGE@" \
210 --package-version='@VERSION@' \
211 --msgid-bugs-address="$$msgid_bugs_address" \
212 $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
215 test ! -f $(DOMAIN).po || { \
216 if test -f $(srcdir)/$(DOMAIN).pot-header; then \
217 sed -e '1,/^#$$/d' < $(DOMAIN).po > $(DOMAIN).1po && \
218 cat $(srcdir)/$(DOMAIN).pot-header $(DOMAIN).1po > $(DOMAIN).po && \
219 rm -f $(DOMAIN).1po \
222 if test -f $(srcdir)/$(DOMAIN).pot; then \
223 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
224 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
225 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
226 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
228 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
229 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
232 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
236 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
237 # every "make" invocation, only create it when it is missing.
238 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
239 $(srcdir)/$(DOMAIN).pot:
240 $(MAKE) $(DOMAIN).pot-update
242 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
243 # Note that a PO file is not touched if it doesn't need to be changed.
244 $(POFILES): $(POFILESDEPS)
245 @test -f $(srcdir)/$(DOMAIN).pot || $(MAKE) $(srcdir)/$(DOMAIN).pot
246 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
247 if test -f "$(srcdir)/$${lang}.po"; then \
248 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
249 echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} --previous $${lang}.po $(DOMAIN).pot"; \
251 && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
252 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].*) \
253 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \
254 0.1[6-7] | 0.1[6-7].*) \
255 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --previous $${lang}.po $(DOMAIN).pot;; \
257 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} --previous $${lang}.po $(DOMAIN).pot;; \
261 $(MAKE) $${lang}.po-create; \
265 install: install-exec install-data
267 install-data: install-data-@USE_NLS@
268 if test "$(PACKAGE)" = "gettext-tools"; then \
269 $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
270 for file in $(DISTFILES.common) Makevars.template; do \
271 $(INSTALL_DATA) $(srcdir)/$$file \
272 $(DESTDIR)$(gettextsrcdir)/$$file; \
274 for file in Makevars; do \
275 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
281 install-data-yes: all
282 @catalogs='$(CATALOGS)'; \
283 for cat in $$catalogs; do \
284 cat=`basename $$cat`; \
285 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
286 dir=$(localedir)/$$lang/LC_MESSAGES; \
287 $(mkdir_p) $(DESTDIR)$$dir; \
288 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
289 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
290 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
291 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
292 if test -n "$$lc"; then \
293 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
294 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
295 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
296 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
297 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
299 if test -f $$file; then \
300 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
303 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
305 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
308 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
309 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
312 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
313 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
314 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
315 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
316 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
321 install-strip: install
323 installdirs: installdirs-exec installdirs-data
325 installdirs-data: installdirs-data-@USE_NLS@
326 if test "$(PACKAGE)" = "gettext-tools"; then \
327 $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
332 installdirs-data-yes:
333 @catalogs='$(CATALOGS)'; \
334 for cat in $$catalogs; do \
335 cat=`basename $$cat`; \
336 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
337 dir=$(localedir)/$$lang/LC_MESSAGES; \
338 $(mkdir_p) $(DESTDIR)$$dir; \
339 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
340 if test -n "$$lc"; then \
341 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
342 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
343 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
344 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
345 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
347 if test -f $$file; then \
348 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
351 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
353 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
356 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
357 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
364 # Define this as empty until I found a useful application.
367 uninstall: uninstall-exec uninstall-data
369 uninstall-data: uninstall-data-@USE_NLS@
370 if test "$(PACKAGE)" = "gettext-tools"; then \
371 for file in $(DISTFILES.common) Makevars.template; do \
372 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
379 catalogs='$(CATALOGS)'; \
380 for cat in $$catalogs; do \
381 cat=`basename $$cat`; \
382 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
383 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
384 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
390 info dvi ps pdf html tags TAGS ctags CTAGS ID:
392 install-dvi install-ps install-pdf install-html:
395 rm -f remove-potcdate.sed
396 rm -f $(srcdir)/stamp-poT
397 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
403 rm -f Makefile Makefile.in POTFILES
405 maintainer-clean: distclean
406 @echo "This command is intended for maintainers to use;"
407 @echo "it deletes files that may require special tools to rebuild."
408 rm -f $(srcdir)/$(DOMAIN).pot $(srcdir)/stamp-po $(GMOFILES)
410 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
412 test -z "$(DISTFILESDEPS)" || $(MAKE) $(DISTFILESDEPS)
414 # This is a separate target because 'update-po' must be executed before.
415 dist2: $(srcdir)/stamp-po $(DISTFILES)
416 dists="$(DISTFILES)"; \
417 if test "$(PACKAGE)" = "gettext-tools"; then \
418 dists="$$dists Makevars.template"; \
420 if test -f $(srcdir)/$(DOMAIN).pot; then \
421 dists="$$dists $(DOMAIN).pot stamp-po"; \
423 if test -f $(srcdir)/ChangeLog; then \
424 dists="$$dists ChangeLog"; \
426 for i in 0 1 2 3 4 5 6 7 8 9; do \
427 if test -f $(srcdir)/ChangeLog.$$i; then \
428 dists="$$dists ChangeLog.$$i"; \
431 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
432 for file in $$dists; do \
433 if test -f $$file; then \
434 cp -p $$file $(distdir) || exit 1; \
436 cp -p $(srcdir)/$$file $(distdir) || exit 1; \
441 $(MAKE) $(DOMAIN).pot-update
442 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
445 # General rule for creating PO files.
448 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
449 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
452 # General rule for updating PO files.
455 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
456 if test "$(PACKAGE)" = "gettext-tools" && test "$(CROSS_COMPILING)" != "yes"; then PATH=`pwd`/../src:$$PATH; fi; \
459 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
460 echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang --previous $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
462 if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
463 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].*) \
464 $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
465 0.1[6-7] | 0.1[6-7].*) \
466 $(MSGMERGE) $(MSGMERGE_OPTIONS) --previous -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
468 $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang --previous -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
471 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
472 rm -f $$tmpdir/$$lang.new.po; \
474 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
477 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
482 echo "msgmerge for $$lang.po failed!" 1>&2; \
483 rm -f $$tmpdir/$$lang.new.po; \
488 update-gmo: Makefile $(GMOFILES)
491 # Recreate Makefile by invoking config.status. Explicitly invoke the shell,
492 # because execution permission bits may not work on the current file system.
493 # Use @SHELL@, which is the shell determined by autoconf for the use by its
494 # scripts, not $(SHELL) which is hardwired to /bin/sh and may be deficient.
495 Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
497 && @SHELL@ ./config.status $(subdir)/$@.in po-directories
501 # Tell versions [3.59,3.63) of GNU make not to export all variables.
502 # Otherwise a system limit (for SysV at least) may be exceeded.